Search in sources :

Example 16 with DoubleObject

use of org.apache.sysml.runtime.instructions.cp.DoubleObject in project incubator-systemml by apache.

the class ExternalFunctionInvocationInstruction method verifyAndAttachOutputs.

private void verifyAndAttachOutputs(ExecutionContext ec, PackageFunction fun, CPOperand[] outputs) {
    for (int i = 0; i < outputs.length; i++) {
        CPOperand output = outputs[i];
        switch(fun.getFunctionOutput(i).getType()) {
            case Matrix:
                Matrix m = (Matrix) fun.getFunctionOutput(i);
                MatrixObject newVar = createOutputMatrixObject(m);
                ec.setVariable(output.getName(), newVar);
                break;
            case Scalar:
                Scalar s = (Scalar) fun.getFunctionOutput(i);
                ScalarObject scalarObject = null;
                switch(s.getScalarType()) {
                    case Integer:
                        scalarObject = new IntObject(Long.parseLong(s.getValue()));
                        break;
                    case Double:
                        scalarObject = new DoubleObject(Double.parseDouble(s.getValue()));
                        break;
                    case Boolean:
                        scalarObject = new BooleanObject(Boolean.parseBoolean(s.getValue()));
                        break;
                    case Text:
                        scalarObject = new StringObject(s.getValue());
                        break;
                    default:
                        throw new DMLRuntimeException("Unknown scalar value type '" + s.getScalarType() + "' of output '" + output.getName() + "'.");
                }
                ec.setVariable(output.getName(), scalarObject);
                break;
            default:
                throw new DMLRuntimeException("Unsupported data type: " + fun.getFunctionOutput(i).getType().name());
        }
    }
}
Also used : ScalarObject(org.apache.sysml.runtime.instructions.cp.ScalarObject) MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) IntObject(org.apache.sysml.runtime.instructions.cp.IntObject) DoubleObject(org.apache.sysml.runtime.instructions.cp.DoubleObject) StringObject(org.apache.sysml.runtime.instructions.cp.StringObject) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) BooleanObject(org.apache.sysml.runtime.instructions.cp.BooleanObject) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Aggregations

DoubleObject (org.apache.sysml.runtime.instructions.cp.DoubleObject)16 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)10 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)9 ScalarObject (org.apache.sysml.runtime.instructions.cp.ScalarObject)7 SparkExecutionContext (org.apache.sysml.runtime.controlprogram.context.SparkExecutionContext)6 BooleanObject (org.apache.sysml.runtime.instructions.cp.BooleanObject)6 IntObject (org.apache.sysml.runtime.instructions.cp.IntObject)6 StringObject (org.apache.sysml.runtime.instructions.cp.StringObject)6 MatrixIndexes (org.apache.sysml.runtime.matrix.data.MatrixIndexes)6 ArrayList (java.util.ArrayList)5 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)5 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)5 StringTokenizer (java.util.StringTokenizer)2 ExecutorService (java.util.concurrent.ExecutorService)2 Future (java.util.concurrent.Future)2 JavaPairRDD (org.apache.spark.api.java.JavaPairRDD)2 DataType (org.apache.sysml.parser.Expression.DataType)2 ValueType (org.apache.sysml.parser.Expression.ValueType)2 CompressedMatrixBlock (org.apache.sysml.runtime.compress.CompressedMatrixBlock)2 KahanPlus (org.apache.sysml.runtime.functionobjects.KahanPlus)2