use of org.apache.sysml.hops.AggBinaryOp in project systemml by apache.
the class RewriteSplitDagDataDependentOperators method rCollectDataDependentOperators.
private void rCollectDataDependentOperators(Hop hop, ArrayList<Hop> cand) {
if (hop.isVisited())
return;
// prevent unnecessary dag split (dims known or no consumer operations)
boolean noSplitRequired = (hop.dimsKnown() || HopRewriteUtils.hasOnlyWriteParents(hop, true, true));
boolean investigateChilds = true;
// #1 removeEmpty
if (hop instanceof ParameterizedBuiltinOp && ((ParameterizedBuiltinOp) hop).getOp() == ParamBuiltinOp.RMEMPTY && !noSplitRequired && !(hop.getParent().size() == 1 && hop.getParent().get(0) instanceof TernaryOp && ((TernaryOp) hop.getParent().get(0)).isMatrixIgnoreZeroRewriteApplicable())) {
ParameterizedBuiltinOp pbhop = (ParameterizedBuiltinOp) hop;
cand.add(pbhop);
investigateChilds = false;
// keep interesting consumer information, flag hops accordingly
boolean noEmptyBlocks = true;
boolean onlyPMM = true;
boolean diagInput = pbhop.isTargetDiagInput();
for (Hop p : hop.getParent()) {
// list of operators without need for empty blocks to be extended as needed
noEmptyBlocks &= (p instanceof AggBinaryOp && hop == p.getInput().get(0) || HopRewriteUtils.isUnary(p, OpOp1.NROW));
onlyPMM &= (p instanceof AggBinaryOp && hop == p.getInput().get(0));
}
pbhop.setOutputEmptyBlocks(!noEmptyBlocks);
if (onlyPMM && diagInput) {
if (ConfigurationManager.isDynamicRecompilation())
pbhop.setOutputPermutationMatrix(true);
for (Hop p : hop.getParent()) ((AggBinaryOp) p).setHasLeftPMInput(true);
}
}
// #2 ctable with unknown dims
if (HopRewriteUtils.isTernary(hop, OpOp3.CTABLE) && // dims not provided
hop.getInput().size() < 4 && !noSplitRequired) {
cand.add(hop);
investigateChilds = false;
// keep interesting consumer information, flag hops accordingly
boolean onlyPMM = true;
for (Hop p : hop.getParent()) {
onlyPMM &= (p instanceof AggBinaryOp && hop == p.getInput().get(0));
}
if (onlyPMM && HopRewriteUtils.isBasic1NSequence(hop.getInput().get(0)))
hop.setOutputEmptyBlocks(false);
}
// #3 orderby childs computed in same DAG
if (HopRewriteUtils.isReorg(hop, ReOrgOp.SORT)) {
// params 'decreasing' / 'indexreturn'
for (int i = 2; i <= 3; i++) {
Hop c = hop.getInput().get(i);
if (!(c instanceof LiteralOp || c instanceof DataOp)) {
cand.add(c);
c.setVisited();
investigateChilds = false;
}
}
}
// #4 second-order eval function
if (HopRewriteUtils.isNary(hop, OpOpN.EVAL) && !noSplitRequired) {
cand.add(hop);
investigateChilds = false;
}
// otherwise, processed by recursive rule application)
if (investigateChilds && hop.getInput() != null)
for (Hop c : hop.getInput()) rCollectDataDependentOperators(c, cand);
hop.setVisited();
}
Aggregations