use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class TsmmSPInstruction method parseInstruction.
public static TsmmSPInstruction parseInstruction(String str) {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
String opcode = parts[0];
// check supported opcode
if (!opcode.equalsIgnoreCase("tsmm"))
throw new DMLRuntimeException("TsmmSPInstruction.parseInstruction():: Unknown opcode " + opcode);
CPOperand in1 = new CPOperand(parts[1]);
CPOperand out = new CPOperand(parts[2]);
MMTSJType type = MMTSJType.valueOf(parts[3]);
return new TsmmSPInstruction(null, in1, out, type, opcode, str);
}
use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class UaggOuterChainSPInstruction method parseInstruction.
public static UaggOuterChainSPInstruction 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 UaggOuterChainSPInstruction(bop, uaggop, aop, in1, in2, out, opcode, str);
} else {
throw new DMLRuntimeException("UaggOuterChainSPInstruction.parseInstruction():: Unknown opcode " + opcode);
}
}
use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class WriteSPInstruction method parseInstruction.
public static WriteSPInstruction parseInstruction(String str) {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
String opcode = parts[0];
if (!opcode.equals("write")) {
throw new DMLRuntimeException("Unsupported opcode");
}
// Write instructions for csv files also include three additional parameters (hasHeader, delimiter, sparse)
if (parts.length != 5 && parts.length != 9) {
throw new DMLRuntimeException("Invalid number of operands in write instruction: " + str);
}
// SPARK°write°_mVar2·MATRIX·DOUBLE°./src/test/scripts/functions/data/out/B·SCALAR·STRING·true°matrixmarket·SCALAR·STRING·true
// _mVar2·MATRIX·DOUBLE
CPOperand in1 = new CPOperand(parts[1]);
CPOperand in2 = new CPOperand(parts[2]);
CPOperand in3 = new CPOperand(parts[3]);
WriteSPInstruction inst = new WriteSPInstruction(in1, in2, in3, opcode, str);
if (in3.getName().equalsIgnoreCase("csv")) {
boolean hasHeader = Boolean.parseBoolean(parts[4]);
String delim = parts[5];
boolean sparse = Boolean.parseBoolean(parts[6]);
FileFormatProperties formatProperties = new CSVFileFormatProperties(hasHeader, delim, sparse);
inst.setFormatProperties(formatProperties);
CPOperand in4 = new CPOperand(parts[8]);
inst.input4 = in4;
} else {
FileFormatProperties ffp = new FileFormatProperties();
CPOperand in4 = new CPOperand(parts[4]);
inst.input4 = in4;
inst.setFormatProperties(ffp);
}
return inst;
}
use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class ZipmmSPInstruction method parseInstruction.
public static ZipmmSPInstruction parseInstruction(String str) {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
String opcode = parts[0];
if (opcode.equalsIgnoreCase("zipmm")) {
CPOperand in1 = new CPOperand(parts[1]);
CPOperand in2 = new CPOperand(parts[2]);
CPOperand out = new CPOperand(parts[3]);
boolean tRewrite = Boolean.parseBoolean(parts[4]);
AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject());
AggregateBinaryOperator aggbin = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), agg);
return new ZipmmSPInstruction(aggbin, in1, in2, out, tRewrite, opcode, str);
} else {
throw new DMLRuntimeException("ZipmmSPInstruction.parseInstruction():: Unknown opcode " + opcode);
}
}
use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class MatrixIndexingCPFileInstruction method parseInstruction.
public static MatrixIndexingCPFileInstruction parseInstruction(String str) {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
String opcode = parts[0];
if (opcode.equalsIgnoreCase(RightIndex.OPCODE)) {
if (parts.length == 7) {
CPOperand in, rl, ru, cl, cu, out;
in = new CPOperand(parts[1]);
rl = new CPOperand(parts[2]);
ru = new CPOperand(parts[3]);
cl = new CPOperand(parts[4]);
cu = new CPOperand(parts[5]);
out = new CPOperand(parts[6]);
return new MatrixIndexingCPFileInstruction(new SimpleOperator(null), in, rl, ru, cl, cu, out, opcode, str);
} else {
throw new DMLRuntimeException("Invalid number of operands in instruction: " + str);
}
} else if (parts[0].equalsIgnoreCase(LeftIndex.OPCODE)) {
throw new DMLRuntimeException("Invalid opcode while parsing a MatrixIndexingCPFileInstruction: " + str);
} else {
throw new DMLRuntimeException("Unknown opcode while parsing a MatrixIndexingCPFileInstruction: " + str);
}
}
Aggregations