Search in sources :

Example 46 with CPOperand

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

the class ReorgGPUInstruction method parseInstruction.

public static ReorgGPUInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    InstructionUtils.checkNumFields(parts, 2);
    String opcode = parts[0];
    CPOperand in = new CPOperand(parts[1]);
    CPOperand out = new CPOperand(parts[2]);
    if (!(opcode.equalsIgnoreCase("r'")))
        throw new DMLRuntimeException("Unknown opcode while parsing a ReorgInstruction: " + str);
    else
        return new ReorgGPUInstruction(new ReorgOperator(SwapIndex.getSwapIndexFnObject()), in, out, opcode, str);
}
Also used : CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) ReorgOperator(org.apache.sysml.runtime.matrix.operators.ReorgOperator) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 47 with CPOperand

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

the class ScalarMatrixArithmeticGPUInstruction method processInstruction.

@Override
public void processInstruction(ExecutionContext ec) {
    GPUStatistics.incrementNoOfExecutedGPUInst();
    CPOperand mat = (_input1.getDataType() == DataType.MATRIX) ? _input1 : _input2;
    CPOperand scalar = (_input1.getDataType() == DataType.MATRIX) ? _input2 : _input1;
    MatrixObject in1 = getMatrixInputForGPUInstruction(ec, mat.getName());
    ScalarObject constant = (ScalarObject) ec.getScalarInput(scalar.getName(), scalar.getValueType(), scalar.isLiteral());
    boolean isTransposed = false;
    int rlen = isTransposed ? (int) in1.getNumColumns() : (int) in1.getNumRows();
    int clen = isTransposed ? (int) in1.getNumRows() : (int) in1.getNumColumns();
    ec.setMetaData(_output.getName(), rlen, clen);
    ScalarOperator sc_op = (ScalarOperator) _optr;
    sc_op = sc_op.setConstant(constant.getDoubleValue());
    LibMatrixCUDA.matrixScalarArithmetic(ec, ec.getGPUContext(0), getExtendedOpcode(), in1, _output.getName(), isTransposed, sc_op);
    ec.releaseMatrixInputForGPUInstruction(mat.getName());
    ec.releaseMatrixOutputForGPUInstruction(_output.getName());
}
Also used : ScalarOperator(org.apache.sysml.runtime.matrix.operators.ScalarOperator) ScalarObject(org.apache.sysml.runtime.instructions.cp.ScalarObject) MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand)

Example 48 with CPOperand

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

the class ScalarMatrixRelationalBinaryGPUInstruction method processInstruction.

@Override
public void processInstruction(ExecutionContext ec) {
    GPUStatistics.incrementNoOfExecutedGPUInst();
    CPOperand mat = (_input1.getDataType() == Expression.DataType.MATRIX) ? _input1 : _input2;
    CPOperand scalar = (_input1.getDataType() == Expression.DataType.MATRIX) ? _input2 : _input1;
    MatrixObject in1 = getMatrixInputForGPUInstruction(ec, mat.getName());
    ScalarObject constant = (ScalarObject) ec.getScalarInput(scalar.getName(), scalar.getValueType(), scalar.isLiteral());
    int rlen = (int) in1.getNumRows();
    int clen = (int) in1.getNumColumns();
    ec.setMetaData(_output.getName(), rlen, clen);
    ScalarOperator sc_op = (ScalarOperator) _optr;
    sc_op = sc_op.setConstant(constant.getDoubleValue());
    LibMatrixCUDA.matrixScalarRelational(ec, ec.getGPUContext(0), getExtendedOpcode(), in1, _output.getName(), sc_op);
    ec.releaseMatrixInputForGPUInstruction(mat.getName());
    ec.releaseMatrixOutputForGPUInstruction(_output.getName());
}
Also used : ScalarOperator(org.apache.sysml.runtime.matrix.operators.ScalarOperator) ScalarObject(org.apache.sysml.runtime.instructions.cp.ScalarObject) MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand)

