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