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