Package org.apache.sysds.hops.codegen.template

## Class TemplateUtils

- java.lang.Object
- - org.apache.sysds.hops.codegen.template.TemplateUtils

-     public class TemplateUtils
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static TemplateBase[]` | `TEMPLATES` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TemplateUtils()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static boolean` | `containsBinary​(CNode node, CNodeBinary.BinType type)` |
    `static boolean` | `containsFusedRowVecAgg​(CNodeTpl tpl)` |
    `static boolean` | `containsOuterProduct​(Hop hop)` |
    `static boolean` | `containsOuterProduct​(Hop hop, Hop probe)` |
    `static int` | `countVectorIntermediates​(CNode node)` |
    `static CNodeData` | `createCNodeData​(Hop hop, boolean compileLiterals)` |
    `static TemplateBase[]` | `createCompatibleTemplates​(TemplateBase.TemplateType type, TemplateBase.CloseType ctype)` |
    `static TemplateBase` | `createTemplate​(TemplateBase.TemplateType type)` |
    `static TemplateBase` | `createTemplate​(TemplateBase.TemplateType type, TemplateBase.CloseType ctype)` |
    `static int` | `determineMinVectorIntermediates​(CNode node, CNode main)` |
    `static LinkedList<Long>` | `findRemovableConditionalPatternInOuterProduct​(Hop hop)` |
    `static Types.AggOp` | `getAggOp​(Hop hop)` |
    `static Map<Long,​Set<Long>>` | `getAllParents​(CNode node)` |
    `static void` | `getAllParents​(CNode node, Map<Long,​Set<Long>> parents)` |
    `static SpoofCellwise.CellType` | `getCellType​(Hop hop)` |
    `static CNodeData` | `getLiteral​(CNode node)` |
    `static int` | `getMaxLiveVectorIntermediates​(CNode node, CNode main, Map<Long,​Set<Long>> parents, Set<org.apache.commons.lang3.tuple.Pair<Long,​Long>> stack)` |
    `static int` | `getMaxVectorIntermediates​(CNode node)` |
    `static SpoofOuterProduct.OutProdType` | `getOuterProductType​(Hop X, Hop U, Hop V, Hop out)` |
    `static long` | `getRowTemplateMatrixInput​(Hop current, CPlanMemoTable memo)` |
    `static SpoofRowwise.RowType` | `getRowType​(Hop output, Hop... inputs)` |
    `static boolean` | `hasCommonRowTemplateMatrixInput​(Hop input1, Hop input2, CPlanMemoTable memo)` |
    `static boolean` | `hasMatrixInput​(Hop hop)` |
    `static boolean` | `hasNoOperation​(CNodeTpl tpl)` |
    `static boolean` | `hasOnlyDataNodeOrLookupInputs​(CNode node)` |
    `static boolean` | `hasSingleOperation​(CNodeTpl tpl)` |
    `static boolean` | `hasTransposeParentUnderOuterProduct​(Hop hop)` |
    `static boolean` | `isBinary​(CNode node, CNodeBinary.BinType... types)` |
    `static boolean` | `isBinaryMatrixColVector​(Hop hop)` |
    `static boolean` | `isBinaryMatrixRowVector​(Hop hop)` |
    `static boolean` | `isColVector​(CNode hop)` |
    `static boolean` | `isColVector​(Hop hop)` |
    `static boolean` | `isLiteral​(CNode node)` |
    `static boolean` | `isLiteral​(CNode node, String val)` |
    `static boolean` | `isLookup​(CNode node, boolean includeRC1)` |
    `static boolean` | `isMatrix​(CNode hop)` |
    `static boolean` | `isMatrix​(Hop hop)` |
    `static boolean` | `isOperationSupported​(Hop h)` |
    `static boolean` | `isRowVector​(CNode hop)` |
    `static boolean` | `isTernary​(CNode node, CNodeTernary.TernaryType... types)` |
    `static boolean` | `isType​(TemplateBase.TemplateType type, TemplateBase.TemplateType... validTypes)` |
    `static boolean` | `isUnary​(CNode node, CNodeUnary.UnaryType... types)` |
    `static boolean` | `isUnaryOperatorPipeline​(CNode node)` |
    `static boolean` | `isUnaryRowAgg​(CNode node)` |
    `static boolean` | `isValidNumVectorIntermediates​(CNode node, CNode main, Map<Long,​Set<Long>> parents, Map<Long,​org.apache.commons.lang3.tuple.Pair<Long,​org.apache.commons.lang3.mutable.MutableInt>> inUse, Set<Long> inUse2, int count)` |
    `static boolean` | `isValidSingleOperation​(Hop hop)` |
    `static boolean` | `isVector​(Hop hop)` |
    `static boolean` | `isVectorOrScalar​(Hop hop)` |
    `static boolean` | `rContainsBinary​(CNode node, CNodeBinary.BinType type)` |
    `static boolean` | `rContainsInput​(CNode node, long hopID)` |
    `static void` | `rFlipVectorLookups​(CNode current)` |
    `static boolean` | `rIsSparseSafeOnly​(CNode node, CNodeBinary.BinType... types)` |
    `static boolean` | `rIsValidNumVectorIntermediates​(CNode node, CNode main, Map<Long,​Set<Long>> parents, Map<Long,​org.apache.commons.lang3.tuple.Pair<Long,​org.apache.commons.lang3.mutable.MutableInt>> inUse, Set<Long> inUse2, IDSequence buff)` |
    `static long` | `skipConditionalInOuterProduct​(Hop hop, HashMap<Long,​CNode> tmp, HashSet<Hop> inHops)` |
    `static CNode` | `skipTranspose​(CNode cdataOrig, Hop hop, HashMap<Long,​CNode> tmp, boolean compileLiterals)` |
    `static CNode` | `wrapLookupIfNecessary​(CNode node, Hop hop)` |
    `static CNode` | `wrapLookupIfNecessary​(CNode node, Hop hop, boolean rowTpl)` |

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TEMPLATES

          public static final TemplateBase[] TEMPLATES

  - ### Constructor Detail

    - #### TemplateUtils

          public TemplateUtils()

  - ### Method Detail

    - #### isVector

          public static boolean isVector​(Hop hop)

    - #### isColVector

          public static boolean isColVector​(Hop hop)

    - #### isColVector

          public static boolean isColVector​(CNode hop)

    - #### isRowVector

          public static boolean isRowVector​(CNode hop)

    - #### isMatrix

          public static boolean isMatrix​(CNode hop)

    - #### wrapLookupIfNecessary

          public static CNode wrapLookupIfNecessary​(CNode node,
                                                    Hop hop)

    - #### wrapLookupIfNecessary

          public static CNode wrapLookupIfNecessary​(CNode node,
                                                    Hop hop,
                                                    boolean rowTpl)

    - #### isMatrix

          public static boolean isMatrix​(Hop hop)

    - #### isVectorOrScalar

          public static boolean isVectorOrScalar​(Hop hop)

    - #### isBinaryMatrixRowVector

          public static boolean isBinaryMatrixRowVector​(Hop hop)

    - #### isBinaryMatrixColVector

          public static boolean isBinaryMatrixColVector​(Hop hop)

    - #### hasMatrixInput

          public static boolean hasMatrixInput​(Hop hop)

    - #### isOperationSupported

          public static boolean isOperationSupported​(Hop h)

    - #### createTemplate

          public static TemplateBase createTemplate​(TemplateBase.TemplateType type)

    - #### createTemplate

          public static TemplateBase createTemplate​(TemplateBase.TemplateType type,
                                                    TemplateBase.CloseType ctype)

    - #### createCompatibleTemplates

          public static TemplateBase[] createCompatibleTemplates​(TemplateBase.TemplateType type,
                                                                 TemplateBase.CloseType ctype)

    - #### getCellType

          public static SpoofCellwise.CellType getCellType​(Hop hop)

    - #### getRowType

          public static SpoofRowwise.RowType getRowType​(Hop output,
                                                        Hop... inputs)

    - #### getAggOp

          public static Types.AggOp getAggOp​(Hop hop)

    - #### getOuterProductType

          public static SpoofOuterProduct.OutProdType getOuterProductType​(Hop X,
                                                                          Hop U,
                                                                          Hop V,
                                                                          Hop out)

    - #### getLiteral

          public static CNodeData getLiteral​(CNode node)

    - #### isLiteral

          public static boolean isLiteral​(CNode node)

    - #### isLiteral

          public static boolean isLiteral​(CNode node,
                                          String val)

    - #### isLookup

          public static boolean isLookup​(CNode node,
                                         boolean includeRC1)

    - #### isUnary

          public static boolean isUnary​(CNode node,
                                        CNodeUnary.UnaryType... types)

    - #### isUnaryRowAgg

          public static boolean isUnaryRowAgg​(CNode node)

    - #### isBinary

          public static boolean isBinary​(CNode node,
                                         CNodeBinary.BinType... types)

    - #### rIsSparseSafeOnly

          public static boolean rIsSparseSafeOnly​(CNode node,
                                                  CNodeBinary.BinType... types)

    - #### rContainsInput

          public static boolean rContainsInput​(CNode node,
                                               long hopID)

    - #### isTernary

          public static boolean isTernary​(CNode node,
                                          CNodeTernary.TernaryType... types)

    - #### createCNodeData

          public static CNodeData createCNodeData​(Hop hop,
                                                  boolean compileLiterals)

    - #### skipTranspose

          public static CNode skipTranspose​(CNode cdataOrig,
                                            Hop hop,
                                            HashMap<Long,​CNode> tmp,
                                            boolean compileLiterals)

    - #### findRemovableConditionalPatternInOuterProduct

          public static LinkedList<Long> findRemovableConditionalPatternInOuterProduct​(Hop hop)

    - #### skipConditionalInOuterProduct

          public static long skipConditionalInOuterProduct​(Hop hop,
                                                           HashMap<Long,​CNode> tmp,
                                                           HashSet<Hop> inHops)

    - #### hasTransposeParentUnderOuterProduct

          public static boolean hasTransposeParentUnderOuterProduct​(Hop hop)

    - #### hasSingleOperation

          public static boolean hasSingleOperation​(CNodeTpl tpl)

    - #### isValidSingleOperation

          public static boolean isValidSingleOperation​(Hop hop)

    - #### hasNoOperation

          public static boolean hasNoOperation​(CNodeTpl tpl)

    - #### hasOnlyDataNodeOrLookupInputs

          public static boolean hasOnlyDataNodeOrLookupInputs​(CNode node)

    - #### determineMinVectorIntermediates

          public static int determineMinVectorIntermediates​(CNode node,
                                                            CNode main)

    - #### isUnaryOperatorPipeline

          public static boolean isUnaryOperatorPipeline​(CNode node)

    - #### getMaxVectorIntermediates

          public static int getMaxVectorIntermediates​(CNode node)

    - #### countVectorIntermediates

          public static int countVectorIntermediates​(CNode node)

    - #### getMaxLiveVectorIntermediates

          public static int getMaxLiveVectorIntermediates​(CNode node,
                                                          CNode main,
                                                          Map<Long,​Set<Long>> parents,
                                                          Set<org.apache.commons.lang3.tuple.Pair<Long,​Long>> stack)

    - #### isValidNumVectorIntermediates

          public static boolean isValidNumVectorIntermediates​(CNode node,
                                                              CNode main,
                                                              Map<Long,​Set<Long>> parents,
                                                              Map<Long,​org.apache.commons.lang3.tuple.Pair<Long,​org.apache.commons.lang3.mutable.MutableInt>> inUse,
                                                              Set<Long> inUse2,
                                                              int count)

    - #### rIsValidNumVectorIntermediates

          public static boolean rIsValidNumVectorIntermediates​(CNode node,
                                                               CNode main,
                                                               Map<Long,​Set<Long>> parents,
                                                               Map<Long,​org.apache.commons.lang3.tuple.Pair<Long,​org.apache.commons.lang3.mutable.MutableInt>> inUse,
                                                               Set<Long> inUse2,
                                                               IDSequence buff)

    - #### getAllParents

          public static Map<Long,​Set<Long>> getAllParents​(CNode node)

    - #### getAllParents

          public static void getAllParents​(CNode node,
                                           Map<Long,​Set<Long>> parents)

    - #### isType

          public static boolean isType​(TemplateBase.TemplateType type,
                                       TemplateBase.TemplateType... validTypes)

    - #### hasCommonRowTemplateMatrixInput

          public static boolean hasCommonRowTemplateMatrixInput​(Hop input1,
                                                                Hop input2,
                                                                CPlanMemoTable memo)

    - #### getRowTemplateMatrixInput

          public static long getRowTemplateMatrixInput​(Hop current,
                                                       CPlanMemoTable memo)

    - #### containsBinary

          public static boolean containsBinary​(CNode node,
                                               CNodeBinary.BinType type)

    - #### rContainsBinary

          public static boolean rContainsBinary​(CNode node,
                                                CNodeBinary.BinType type)

    - #### containsOuterProduct

          public static boolean containsOuterProduct​(Hop hop)

    - #### containsOuterProduct

          public static boolean containsOuterProduct​(Hop hop,
                                                     Hop probe)

    - #### rFlipVectorLookups

          public static void rFlipVectorLookups​(CNode current)

    - #### containsFusedRowVecAgg

          public static boolean containsFusedRowVecAgg​(CNodeTpl tpl)