Search in sources :

Example 16 with AggregateUnaryOperator

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

the class AggregateUnaryInstruction method parseInstruction.

public static AggregateUnaryInstruction parseInstruction(String str) {
    InstructionUtils.checkNumFields(str, 3);
    String[] parts = InstructionUtils.getInstructionParts(str);
    String opcode = parts[0];
    byte in = Byte.parseByte(parts[1]);
    byte out = Byte.parseByte(parts[2]);
    boolean drop = Boolean.parseBoolean(parts[3]);
    AggregateUnaryOperator aggun = InstructionUtils.parseBasicAggregateUnaryOperator(opcode);
    return new AggregateUnaryInstruction(aggun, in, out, drop, str);
}
Also used : AggregateUnaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator)

Example 17 with AggregateUnaryOperator

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

the class CumulativeAggregateInstruction method processInstruction.

@Override
public void processInstruction(Class<? extends MatrixValue> valueClass, CachedValueMap cachedValues, IndexedMatrixValue tempValue, IndexedMatrixValue zeroInput, int blockRowFactor, int blockColFactor) {
    ArrayList<IndexedMatrixValue> blkList = cachedValues.get(input);
    if (blkList == null)
        return;
    for (IndexedMatrixValue in1 : blkList) {
        if (in1 == null)
            continue;
        MatrixIndexes inix = in1.getIndexes();
        // output allocation
        IndexedMatrixValue out = cachedValues.holdPlace(output, valueClass);
        // process instruction
        OperationsOnMatrixValues.performAggregateUnary(inix, in1.getValue(), out.getIndexes(), out.getValue(), ((AggregateUnaryOperator) optr), blockRowFactor, blockColFactor);
        if (((AggregateUnaryOperator) optr).aggOp.correctionExists)
            ((MatrixBlock) out.getValue()).dropLastRowsOrColumns(((AggregateUnaryOperator) optr).aggOp.correctionLocation);
        // cumsum expand partial aggregates
        long rlenOut = (long) Math.ceil((double) _mcIn.getRows() / blockRowFactor);
        long rixOut = (long) Math.ceil((double) inix.getRowIndex() / blockRowFactor);
        int rlenBlk = (int) Math.min(rlenOut - (rixOut - 1) * blockRowFactor, blockRowFactor);
        int clenBlk = out.getValue().getNumColumns();
        int posBlk = (int) ((inix.getRowIndex() - 1) % blockRowFactor);
        MatrixBlock outBlk = new MatrixBlock(rlenBlk, clenBlk, false);
        outBlk.copy(posBlk, posBlk, 0, clenBlk - 1, (MatrixBlock) out.getValue(), true);
        MatrixIndexes outIx = out.getIndexes();
        outIx.setIndexes(rixOut, outIx.getColumnIndex());
        out.set(outIx, outBlk);
    }
}
Also used : MatrixBlock(org.apache.sysml.runtime.matrix.data.MatrixBlock) MatrixIndexes(org.apache.sysml.runtime.matrix.data.MatrixIndexes) AggregateUnaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator) IndexedMatrixValue(org.apache.sysml.runtime.matrix.mapred.IndexedMatrixValue)

Example 18 with AggregateUnaryOperator

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

the class CumulativeAggregateInstruction method parseInstruction.

public static CumulativeAggregateInstruction parseInstruction(String str) {
    InstructionUtils.checkNumFields(str, 2);
    String[] parts = InstructionUtils.getInstructionParts(str);
    String opcode = parts[0];
    byte in = Byte.parseByte(parts[1]);
    byte out = Byte.parseByte(parts[2]);
    AggregateUnaryOperator aggun = InstructionUtils.parseCumulativeAggregateUnaryOperator(opcode);
    return new CumulativeAggregateInstruction(aggun, in, out, str);
}
Also used : AggregateUnaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator)

Example 19 with AggregateUnaryOperator

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

the class UaggOuterChainInstruction method parseInstruction.

public static UaggOuterChainInstruction parseInstruction(String str) {
    // check number of fields (2/3 inputs, output, type)
    InstructionUtils.checkNumFields(str, 5);
    // parse instruction parts (without exec type)
    String[] parts = InstructionUtils.getInstructionParts(str);
    AggregateUnaryOperator uaggop = InstructionUtils.parseBasicAggregateUnaryOperator(parts[1]);
    BinaryOperator bop = InstructionUtils.parseBinaryOperator(parts[2]);
    byte in1 = Byte.parseByte(parts[3]);
    byte in2 = Byte.parseByte(parts[4]);
    byte out = Byte.parseByte(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 UaggOuterChainInstruction(bop, uaggop, aop, in1, in2, out, str);
}
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)

Example 20 with AggregateUnaryOperator

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

the class AggregateUnarySPInstruction method parseInstruction.

public static AggregateUnarySPInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    InstructionUtils.checkNumFields(parts, 3);
    String opcode = parts[0];
    CPOperand in1 = new CPOperand(parts[1]);
    CPOperand out = new CPOperand(parts[2]);
    SparkAggType aggtype = SparkAggType.valueOf(parts[3]);
    String aopcode = InstructionUtils.deriveAggregateOperatorOpcode(opcode);
    CorrectionLocationType corrLoc = InstructionUtils.deriveAggregateOperatorCorrectionLocation(opcode);
    String corrExists = (corrLoc != CorrectionLocationType.NONE) ? "true" : "false";
    AggregateUnaryOperator aggun = InstructionUtils.parseBasicAggregateUnaryOperator(opcode);
    AggregateOperator aop = InstructionUtils.parseAggregateOperator(aopcode, corrExists, corrLoc.toString());
    return new AggregateUnarySPInstruction(SPType.AggregateUnary, aggun, aop, in1, out, aggtype, opcode, str);
}
Also used : SparkAggType(org.apache.sysml.hops.AggBinaryOp.SparkAggType) AggregateUnaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator) AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) CorrectionLocationType(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType)

Aggregations

AggregateUnaryOperator (org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator)26 AggregateOperator (org.apache.sysml.runtime.matrix.operators.AggregateOperator)11 CorrectionLocationType (org.apache.sysml.lops.PartialAggregate.CorrectionLocationType)7 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)7 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)5 BinaryOperator (org.apache.sysml.runtime.matrix.operators.BinaryOperator)5 CPOperand (org.apache.sysml.runtime.instructions.cp.CPOperand)4 CompressedMatrixBlock (org.apache.sysml.runtime.compress.CompressedMatrixBlock)3 MatrixIndexes (org.apache.sysml.runtime.matrix.data.MatrixIndexes)3 SparkExecutionContext (org.apache.sysml.runtime.controlprogram.context.SparkExecutionContext)2 CM (org.apache.sysml.runtime.functionobjects.CM)2 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)2 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 SparkAggType (org.apache.sysml.hops.AggBinaryOp.SparkAggType)1 MMTSJType (org.apache.sysml.lops.MMTSJ.MMTSJType)1 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)1 IndexFunction (org.apache.sysml.runtime.functionobjects.IndexFunction)1 ReduceAll (org.apache.sysml.runtime.functionobjects.ReduceAll)1