Search in sources :

Example 1 with CumulativeSplitInstruction

use of org.apache.sysml.runtime.instructions.mr.CumulativeSplitInstruction in project incubator-systemml by apache.

the class MRBaseForCommonInstructions method processOneInstruction.

protected void processOneInstruction(MRInstruction ins, Class<? extends MatrixValue> valueClass, CachedValueMap cachedValues, IndexedMatrixValue tempValue, IndexedMatrixValue zeroInput) {
    if (ins instanceof AggregateBinaryInstruction) {
        byte input = ((AggregateBinaryInstruction) ins).input1;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof ZeroOutInstruction || ins instanceof AggregateUnaryInstruction || ins instanceof RangeBasedReIndexInstruction || ins instanceof CumulativeSplitInstruction) {
        byte input = ((UnaryMRInstructionBase) ins).input;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        if (ins instanceof CumulativeAggregateInstruction)
            ((CumulativeAggregateInstruction) ins).setMatrixCharacteristics(dim);
        if (ins instanceof CumulativeSplitInstruction)
            ((CumulativeSplitInstruction) ins).setMatrixCharacteristics(dim);
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof ReorgInstruction) {
        ReorgInstruction rinst = (ReorgInstruction) ins;
        byte input = rinst.input;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        rinst.setInputMatrixCharacteristics(dim);
        // MMCJMRMapper does not output empty blocks, no need to generate
        rinst.setOutputEmptyBlocks(!(this instanceof MMCJMRMapper));
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof MatrixReshapeMRInstruction) {
        MatrixReshapeMRInstruction mrins = (MatrixReshapeMRInstruction) ins;
        byte input = mrins.input;
        byte output = mrins.output;
        MatrixCharacteristics dimIn = dimensions.get(input);
        MatrixCharacteristics dimOut = dimensions.get(output);
        if (dimIn == null || dimOut == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        mrins.setMatrixCharacteristics(dimIn, dimOut);
        mrins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dimIn.getRowsPerBlock(), dimIn.getColsPerBlock());
    } else if (ins instanceof AppendMInstruction) {
        byte input = ((AppendMInstruction) ins).input1;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof BinaryMInstruction || ins instanceof RemoveEmptyMRInstruction) {
        byte input = ((BinaryMRInstructionBase) ins).input1;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof AppendGInstruction) {
        AppendGInstruction arinst = ((AppendGInstruction) ins);
        byte input = arinst.input1;
        MatrixCharacteristics dimIn = dimensions.get(input);
        if (dimIn == null)
            throw new DMLRuntimeException("Dimensions for instruction " + arinst + "  is unset!!!");
        arinst.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dimIn.getRowsPerBlock(), dimIn.getColsPerBlock());
    } else if (ins instanceof UnaryMRInstructionBase) {
        UnaryMRInstructionBase rinst = (UnaryMRInstructionBase) ins;
        MatrixCharacteristics dimIn = dimensions.get(rinst.input);
        if (dimIn == null)
            throw new DMLRuntimeException("Dimensions for instruction " + rinst + "  is unset!!!");
        rinst.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dimIn.getRowsPerBlock(), dimIn.getColsPerBlock());
    } else if (ins instanceof BinaryMRInstructionBase) {
        BinaryMRInstructionBase rinst = (BinaryMRInstructionBase) ins;
        MatrixCharacteristics dimIn = dimensions.get(rinst.input1);
        if (// not set for all
        dimIn != null)
            rinst.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dimIn.getRowsPerBlock(), dimIn.getColsPerBlock());
        else
            ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, -1, -1);
    } else
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, -1, -1);
// System.out.println(ins.getMRInstructionType()+" in "+time.stop());
}
Also used : BinaryMRInstructionBase(org.apache.sysml.runtime.instructions.mr.BinaryMRInstructionBase) AppendGInstruction(org.apache.sysml.runtime.instructions.mr.AppendGInstruction) AggregateUnaryInstruction(org.apache.sysml.runtime.instructions.mr.AggregateUnaryInstruction) RangeBasedReIndexInstruction(org.apache.sysml.runtime.instructions.mr.RangeBasedReIndexInstruction) MatrixCharacteristics(org.apache.sysml.runtime.matrix.MatrixCharacteristics) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) MatrixReshapeMRInstruction(org.apache.sysml.runtime.instructions.mr.MatrixReshapeMRInstruction) RemoveEmptyMRInstruction(org.apache.sysml.runtime.instructions.mr.RemoveEmptyMRInstruction) AppendMInstruction(org.apache.sysml.runtime.instructions.mr.AppendMInstruction) ZeroOutInstruction(org.apache.sysml.runtime.instructions.mr.ZeroOutInstruction) ReorgInstruction(org.apache.sysml.runtime.instructions.mr.ReorgInstruction) CumulativeAggregateInstruction(org.apache.sysml.runtime.instructions.mr.CumulativeAggregateInstruction) AggregateBinaryInstruction(org.apache.sysml.runtime.instructions.mr.AggregateBinaryInstruction) UnaryMRInstructionBase(org.apache.sysml.runtime.instructions.mr.UnaryMRInstructionBase) CumulativeSplitInstruction(org.apache.sysml.runtime.instructions.mr.CumulativeSplitInstruction) BinaryMInstruction(org.apache.sysml.runtime.instructions.mr.BinaryMInstruction)

