use of org.apache.sysml.lops.PickByCount.OperationTypes in project incubator-systemml by apache.
the class QuantilePickCPInstruction method parseInstruction.
public static QuantilePickCPInstruction parseInstruction(String str) throws DMLRuntimeException {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
String opcode = parts[0];
//sanity check opcode
if (!opcode.equalsIgnoreCase("qpick")) {
throw new DMLRuntimeException("Unknown opcode while parsing a QuantilePickCPInstruction: " + str);
}
//instruction parsing
if (parts.length == 4) {
//instructions of length 4 originate from unary - mr-iqm
//TODO this should be refactored to use pickvaluecount lops
CPOperand in1 = new CPOperand(parts[1]);
CPOperand in2 = new CPOperand(parts[2]);
CPOperand out = new CPOperand(parts[3]);
OperationTypes ptype = OperationTypes.IQM;
boolean inmem = false;
return new QuantilePickCPInstruction(null, in1, in2, out, ptype, inmem, opcode, str);
} else if (parts.length == 5) {
CPOperand in1 = new CPOperand(parts[1]);
CPOperand out = new CPOperand(parts[2]);
OperationTypes ptype = OperationTypes.valueOf(parts[3]);
boolean inmem = Boolean.parseBoolean(parts[4]);
return new QuantilePickCPInstruction(null, in1, out, ptype, inmem, opcode, str);
} else if (parts.length == 6) {
CPOperand in1 = new CPOperand(parts[1]);
CPOperand in2 = new CPOperand(parts[2]);
CPOperand out = new CPOperand(parts[3]);
OperationTypes ptype = OperationTypes.valueOf(parts[4]);
boolean inmem = Boolean.parseBoolean(parts[5]);
return new QuantilePickCPInstruction(null, in1, in2, out, ptype, inmem, opcode, str);
}
return null;
}
use of org.apache.sysml.lops.PickByCount.OperationTypes in project incubator-systemml by apache.
the class PickByCountInstruction method parseInstruction.
public static PickByCountInstruction parseInstruction(String str) throws DMLRuntimeException {
InstructionUtils.checkNumFields(str, 5);
String[] parts = InstructionUtils.getInstructionParts(str);
OperationTypes ptype = OperationTypes.valueOf(parts[4]);
if (ptype == OperationTypes.VALUEPICK) {
byte in1 = Byte.parseByte(parts[1]);
byte in2 = Byte.parseByte(parts[2]);
byte out = Byte.parseByte(parts[3]);
return new PickByCountInstruction(null, in1, in2, out, str);
} else if (ptype == OperationTypes.RANGEPICK) {
byte in1 = Byte.parseByte(parts[1]);
double cstant = Double.parseDouble(parts[2]);
byte out = Byte.parseByte(parts[3]);
return new PickByCountInstruction(null, in1, cstant, out, str);
}
return null;
}
use of org.apache.sysml.lops.PickByCount.OperationTypes in project incubator-systemml by apache.
the class QuantilePickSPInstruction method parseInstruction.
public static QuantilePickSPInstruction parseInstruction(String str) throws DMLRuntimeException {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
String opcode = parts[0];
//sanity check opcode
if (!opcode.equalsIgnoreCase("qpick")) {
throw new DMLRuntimeException("Unknown opcode while parsing a QuantilePickCPInstruction: " + str);
}
//instruction parsing
if (parts.length == 4) {
//instructions of length 4 originate from unary - mr-iqm
//TODO this should be refactored to use pickvaluecount lops
CPOperand in1 = new CPOperand(parts[1]);
CPOperand in2 = new CPOperand(parts[2]);
CPOperand out = new CPOperand(parts[3]);
OperationTypes ptype = OperationTypes.IQM;
boolean inmem = false;
return new QuantilePickSPInstruction(null, in1, in2, out, ptype, inmem, opcode, str);
} else if (parts.length == 5) {
CPOperand in1 = new CPOperand(parts[1]);
CPOperand out = new CPOperand(parts[2]);
OperationTypes ptype = OperationTypes.valueOf(parts[3]);
boolean inmem = Boolean.parseBoolean(parts[4]);
return new QuantilePickSPInstruction(null, in1, out, ptype, inmem, opcode, str);
} else if (parts.length == 6) {
CPOperand in1 = new CPOperand(parts[1]);
CPOperand in2 = new CPOperand(parts[2]);
CPOperand out = new CPOperand(parts[3]);
OperationTypes ptype = OperationTypes.valueOf(parts[4]);
boolean inmem = Boolean.parseBoolean(parts[5]);
return new QuantilePickSPInstruction(null, in1, in2, out, ptype, inmem, opcode, str);
}
return null;
}
Aggregations