use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class PMMJCPInstruction method parseInstruction.
public static PMMJCPInstruction parseInstruction(String str) throws DMLRuntimeException {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
InstructionUtils.checkNumFields(parts, 5);
String opcode = parts[0];
CPOperand in1 = new CPOperand(parts[1]);
CPOperand in2 = new CPOperand(parts[2]);
CPOperand in3 = new CPOperand(parts[3]);
CPOperand out = new CPOperand(parts[4]);
int k = Integer.parseInt(parts[5]);
if (!opcode.equalsIgnoreCase("pmm"))
throw new DMLRuntimeException("Unknown opcode while parsing an PMMJCPInstruction: " + str);
else
return new PMMJCPInstruction(new Operator(true), in1, in2, in3, out, k, opcode, str);
}
use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class RelationalBinaryCPInstruction method parseInstruction.
public static RelationalBinaryCPInstruction parseInstruction(String str) throws DMLRuntimeException {
InstructionUtils.checkNumFields(str, 3);
CPOperand in1 = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
CPOperand in2 = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
CPOperand out = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
String opcode = parseBinaryInstruction(str, in1, in2, out);
checkOutputDataType(in1, in2, out);
Operator operator = (in1.getDataType() != in2.getDataType()) ? InstructionUtils.parseScalarBinaryOperator(opcode, (in1.getDataType() == DataType.SCALAR)) : InstructionUtils.parseBinaryOperator(opcode);
if (in1.getDataType() == DataType.SCALAR && in2.getDataType() == DataType.SCALAR)
return new ScalarScalarRelationalCPInstruction(operator, in1, in2, out, opcode, str);
else if (in1.getDataType() == DataType.MATRIX && in2.getDataType() == DataType.MATRIX)
return new MatrixMatrixRelationalCPInstruction(operator, in1, in2, out, opcode, str);
else
return new ScalarMatrixRelationalCPInstruction(operator, in1, in2, out, opcode, str);
}
use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class MatrixReshapeCPInstruction method parseInstruction.
public static MatrixReshapeCPInstruction parseInstruction(String str) throws DMLRuntimeException {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
InstructionUtils.checkNumFields(parts, 5);
String opcode = parts[0];
CPOperand in1 = new CPOperand(parts[1]);
CPOperand in2 = new CPOperand(parts[2]);
CPOperand in3 = new CPOperand(parts[3]);
CPOperand in4 = new CPOperand(parts[4]);
CPOperand out = new CPOperand(parts[5]);
if (!opcode.equalsIgnoreCase("rshape"))
throw new DMLRuntimeException("Unknown opcode while parsing an MatrixReshapeInstruction: " + str);
else
return new MatrixReshapeCPInstruction(new Operator(true), in1, in2, in3, in4, out, opcode, str);
}
use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class ArithmeticBinarySPInstruction method parseInstruction.
public static ArithmeticBinarySPInstruction parseInstruction(String str) throws DMLRuntimeException {
CPOperand in1 = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
CPOperand in2 = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
CPOperand out = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
String opcode = null;
boolean isBroadcast = false;
VectorType vtype = null;
if (str.startsWith("SPARK" + Lop.OPERAND_DELIMITOR + "map")) {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
InstructionUtils.checkNumFields(parts, 5);
opcode = parts[0];
in1.split(parts[1]);
in2.split(parts[2]);
out.split(parts[3]);
vtype = VectorType.valueOf(parts[5]);
isBroadcast = true;
} else {
opcode = parseBinaryInstruction(str, in1, in2, out);
}
// Arithmetic operations must be performed on DOUBLE or INT
DataType dt1 = in1.getDataType();
DataType dt2 = in2.getDataType();
Operator operator = (dt1 != dt2) ? InstructionUtils.parseScalarBinaryOperator(opcode, (dt1 == DataType.SCALAR)) : InstructionUtils.parseExtendedBinaryOperator(opcode);
if (dt1 == DataType.MATRIX || dt2 == DataType.MATRIX) {
if (dt1 == DataType.MATRIX && dt2 == DataType.MATRIX) {
if (isBroadcast)
return new MatrixBVectorArithmeticSPInstruction(operator, in1, in2, out, vtype, opcode, str);
else
return new MatrixMatrixArithmeticSPInstruction(operator, in1, in2, out, opcode, str);
} else
return new MatrixScalarArithmeticSPInstruction(operator, in1, in2, out, opcode, str);
}
return null;
}
use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.
the class MMTSJGPUInstruction method parseInstruction.
/**
* parse MMTSJ GPU instruction
* @param str instruction string
* @return MMTSJGPUInstruction object
* @throws DMLRuntimeException if DMLRuntimeException occurs
*/
public static MMTSJGPUInstruction parseInstruction(String str) throws DMLRuntimeException {
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]);
MMTSJType titype = MMTSJType.valueOf(parts[3]);
if (!opcode.equalsIgnoreCase("tsmm"))
throw new DMLRuntimeException("Unknown opcode while parsing an MMTSJGPUInstruction: " + str);
else
return new MMTSJGPUInstruction(new Operator(true), in1, titype, out, opcode, str);
}
Aggregations