Search in sources :

Example 21 with Operator

use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.

the class MatrixMatrixAxpyGPUInstruction method parseInstruction.

public static MatrixMatrixAxpyGPUInstruction parseInstruction(String str) throws DMLRuntimeException {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    InstructionUtils.checkNumFields(parts, 4);
    String opcode = parts[0];
    int multiplier = 1;
    if (opcode.equals("-*"))
        multiplier = -1;
    CPOperand in1 = new CPOperand(parts[1]);
    CPOperand constant = new CPOperand(parts[2]);
    if (constant.getDataType() != DataType.SCALAR)
        throw new DMLRuntimeException("Expected second operand to be a scalar");
    CPOperand in2 = new CPOperand(parts[3]);
    CPOperand out = new CPOperand(parts[4]);
    DataType dt1 = in1.getDataType();
    DataType dt2 = in2.getDataType();
    DataType dt3 = out.getDataType();
    Operator operator = (dt1 != dt2) ? InstructionUtils.parseScalarBinaryOperator(opcode, (dt1 == DataType.SCALAR)) : InstructionUtils.parseBinaryOperator(opcode);
    if (dt1 == DataType.MATRIX && dt2 == DataType.MATRIX && dt3 == DataType.MATRIX) {
        return new MatrixMatrixAxpyGPUInstruction(operator, in1, constant, multiplier, in2, out, opcode, str);
    } else if (dt3 == DataType.MATRIX && ((dt1 == DataType.SCALAR && dt2 == DataType.MATRIX) || (dt1 == DataType.MATRIX && dt2 == DataType.SCALAR))) {
        throw new DMLRuntimeException("Unsupported GPU PlusMult/MinusMult ArithmeticInstruction.");
    // return new ScalarMatrixArithmeticGPUInstruction(operator, in1, in2, out, opcode, str);
    } else
        throw new DMLRuntimeException("Unsupported GPU ArithmeticInstruction.");
}
Also used : Operator(org.apache.sysml.runtime.matrix.operators.Operator) DataType(org.apache.sysml.parser.Expression.DataType) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 22 with Operator

use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.

the class GroupedAggregateMInstruction method parseInstruction.

public static GroupedAggregateMInstruction parseInstruction(String str) throws DMLRuntimeException {
    String[] parts = InstructionUtils.getInstructionParts(str);
    InstructionUtils.checkNumFields(parts, 5);
    byte in1 = Byte.parseByte(parts[1]);
    byte in2 = Byte.parseByte(parts[2]);
    byte out = Byte.parseByte(parts[3]);
    int ngroups = Integer.parseInt(parts[4]);
    //partitioning ignored
    Operator op = new AggregateOperator(0, KahanPlus.getKahanPlusFnObject(), true, CorrectionLocationType.LASTCOLUMN);
    return new GroupedAggregateMInstruction(op, in1, in2, out, ngroups, str);
}
Also used : AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) Operator(org.apache.sysml.runtime.matrix.operators.Operator) AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator)

Example 23 with Operator

use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.

the class MMTSJMRInstruction method parseInstruction.

public static MMTSJMRInstruction parseInstruction(String str) throws DMLRuntimeException {
    InstructionUtils.checkNumFields(str, 3);
    String[] parts = InstructionUtils.getInstructionParts(str);
    String opcode = parts[0];
    byte in = Byte.parseByte(parts[1]);
    byte out = Byte.parseByte(parts[2]);
    MMTSJType titype = MMTSJType.valueOf(parts[3]);
    if (!opcode.equalsIgnoreCase("tsmm"))
        throw new DMLRuntimeException("Unknown opcode while parsing an MMTIJMRInstruction: " + str);
    else
        return new MMTSJMRInstruction(new Operator(true), in, titype, out, str);
}
Also used : Operator(org.apache.sysml.runtime.matrix.operators.Operator) MMTSJType(org.apache.sysml.lops.MMTSJ.MMTSJType) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 24 with Operator

use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.

the class SeqInstruction method parseInstruction.

