use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class ScalarMatrixBuiltinGPUInstruction method processInstruction.
@Override
public void processInstruction(ExecutionContext ec) {
GPUStatistics.incrementNoOfExecutedGPUInst();
String opcode = getOpcode();
CPOperand mat = (input1.getDataType() == DataType.MATRIX) ? input1 : input2;
CPOperand scalar = (input1.getDataType() == DataType.MATRIX) ? input2 : input1;
MatrixObject in1 = getMatrixInputForGPUInstruction(ec, mat.getName());
ScalarObject constant = (ScalarObject) ec.getScalarInput(scalar.getName(), scalar.getValueType(), scalar.isLiteral());
if (opcode.equals("max")) {
ec.setMetaData(output.getName(), in1.getNumRows(), in1.getNumColumns());
double constVal = constant.getDoubleValue();
if (constVal == 0)
LibMatrixCuDNN.relu(ec, ec.getGPUContext(0), getExtendedOpcode(), in1, output.getName());
else
LibMatrixCUDA.matrixScalarOp(ec, ec.getGPUContext(0), getExtendedOpcode(), in1, output.getName(), false, InstructionUtils.parseScalarBinaryOperator(opcode, false, constVal));
} else if (opcode.equals("min")) {
ec.setMetaData(output.getName(), in1.getNumRows(), in1.getNumColumns());
double constVal = constant.getDoubleValue();
LibMatrixCUDA.matrixScalarOp(ec, ec.getGPUContext(0), getExtendedOpcode(), in1, output.getName(), false, InstructionUtils.parseScalarBinaryOperator(opcode, false, constVal));
} else {
throw new DMLRuntimeException("Unsupported GPU operator:" + opcode);
}
ec.releaseMatrixInputForGPUInstruction(mat.getName());
ec.releaseMatrixOutputForGPUInstruction(output.getName());
}
use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class TernaryInstruction method parseInstruction.
public static TernaryInstruction parseInstruction(String str) {
InstructionUtils.checkNumFields(str, 4);
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
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]);
TernaryOperator op = InstructionUtils.parseTernaryOperator(opcode);
return new TernaryInstruction(op, in1, in2, in3, out, str);
}
use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class AppendGAlignedSPInstruction method parseInstruction.
public static AppendGAlignedSPInstruction parseInstruction(String str) {
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]);
boolean cbind = Boolean.parseBoolean(parts[5]);
if (!opcode.equalsIgnoreCase("galignedappend"))
throw new DMLRuntimeException("Unknown opcode while parsing a AppendGSPInstruction: " + str);
return new AppendGAlignedSPInstruction(new ReorgOperator(OffsetColumnIndex.getOffsetColumnIndexFnObject(-1)), in1, in2, in3, out, cbind, opcode, str);
}
use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class AppendGSPInstruction method parseInstruction.
public static AppendGSPInstruction parseInstruction(String str) {
String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
InstructionUtils.checkNumFields(parts, 6);
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]);
boolean cbind = Boolean.parseBoolean(parts[6]);
if (!opcode.equalsIgnoreCase("gappend"))
throw new DMLRuntimeException("Unknown opcode while parsing a AppendGSPInstruction: " + str);
return new AppendGSPInstruction(new ReorgOperator(OffsetColumnIndex.getOffsetColumnIndexFnObject(-1)), in1, in2, in3, in4, out, cbind, opcode, str);
}
use of org.apache.sysml.runtime.instructions.cp.CPOperand in project incubator-systemml by apache.
the class AppendMSPInstruction method parseInstruction.
public static AppendMSPInstruction parseInstruction(String str) {
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 offset = new CPOperand(parts[3]);
CPOperand out = new CPOperand(parts[4]);
boolean cbind = Boolean.parseBoolean(parts[5]);
if (!opcode.equalsIgnoreCase("mappend"))
throw new DMLRuntimeException("Unknown opcode while parsing a AppendMSPInstruction: " + str);
// construct matrix/frame appendm instruction
if (in1.getDataType().isMatrix()) {
return new MatrixAppendMSPInstruction(new ReorgOperator(OffsetColumnIndex.getOffsetColumnIndexFnObject(-1)), in1, in2, offset, out, cbind, opcode, str);
} else {
// frame
return new FrameAppendMSPInstruction(new ReorgOperator(OffsetColumnIndex.getOffsetColumnIndexFnObject(-1)), in1, in2, offset, out, cbind, opcode, str);
}
}
Aggregations