Example 2 with CumulativeSplitInstruction

use of org.apache.sysml.runtime.instructions.mr.CumulativeSplitInstruction in project systemml by apache.

the class MRBaseForCommonInstructions method processOneInstruction.

protected void processOneInstruction(MRInstruction ins, Class<? extends MatrixValue> valueClass, CachedValueMap cachedValues, IndexedMatrixValue tempValue, IndexedMatrixValue zeroInput) {
    if (ins instanceof AggregateBinaryInstruction) {
        byte input = ((AggregateBinaryInstruction) ins).input1;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof ZeroOutInstruction || ins instanceof AggregateUnaryInstruction || ins instanceof RangeBasedReIndexInstruction || ins instanceof CumulativeSplitInstruction) {
        byte input = ((UnaryMRInstructionBase) ins).input;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        if (ins instanceof CumulativeAggregateInstruction)
            ((CumulativeAggregateInstruction) ins).setMatrixCharacteristics(dim);
        if (ins instanceof CumulativeSplitInstruction)
            ((CumulativeSplitInstruction) ins).setMatrixCharacteristics(dim);
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof ReorgInstruction) {
        ReorgInstruction rinst = (ReorgInstruction) ins;
        byte input = rinst.input;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        rinst.setInputMatrixCharacteristics(dim);
        // MMCJMRMapper does not output empty blocks, no need to generate
        rinst.setOutputEmptyBlocks(!(this instanceof MMCJMRMapper));
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof MatrixReshapeMRInstruction) {
        MatrixReshapeMRInstruction mrins = (MatrixReshapeMRInstruction) ins;
        byte input = mrins.input;
        byte output = mrins.output;
        MatrixCharacteristics dimIn = dimensions.get(input);
        MatrixCharacteristics dimOut = dimensions.get(output);
        if (dimIn == null || dimOut == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        mrins.setMatrixCharacteristics(dimIn, dimOut);
        mrins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dimIn.getRowsPerBlock(), dimIn.getColsPerBlock());
    } else if (ins instanceof AppendMInstruction) {
        byte input = ((AppendMInstruction) ins).input1;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof BinaryMInstruction || ins instanceof RemoveEmptyMRInstruction) {
        byte input = ((BinaryMRInstructionBase) ins).input1;
        MatrixCharacteristics dim = dimensions.get(input);
        if (dim == null)
            throw new DMLRuntimeException("dimension for instruction " + ins + "  is unset!!!");
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dim.getRowsPerBlock(), dim.getColsPerBlock());
    } else if (ins instanceof AppendGInstruction) {
        AppendGInstruction arinst = ((AppendGInstruction) ins);
        byte input = arinst.input1;
        MatrixCharacteristics dimIn = dimensions.get(input);
        if (dimIn == null)
            throw new DMLRuntimeException("Dimensions for instruction " + arinst + "  is unset!!!");
        arinst.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dimIn.getRowsPerBlock(), dimIn.getColsPerBlock());
    } else if (ins instanceof UnaryMRInstructionBase) {
        UnaryMRInstructionBase rinst = (UnaryMRInstructionBase) ins;
        MatrixCharacteristics dimIn = dimensions.get(rinst.input);
        if (dimIn == null)
            throw new DMLRuntimeException("Dimensions for instruction " + rinst + "  is unset!!!");
        rinst.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dimIn.getRowsPerBlock(), dimIn.getColsPerBlock());
    } else if (ins instanceof BinaryMRInstructionBase) {
        BinaryMRInstructionBase rinst = (BinaryMRInstructionBase) ins;
        MatrixCharacteristics dimIn = dimensions.get(rinst.input1);
        if (// not set for all
        dimIn != null)
            rinst.processInstruction(valueClass, cachedValues, tempValue, zeroInput, dimIn.getRowsPerBlock(), dimIn.getColsPerBlock());
        else
            ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, -1, -1);
    } else
        ins.processInstruction(valueClass, cachedValues, tempValue, zeroInput, -1, -1);
