use of org.apache.sysml.runtime.functionobjects.ValueFunctionWithConstant in project incubator-systemml by apache.
the class PlusMultInstruction method parseInstruction.
public static PlusMultInstruction parseInstruction(String str) throws DMLRuntimeException {
InstructionUtils.checkNumFields(str, 4);
String[] parts = InstructionUtils.getInstructionParts(str);
String opcode = parts[0];
byte in1 = Byte.parseByte(parts[1]);
double scalar = Double.parseDouble(parts[2]);
byte in2 = Byte.parseByte(parts[3]);
byte out = Byte.parseByte(parts[4]);
BinaryOperator bop = InstructionUtils.parseBinaryOperator(opcode);
((ValueFunctionWithConstant) bop.fn).setConstant(scalar);
return new PlusMultInstruction(bop, in1, in2, out, str);
}
use of org.apache.sysml.runtime.functionobjects.ValueFunctionWithConstant in project incubator-systemml by apache.
the class PlusMultSPInstruction method processInstruction.
@Override
public void processInstruction(ExecutionContext ec) throws DMLRuntimeException {
SparkExecutionContext sec = (SparkExecutionContext) ec;
//pass the scalar
ScalarObject constant = (ScalarObject) ec.getScalarInput(input3.getName(), input3.getValueType(), input3.isLiteral());
((ValueFunctionWithConstant) ((BinaryOperator) _optr).fn).setConstant(constant.getDoubleValue());
super.processMatrixMatrixBinaryInstruction(sec);
}
use of org.apache.sysml.runtime.functionobjects.ValueFunctionWithConstant in project incubator-systemml by apache.
the class PlusMultCPInstruction method processInstruction.
@Override
public void processInstruction(ExecutionContext ec) throws DMLRuntimeException {
String output_name = output.getName();
//get all the inputs
MatrixBlock matrix1 = ec.getMatrixInput(input1.getName());
MatrixBlock matrix2 = ec.getMatrixInput(input2.getName());
ScalarObject scalar = ec.getScalarInput(input3.getName(), input3.getValueType(), input3.isLiteral());
//execution
((ValueFunctionWithConstant) ((BinaryOperator) _optr).fn).setConstant(scalar.getDoubleValue());
MatrixBlock out = (MatrixBlock) matrix1.binaryOperations((BinaryOperator) _optr, matrix2, new MatrixBlock());
//release the matrices
ec.releaseMatrixInput(input1.getName());
ec.releaseMatrixInput(input2.getName());
ec.setMatrixOutput(output_name, out);
}
Aggregations