Search in sources :

Example 16 with Operator

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

the class PMMJCPInstruction method parseInstruction.

public static PMMJCPInstruction parseInstruction(String str) throws DMLRuntimeException {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    InstructionUtils.checkNumFields(parts, 5);
    String opcode = parts[0];
    CPOperand in1 = new CPOperand(parts[1]);
    CPOperand in2 = new CPOperand(parts[2]);
    CPOperand in3 = new CPOperand(parts[3]);
    CPOperand out = new CPOperand(parts[4]);
    int k = Integer.parseInt(parts[5]);
    if (!opcode.equalsIgnoreCase("pmm"))
        throw new DMLRuntimeException("Unknown opcode while parsing an PMMJCPInstruction: " + str);
    else
        return new PMMJCPInstruction(new Operator(true), in1, in2, in3, out, k, opcode, str);
}
Also used : Operator(org.apache.sysml.runtime.matrix.operators.Operator) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 17 with Operator

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

the class RelationalBinaryCPInstruction method parseInstruction.

public static RelationalBinaryCPInstruction parseInstruction(String str) throws DMLRuntimeException {
    InstructionUtils.checkNumFields(str, 3);
    CPOperand in1 = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
    CPOperand in2 = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
    CPOperand out = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
    String opcode = parseBinaryInstruction(str, in1, in2, out);
    checkOutputDataType(in1, in2, out);
    Operator operator = (in1.getDataType() != in2.getDataType()) ? InstructionUtils.parseScalarBinaryOperator(opcode, (in1.getDataType() == DataType.SCALAR)) : InstructionUtils.parseBinaryOperator(opcode);
    if (in1.getDataType() == DataType.SCALAR && in2.getDataType() == DataType.SCALAR)
        return new ScalarScalarRelationalCPInstruction(operator, in1, in2, out, opcode, str);
    else if (in1.getDataType() == DataType.MATRIX && in2.getDataType() == DataType.MATRIX)
        return new MatrixMatrixRelationalCPInstruction(operator, in1, in2, out, opcode, str);
    else
        return new ScalarMatrixRelationalCPInstruction(operator, in1, in2, out, opcode, str);
}
Also used : Operator(org.apache.sysml.runtime.matrix.operators.Operator)

Example 18 with Operator

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

the class MatrixReshapeCPInstruction method parseInstruction.

public static MatrixReshapeCPInstruction parseInstruction(String str) throws DMLRuntimeException {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    InstructionUtils.checkNumFields(parts, 5);
    String opcode = parts[0];
    CPOperand in1 = new CPOperand(parts[1]);
    CPOperand in2 = new CPOperand(parts[2]);
    CPOperand in3 = new CPOperand(parts[3]);
    CPOperand in4 = new CPOperand(parts[4]);
    CPOperand out = new CPOperand(parts[5]);
    if (!opcode.equalsIgnoreCase("rshape"))
        throw new DMLRuntimeException("Unknown opcode while parsing an MatrixReshapeInstruction: " + str);
    else
        return new MatrixReshapeCPInstruction(new Operator(true), in1, in2, in3, in4, out, opcode, str);
}
Also used : Operator(org.apache.sysml.runtime.matrix.operators.Operator) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 19 with Operator

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

the class ArithmeticBinarySPInstruction method parseInstruction.

public static ArithmeticBinarySPInstruction parseInstruction(String str) throws DMLRuntimeException {
    CPOperand in1 = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
    CPOperand in2 = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
    CPOperand out = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN);
    String opcode = null;
    boolean isBroadcast = false;
    VectorType vtype = null;
    if (str.startsWith("SPARK" + Lop.OPERAND_DELIMITOR + "map")) {
        String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
        InstructionUtils.checkNumFields(parts, 5);
        opcode = parts[0];
        in1.split(parts[1]);
        in2.split(parts[2]);
        out.split(parts[3]);
        vtype = VectorType.valueOf(parts[5]);
        isBroadcast = true;
    } else {
        opcode = parseBinaryInstruction(str, in1, in2, out);
    }
    // Arithmetic operations must be performed on DOUBLE or INT
    DataType dt1 = in1.getDataType();
    DataType dt2 = in2.getDataType();
    Operator operator = (dt1 != dt2) ? InstructionUtils.parseScalarBinaryOperator(opcode, (dt1 == DataType.SCALAR)) : InstructionUtils.parseExtendedBinaryOperator(opcode);
    if (dt1 == DataType.MATRIX || dt2 == DataType.MATRIX) {
        if (dt1 == DataType.MATRIX && dt2 == DataType.MATRIX) {
            if (isBroadcast)
                return new MatrixBVectorArithmeticSPInstruction(operator, in1, in2, out, vtype, opcode, str);
            else
                return new MatrixMatrixArithmeticSPInstruction(operator, in1, in2, out, opcode, str);
        } else
            return new MatrixScalarArithmeticSPInstruction(operator, in1, in2, out, opcode, str);
    }
    return null;
}
Also used : Operator(org.apache.sysml.runtime.matrix.operators.Operator) VectorType(org.apache.sysml.lops.BinaryM.VectorType) DataType(org.apache.sysml.parser.Expression.DataType) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand)

Example 20 with Operator

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

the class MMTSJGPUInstruction method parseInstruction.

/**
         * parse MMTSJ GPU instruction
         * @param str instruction string
         * @return MMTSJGPUInstruction object
         * @throws DMLRuntimeException if DMLRuntimeException occurs
         */
public static MMTSJGPUInstruction parseInstruction(String str) throws DMLRuntimeException {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    InstructionUtils.checkNumFields(parts, 3);
    String opcode = parts[0];
    CPOperand in1 = new CPOperand(parts[1]);
    CPOperand out = new CPOperand(parts[2]);
    MMTSJType titype = MMTSJType.valueOf(parts[3]);
    if (!opcode.equalsIgnoreCase("tsmm"))
        throw new DMLRuntimeException("Unknown opcode while parsing an MMTSJGPUInstruction: " + str);
    else
        return new MMTSJGPUInstruction(new Operator(true), in1, titype, out, opcode, str);
}
Also used : Operator(org.apache.sysml.runtime.matrix.operators.Operator) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) MMTSJType(org.apache.sysml.lops.MMTSJ.MMTSJType) 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