Search in sources :

Example 1 with LixCacheType

use of org.apache.sysml.lops.LeftIndex.LixCacheType in project systemml by apache.

the class IndexingSPInstruction method parseInstruction.

public static IndexingSPInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    String opcode = parts[0];
    if (opcode.equalsIgnoreCase(RightIndex.OPCODE)) {
        if (parts.length == 8) {
            CPOperand in = new CPOperand(parts[1]);
            CPOperand rl = new CPOperand(parts[2]);
            CPOperand ru = new CPOperand(parts[3]);
            CPOperand cl = new CPOperand(parts[4]);
            CPOperand cu = new CPOperand(parts[5]);
            CPOperand out = new CPOperand(parts[6]);
            SparkAggType aggtype = SparkAggType.valueOf(parts[7]);
            if (in.getDataType() == DataType.MATRIX)
                return new MatrixIndexingSPInstruction(in, rl, ru, cl, cu, out, aggtype, opcode, str);
            else
                return new FrameIndexingSPInstruction(in, rl, ru, cl, cu, out, aggtype, opcode, str);
        } else {
            throw new DMLRuntimeException("Invalid number of operands in instruction: " + str);
        }
    } else if (opcode.equalsIgnoreCase(LeftIndex.OPCODE) || opcode.equalsIgnoreCase("mapLeftIndex")) {
        if (parts.length == 9) {
            CPOperand lhsInput = new CPOperand(parts[1]);
            CPOperand rhsInput = new CPOperand(parts[2]);
            CPOperand rl = new CPOperand(parts[3]);
            CPOperand ru = new CPOperand(parts[4]);
            CPOperand cl = new CPOperand(parts[5]);
            CPOperand cu = new CPOperand(parts[6]);
            CPOperand out = new CPOperand(parts[7]);
            LixCacheType lixtype = LixCacheType.valueOf(parts[8]);
            if (lhsInput.getDataType() == DataType.MATRIX)
                return new MatrixIndexingSPInstruction(lhsInput, rhsInput, rl, ru, cl, cu, out, lixtype, opcode, str);
            else
                return new FrameIndexingSPInstruction(lhsInput, rhsInput, rl, ru, cl, cu, out, opcode, str);
        } else {
            throw new DMLRuntimeException("Invalid number of operands in instruction: " + str);
        }
    } else {
        throw new DMLRuntimeException("Unknown opcode while parsing a IndexingSPInstruction: " + str);
    }
}
Also used : SparkAggType(org.apache.sysml.hops.AggBinaryOp.SparkAggType) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) LixCacheType(org.apache.sysml.lops.LeftIndex.LixCacheType) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 2 with LixCacheType

use of org.apache.sysml.lops.LeftIndex.LixCacheType in project incubator-systemml by apache.

the class IndexingSPInstruction method parseInstruction.

public static IndexingSPInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    String opcode = parts[0];
    if (opcode.equalsIgnoreCase(RightIndex.OPCODE)) {
        if (parts.length == 8) {
            CPOperand in = new CPOperand(parts[1]);
            CPOperand rl = new CPOperand(parts[2]);
            CPOperand ru = new CPOperand(parts[3]);
            CPOperand cl = new CPOperand(parts[4]);
            CPOperand cu = new CPOperand(parts[5]);
            CPOperand out = new CPOperand(parts[6]);
            SparkAggType aggtype = SparkAggType.valueOf(parts[7]);
            if (in.getDataType() == DataType.MATRIX)
                return new MatrixIndexingSPInstruction(new SimpleOperator(null), in, rl, ru, cl, cu, out, aggtype, opcode, str);
            else
                return new FrameIndexingSPInstruction(new SimpleOperator(null), in, rl, ru, cl, cu, out, aggtype, opcode, str);
        } else {
            throw new DMLRuntimeException("Invalid number of operands in instruction: " + str);
        }
    } else if (opcode.equalsIgnoreCase(LeftIndex.OPCODE) || opcode.equalsIgnoreCase("mapLeftIndex")) {
        if (parts.length == 9) {
            CPOperand lhsInput = new CPOperand(parts[1]);
            CPOperand rhsInput = new CPOperand(parts[2]);
            CPOperand rl = new CPOperand(parts[3]);
            CPOperand ru = new CPOperand(parts[4]);
            CPOperand cl = new CPOperand(parts[5]);
            CPOperand cu = new CPOperand(parts[6]);
            CPOperand out = new CPOperand(parts[7]);
            LixCacheType lixtype = LixCacheType.valueOf(parts[8]);
            if (lhsInput.getDataType() == DataType.MATRIX)
                return new MatrixIndexingSPInstruction(new SimpleOperator(null), lhsInput, rhsInput, rl, ru, cl, cu, out, lixtype, opcode, str);
            else
                return new FrameIndexingSPInstruction(new SimpleOperator(null), lhsInput, rhsInput, rl, ru, cl, cu, out, opcode, str);
        } else {
            throw new DMLRuntimeException("Invalid number of operands in instruction: " + str);
        }
    } else {
        throw new DMLRuntimeException("Unknown opcode while parsing a IndexingSPInstruction: " + str);
    }
}
Also used : SimpleOperator(org.apache.sysml.runtime.matrix.operators.SimpleOperator) SparkAggType(org.apache.sysml.hops.AggBinaryOp.SparkAggType) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) LixCacheType(org.apache.sysml.lops.LeftIndex.LixCacheType) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Aggregations

SparkAggType (org.apache.sysml.hops.AggBinaryOp.SparkAggType)2 LixCacheType (org.apache.sysml.lops.LeftIndex.LixCacheType)2 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)2 CPOperand (org.apache.sysml.runtime.instructions.cp.CPOperand)2 SimpleOperator (org.apache.sysml.runtime.matrix.operators.SimpleOperator)1