use of org.apache.sysml.lops.CoVariance in project incubator-systemml by apache.
the class TernaryOp method constructLopsCovariance.
/**
* Method to construct LOPs when op = COVARIANCE.
*
* @throws HopsException if HopsException occurs
* @throws LopsException if LopsException occurs
*/
private void constructLopsCovariance() throws HopsException, LopsException {
if (_op != OpOp3.COVARIANCE)
throw new HopsException("Unexpected operation: " + _op + ", expecting " + OpOp3.COVARIANCE);
ExecType et = optFindExecType();
if (et == ExecType.MR) {
// combineTertiary -> CoVariance -> CastAsScalar
CombineTernary combine = CombineTernary.constructCombineLop(CombineTernary.OperationTypes.PreCovWeighted, getInput().get(0).constructLops(), getInput().get(1).constructLops(), getInput().get(2).constructLops(), DataType.MATRIX, getValueType());
combine.getOutputParameters().setDimensions(getInput().get(0).getDim1(), getInput().get(0).getDim2(), getInput().get(0).getRowsInBlock(), getInput().get(0).getColsInBlock(), getInput().get(0).getNnz());
CoVariance cov = new CoVariance(combine, DataType.MATRIX, getValueType(), et);
cov.getOutputParameters().setDimensions(1, 1, 0, 0, -1);
setLineNumbers(cov);
UnaryCP unary1 = new UnaryCP(cov, HopsOpOp1LopsUS.get(OpOp1.CAST_AS_SCALAR), getDataType(), getValueType());
unary1.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
setLineNumbers(unary1);
setLops(unary1);
} else //CP / SPARK
{
CoVariance cov = new CoVariance(getInput().get(0).constructLops(), getInput().get(1).constructLops(), getInput().get(2).constructLops(), getDataType(), getValueType(), et);
cov.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
setLineNumbers(cov);
setLops(cov);
}
}
use of org.apache.sysml.lops.CoVariance in project incubator-systemml by apache.
the class BinaryOp method constructLopsCovariance.
private void constructLopsCovariance(ExecType et) throws LopsException, HopsException {
if (et == ExecType.MR) {
// combineBinary -> CoVariance -> CastAsScalar
CombineBinary combine = CombineBinary.constructCombineLop(OperationTypes.PreCovUnweighted, getInput().get(0).constructLops(), getInput().get(1).constructLops(), DataType.MATRIX, getValueType());
combine.getOutputParameters().setDimensions(getInput().get(0).getDim1(), getInput().get(0).getDim2(), getInput().get(0).getRowsInBlock(), getInput().get(0).getColsInBlock(), getInput().get(0).getNnz());
CoVariance cov = new CoVariance(combine, DataType.MATRIX, getValueType(), et);
cov.getOutputParameters().setDimensions(1, 1, 0, 0, -1);
setLineNumbers(cov);
UnaryCP unary1 = new UnaryCP(cov, HopsOpOp1LopsUS.get(OpOp1.CAST_AS_SCALAR), getDataType(), getValueType());
unary1.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
setLineNumbers(unary1);
setLops(unary1);
} else //CP/SPARK
{
CoVariance cov = new CoVariance(getInput().get(0).constructLops(), getInput().get(1).constructLops(), getDataType(), getValueType(), et);
cov.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
setLineNumbers(cov);
setLops(cov);
}
}
Aggregations