use of org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator in project incubator-systemml by apache.
the class UaggOuterChainSPInstruction method parseInstruction.
public static UaggOuterChainSPInstruction parseInstruction(String str) throws DMLRuntimeException {
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 UaggOuterChainSPInstruction(bop, uaggop, aop, in1, in2, out, opcode, str);
} else {
throw new DMLRuntimeException("UaggOuterChainSPInstruction.parseInstruction():: Unknown opcode " + opcode);
}
}
use of org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator in project incubator-systemml by apache.
the class InstructionUtils method parseBasicAggregateUnaryOperator.
public static AggregateUnaryOperator parseBasicAggregateUnaryOperator(String opcode) {
AggregateUnaryOperator aggun = null;
if (opcode.equalsIgnoreCase("uak+")) {
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject());
} else if (opcode.equalsIgnoreCase("uark+")) {
// RowSums
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject());
} else if (opcode.equalsIgnoreCase("uack+")) {
// ColSums
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTROW);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject());
} else if (opcode.equalsIgnoreCase("uasqk+")) {
AggregateOperator agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject());
} else if (opcode.equalsIgnoreCase("uarsqk+")) {
// RowSums
AggregateOperator agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject());
} else if (opcode.equalsIgnoreCase("uacsqk+")) {
// ColSums
AggregateOperator agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), true, CorrectionLocationType.LASTROW);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject());
} else if (opcode.equalsIgnoreCase("uamean")) {
// Mean
AggregateOperator agg = new AggregateOperator(0, Mean.getMeanFnObject(), true, CorrectionLocationType.LASTTWOCOLUMNS);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject());
} else if (opcode.equalsIgnoreCase("uarmean")) {
// RowMeans
AggregateOperator agg = new AggregateOperator(0, Mean.getMeanFnObject(), true, CorrectionLocationType.LASTTWOCOLUMNS);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject());
} else if (opcode.equalsIgnoreCase("uacmean")) {
// ColMeans
AggregateOperator agg = new AggregateOperator(0, Mean.getMeanFnObject(), true, CorrectionLocationType.LASTTWOROWS);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject());
} else if (opcode.equalsIgnoreCase("uavar")) {
// Variance
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
CorrectionLocationType cloc = CorrectionLocationType.LASTFOURCOLUMNS;
AggregateOperator agg = new AggregateOperator(0, varFn, true, cloc);
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject());
} else if (opcode.equalsIgnoreCase("uarvar")) {
// RowVariances
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
CorrectionLocationType cloc = CorrectionLocationType.LASTFOURCOLUMNS;
AggregateOperator agg = new AggregateOperator(0, varFn, true, cloc);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject());
} else if (opcode.equalsIgnoreCase("uacvar")) {
// ColVariances
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
CorrectionLocationType cloc = CorrectionLocationType.LASTFOURROWS;
AggregateOperator agg = new AggregateOperator(0, varFn, true, cloc);
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject());
} else if (opcode.equalsIgnoreCase("ua+")) {
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject());
} else if (opcode.equalsIgnoreCase("uar+")) {
// RowSums
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject());
} else if (opcode.equalsIgnoreCase("uac+")) {
// ColSums
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject());
} else if (opcode.equalsIgnoreCase("ua*")) {
AggregateOperator agg = new AggregateOperator(1, Multiply.getMultiplyFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject());
} else if (opcode.equalsIgnoreCase("uamax")) {
AggregateOperator agg = new AggregateOperator(-Double.MAX_VALUE, Builtin.getBuiltinFnObject("max"));
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject());
} else if (opcode.equalsIgnoreCase("uamin")) {
AggregateOperator agg = new AggregateOperator(Double.MAX_VALUE, Builtin.getBuiltinFnObject("min"));
aggun = new AggregateUnaryOperator(agg, ReduceAll.getReduceAllFnObject());
} else if (opcode.equalsIgnoreCase("uatrace")) {
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
aggun = new AggregateUnaryOperator(agg, ReduceDiag.getReduceDiagFnObject());
} else if (opcode.equalsIgnoreCase("uaktrace")) {
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceDiag.getReduceDiagFnObject());
} else if (opcode.equalsIgnoreCase("uarmax")) {
AggregateOperator agg = new AggregateOperator(-Double.MAX_VALUE, Builtin.getBuiltinFnObject("max"));
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject());
} else if (opcode.equalsIgnoreCase("uarimax")) {
AggregateOperator agg = new AggregateOperator(-Double.MAX_VALUE, Builtin.getBuiltinFnObject("maxindex"), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject());
} else if (opcode.equalsIgnoreCase("uarmin")) {
AggregateOperator agg = new AggregateOperator(Double.MAX_VALUE, Builtin.getBuiltinFnObject("min"));
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject());
} else if (opcode.equalsIgnoreCase("uarimin")) {
AggregateOperator agg = new AggregateOperator(Double.MAX_VALUE, Builtin.getBuiltinFnObject("minindex"), true, CorrectionLocationType.LASTCOLUMN);
aggun = new AggregateUnaryOperator(agg, ReduceCol.getReduceColFnObject());
} else if (opcode.equalsIgnoreCase("uacmax")) {
AggregateOperator agg = new AggregateOperator(-Double.MAX_VALUE, Builtin.getBuiltinFnObject("max"));
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject());
} else if (opcode.equalsIgnoreCase("uacmin")) {
AggregateOperator agg = new AggregateOperator(Double.MAX_VALUE, Builtin.getBuiltinFnObject("min"));
aggun = new AggregateUnaryOperator(agg, ReduceRow.getReduceRowFnObject());
}
return aggun;
}
use of org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator in project incubator-systemml by apache.
the class CumulativeAggregateSPInstruction method processInstruction.
@Override
public void processInstruction(ExecutionContext ec) throws DMLRuntimeException {
SparkExecutionContext sec = (SparkExecutionContext) ec;
MatrixCharacteristics mc = sec.getMatrixCharacteristics(input1.getName());
long rlen = mc.getRows();
int brlen = mc.getRowsPerBlock();
int bclen = mc.getColsPerBlock();
//get input
JavaPairRDD<MatrixIndexes, MatrixBlock> in = sec.getBinaryBlockRDDHandleForVariable(input1.getName());
//execute unary aggregate (w/ implicit drop correction)
AggregateUnaryOperator auop = (AggregateUnaryOperator) _optr;
JavaPairRDD<MatrixIndexes, MatrixBlock> out = in.mapToPair(new RDDCumAggFunction(auop, rlen, brlen, bclen));
out = RDDAggregateUtils.mergeByKey(out, false);
//put output handle in symbol table
sec.setRDDHandleForVariable(output.getName(), out);
sec.addLineageRDD(output.getName(), input1.getName());
}
use of org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator in project incubator-systemml by apache.
the class BinUaggChainInstruction method parseInstruction.
public static BinUaggChainInstruction parseInstruction(String str) throws DMLRuntimeException {
//check number of fields (2/3 inputs, output, type)
InstructionUtils.checkNumFields(str, 4);
//parse instruction parts (without exec type)
String[] parts = InstructionUtils.getInstructionParts(str);
BinaryOperator bop = InstructionUtils.parseBinaryOperator(parts[1]);
AggregateUnaryOperator uaggop = InstructionUtils.parseBasicAggregateUnaryOperator(parts[2]);
byte in1 = Byte.parseByte(parts[3]);
byte out = Byte.parseByte(parts[4]);
return new BinUaggChainInstruction(bop, uaggop, in1, out, str);
}
use of org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator in project incubator-systemml by apache.
the class BinUaggChainSPInstruction method parseInstruction.
public static BinUaggChainSPInstruction parseInstruction(String str) throws DMLRuntimeException {
//parse instruction parts (without exec type)
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
InstructionUtils.checkNumFields(parts, 4);
String opcode = parts[0];
BinaryOperator bop = InstructionUtils.parseBinaryOperator(parts[1]);
AggregateUnaryOperator uaggop = InstructionUtils.parseBasicAggregateUnaryOperator(parts[2]);
CPOperand in = new CPOperand(parts[3]);
CPOperand out = new CPOperand(parts[4]);
return new BinUaggChainSPInstruction(in, out, bop, uaggop, opcode, str);
}
Aggregations