Search in sources :

Example 1 with ValueFunctionWithConstant

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);
}
Also used : ValueFunctionWithConstant(org.apache.sysml.runtime.functionobjects.ValueFunctionWithConstant) BinaryOperator(org.apache.sysml.runtime.matrix.operators.BinaryOperator)

Example 2 with ValueFunctionWithConstant

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);
}
Also used : ScalarObject(org.apache.sysml.runtime.instructions.cp.ScalarObject) ValueFunctionWithConstant(org.apache.sysml.runtime.functionobjects.ValueFunctionWithConstant) SparkExecutionContext(org.apache.sysml.runtime.controlprogram.context.SparkExecutionContext)

Example 3 with ValueFunctionWithConstant

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);
}
Also used : MatrixBlock(org.apache.sysml.runtime.matrix.data.MatrixBlock) ValueFunctionWithConstant(org.apache.sysml.runtime.functionobjects.ValueFunctionWithConstant) BinaryOperator(org.apache.sysml.runtime.matrix.operators.BinaryOperator)

Aggregations

ValueFunctionWithConstant (org.apache.sysml.runtime.functionobjects.ValueFunctionWithConstant)3 BinaryOperator (org.apache.sysml.runtime.matrix.operators.BinaryOperator)2 SparkExecutionContext (org.apache.sysml.runtime.controlprogram.context.SparkExecutionContext)1 ScalarObject (org.apache.sysml.runtime.instructions.cp.ScalarObject)1 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)1