public static SeqInstruction parseInstruction(String str) throws DMLRuntimeException {
    InstructionUtils.checkNumFields(str, 10);
    String[] parts = InstructionUtils.getInstructionParts(str);
    Operator op = null;
    byte input = Byte.parseByte(parts[1]);
    byte output = Byte.parseByte(parts[2]);
    long rows = Double.valueOf(parts[3]).longValue();
    long cols = Double.valueOf(parts[4]).longValue();
    int rpb = Integer.parseInt(parts[5]);
    int cpb = Integer.parseInt(parts[6]);
    double fromValue = Double.parseDouble(parts[7]);
    double toValue = Double.parseDouble(parts[8]);
    double incrValue = Double.parseDouble(parts[9]);
    String baseDir = parts[10];
    return new SeqInstruction(op, input, output, rows, cols, rpb, cpb, fromValue, toValue, incrValue, baseDir, str);
}
Also used : Operator(org.apache.sysml.runtime.matrix.operators.Operator)

Example 25 with Operator

use of org.apache.sysml.runtime.matrix.operators.Operator in project incubator-systemml by apache.

the class ParameterizedBuiltinMRInstruction method parseInstruction.

public static ParameterizedBuiltinMRInstruction parseInstruction(String str) throws DMLRuntimeException {
    String[] parts = InstructionUtils.getInstructionParts(str);
    String opcode = parts[0];
    if (opcode.equalsIgnoreCase("replace")) {
        InstructionUtils.checkNumFields(str, 4);
        byte in = Byte.parseByte(parts[1]);
        double pattern = Double.parseDouble(parts[2]);
        double replace = Double.parseDouble(parts[3]);
        byte out = Byte.parseByte(parts[4]);
        return new ParameterizedBuiltinMRInstruction(new Operator(true), in, pattern, replace, out, opcode, str);
    } else if (opcode.equalsIgnoreCase("rexpand")) {
        InstructionUtils.checkNumFields(str, 6);
        byte in = Byte.parseByte(parts[1]);
        double max = Double.parseDouble(parts[2]);
        boolean dirRows = parts[3].equals("rows");
        boolean cast = Boolean.parseBoolean(parts[4]);
        boolean ignore = Boolean.parseBoolean(parts[5]);
        byte out = Byte.parseByte(parts[6]);
        return new ParameterizedBuiltinMRInstruction(new Operator(true), in, max, dirRows, cast, ignore, out, opcode, str);
    } else {
        throw new DMLRuntimeException("Unknown opcode while parsing an ParameterizedBuiltinMRInstruction: " + str);
    }
}
Also used : Operator(org.apache.sysml.runtime.matrix.operators.Operator) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Aggregations

Operator (org.apache.sysml.runtime.matrix.operators.Operator)32 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)20 CPOperand (org.apache.sysml.runtime.instructions.cp.CPOperand)10 AggregateOperator (org.apache.sysml.runtime.matrix.operators.AggregateOperator)5 DataType (org.apache.sysml.parser.Expression.DataType)4 CMOperator (org.apache.sysml.runtime.matrix.operators.CMOperator)4 MMTSJType (org.apache.sysml.lops.MMTSJ.MMTSJType)3 IOException (java.io.IOException)2 DataGenMethod (org.apache.sysml.hops.Hop.DataGenMethod)2 VectorType (org.apache.sysml.lops.BinaryM.VectorType)2 CM (org.apache.sysml.runtime.functionobjects.CM)2 ValueFunction (org.apache.sysml.runtime.functionobjects.ValueFunction)2 KahanObject (org.apache.sysml.runtime.instructions.cp.KahanObject)2 GroupedAggregateInstruction (org.apache.sysml.runtime.instructions.mr.GroupedAggregateInstruction)2 WeightedCell (org.apache.sysml.runtime.matrix.data.WeightedCell)2 SimpleOperator (org.apache.sysml.runtime.matrix.operators.SimpleOperator)2 HashMap (java.util.HashMap)1 CacheType (org.apache.sysml.lops.PMMJ.CacheType)1 PDataPartitionFormat (org.apache.sysml.runtime.controlprogram.ParForProgramBlock.PDataPartitionFormat)1 AggregateUnaryOperator (org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator)1