Search in sources :

Example 1 with MatrixScalarUnaryFunction

use of org.apache.sysml.runtime.instructions.spark.functions.MatrixScalarUnaryFunction in project incubator-systemml by apache.

the class BinarySPInstruction method processMatrixScalarBinaryInstruction.

protected void processMatrixScalarBinaryInstruction(ExecutionContext ec) throws DMLRuntimeException {
    SparkExecutionContext sec = (SparkExecutionContext) ec;
    //get input RDD
    String rddVar = (input1.getDataType() == DataType.MATRIX) ? input1.getName() : input2.getName();
    JavaPairRDD<MatrixIndexes, MatrixBlock> in1 = sec.getBinaryBlockRDDHandleForVariable(rddVar);
    //get operator and scalar
    CPOperand scalar = (input1.getDataType() == DataType.MATRIX) ? input2 : input1;
    ScalarObject constant = (ScalarObject) ec.getScalarInput(scalar.getName(), scalar.getValueType(), scalar.isLiteral());
    ScalarOperator sc_op = (ScalarOperator) _optr;
    sc_op.setConstant(constant.getDoubleValue());
    //execute scalar matrix arithmetic instruction
    JavaPairRDD<MatrixIndexes, MatrixBlock> out = in1.mapValues(new MatrixScalarUnaryFunction(sc_op));
    //put output RDD handle into symbol table
    updateUnaryOutputMatrixCharacteristics(sec, rddVar, output.getName());
    sec.setRDDHandleForVariable(output.getName(), out);
    sec.addLineageRDD(output.getName(), rddVar);
}
Also used : ScalarOperator(org.apache.sysml.runtime.matrix.operators.ScalarOperator) ScalarObject(org.apache.sysml.runtime.instructions.cp.ScalarObject) MatrixBlock(org.apache.sysml.runtime.matrix.data.MatrixBlock) MatrixScalarUnaryFunction(org.apache.sysml.runtime.instructions.spark.functions.MatrixScalarUnaryFunction) MatrixIndexes(org.apache.sysml.runtime.matrix.data.MatrixIndexes) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) SparkExecutionContext(org.apache.sysml.runtime.controlprogram.context.SparkExecutionContext)

Aggregations

SparkExecutionContext (org.apache.sysml.runtime.controlprogram.context.SparkExecutionContext)1 CPOperand (org.apache.sysml.runtime.instructions.cp.CPOperand)1 ScalarObject (org.apache.sysml.runtime.instructions.cp.ScalarObject)1 MatrixScalarUnaryFunction (org.apache.sysml.runtime.instructions.spark.functions.MatrixScalarUnaryFunction)1 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)1 MatrixIndexes (org.apache.sysml.runtime.matrix.data.MatrixIndexes)1 ScalarOperator (org.apache.sysml.runtime.matrix.operators.ScalarOperator)1