Search in sources :

Example 6 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project incubator-systemml by apache.

the class UaggOuterChainCPInstruction method parseInstruction.

public static UaggOuterChainCPInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    String opcode = parts[0];
    if (opcode.equalsIgnoreCase(UAggOuterChain.OPCODE)) {
        AggregateUnaryOperator uaggop = InstructionUtils.parseBasicAggregateUnaryOperator(parts[1]);
        BinaryOperator bop = InstructionUtils.parseBinaryOperator(parts[2]);
        CPOperand in1 = new CPOperand(parts[3]);
        CPOperand in2 = new CPOperand(parts[4]);
        CPOperand out = new CPOperand(parts[5]);
        // derive aggregation operator from unary operator
        String aopcode = InstructionUtils.deriveAggregateOperatorOpcode(parts[1]);
        CorrectionLocationType corrLoc = InstructionUtils.deriveAggregateOperatorCorrectionLocation(parts[1]);
        String corrExists = (corrLoc != CorrectionLocationType.NONE) ? "true" : "false";
        AggregateOperator aop = InstructionUtils.parseAggregateOperator(aopcode, corrExists, corrLoc.toString());
        return new UaggOuterChainCPInstruction(bop, uaggop, aop, in1, in2, out, opcode, str);
    } else {
        throw new DMLRuntimeException("UaggOuterChainCPInstruction.parseInstruction():: Unknown opcode " + opcode);
    }
}
Also used : AggregateUnaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator) AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) BinaryOperator(org.apache.sysml.runtime.matrix.operators.BinaryOperator) CorrectionLocationType(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 7 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project incubator-systemml by apache.

the class AggregateBinaryInstruction method parseInstruction.

public static AggregateBinaryInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionParts(str);
    byte in1, in2, out;
    String opcode = parts[0];
    in1 = Byte.parseByte(parts[1]);
    in2 = Byte.parseByte(parts[2]);
    out = Byte.parseByte(parts[3]);
    if (opcode.equalsIgnoreCase("cpmm") || opcode.equalsIgnoreCase("rmm") || opcode.equalsIgnoreCase(MapMult.OPCODE)) {
        AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
        AggregateBinaryOperator aggbin = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), agg);
        AggregateBinaryInstruction inst = new AggregateBinaryInstruction(aggbin, opcode, in1, in2, out, str);
        if (parts.length == 5) {
            inst.setMMCJType(MMCJType.valueOf(parts[4]));
        } else if (parts.length == 6) {
            // mapmm
            inst.setCacheTypeMapMult(CacheType.valueOf(parts[4]));
            inst.setOutputEmptyBlocksMapMult(Boolean.parseBoolean(parts[5]));
        }
        return inst;
    }
    throw new DMLRuntimeException("AggregateBinaryInstruction.parseInstruction():: Unknown opcode " + opcode);
}
Also used : AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) AggregateBinaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 8 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project incubator-systemml by apache.

the class AggregateInstruction method parseInstruction.

public static AggregateInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionParts(str);
    byte in, out;
    String opcode = parts[0];
    in = Byte.parseByte(parts[1]);
    out = Byte.parseByte(parts[2]);
    AggregateOperator agg = null;
    if (opcode.equalsIgnoreCase("ak+") || opcode.equalsIgnoreCase("asqk+") || opcode.equalsIgnoreCase("amean") || opcode.equalsIgnoreCase("avar")) {
        InstructionUtils.checkNumFields(str, 4);
        agg = InstructionUtils.parseAggregateOperator(opcode, parts[3], parts[4]);
    } else {
        InstructionUtils.checkNumFields(str, 2);
        agg = InstructionUtils.parseAggregateOperator(opcode, null, null);
    }
    return new AggregateInstruction(agg, in, out, str);
}
Also used : AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator)

Example 9 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project incubator-systemml by apache.

the class CpmmSPInstruction method parseInstruction.