Example 49 with CPOperand

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

the class AggregateTernarySPInstruction method parseInstruction.

public static AggregateTernarySPInstruction parseInstruction(String str) {
    String[] parts = InstructionUtils.getInstructionPartsWithValueType(str);
    String opcode = parts[0];
    if (opcode.equalsIgnoreCase("tak+*") || opcode.equalsIgnoreCase("tack+*")) {
        InstructionUtils.checkNumFields(parts, 4);
        CPOperand in1 = new CPOperand(parts[1]);
        CPOperand in2 = new CPOperand(parts[2]);
        CPOperand in3 = new CPOperand(parts[3]);
        CPOperand out = new CPOperand(parts[4]);
        AggregateTernaryOperator op = InstructionUtils.parseAggregateTernaryOperator(opcode);
        return new AggregateTernarySPInstruction(op, in1, in2, in3, out, opcode, str);
    } else {
        throw new DMLRuntimeException("AggregateTernaryInstruction.parseInstruction():: Unknown opcode " + opcode);
    }
}
Also used : CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) AggregateTernaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateTernaryOperator) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 50 with CPOperand

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

the class AggregateUnarySPInstruction method parseInstruction.

public static AggregateUnarySPInstruction parseInstruction(String str) {
    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]);
    SparkAggType aggtype = SparkAggType.valueOf(parts[3]);
    String aopcode = InstructionUtils.deriveAggregateOperatorOpcode(opcode);
    CorrectionLocationType corrLoc = InstructionUtils.deriveAggregateOperatorCorrectionLocation(opcode);
    String corrExists = (corrLoc != CorrectionLocationType.NONE) ? "true" : "false";
    AggregateUnaryOperator aggun = InstructionUtils.parseBasicAggregateUnaryOperator(opcode);
    AggregateOperator aop = InstructionUtils.parseAggregateOperator(aopcode, corrExists, corrLoc.toString());
    return new AggregateUnarySPInstruction(SPType.AggregateUnary, aggun, aop, in1, out, aggtype, opcode, str);
}
Also used : SparkAggType(org.apache.sysml.hops.AggBinaryOp.SparkAggType) AggregateUnaryOperator(org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator) AggregateOperator(org.apache.sysml.runtime.matrix.operators.AggregateOperator) CPOperand(org.apache.sysml.runtime.instructions.cp.CPOperand) CorrectionLocationType(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType)

Aggregations

CPOperand (org.apache.sysml.runtime.instructions.cp.CPOperand)77 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)51 Operator (org.apache.sysml.runtime.matrix.operators.Operator)13 AggregateOperator (org.apache.sysml.runtime.matrix.operators.AggregateOperator)10 ScalarObject (org.apache.sysml.runtime.instructions.cp.ScalarObject)7 ReorgOperator (org.apache.sysml.runtime.matrix.operators.ReorgOperator)7 SimpleOperator (org.apache.sysml.runtime.matrix.operators.SimpleOperator)7 ArrayList (java.util.ArrayList)6 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)6 AggregateBinaryOperator (org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator)6 BinaryOperator (org.apache.sysml.runtime.matrix.operators.BinaryOperator)6 DataType (org.apache.sysml.parser.Expression.DataType)5 ValueFunction (org.apache.sysml.runtime.functionobjects.ValueFunction)5 AggregateUnaryOperator (org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator)5 SparkAggType (org.apache.sysml.hops.AggBinaryOp.SparkAggType)4 VectorType (org.apache.sysml.lops.BinaryM.VectorType)4 SparkExecutionContext (org.apache.sysml.runtime.controlprogram.context.SparkExecutionContext)4 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)4 MatrixIndexes (org.apache.sysml.runtime.matrix.data.MatrixIndexes)4 MMTSJType (org.apache.sysml.lops.MMTSJ.MMTSJType)3