Package org.apache.sysds.hops
Class Hop
java.lang.Object
org.apache.sysds.hops.Hop
- All Implemented Interfaces:
ParseInfo
- Direct Known Subclasses:
DataOp,IndexingOp,LeftIndexingOp,LiteralOp,MultiThreadedHop,NaryOp
Hop is a High level operator, that is the first intermediate representation compiled from the definitions supplied in
DML.
-
Field Summary
FieldsModifier and TypeFieldDescriptionintintintintstatic final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidActivate prefetch of HOP.voidaddAllInputs(List<Hop> list) voidabstract booleanvoidvoidvoidabstract Objectclone()booleanabstract booleanlongdoublecomputeBoundsInformation(Hop input) static doublecomputeBoundsInformation(Hop input, LocalVariableMap vars) static doublecomputeBoundsInformation(Hop input, LocalVariableMap vars, Map<Long, Double> memo) voidcomputeMemEstimate(MemoTable memo) Computes the estimate of memory required to store the input/output of this hop in memory.static longcomputeSizeInformation(Hop input) longcomputeSizeInformation(Hop input, LocalVariableMap vars) longcomputeSizeInformation(Hop input, LocalVariableMap vars, Map<Long, Long> memo) voidabstract Lopstatic LopcreateOffsetLop(Hop hop, boolean repCols) voidbooleanbooleandimsKnown(boolean includeNnz) booleanintintintlonglonggetDim(int i) longgetDim1()Get the number of rows in the Hop.longgetDim2()Get the number of columns in the Hop.intintlonggetHopID()getInput()getInput(int ix) doubleGet the memory estimate of inputs as the sum of input estimates in bytes.doublegetInputMemEstimate(double injectedDefault) Get the memory estimate of inputs as the sum of input estimates in bytes.doublegetInputOutputSize(Collection<String> exclVars) doublelonggetLops()doubleNOTES: * Purpose: Whenever the output dimensions / sparsity of a hop are unknown, this hop should store its worst-case output statistics (if known) in that table.getName()longgetNnz()abstract StringdoubleOutput memory estimate in bytes.doublegetOutputMemEstimate(double injectedDefault) Output memory estimate in bytes with negative memory estimates replaced by the injected default.doubledoublegetText()booleanbooleanbooleanbooleanbooleanbooleanChecks if ExecType is federated.booleanChecks if the hop is a DataOp with federated data.abstract booleanIn memory-based optimizer mode (see OptimizerUtils.isMemoryBasedOptLevel()), the exectype is determined by checking this method as well as memory budget of this Hop.booleanisMatrix()booleanbooleanbooleanbooleanisScalar()booleanDefines if this operation is transpose-safe, which means that the result of op(input) is equivalent to op(t(input)).booleanbooleanChecks if prefetch is activated for this hop.voidrefreshColsParameterInformation(Hop input, LocalVariableMap vars) voidrefreshColsParameterInformation(Hop input, LocalVariableMap vars, Map<Long, Long> memo) voidrefreshMemEstimates(MemoTable memo) Recursively computes memory estimates for all the Hops in the DAG rooted at the current hop pointed bythis.voidrefreshRowsParameterInformation(Hop input, LocalVariableMap vars) voidrefreshRowsParameterInformation(Hop input, LocalVariableMap vars, Map<Long, Long> memo) abstract voidUpdate the output size information for this hop.booleanbooleanbooleanbooleanbooleanIndicates if dynamic recompilation is required for this hop.voidstatic voidresetRecompilationFlag(ArrayList<Hop> hops, Types.ExecType et, Recompiler.ResetType reset) static voidresetRecompilationFlag(Hop hops, Types.ExecType et, Recompiler.ResetType reset) static voidresetVisitStatus(List<Hop> hops) static voidresetVisitStatus(List<Hop> hops, boolean force) voidresetVisitStatusForced(HashSet<Long> memo) booleanvoidsetBeginColumn(int passed) voidsetBeginLine(int passed) voidsetBlocksize(int blen) voidsetCompressedOutput(boolean value) voidsetCompressedSize(long size) voidvoidsetDim(int i, long dim) voidsetDim1(long dim1) voidsetDim2(long dim2) voidsetEndColumn(int passed) voidsetEndLine(int passed) voidsetExecType(Types.ExecType execType) voidsetFederatedOutput(FEDInstruction.FederatedOutput federatedOutput) voidsetFilename(String passed) voidsetForcedExecType(Types.ExecType etype) voidvoidsetMemEstimate(double mem) Sets memory estimate in bytesvoidvoidsetNnz(long nnz) voidsetOutputEmptyBlocks(boolean flag) voidsetParseInfo(ParseInfo parseInfo) Set parse information.voidsetRequiresCheckpoint(boolean flag) voidvoidvoidvoidsetRequiresLineageCaching(boolean flag) voidsetRequiresReblock(boolean flag) voidMarks the hop for dynamic recompilation.voidvoidsetUpdateType(MatrixObject.UpdateType update) voidvoidvoidsetVisited(boolean flag) booleanfinal StringtoString()voidupdateLopFedOut(Lop lop) voidupdateLopFedOut(Lop lop, Types.ExecType execType, FEDInstruction.FederatedOutput fedOut)
-
Field Details
-
CPThreshold
public static final long CPThreshold- See Also:
-
_beginLine
public int _beginLine -
_beginColumn
public int _beginColumn -
_endLine
public int _endLine -
_endColumn
public int _endColumn -
_filename
-
_text
-
-
Constructor Details
-
Hop
-
-
Method Details
-
getHopID
public long getHopID() -
getExecType
-
setExecType
-
setFederatedOutput
-
activatePrefetch
public void activatePrefetch()Activate prefetch of HOP. -
deactivatePrefetch
public void deactivatePrefetch() -
prefetchActivated
public boolean prefetchActivated()Checks if prefetch is activated for this hop.- Returns:
- true if prefetch is activated
-
resetExecType
public void resetExecType() -
getForcedExecType
-
setForcedExecType
-
allowsAllExecTypes
public abstract boolean allowsAllExecTypes() -
isTransposeSafe
public boolean isTransposeSafe()Defines if this operation is transpose-safe, which means that the result of op(input) is equivalent to op(t(input)). Usually, this applies to aggregate operations with fixed output dimension. Finally, this information is very useful in order to safely optimize the plan for sparse vectors, which otherwise would be (currently) always represented dense.- Returns:
- always returns false
-
checkAndSetForcedPlatform
public void checkAndSetForcedPlatform() -
checkAndSetInvalidCPDimsAndSize
public void checkAndSetInvalidCPDimsAndSize() -
hasValidCPDimsAndSize
public boolean hasValidCPDimsAndSize() -
setRequiresReblock
public void setRequiresReblock(boolean flag) -
requiresReblock
public boolean requiresReblock() -
setRequiresCheckpoint
public void setRequiresCheckpoint(boolean flag) -
requiresCheckpoint
public boolean requiresCheckpoint() -
setRequiresCompression
public void setRequiresCompression() -
setRequiresCompression
-
setRequiresDeCompression
public void setRequiresDeCompression() -
isRequiredDecompression
public boolean isRequiredDecompression() -
requiresCompression
public boolean requiresCompression() -
setCompressedOutput
public void setCompressedOutput(boolean value) -
setCompressedSize
public void setCompressedSize(long size) -
getCompressedSize
public long getCompressedSize() -
isCompressedOutput
public boolean isCompressedOutput() -
hasCompressedInput
public boolean hasCompressedInput() -
compressedSize
public long compressedSize() -
setRequiresLineageCaching
public void setRequiresLineageCaching(boolean flag) -
requiresLineageCaching
public boolean requiresLineageCaching() -
updateLopFedOut
-
updateLopFedOut
public void updateLopFedOut(Lop lop, Types.ExecType execType, FEDInstruction.FederatedOutput fedOut) -
constructAndSetLopsDataFlowProperties
public void constructAndSetLopsDataFlowProperties() -
createOffsetLop
-
setOutputEmptyBlocks
public void setOutputEmptyBlocks(boolean flag) -
isOutputEmptyBlocks
public boolean isOutputEmptyBlocks() -
getInputOutputSize
-
getMemEstimate
public double getMemEstimate()NOTES: * Purpose: Whenever the output dimensions / sparsity of a hop are unknown, this hop should store its worst-case output statistics (if known) in that table. * Invocation: Intended to be called for ALL root nodes of one Hops DAG with the same (initially empty) memo table.- Returns:
- memory estimate in bytes
-
setMemEstimate
public void setMemEstimate(double mem) Sets memory estimate in bytes- Parameters:
mem- memory estimate
-
clearMemEstimate
public void clearMemEstimate() -
isMemEstimated
public boolean isMemEstimated() -
getInputMemEstimate
public double getInputMemEstimate()Get the memory estimate of inputs as the sum of input estimates in bytes.- Returns:
- input memory estimate in bytes
-
getInputMemEstimate
public double getInputMemEstimate(double injectedDefault) Get the memory estimate of inputs as the sum of input estimates in bytes.- Parameters:
injectedDefault- default memory estimate (bytes) used when the memory estimate of the input is negative- Returns:
- input memory estimate in bytes
-
getOutputMemEstimate
public double getOutputMemEstimate()Output memory estimate in bytes.- Returns:
- output memory estimate in bytes
-
getOutputMemEstimate
public double getOutputMemEstimate(double injectedDefault) Output memory estimate in bytes with negative memory estimates replaced by the injected default. The injected default represents the memory estimate per output cell, hence it is multiplied by the estimated dimensions of the output of the hop.- Parameters:
injectedDefault- memory estimate to be returned in case the memory estimate defaults to a negative number- Returns:
- output memory estimate in bytes
-
getIntermediateMemEstimate
public double getIntermediateMemEstimate() -
getSpBroadcastSize
public double getSpBroadcastSize() -
computeMemEstimate
Computes the estimate of memory required to store the input/output of this hop in memory. This is the default implementation (orchestration of hop-specific implementation) that should suffice for most hops. If a hop requires more control, this method should be overwritten with awareness of (1) output estimates, and (2) propagation of worst-case matrix characteristics (dimensions, sparsity). TODO remove memo table and, on constructor refresh, inference in refresh, single compute mem, maybe general computeMemEstimate, flags to indicate if estimate or not.- Parameters:
memo- memory table
-
refreshMemEstimates
Recursively computes memory estimates for all the Hops in the DAG rooted at the current hop pointed bythis.- Parameters:
memo- memory table
-
isFederated
public boolean isFederated()Checks if ExecType is federated.- Returns:
- true if ExecType is federated
-
someInputFederated
public boolean someInputFederated() -
isFederatedDataOp
public boolean isFederatedDataOp()Checks if the hop is a DataOp with federated data.- Returns:
- true if hop is a federated DataOp
-
getParent
-
getInput
-
getInput
-
addInput
-
addAllInputs
-
getBlocksize
public int getBlocksize() -
setBlocksize
public void setBlocksize(int blen) -
setNnz
public void setNnz(long nnz) -
getNnz
public long getNnz() -
getFederatedOutput
-
hasFederatedOutput
public boolean hasFederatedOutput() -
hasLocalOutput
public boolean hasLocalOutput() -
setUpdateType
-
getUpdateType
-
constructLops
-
getOpString
-
toString
-
isGPUEnabled
public abstract boolean isGPUEnabled()In memory-based optimizer mode (see OptimizerUtils.isMemoryBasedOptLevel()), the exectype is determined by checking this method as well as memory budget of this Hop. Please see findExecTypeByMemEstimate for more detail. This method is necessary because not all operator are supported efficiently on GPU (for example: operations on frames and scalar as well as operations such as table).- Returns:
- true if the Hop is eligible for GPU Exectype.
-
dimsKnown
public boolean dimsKnown() -
dimsKnown
public boolean dimsKnown(boolean includeNnz) -
dimsKnownAny
public boolean dimsKnownAny() -
rowsKnown
public boolean rowsKnown() -
colsKnown
public boolean colsKnown() -
resetVisitStatus
-
resetVisitStatus
-
resetVisitStatus
-
resetVisitStatusForced
-
resetRecompilationFlag
public static void resetRecompilationFlag(ArrayList<Hop> hops, Types.ExecType et, Recompiler.ResetType reset) -
resetRecompilationFlag
-
getDim1
public long getDim1()Get the number of rows in the Hop.- Returns:
- a long.
-
setDim1
public void setDim1(long dim1) -
getDim2
public long getDim2()Get the number of columns in the Hop.- Returns:
- a long.
-
setDim2
public void setDim2(long dim2) -
getDim
public long getDim(int i) -
setDim
public void setDim(int i, long dim) -
getLength
public long getLength() -
getSparsity
public double getSparsity() -
getDataCharacteristics
-
getLops
-
setLops
-
isVisited
public boolean isVisited() -
getDataType
-
setDataType
-
isScalar
public boolean isScalar() -
isMatrix
public boolean isMatrix() -
setVisited
public void setVisited() -
setVisited
public void setVisited(boolean flag) -
setName
-
getName
-
getValueType
-
setValueType
-
requiresRecompile
public boolean requiresRecompile()Indicates if dynamic recompilation is required for this hop.- Returns:
- true if dynamic recompilation required
-
setRequiresRecompile
public void setRequiresRecompile()Marks the hop for dynamic recompilation. -
refreshSizeInformation
public abstract void refreshSizeInformation()Update the output size information for this hop. -
computeSizeInformation
-
refreshRowsParameterInformation
-
refreshRowsParameterInformation
-
refreshColsParameterInformation
-
refreshColsParameterInformation
-
computeSizeInformation
-
computeSizeInformation
-
computeBoundsInformation
-
computeBoundsInformation
-
computeBoundsInformation
public static double computeBoundsInformation(Hop input, LocalVariableMap vars, Map<Long, Double> memo) -
clone
- Throws:
CloneNotSupportedException
-
compare
-
setBeginLine
public void setBeginLine(int passed) - Specified by:
setBeginLinein interfaceParseInfo
-
setBeginColumn
public void setBeginColumn(int passed) - Specified by:
setBeginColumnin interfaceParseInfo
-
setEndLine
public void setEndLine(int passed) - Specified by:
setEndLinein interfaceParseInfo
-
setEndColumn
public void setEndColumn(int passed) - Specified by:
setEndColumnin interfaceParseInfo
-
setFilename
- Specified by:
setFilenamein interfaceParseInfo
-
setText
-
getBeginLine
public int getBeginLine()- Specified by:
getBeginLinein interfaceParseInfo
-
getBeginColumn
public int getBeginColumn()- Specified by:
getBeginColumnin interfaceParseInfo
-
getEndLine
public int getEndLine()- Specified by:
getEndLinein interfaceParseInfo
-
getEndColumn
public int getEndColumn()- Specified by:
getEndColumnin interfaceParseInfo
-
getFilename
- Specified by:
getFilenamein interfaceParseInfo
-
getText
-
printErrorLocation
-
setParseInfo
Set parse information.- Parameters:
parseInfo- parse information, such as beginning line position, beginning column position, ending line position, ending column position, text, and filename
-