use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class MatrixMatrixAxpyGPUInstruction method parseInstruction.
public static MatrixMatrixAxpyGPUInstruction parseInstruction(String str) throws DMLRuntimeException {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
InstructionUtils.checkNumFields(parts, 4);
String opcode = parts[0];
int multiplier = 1;
if (opcode.equals("-*"))
multiplier = -1;
CPOperand in1 = new CPOperand(parts[1]);
CPOperand constant = new CPOperand(parts[2]);
if (constant.getDataType() != DataType.SCALAR)
throw new DMLRuntimeException("Expected second operand to be a scalar");
CPOperand in2 = new CPOperand(parts[3]);
CPOperand out = new CPOperand(parts[4]);
DataType dt1 = in1.getDataType();
DataType dt2 = in2.getDataType();
DataType dt3 = out.getDataType();
Operator operator = (dt1 != dt2) ? InstructionUtils.parseScalarBinaryOperator(opcode, (dt1 == DataType.SCALAR)) : InstructionUtils.parseBinaryOperator(opcode);
if (dt1 == DataType.MATRIX && dt2 == DataType.MATRIX && dt3 == DataType.MATRIX) {
return new MatrixMatrixAxpyGPUInstruction(operator, in1, constant, multiplier, in2, out, opcode, str);
} else if (dt3 == DataType.MATRIX && ((dt1 == DataType.SCALAR && dt2 == DataType.MATRIX) || (dt1 == DataType.MATRIX && dt2 == DataType.SCALAR))) {
throw new DMLRuntimeException("Unsupported GPU PlusMult/MinusMult ArithmeticInstruction.");
// return new ScalarMatrixArithmeticGPUInstruction(operator, in1, in2, out, opcode, str);
} else
throw new DMLRuntimeException("Unsupported GPU ArithmeticInstruction.");
}
use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class GroupedAggregateMInstruction method parseInstruction.
public static GroupedAggregateMInstruction parseInstruction(String str) throws DMLRuntimeException {
String[] parts = InstructionUtils.getInstructionParts(str);
InstructionUtils.checkNumFields(parts, 5);
byte in1 = Byte.parseByte(parts[1]);
byte in2 = Byte.parseByte(parts[2]);
byte out = Byte.parseByte(parts[3]);
int ngroups = Integer.parseInt(parts[4]);
//partitioning ignored
Operator op = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
return new GroupedAggregateMInstruction(op, in1, in2, out, ngroups, str);
}
use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class MMTSJMRInstruction method parseInstruction.
public static MMTSJMRInstruction parseInstruction(String str) throws DMLRuntimeException {
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]);
MMTSJType titype = MMTSJType.valueOf(parts[3]);
if (!opcode.equalsIgnoreCase("tsmm"))
throw new DMLRuntimeException("Unknown opcode while parsing an MMTIJMRInstruction: " + str);
else
return new MMTSJMRInstruction(new Operator(true), in, titype, out, str);
}
use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class SeqInstruction method parseInstruction.
public static SeqInstruction parseInstruction(String str) throws DMLRuntimeException {
InstructionUtils.checkNumFields(str, 10);
String[] parts = InstructionUtils.getInstructionParts(str);
Operator op = null;
byte input = Byte.parseByte(parts[1]);
byte output = Byte.parseByte(parts[2]);
long rows = Double.valueOf(parts[3]).longValue();
long cols = Double.valueOf(parts[4]).longValue();
int rpb = Integer.parseInt(parts[5]);
int cpb = Integer.parseInt(parts[6]);
double fromValue = Double.parseDouble(parts[7]);
double toValue = Double.parseDouble(parts[8]);
double incrValue = Double.parseDouble(parts[9]);
String baseDir = parts[10];
return new SeqInstruction(op, input, output, rows, cols, rpb, cpb, fromValue, toValue, incrValue, baseDir, str);
}
use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class ParameterizedBuiltinMRInstruction method parseInstruction.
public static ParameterizedBuiltinMRInstruction parseInstruction(String str) throws DMLRuntimeException {
String[] parts = InstructionUtils.getInstructionParts(str);
String opcode = parts[0];
if (opcode.equalsIgnoreCase("replace")) {
InstructionUtils.checkNumFields(str, 4);
byte in = Byte.parseByte(parts[1]);
double pattern = Double.parseDouble(parts[2]);
double replace = Double.parseDouble(parts[3]);
byte out = Byte.parseByte(parts[4]);
return new ParameterizedBuiltinMRInstruction(new Operator(true), in, pattern, replace, out, opcode, str);
} else if (opcode.equalsIgnoreCase("rexpand")) {
InstructionUtils.checkNumFields(str, 6);
byte in = Byte.parseByte(parts[1]);
double max = Double.parseDouble(parts[2]);
boolean dirRows = parts[3].equals("rows");
boolean cast = Boolean.parseBoolean(parts[4]);
boolean ignore = Boolean.parseBoolean(parts[5]);
byte out = Byte.parseByte(parts[6]);
return new ParameterizedBuiltinMRInstruction(new Operator(true), in, max, dirRows, cast, ignore, out, opcode, str);
} else {
throw new DMLRuntimeException("Unknown opcode while parsing an ParameterizedBuiltinMRInstruction: " + str);
}
}
Aggregations