// System.out.println(ins.getMRInstructionType()+" in "+time.stop());
}
Also used : BinaryMRInstructionBase(org.apache.sysml.runtime.instructions.mr.BinaryMRInstructionBase) AppendGInstruction(org.apache.sysml.runtime.instructions.mr.AppendGInstruction) AggregateUnaryInstruction(org.apache.sysml.runtime.instructions.mr.AggregateUnaryInstruction) RangeBasedReIndexInstruction(org.apache.sysml.runtime.instructions.mr.RangeBasedReIndexInstruction) MatrixCharacteristics(org.apache.sysml.runtime.matrix.MatrixCharacteristics) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) MatrixReshapeMRInstruction(org.apache.sysml.runtime.instructions.mr.MatrixReshapeMRInstruction) RemoveEmptyMRInstruction(org.apache.sysml.runtime.instructions.mr.RemoveEmptyMRInstruction) AppendMInstruction(org.apache.sysml.runtime.instructions.mr.AppendMInstruction) ZeroOutInstruction(org.apache.sysml.runtime.instructions.mr.ZeroOutInstruction) ReorgInstruction(org.apache.sysml.runtime.instructions.mr.ReorgInstruction) CumulativeAggregateInstruction(org.apache.sysml.runtime.instructions.mr.CumulativeAggregateInstruction) AggregateBinaryInstruction(org.apache.sysml.runtime.instructions.mr.AggregateBinaryInstruction) UnaryMRInstructionBase(org.apache.sysml.runtime.instructions.mr.UnaryMRInstructionBase) CumulativeSplitInstruction(org.apache.sysml.runtime.instructions.mr.CumulativeSplitInstruction) BinaryMInstruction(org.apache.sysml.runtime.instructions.mr.BinaryMInstruction)

Aggregations

DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)2 AggregateBinaryInstruction (org.apache.sysml.runtime.instructions.mr.AggregateBinaryInstruction)2 AggregateUnaryInstruction (org.apache.sysml.runtime.instructions.mr.AggregateUnaryInstruction)2 AppendGInstruction (org.apache.sysml.runtime.instructions.mr.AppendGInstruction)2 AppendMInstruction (org.apache.sysml.runtime.instructions.mr.AppendMInstruction)2 BinaryMInstruction (org.apache.sysml.runtime.instructions.mr.BinaryMInstruction)2 BinaryMRInstructionBase (org.apache.sysml.runtime.instructions.mr.BinaryMRInstructionBase)2 CumulativeAggregateInstruction (org.apache.sysml.runtime.instructions.mr.CumulativeAggregateInstruction)2 CumulativeSplitInstruction (org.apache.sysml.runtime.instructions.mr.CumulativeSplitInstruction)2 MatrixReshapeMRInstruction (org.apache.sysml.runtime.instructions.mr.MatrixReshapeMRInstruction)2 RangeBasedReIndexInstruction (org.apache.sysml.runtime.instructions.mr.RangeBasedReIndexInstruction)2 RemoveEmptyMRInstruction (org.apache.sysml.runtime.instructions.mr.RemoveEmptyMRInstruction)2 ReorgInstruction (org.apache.sysml.runtime.instructions.mr.ReorgInstruction)2 UnaryMRInstructionBase (org.apache.sysml.runtime.instructions.mr.UnaryMRInstructionBase)2 ZeroOutInstruction (org.apache.sysml.runtime.instructions.mr.ZeroOutInstruction)2 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)2