Search in sources :

Example 1 with CombineTernary

use of org.apache.sysml.lops.CombineTernary 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);
    }
}
Also used : CombineTernary(org.apache.sysml.lops.CombineTernary) CoVariance(org.apache.sysml.lops.CoVariance) ExecType(org.apache.sysml.lops.LopProperties.ExecType) UnaryCP(org.apache.sysml.lops.UnaryCP)

Aggregations

CoVariance (org.apache.sysml.lops.CoVariance)1 CombineTernary (org.apache.sysml.lops.CombineTernary)1 ExecType (org.apache.sysml.lops.LopProperties.ExecType)1 UnaryCP (org.apache.sysml.lops.UnaryCP)1