use of org.apache.sysml.lops.PlusMult in project incubator-systemml by apache.
the class TernaryOp method constructLopsPlusMult.
private void constructLopsPlusMult() throws HopsException, LopsException {
if (_op != OpOp3.PLUS_MULT && _op != OpOp3.MINUS_MULT)
throw new HopsException("Unexpected operation: " + _op + ", expecting " + OpOp3.PLUS_MULT + " or" + OpOp3.MINUS_MULT);
ExecType et = null;
if (DMLScript.USE_ACCELERATOR && (DMLScript.FORCE_ACCELERATOR || getMemEstimate() < OptimizerUtils.GPU_MEMORY_BUDGET))
et = ExecType.GPU;
else
et = optFindExecType();
PlusMult plusmult = null;
if (et == ExecType.CP || et == ExecType.SPARK || et == ExecType.GPU) {
plusmult = new PlusMult(getInput().get(0).constructLops(), getInput().get(1).constructLops(), getInput().get(2).constructLops(), _op, getDataType(), getValueType(), et);
} else {
//MR
Hop left = getInput().get(0);
Hop right = getInput().get(2);
boolean requiresRep = BinaryOp.requiresReplication(left, right);
Lop rightLop = right.constructLops();
if (requiresRep) {
//ncol of left input (determines num replicates)
Lop offset = createOffsetLop(left, (right.getDim2() <= 1));
rightLop = new RepMat(rightLop, offset, (right.getDim2() <= 1), right.getDataType(), right.getValueType());
setOutputDimensions(rightLop);
setLineNumbers(rightLop);
}
Group group1 = new Group(left.constructLops(), Group.OperationTypes.Sort, getDataType(), getValueType());
setLineNumbers(group1);
setOutputDimensions(group1);
Group group2 = new Group(rightLop, Group.OperationTypes.Sort, getDataType(), getValueType());
setLineNumbers(group2);
setOutputDimensions(group2);
plusmult = new PlusMult(group1, getInput().get(1).constructLops(), group2, _op, getDataType(), getValueType(), et);
}
setOutputDimensions(plusmult);
setLineNumbers(plusmult);
setLops(plusmult);
}