Search in sources :

Example 1 with CentralMoment

use of org.apache.sysml.lops.CentralMoment in project incubator-systemml by apache.

the class BinaryOp method constructLopsCentralMoment.

private void constructLopsCentralMoment(ExecType et) throws HopsException, LopsException {
    // The output data type is a SCALAR if central moment 
    // gets computed in CP/SPARK, and it will be MATRIX otherwise.
    DataType dt = (et == ExecType.MR ? DataType.MATRIX : DataType.SCALAR);
    CentralMoment cm = new CentralMoment(getInput().get(0).constructLops(), getInput().get(1).constructLops(), dt, getValueType(), et);
    setLineNumbers(cm);
    if (et == ExecType.MR) {
        cm.getOutputParameters().setDimensions(1, 1, 0, 0, -1);
        UnaryCP unary1 = new UnaryCP(cm, HopsOpOp1LopsUS.get(OpOp1.CAST_AS_SCALAR), getDataType(), getValueType());
        unary1.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(unary1);
        setLops(unary1);
    } else {
        cm.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLops(cm);
    }
}
Also used : CentralMoment(org.apache.sysml.lops.CentralMoment) DataType(org.apache.sysml.parser.Expression.DataType) UnaryCP(org.apache.sysml.lops.UnaryCP)

Example 2 with CentralMoment

use of org.apache.sysml.lops.CentralMoment in project incubator-systemml by apache.

the class TernaryOp method constructLopsCentralMoment.

/**
	 * Method to construct LOPs when op = CENTRAILMOMENT.
	 * 
	 * @throws HopsException if HopsException occurs
	 * @throws LopsException if LopsException occurs
	 */
private void constructLopsCentralMoment() throws HopsException, LopsException {
    if (_op != OpOp3.CENTRALMOMENT)
        throw new HopsException("Unexpected operation: " + _op + ", expecting " + OpOp3.CENTRALMOMENT);
    ExecType et = optFindExecType();
    if (et == ExecType.MR) {
        CombineBinary combine = CombineBinary.constructCombineLop(OperationTypes.PreCentralMoment, 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());
        CentralMoment cm = new CentralMoment(combine, getInput().get(2).constructLops(), DataType.MATRIX, getValueType(), et);
        cm.getOutputParameters().setDimensions(1, 1, 0, 0, -1);
        setLineNumbers(cm);
        UnaryCP unary1 = new UnaryCP(cm, HopsOpOp1LopsUS.get(OpOp1.CAST_AS_SCALAR), getDataType(), getValueType());
        unary1.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(unary1);
        setLops(unary1);
    } else //CP / SPARK
    {
        CentralMoment cm = new CentralMoment(getInput().get(0).constructLops(), getInput().get(1).constructLops(), getInput().get(2).constructLops(), getDataType(), getValueType(), et);
        cm.getOutputParameters().setDimensions(0, 0, 0, 0, -1);
        setLineNumbers(cm);
        setLops(cm);
    }
}
Also used : CombineBinary(org.apache.sysml.lops.CombineBinary) CentralMoment(org.apache.sysml.lops.CentralMoment) ExecType(org.apache.sysml.lops.LopProperties.ExecType) UnaryCP(org.apache.sysml.lops.UnaryCP)

Aggregations

CentralMoment (org.apache.sysml.lops.CentralMoment)2 UnaryCP (org.apache.sysml.lops.UnaryCP)2 CombineBinary (org.apache.sysml.lops.CombineBinary)1 ExecType (org.apache.sysml.lops.LopProperties.ExecType)1 DataType (org.apache.sysml.parser.Expression.DataType)1