Search in sources :

Example 1 with CoVariance

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);
    }
}
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)

Example 2 with CoVariance

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);
    }
}
Also used : CombineBinary(org.apache.sysml.lops.CombineBinary) CoVariance(org.apache.sysml.lops.CoVariance) UnaryCP(org.apache.sysml.lops.UnaryCP)

Aggregations

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