Search in sources :

Example 46 with MatrixObject

use of org.apache.sysml.runtime.controlprogram.caching.MatrixObject in project incubator-systemml by apache.

the class ConvolutionGPUInstruction method processBiasInstruction.

public void processBiasInstruction(String instOpcode, ExecutionContext ec) {
    GPUStatistics.incrementNoOfExecutedGPUInst();
    MatrixObject input = getMatrixInputForGPUInstruction(ec, _input1.getName());
    MatrixObject bias = getMatrixInputForGPUInstruction(ec, _input2.getName());
    MatrixObject out = getDenseMatrixOutputForGPUInstruction(ec, _output.getName(), input.getNumRows(), input.getNumColumns());
    if (instOpcode.equalsIgnoreCase("bias_add"))
        LibMatrixCUDA.biasAdd(ec.getGPUContext(0), getExtendedOpcode(), input, bias, out);
    else if (instOpcode.equalsIgnoreCase("bias_multiply"))
        LibMatrixCUDA.biasMultiply(ec.getGPUContext(0), getExtendedOpcode(), input, bias, out);
    // release inputs/outputs
    ec.releaseMatrixInputForGPUInstruction(_input1.getName());
    ec.releaseMatrixInputForGPUInstruction(_input2.getName());
    ec.releaseMatrixOutputForGPUInstruction(_output.getName());
}
Also used : MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject)

Example 47 with MatrixObject

use of org.apache.sysml.runtime.controlprogram.caching.MatrixObject in project incubator-systemml by apache.

the class MatrixAppendGPUInstruction method processInstruction.

@Override
public void processInstruction(ExecutionContext ec) {
    GPUStatistics.incrementNoOfExecutedGPUInst();
    String opcode = getOpcode();
    MatrixObject mat1 = getMatrixInputForGPUInstruction(ec, input1.getName());
    MatrixObject mat2 = getMatrixInputForGPUInstruction(ec, input2.getName());
    if (atype == AppendCPInstruction.AppendType.CBIND)
        LibMatrixCUDA.cbind(ec, ec.getGPUContext(0), getExtendedOpcode(), mat1, mat2, output.getName());
    else if (atype == AppendCPInstruction.AppendType.RBIND)
        LibMatrixCUDA.rbind(ec, ec.getGPUContext(0), getExtendedOpcode(), mat1, mat2, output.getName());
    else
        throw new DMLRuntimeException("Unsupported GPU operator:" + opcode);
    ec.releaseMatrixInputForGPUInstruction(input1.getName());
    ec.releaseMatrixInputForGPUInstruction(input2.getName());
    ec.releaseMatrixOutputForGPUInstruction(output.getName());
}
Also used : MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 48 with MatrixObject

use of org.apache.sysml.runtime.controlprogram.caching.MatrixObject in project incubator-systemml by apache.

the class MatrixBuiltinGPUInstruction method processInstruction.