public static CpmmSPInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    String opcode = parts[0];
    if (!opcode.equalsIgnoreCase("cpmm"))
        throw new DMLRuntimeException("CpmmSPInstruction.parseInstruction(): Unknown opcode " + opcode);
    CPOperand in1 = new CPOperand(parts[1]);
    CPOperand in2 = new CPOperand(parts[2]);
    CPOperand out = new CPOperand(parts[3]);
    AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
    AggregateBinaryOperator aggbin = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), agg);
    SparkAggType aggtype = SparkAggType.valueOf(parts[4]);
    return new CpmmSPInstruction(aggbin, in1, in2, out, aggtype, opcode, str);
}
Also used : SparkAggType(org.apache.sysml.hops.AggBinaryOp.SparkAggType) AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) AggregateBinaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 10 with AggregateOperator

use of org.apache.sysml.runtime.matrix.operators.AggregateOperator in project incubator-systemml by apache.

the class InstructionUtils method parseAggregateOperator.

public static AggregateOperator parseAggregateOperator(String opcode, String corrExists, String corrLoc) {
    AggregateOperator agg = null;
    if (opcode.equalsIgnoreCase("ak+") || opcode.equalsIgnoreCase("aktrace")) {
        boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
        CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTCOLUMN : CorrectionLocationType.valueOf(corrLoc);
        agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), lcorrExists, lcorrLoc);
    } else if (opcode.equalsIgnoreCase("asqk+")) {
        boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
        CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTCOLUMN : CorrectionLocationType.valueOf(corrLoc);
        agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), lcorrExists, lcorrLoc);
    } else if (opcode.equalsIgnoreCase("a+")) {
        agg = new AggregateOperator(0, Plus.getPlusFnObject());
    } else if (opcode.equalsIgnoreCase("a*")) {
        agg = new AggregateOperator(1, Multiply.getMultiplyFnObject());
    } else if (opcode.equalsIgnoreCase("arimax")) {
        agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("maxindex"), true, CorrectionLocationType.LASTCOLUMN);
    } else if (opcode.equalsIgnoreCase("amax")) {
        agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("max"));
    } else if (opcode.equalsIgnoreCase("amin")) {
        agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
    } else if (opcode.equalsIgnoreCase("arimin")) {
        agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("minindex"), true, CorrectionLocationType.LASTCOLUMN);
    } else if (opcode.equalsIgnoreCase("amean")) {
        boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
        CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTTWOCOLUMNS : CorrectionLocationType.valueOf(corrLoc);
        agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), lcorrExists, lcorrLoc);
    } else if (opcode.equalsIgnoreCase("avar")) {
        boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
        CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTFOURCOLUMNS : CorrectionLocationType.valueOf(corrLoc);
        CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
        agg = new AggregateOperator(0, varFn, lcorrExists, lcorrLoc);
    }
    return agg;
}
Also used : AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) CM(org.apache.sysml.runtime.functionobjects.CM) CorrectionLocationType(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType)

Aggregations

AggregateOperator (org.apache.sysml.runtime.matrix.operators.AggregateOperator)42 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)17 AggregateBinaryOperator (org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator)16 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)12 AggregateUnaryOperator (org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator)11 CPOperand (org.apache.sysml.runtime.instructions.cp.CPOperand)10 CorrectionLocationType (org.apache.sysml.lops.PartialAggregate.CorrectionLocationType)9 CompressedMatrixBlock (org.apache.sysml.runtime.compress.CompressedMatrixBlock)8 CM (org.apache.sysml.runtime.functionobjects.CM)8 CMOperator (org.apache.sysml.runtime.matrix.operators.CMOperator)7 KahanObject (org.apache.sysml.runtime.instructions.cp.KahanObject)5 WeightedCell (org.apache.sysml.runtime.matrix.data.WeightedCell)5 BinaryOperator (org.apache.sysml.runtime.matrix.operators.BinaryOperator)4 Operator (org.apache.sysml.runtime.matrix.operators.Operator)4 ArrayList (java.util.ArrayList)3 SparkAggType (org.apache.sysml.hops.AggBinaryOp.SparkAggType)3 SparkExecutionContext (org.apache.sysml.runtime.controlprogram.context.SparkExecutionContext)3 CM_COV_Object (org.apache.sysml.runtime.instructions.cp.CM_COV_Object)3 MatrixIndexes (org.apache.sysml.runtime.matrix.data.MatrixIndexes)3 IOException (java.io.IOException)2