Search in sources :

Example 11 with FunctionCallCPInstruction

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

the class EvalFunction method execute.

@Override
public void execute(ExecutionContext ec) {
    String fname = ((Scalar) getFunctionInput(0)).getValue();
    MatrixObject in = ((Matrix) getFunctionInput(1)).getMatrixObject();
    ArrayList<String> inputs = new ArrayList<>();
    inputs.add("A");
    ArrayList<String> outputs = new ArrayList<>();
    outputs.add("B");
    ExecutionContext ec2 = ExecutionContextFactory.createContext(ec.getProgram());
    CPOperand inName = new CPOperand("TMP", org.apache.sysml.parser.Expression.ValueType.DOUBLE, DataType.MATRIX);
    ec2.setVariable("TMP", in);
    FunctionCallCPInstruction fcpi = new FunctionCallCPInstruction(null, fname, new CPOperand[] { inName }, inputs, outputs, "eval func");
    fcpi.processInstruction(ec2);
    MatrixObject out = (MatrixObject) ec2.getVariable("B");
    _ret = new Matrix(out, ValueType.Double);
}
Also used : MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) Matrix(org.apache.sysml.udf.Matrix) ExecutionContext(org.apache.sysml.runtime.controlprogram.context.ExecutionContext) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction) ArrayList(java.util.ArrayList) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) Scalar(org.apache.sysml.udf.Scalar)

Example 12 with FunctionCallCPInstruction

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

the class Statistics method getCPHeavyHitterCode.

public static String getCPHeavyHitterCode(Instruction inst) {
    String opcode = null;
    if (inst instanceof MRJobInstruction) {
        MRJobInstruction mrinst = (MRJobInstruction) inst;
        opcode = "MR-Job_" + mrinst.getJobType();
    } else if (inst instanceof SPInstruction) {
        opcode = "SP_" + InstructionUtils.getOpCode(inst.toString());
        if (inst instanceof FunctionCallCPInstruction) {
            FunctionCallCPInstruction extfunct = (FunctionCallCPInstruction) inst;
            opcode = extfunct.getFunctionName();
        }
    } else // CPInstructions
    {
        opcode = InstructionUtils.getOpCode(inst.toString());
        if (inst instanceof FunctionCallCPInstruction) {
            FunctionCallCPInstruction extfunct = (FunctionCallCPInstruction) inst;
            opcode = extfunct.getFunctionName();
        }
    }
    return opcode;
}
Also used : SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction)

Aggregations

FunctionCallCPInstruction (org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction)12 Instruction (org.apache.sysml.runtime.instructions.Instruction)7 MRJobInstruction (org.apache.sysml.runtime.instructions.MRJobInstruction)6 VariableCPInstruction (org.apache.sysml.runtime.instructions.cp.VariableCPInstruction)6 ArrayList (java.util.ArrayList)5 FunctionProgramBlock (org.apache.sysml.runtime.controlprogram.FunctionProgramBlock)5 CPInstruction (org.apache.sysml.runtime.instructions.cp.CPInstruction)5 ForProgramBlock (org.apache.sysml.runtime.controlprogram.ForProgramBlock)4 ProgramBlock (org.apache.sysml.runtime.controlprogram.ProgramBlock)4 MRInstruction (org.apache.sysml.runtime.instructions.mr.MRInstruction)4 SPInstruction (org.apache.sysml.runtime.instructions.spark.SPInstruction)4 IfProgramBlock (org.apache.sysml.runtime.controlprogram.IfProgramBlock)3 ParForProgramBlock (org.apache.sysml.runtime.controlprogram.ParForProgramBlock)3 WhileProgramBlock (org.apache.sysml.runtime.controlprogram.WhileProgramBlock)3 SpoofCPInstruction (org.apache.sysml.runtime.instructions.cp.SpoofCPInstruction)3 GPUInstruction (org.apache.sysml.runtime.instructions.gpu.GPUInstruction)3 ExternalFunctionInvocationInstruction (org.apache.sysml.udf.ExternalFunctionInvocationInstruction)3 FunctionOp (org.apache.sysml.hops.FunctionOp)2 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)2 ExternalFunctionProgramBlock (org.apache.sysml.runtime.controlprogram.ExternalFunctionProgramBlock)2