use of org.apache.sysml.lops.PartialAggregate.CorrectionLocationType 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.lops.PartialAggregate.CorrectionLocationType 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);
}
use of org.apache.sysml.lops.PartialAggregate.CorrectionLocationType in project systemml by apache.
the class InstructionUtils method parseAggregateOperator.
public static AggregateOperator parseAggregateOperator(String opcode, String corrExists, String corrLoc) {
AggregateOperator agg = null;
if (opcode.equalsIgnoreCase("ak+") || opcode.equalsIgnoreCase("aktrace")) {
boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTCOLUMN : CorrectionLocationType.valueOf(corrLoc);
agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), lcorrExists, lcorrLoc);
} else if (opcode.equalsIgnoreCase("asqk+")) {
boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTCOLUMN : CorrectionLocationType.valueOf(corrLoc);
agg = new AggregateOperator(0, KahanPlusSq.getKahanPlusSqFnObject(), lcorrExists, lcorrLoc);
} else if (opcode.equalsIgnoreCase("a+")) {
agg = new AggregateOperator(0, Plus.getPlusFnObject());
} else if (opcode.equalsIgnoreCase("a*")) {
agg = new AggregateOperator(1, Multiply.getMultiplyFnObject());
} else if (opcode.equalsIgnoreCase("arimax")) {
agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("maxindex"), true, CorrectionLocationType.LASTCOLUMN);
} else if (opcode.equalsIgnoreCase("amax")) {
agg = new AggregateOperator(Double.NEGATIVE_INFINITY, Builtin.getBuiltinFnObject("max"));
} else if (opcode.equalsIgnoreCase("amin")) {
agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("min"));
} else if (opcode.equalsIgnoreCase("arimin")) {
agg = new AggregateOperator(Double.POSITIVE_INFINITY, Builtin.getBuiltinFnObject("minindex"), true, CorrectionLocationType.LASTCOLUMN);
} else if (opcode.equalsIgnoreCase("amean")) {
boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTTWOCOLUMNS : CorrectionLocationType.valueOf(corrLoc);
agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), lcorrExists, lcorrLoc);
} else if (opcode.equalsIgnoreCase("avar")) {
boolean lcorrExists = (corrExists == null) ? true : Boolean.parseBoolean(corrExists);
CorrectionLocationType lcorrLoc = (corrLoc == null) ? CorrectionLocationType.LASTFOURCOLUMNS : CorrectionLocationType.valueOf(corrLoc);
CM varFn = CM.getCMFnObject(AggregateOperationTypes.VARIANCE);
agg = new AggregateOperator(0, varFn, lcorrExists, lcorrLoc);
}
return agg;
}
use of org.apache.sysml.lops.PartialAggregate.CorrectionLocationType in project systemml by apache.
the class InstructionUtils method parseAggregateTernaryOperator.
public static AggregateTernaryOperator parseAggregateTernaryOperator(String opcode, int numThreads) {
CorrectionLocationType corr = opcode.equalsIgnoreCase("tak+*") ? CorrectionLocationType.LASTCOLUMN : CorrectionLocationType.LASTROW;
AggregateOperator agg = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, corr);
IndexFunction ixfun = opcode.equalsIgnoreCase("tak+*") ? ReduceAll.getReduceAllFnObject() : ReduceRow.getReduceRowFnObject();
return new AggregateTernaryOperator(Multiply.getMultiplyFnObject(), agg, ixfun, numThreads);
}
use of org.apache.sysml.lops.PartialAggregate.CorrectionLocationType in project systemml by apache.
the class UaggOuterChainCPInstruction method parseInstruction.
public static UaggOuterChainCPInstruction parseInstruction(String str) {
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 UaggOuterChainCPInstruction(bop, uaggop, aop, in1, in2, out, opcode, str);
} else {
throw new DMLRuntimeException("UaggOuterChainCPInstruction.parseInstruction():: Unknown opcode " + opcode);
}
}
Aggregations