Search in sources :

Example 6 with PackageFunction

use of org.apache.sysml.udf.PackageFunction in project systemml by apache.

the class ExternalFunctionProgramBlock method createInstructions.

/**
 * method to create instructions
 */
protected void createInstructions() {
    _inst = new ArrayList<>();
    // unblock all input matrices
    block2CellInst = getBlock2CellInstructions(getInputParams(), _unblockedFileNames);
    // assemble information provided through keyvalue pairs
    String className = _otherParams.get(ExternalFunctionStatement.CLASS_NAME);
    String configFile = _otherParams.get(ExternalFunctionStatement.CONFIG_FILE);
    // class name cannot be null, however, configFile and execLocation can be null
    if (className == null)
        throw new RuntimeException(this.printBlockErrorLocation() + ExternalFunctionStatement.CLASS_NAME + " not provided!");
    // assemble input and output operands
    CPOperand[] inputs = getOperands(getInputParams());
    CPOperand[] outputs = getOperands(getOutputParams());
    // generate instruction
    PackageFunction fun = createFunctionObject(className, configFile);
    ExternalFunctionInvocationInstruction einst = new ExternalFunctionInvocationInstruction(inputs, outputs, fun, _baseDir, InputInfo.TextCellInputInfo);
    verifyFunctionInputsOutputs(fun, inputs, outputs);
    if (getInputParams().size() > 0)
        einst.setLocation(getInputParams().get(0));
    else if (getOutputParams().size() > 0)
        einst.setLocation(getOutputParams().get(0));
    else
        einst.setLocation(getFilename(), _beginLine, _endLine, _beginColumn, _endColumn);
    _inst.add(einst);
    // block output matrices
    cell2BlockInst = getCell2BlockInstructions(getOutputParams(), _blockedFileNames);
}
Also used : ExternalFunctionInvocationInstruction(org.apache.sysml.udf.ExternalFunctionInvocationInstruction) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) PackageFunction(org.apache.sysml.udf.PackageFunction)

Example 7 with PackageFunction

use of org.apache.sysml.udf.PackageFunction in project systemml by apache.

the class ExternalFunctionProgramBlockCP method createInstructions.

@Override
protected void createInstructions() {
    _inst = new ArrayList<>();
    // assemble information provided through keyvalue pairs
    String className = _otherParams.get(ExternalFunctionStatement.CLASS_NAME);
    String configFile = _otherParams.get(ExternalFunctionStatement.CONFIG_FILE);
    // class name cannot be null, however, configFile and execLocation can be null
    if (className == null)
        throw new RuntimeException(this.printBlockErrorLocation() + ExternalFunctionStatement.CLASS_NAME + " not provided!");
    // assemble input and output param strings
    CPOperand[] inputs = getOperands(getInputParams());
    CPOperand[] outputs = getOperands(getOutputParams());
    // generate instruction
    PackageFunction fun = createFunctionObject(className, configFile);
    ExternalFunctionInvocationInstruction einst = new ExternalFunctionInvocationInstruction(inputs, outputs, fun, _baseDir, InputInfo.BinaryBlockInputInfo);
    verifyFunctionInputsOutputs(fun, inputs, outputs);
    _inst.add(einst);
}
Also used : ExternalFunctionInvocationInstruction(org.apache.sysml.udf.ExternalFunctionInvocationInstruction) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) PackageFunction(org.apache.sysml.udf.PackageFunction)

Aggregations

DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)7 ExternalFunctionInvocationInstruction (org.apache.sysml.udf.ExternalFunctionInvocationInstruction)7 PackageFunction (org.apache.sysml.udf.PackageFunction)7 CPOperand (org.apache.sysml.runtime.instructions.cp.CPOperand)4 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)3 Instruction (org.apache.sysml.runtime.instructions.Instruction)3 MRJobInstruction (org.apache.sysml.runtime.instructions.MRJobInstruction)3 VariableCPInstruction (org.apache.sysml.runtime.instructions.cp.VariableCPInstruction)3 CacheException (org.apache.sysml.runtime.controlprogram.caching.CacheException)1 BooleanObject (org.apache.sysml.runtime.instructions.cp.BooleanObject)1 DoubleObject (org.apache.sysml.runtime.instructions.cp.DoubleObject)1 IntObject (org.apache.sysml.runtime.instructions.cp.IntObject)1 ScalarObject (org.apache.sysml.runtime.instructions.cp.ScalarObject)1 StringObject (org.apache.sysml.runtime.instructions.cp.StringObject)1 BinaryObject (org.apache.sysml.udf.BinaryObject)1