Package org.apache.sysds.hops.rewrite
Class HopRewriteUtils
java.lang.Object
org.apache.sysds.hops.rewrite.HopRewriteUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddChildReference(Hop parent, Hop child) static voidaddChildReference(Hop parent, Hop child, int pos) static booleanalwaysRequiresReblock(Hop hop) static booleancheckAvgRowsGteCols(List<Hop> list) static booleancheckConsistentRows(List<Hop> list1, List<Hop> list2) static booleancheckInputDataTypes(Hop hop, Types.DataType... dt) static voidcleanupUnreferenced(Hop... inputs) static intcompareSize(Hop hop1, Hop hop2) Compares the size of outputs from hop1 and hop2, in terms of number of matrix cells.static booleancontainsInput(Hop current, Hop probe) static booleancontainsOp(List<Hop> candidates, Class<? extends Hop> clazz) static booleancontainsSecondOrderBuiltin(List<Hop> roots) static booleancontainsTransposeOperation(List<Hop> hops) static DataGenOpcopyDataGenOp(DataGenOp inputGen, double scale, double shift) Assumes that min and max are literal ops, needs to be checked from outside.static voidcopyLineNumbers(Hop src, Hop dest) static voidcopyLineNumbers(MatrixObject mo, Hop tread) static voidcopyLineNumbers(MatrixBlock mb, Hop tread) static AggUnaryOpcreateAggUnaryOp(Hop input, String op) static AggUnaryOpcreateAggUnaryOp(Hop input, Types.AggOp op, Types.Direction dir) static BinaryOpcreateBinary(Hop input1, Hop input2, String op) static BinaryOpcreateBinary(Hop input1, Hop input2, Types.OpOp2 op) static BinaryOpcreateBinary(Hop input1, Hop input2, Types.OpOp2 op, boolean outer) static BinaryOpcreateBinaryMinus(Hop input) static HopcreateComputeNnz(Hop input) static HopcreateDataGenOp(Hop rowInput, boolean tRowInput, Hop colInput, boolean tColInput, double value) static HopcreateDataGenOp(Hop input, double value) static HopcreateDataGenOp(Hop rowInput, Hop colInput, double value) static HopcreateDataGenOpByVal(List<LiteralOp> values, long rows, long cols) static HopcreateDataGenOpByVal(Hop rowInput, Hop colInput, Hop dimsInput, Types.DataType dt, Types.ValueType vt, double value) static DataOpcreateDataOp(String name, Hop in, Types.OpOpData type) static IndexingOpcreateIndexingOp(Hop input, long rix, long cix) static IndexingOpcreateIndexingOp(Hop input, long rl, long ru, long cl, long cu) static IndexingOpcreateIndexingOp(Hop input, Hop batchsize) static IndexingOpstatic LeftIndexingOpstatic AggBinaryOpcreateMatrixMultiply(Hop left, Hop right) static NaryOpcreateNary(Types.OpOpN op, Hop... inputs) static ParameterizedBuiltinOpcreateParameterizedBuiltinOp(Hop input, LinkedHashMap<String, Hop> args, Types.ParamBuiltinOp op) static HopcreatePartialTsmmCbind(Hop X, Hop deltaX, Hop tsmmIn1) static ReorgOpcreateReorg(List<Hop> inputs, Types.ReOrgOp rop) static ReorgOpcreateReorg(Hop input, String rop) static ReorgOpcreateReorg(Hop input, Types.ReOrgOp rop) static HopcreateScalarIndexing(Hop input, long rix, long cix) static DataGenOpcreateSeqDataGenOp(Hop input) static DataGenOpcreateSeqDataGenOp(Hop input, boolean asc) static DataGenOpcreateSeqDataGenOp(Hop proxy, Hop from, Hop to, Hop incr) static AggUnaryOpstatic TernaryOpcreateTernary(Hop mleft, Hop smid, Hop mright, String opcode) static TernaryOpcreateTernary(Hop mleft, Hop smid, Hop mright, Types.OpOp3 op) static TernaryOpcreateTernary(Hop in1, Hop in2, Hop in3, Hop in4, Hop in5, Types.OpOp3 op) static DataOpcreateTransientRead(String name, Hop h) static DataOpcreateTransientRead(String name, MatrixObject mo) static DataOpcreateTransientRead(String name, MatrixBlock mb) static DataOpcreateTransientWrite(String name, Hop in) static ReorgOpcreateTranspose(Hop input) static AggBinaryOpcreateTsmm(Hop input, boolean left) static UnaryOpcreateUnary(Hop input, String type) static UnaryOpcreateUnary(Hop input, Types.OpOp1 type) static HopcreateValueHop(Hop hop, boolean row) static HopgetBasic1NSequenceMax(Hop hop) static booleanstatic booleanstatic intgetChildReferencePos(Hop parent, Hop child) static Hopstatic doublestatic doublestatic longgetIntValue(LiteralOp op) Return the int value of a LiteralOp (as a long).static longgetIntValueSafe(Hop op) static longstatic HopgetLargestInput(Hop hop) static longgetMaxInputDim(Hop hop, boolean dim1) static longgetMaxInputDim(DataCharacteristics[] dc, boolean dim1) static longgetMaxNcolInput(Hop hop) static longgetMaxNrowInput(Hop hop) static HopgetOtherInput(Hop hop, Hop input) static ScalarObjectstatic longgetSumValidInputDims(Hop hop, boolean dim1) static longgetSumValidInputDims(DataCharacteristics[] mc, boolean dim1) static longgetSumValidInputNnz(Hop hop) static longgetSumValidInputNnz(DataCharacteristics[] mc, boolean worstcase) static intgetValidOpPos(Types.OpOp2 input, Types.OpOp2... validTab) static booleanhasListInputs(Hop hop) static booleanhasOnlyUnaryBinaryParents(Hop hop, boolean disallowLhs) static booleanhasOnlyWriteParents(Hop hop, boolean inclTransient, boolean inclPersistent) static booleanhasValidInputDims(Hop hop, boolean dim1) static booleanhasValidInputDims(DataCharacteristics[] mc, boolean dim1) static booleanhasValidInputNnz(Hop hop) static booleanhasValidInputNnz(DataCharacteristics[] mc, boolean worstcase) static booleanisAggUnaryOp(Hop hop, Types.AggOp... op) static booleanisAggUnaryOp(Hop hop, Types.AggOp op, Types.Direction dir) static booleanisBasic1NSequence(Hop hop) static booleanisBasic1NSequence(Hop seq, Hop input, boolean row) static booleanisBasicN1Sequence(Hop hop) static booleanisBinary(Hop hop, Types.OpOp2 type) static booleanisBinary(Hop hop, Types.OpOp2... types) static booleanisBinary(Hop hop, Types.OpOp2 type, int maxParents) static booleanstatic booleanstatic booleanstatic booleanstatic booleanisBinaryMatrixScalar(Hop hop, Types.OpOp2 type, double val) static booleanstatic booleanisBinaryPPred(Hop hop) static booleanisBinarySparseSafe(Hop hop) static booleanstatic booleanisColumnRightIndexing(Hop hop) static booleanisConsecutiveIndex(Hop index, Hop index2) static booleanisData(Hop hop, Types.OpOpData type) static booleanisData(Hop hop, Types.OpOpData... types) static booleanisData(Hop hop, Types.OpOpData type, Types.DataType dt) static booleanisDataGenOp(Hop hop, Types.OpOpDG... ops) static booleanstatic booleanisDataGenOpWithConstantValue(Hop hop, double value) static booleanisDataGenOpWithLiteralInputs(Hop hop, Types.OpOpDG... ops) static booleanstatic booleanstatic booleanisDimsKnown(Hop hop) static booleanisDnn(Hop hop, Types.OpOpDnn type) static booleanisDnn(Hop hop, Types.OpOpDnn... types) static booleanstatic booleanstatic booleanisEqualSize(Hop hop1, Hop hop2) static booleanisEqualSize(Hop hop1, Hop... hops) static booleanisEqualValue(Hop hop1, Hop hop2) static booleanisEqualValue(LiteralOp hop1, LiteralOp hop2) static booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanisLiteralOfValue(Hop hop, boolean val) static booleanisLiteralOfValue(Hop hop, double val) static booleanisLiteralOfValue(Hop hop, Double... val) static booleanisLiteralOfValue(Hop hop, String val) static booleanstatic booleanisMatrixMultiply(Hop hop) static booleanisNary(Hop hop, Types.OpOpN type) static booleanisNary(Hop hop, Types.OpOpN... types) static booleanisNonZeroIndicator(Hop pred, Hop hop) static booleanstatic booleanisOuterBinary(Hop hop) static booleanisOuterProductLikeMM(Hop hop) static booleanisParameterizedBuiltinOp(Hop hop, Types.ParamBuiltinOp type) static booleanisParameterizedBuiltinOp(Hop hop, Types.ParamBuiltinOp... types) static booleanisRemoveEmpty(Hop hop) static booleanisRemoveEmpty(Hop hop, boolean rows) static booleanisReorg(Hop hop, Types.ReOrgOp type) static booleanisReorg(Hop hop, Types.ReOrgOp... types) static booleanstatic booleanisSingleBlock(Hop hop) static booleanisSingleBlock(Hop hop, boolean cols) Checks our BLOCKSIZE CONSTRAINT, w/ awareness of forced single node execution mode.static booleanisSizeExpressionOf(Hop size, Hop input, boolean row) static booleanstatic booleanstatic booleanstatic booleanstatic booleanisTerminalHop(Hop hop) Check if given hop is of a terminal type.static booleanisTernary(Hop hop, Types.OpOp3 type) static booleanisTernary(Hop hop, Types.OpOp3... types) static booleanisTransformEncode(Hop hop) static booleanisTransposeOfItself(Hop hop1, Hop hop2) static booleanisTransposeOperation(Hop hop) static booleanisTransposeOperation(Hop hop, int maxParents) static booleanstatic booleanisTsmmInput(Hop input) static booleanisUnary(Hop hop, Types.OpOp1 type) static booleanisUnary(Hop hop, Types.OpOp1... types) static booleanisUnary(Hop hop, Types.OpOp1 type, int maxParents) static booleanstatic booleanisValidOp(Types.AggOp input, Types.AggOp... validTab) static booleanisValidOp(Types.OpOp1 input, Types.OpOp1... validTab) static booleanisValidOp(Types.OpOp2 input, Types.OpOp2... validTab) static booleanisValidOp(Types.ParamBuiltinOp input, Types.ParamBuiltinOp... validTab) static booleanisValidOp(Types.ReOrgOp input, Types.ReOrgOp... validTab) static booleanstatic booleanstatic booleanstatic booleanknownParamservFunctions(Hop hop, DMLProgram prog) static booleanrContainsRead(Hop root, String var, boolean includeMetaOp) static voidrefreshOutputParameters(Hop hnew, Hop hold) static voidremoveAllChildReferences(Hop parent) static voidremoveChildReference(Hop parent, Hop child) static voidremoveChildReferenceByPos(Hop parent, Hop child, int posChild) static voidreplaceChildReference(Hop parent, Hop inOld, Hop inNew) static voidreplaceChildReference(Hop parent, Hop inOld, Hop inNew, int pos) static voidreplaceChildReference(Hop parent, Hop inOld, Hop inNew, int pos, boolean refresh) static HoprewireAllParentChildReferences(Hop hold, Hop hnew) Replace an old Hop with a replacement Hop.static booleanrHasSimpleReadChain(Hop root, String var) static voidsetOutputParameters(Hop hop, long rlen, long clen, int blen, long nnz) static voidstatic voidstatic voidupdateHopCharacteristics(Hop hop, int blen, Hop src) static voidupdateHopCharacteristics(Hop hop, int blen, MemoTable memo, Hop src)
-
Constructor Details
-
HopRewriteUtils
public HopRewriteUtils()
-
-
Method Details
-
isValueTypeCast
-
getBooleanValue
-
getBooleanValueSafe
-
getDoubleValue
-
getDoubleValueSafe
-
getIntValue
Return the int value of a LiteralOp (as a long). Note: For comparisons, this is *only* to be used in situations in which the value is absolutely guaranteed to be an integer. Otherwise, a safer alternative is `getDoubleValue`.- Parameters:
op- literal operator- Returns:
- long value of literal op
-
getIntValueSafe
-
getIntValueSafe
-
isLiteralOfValue
-
isLiteralOfValue
-
isLiteralOfValue
-
isLiteralOfValue
-
getScalarObject
-
getChildReferencePos
-
removeChildReference
-
removeChildReferenceByPos
-
removeAllChildReferences
-
addChildReference
-
addChildReference
-
rewireAllParentChildReferences
Replace an old Hop with a replacement Hop. If the old Hop has no parents, then return the replacement. Otherwise rewire each of the Hop's parents into the replacement and return the replacement.- Parameters:
hold- To be replacedhnew- The replacement- Returns:
- hnew
-
replaceChildReference
-
replaceChildReference
-
replaceChildReference
-
cleanupUnreferenced
-
getOtherInput
-
getLargestInput
-
createDataGenOp
-
copyDataGenOp
Assumes that min and max are literal ops, needs to be checked from outside.- Parameters:
inputGen- input data gen opscale- the scaleshift- the shift- Returns:
- data gen op
-
createDataGenOp
-
createDataGenOp
-
createDataGenOpByVal
public static Hop createDataGenOpByVal(Hop rowInput, Hop colInput, Hop dimsInput, Types.DataType dt, Types.ValueType vt, double value) -
createDataGenOpByVal
-
isDataGenOp
-
isDataGenOpWithLiteralInputs
-
isDataGenOpWithConstantValue
-
isDataGenOpWithConstantValue
-
isDataGenOpWithNonDeterminism
-
getDataGenOpConstantValue
-
createTransientRead
-
createTransientRead
-
createTransientRead
-
createTransientWrite
-
createDataOp
-
createTranspose
-
createReorg
-
createReorg
-
createReorg
-
createUnary
-
createUnary
-
createBinaryMinus
-
createBinary
-
createBinary
-
createBinary
-
createSum
-
createAggUnaryOp
-
createAggUnaryOp
-
createTsmm
-
createMatrixMultiply
-
createParameterizedBuiltinOp
public static ParameterizedBuiltinOp createParameterizedBuiltinOp(Hop input, LinkedHashMap<String, Hop> args, Types.ParamBuiltinOp op) -
createScalarIndexing
-
createIndexingOp
-
createIndexingOp
-
createIndexingOp
-
createIndexingOp
-
createLeftIndexingOp
-
createNary
-
createValueHop
-
createSeqDataGenOp
-
createSeqDataGenOp
-
createSeqDataGenOp
-
createTernary
-
createTernary
-
createTernary
-
createComputeNnz
-
setOutputParameters
-
setOutputParametersForScalar
-
refreshOutputParameters
-
copyLineNumbers
-
copyLineNumbers
-
copyLineNumbers
-
updateHopCharacteristics
-
updateHopCharacteristics
-
isDimsKnown
-
isEmpty
-
isEqualMatrixSize
-
isEqualSize
-
isEqualSize
-
isSingleBlock
-
isSingleBlock
Checks our BLOCKSIZE CONSTRAINT, w/ awareness of forced single node execution mode.- Parameters:
hop- high-level operatorcols- true if cols- Returns:
- true if single block
-
isOuterProductLikeMM
-
isOuterBinary
-
isValidOuterBinaryOp
-
isSparse
-
isDense
-
isSparse
-
isEqualValue
-
isEqualValue
-
isNotMatrixVectorBinaryOperation
-
isReorg
-
isReorg
-
isTransposeOperation
-
isTransposeOperation
-
containsTransposeOperation
-
isTransposeOfItself
-
isTsmm
-
isTsmmInput
-
isBinary
-
isBinary
-
isBinary
-
isBinaryPPred
-
isBinarySparseSafe
-
isBinaryMatrixScalarOperation
-
isBinaryMatrixMatrixOperation
-
isBinaryMatrixScalar
-
isTernary
-
isTernary
-
containsInput
-
isData
-
isData
-
isData
-
isTransformEncode
-
isBinaryMatrixColVectorOperation
-
isBinaryMatrixRowVectorOperation
-
isUnary
-
isUnary
-
isUnary
-
isTerminalHop
Check if given hop is of a terminal type. Terminal hops are either of type print or write.- Parameters:
hop- for which the type is checked- Returns:
- true if hop is terminal
-
isMatrixMultiply
-
isAggUnaryOp
-
isAggUnaryOp
-
isSum
-
isSumSq
-
isParameterizedBuiltinOp
-
isParameterizedBuiltinOp
-
isRemoveEmpty
-
isRemoveEmpty
-
isNary
-
isNary
-
isDnn
-
isDnn
-
isNonZeroIndicator
-
checkInputDataTypes
-
checkAvgRowsGteCols
-
checkConsistentRows
-
isColumnRightIndexing
-
isFullColumnIndexing
-
isFullColumnIndexing
-
isFullRowIndexing
-
isFullRowIndexing
-
isColumnRangeIndexing
-
isConsecutiveIndex
-
isUnnecessaryRightIndexing
-
isScalarMatrixBinaryMult
-
isBasic1NSequence
-
isBasic1NSequence
-
isBasicN1Sequence
-
getBasic1NSequenceMax
-
isSizeExpressionOf
-
hasOnlyWriteParents
-
hasOnlyUnaryBinaryParents
-
alwaysRequiresReblock
-
containsOp
-
rHasSimpleReadChain
-
rContainsRead
-
createPartialTsmmCbind
-
isValidOp
-
isValidOp
-
isValidOp
-
isValidOp
-
isValidOp
-
getValidOpPos
-
compareSize
Compares the size of outputs from hop1 and hop2, in terms of number of matrix cells.- Parameters:
hop1- high-level operator 1hop2- high-level operator 2- Returns:
- 0 if sizes are equal, <0 for hop1<hop2, >0 for hop1>hop2.
-
isLastLevelStatementBlock
-
isLoopStatementBlock
-
isLastLevelLoopStatementBlock
-
getMaxNrowInput
-
getMaxNcolInput
-
getMaxInputDim
-
getSumValidInputDims
-
hasValidInputDims
-
getSumValidInputNnz
-
hasValidInputNnz
-
getMaxInputDim
-
getSumValidInputDims
-
hasValidInputDims
-
getSumValidInputNnz
-
hasValidInputNnz
-
hasListInputs
-
containsSecondOrderBuiltin
-
knownParamservFunctions
-
knownParamservFunctions
-
setUnoptimizedFunctionCalls
-