@Override
public void processInstruction(ExecutionContext ec) {
    GPUStatistics.incrementNoOfExecutedGPUInst();
    String opcode = getOpcode();
    MatrixObject mat = getMatrixInputForGPUInstruction(ec, _input.getName());
    ec.setMetaData(_output.getName(), mat.getNumRows(), mat.getNumColumns());
    switch(opcode) {
        case "exp":
            LibMatrixCUDA.exp(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "sqrt":
            LibMatrixCUDA.sqrt(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "log":
            LibMatrixCUDA.log(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "round":
            LibMatrixCUDA.round(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "floor":
            LibMatrixCUDA.floor(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "ceil":
            LibMatrixCUDA.ceil(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "abs":
            LibMatrixCUDA.abs(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "sin":
            LibMatrixCUDA.sin(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "cos":
            LibMatrixCUDA.cos(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "tan":
            LibMatrixCUDA.tan(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "sinh":
            LibMatrixCUDA.sinh(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "cosh":
            LibMatrixCUDA.cosh(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "tanh":
            LibMatrixCUDA.tanh(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "asin":
            LibMatrixCUDA.asin(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "acos":
            LibMatrixCUDA.acos(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "atan":
            LibMatrixCUDA.atan(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "sign":
            LibMatrixCUDA.sign(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "sigmoid":
            LibMatrixCUDA.sigmoid(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        case "softmax":
            LibMatrixCuDNN.softmax(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName());
            break;
        default:
            throw new DMLRuntimeException("Unsupported GPU operator:" + opcode);
    }
    ec.releaseMatrixInputForGPUInstruction(_input.getName());
    ec.releaseMatrixOutputForGPUInstruction(_output.getName());
}
Also used : MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 49 with MatrixObject

use of org.apache.sysml.runtime.controlprogram.caching.MatrixObject in project incubator-systemml by apache.

the class MatrixMatrixAxpyGPUInstruction method processInstruction.

@Override
public void processInstruction(ExecutionContext ec) {
    GPUStatistics.incrementNoOfExecutedGPUInst();
    MatrixObject in1 = getMatrixInputForGPUInstruction(ec, _input1.getName());
    MatrixObject in2 = getMatrixInputForGPUInstruction(ec, _input2.getName());
    ScalarObject scalar = ec.getScalarInput(constant.getName(), constant.getValueType(), constant.isLiteral());
    long rlen1 = in1.getNumRows();
    long clen1 = in1.getNumColumns();
    long rlen2 = in2.getNumRows();
    long clen2 = in2.getNumColumns();
    if (isValidMMOperation(rlen1, rlen2, clen1, clen2) || isValidMVOperation(rlen1, rlen2, clen1, clen2)) {
        ec.setMetaData(_output.getName(), (int) rlen1, (int) clen1);
    } else {
        throw new DMLRuntimeException("Incorrect dimensions of inputs in GPU axpy operation. input1:" + rlen1 + " X " + clen1 + " and input2:" + rlen2 + " X " + clen2);
    }
    LibMatrixCUDA.axpy(ec, ec.getGPUContext(0), getExtendedOpcode(), in1, in2, _output.getName(), multiplier * scalar.getDoubleValue());
    ec.releaseMatrixInputForGPUInstruction(_input1.getName());
    ec.releaseMatrixInputForGPUInstruction(_input2.getName());
    ec.releaseMatrixOutputForGPUInstruction(_output.getName());
}
Also used : ScalarObject(org.apache.sysml.runtime.instructions.cp.ScalarObject) MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 50 with MatrixObject

use of org.apache.sysml.runtime.controlprogram.caching.MatrixObject in project incubator-systemml by apache.

the class MatrixMatrixBuiltinGPUInstruction method processInstruction.

@Override
public void processInstruction(ExecutionContext ec) {
    GPUStatistics.incrementNoOfExecutedGPUInst();
    String opcode = getOpcode();
    MatrixObject mat1 = getMatrixInputForGPUInstruction(ec, input1.getName());
    MatrixObject mat2 = getMatrixInputForGPUInstruction(ec, input2.getName());
    if (opcode.equals("solve")) {
        ec.setMetaData(output.getName(), mat1.getNumColumns(), 1);
        LibMatrixCUDA.solve(ec, ec.getGPUContext(0), getExtendedOpcode(), mat1, mat2, output.getName());
    } else {
        throw new DMLRuntimeException("Unsupported GPU operator:" + opcode);
    }
    ec.releaseMatrixInputForGPUInstruction(input1.getName());
    ec.releaseMatrixInputForGPUInstruction(input2.getName());
    ec.releaseMatrixOutputForGPUInstruction(output.getName());
}
Also used : MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Aggregations

MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)201 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)74 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)45 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)39 Data (org.apache.sysml.runtime.instructions.cp.Data)37 MetaDataFormat (org.apache.sysml.runtime.matrix.MetaDataFormat)26 Pointer (jcuda.Pointer)20 CSRPointer (org.apache.sysml.runtime.instructions.gpu.context.CSRPointer)20 IOException (java.io.IOException)17 ArrayList (java.util.ArrayList)16 ScalarObject (org.apache.sysml.runtime.instructions.cp.ScalarObject)14 OutputInfo (org.apache.sysml.runtime.matrix.data.OutputInfo)13 CacheableData (org.apache.sysml.runtime.controlprogram.caching.CacheableData)12 RDDObject (org.apache.sysml.runtime.instructions.spark.data.RDDObject)12 Hop (org.apache.sysml.hops.Hop)11 MatrixFormatMetaData (org.apache.sysml.runtime.matrix.MatrixFormatMetaData)11 ParForProgramBlock (org.apache.sysml.runtime.controlprogram.ParForProgramBlock)10 MatrixIndexes (org.apache.sysml.runtime.matrix.data.MatrixIndexes)10 Path (org.apache.hadoop.fs.Path)9 LongWritable (org.apache.hadoop.io.LongWritable)9