public class LibMatrixCuDNN extends LibMatrixCUDA
Modifier and Type | Field and Description |
---|---|
protected static int |
CONVOLUTION_PREFERENCE |
cudaSupportFunctions, CUDNN_DATA_TYPE, customKernelSuffix, maxNumElementsOfCuDNNTensor, sizeOfDataType
Constructor and Description |
---|
LibMatrixCuDNN() |
Modifier and Type | Method and Description |
---|---|
protected static void |
checkStatus(int status)
Convenience method for checking the status of CuDNN kernel.
|
static void |
conv2d(GPUContext gCtx,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q,
double intermediateMemoryBudget)
Performs a 2D convolution
|
static void |
conv2dBackwardData(GPUContext gCtx,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q,
double intermediateMemoryBudget)
This method computes the backpropogation errors for previous layer of convolution operation
|
static void |
conv2dBackwardFilter(GPUContext gCtx,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q,
double intermediateMemoryBudget)
This method computes the backpropogation errors for filter of convolution operation
|
static void |
conv2dBiasAdd(GPUContext gCtx,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q,
double intermediateMemoryBudget)
Does a 2D convolution followed by a bias_add
|
protected static jcuda.jcudnn.cudnnHandle |
getCudnnHandle(GPUContext gCtx) |
protected static jcuda.Pointer |
getDensePointerForCuDNN(GPUContext gCtx,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
String instName)
Convenience method to get jcudaDenseMatrixPtr.
|
static void |
maxpooling(GPUContext gCtx,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q,
double intermediateMemoryBudget)
performs maxpooling on GPU by exploiting cudnnPoolingForward(...)
|
static void |
maxpoolingBackward(GPUContext gCtx,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject maxpoolOutput,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q,
double intermediateMemoryBudget)
Performs maxpoolingBackward on GPU by exploiting cudnnPoolingBackward(...)
This method computes the backpropogation errors for previous layer of maxpooling operation
|
static void |
relu(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
GPUContext gCtx,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in,
String outputName)
Performs the relu operation on the GPU.
|
static void |
softmax(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
GPUContext gCtx,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1,
String outputName)
Performs an "softmax" operation on a matrix on the GPU
|
abs, acos, asin, atan, axpy, biasAdd, biasMultiply, cbind, ceil, channelSums, cos, cosh, dataTypePointerTo, double2float, exp, float2double, floor, getCublasHandle, getCudaKernels, getCusparseHandle, getDenseMatrixOutputForGPUInstruction, getDensePointer, getSparsePointer, isInSparseFormat, log, matmultTSMM, matrixMatrixArithmetic, matrixMatrixRelational, matrixScalarArithmetic, matrixScalarRelational, one, rbind, reluBackward, resetFloatingPointPrecision, round, sigmoid, sign, sin, sinh, sliceDenseDense, sliceOperations, sliceSparseDense, solve, sqrt, tan, tanh, toInt, transpose, unaryAggregate, zero
protected static jcuda.jcudnn.cudnnHandle getCudnnHandle(GPUContext gCtx) throws DMLRuntimeException
DMLRuntimeException
public static void conv2dBiasAdd(GPUContext gCtx, String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias, org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q, double intermediateMemoryBudget) throws DMLRuntimeException
gCtx
- a valid GPUContext
instName
- the invoking instruction's name for record Statistics
.image
- input image matrix objectbias
- bias matrix objectfilter
- filter matrix objectoutput
- output matrix objectN
- number of input imagesC
- number of channelsH
- height of each imageW
- width of each imageK
- number of output "channels"R
- height of filterS
- width of filterpad_h
- padding heightpad_w
- padding widthstride_h
- stride heightstride_w
- string widthP
- output heightQ
- output widthintermediateMemoryBudget
- intermediate memory budgetDMLRuntimeException
- if errorpublic static void conv2d(GPUContext gCtx, String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q, double intermediateMemoryBudget) throws DMLRuntimeException
gCtx
- a valid GPUContext
instName
- the invoking instruction's name for record Statistics
.image
- input matrix objectfilter
- filter matrix objectoutputBlock
- output matrix objectN
- number of input imagesC
- number of channelsH
- height of each imageW
- width of each imageK
- number of output "channels"R
- height of filterS
- width of filterpad_h
- padding heightpad_w
- padding widthstride_h
- stride heightstride_w
- string widthP
- output heightQ
- output widthintermediateMemoryBudget
- intermediate memory budgetDMLRuntimeException
- if errorpublic static void softmax(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec, GPUContext gCtx, String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1, String outputName) throws DMLRuntimeException
ec
- execution contextgCtx
- a valid GPUContext
instName
- the invoking instruction's name for record Statistics
.in1
- input matrixoutputName
- output matrix nameDMLRuntimeException
- if DMLRuntimeException occurspublic static void conv2dBackwardFilter(GPUContext gCtx, String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q, double intermediateMemoryBudget) throws DMLRuntimeException
gCtx
- a valid GPUContext
instName
- the invoking instruction's name for record Statistics
.image
- input imagedout
- errors from next layeroutputBlock
- output errorsN
- number of imagesC
- number of channelsH
- heightW
- widthK
- number of filtersR
- filter heightS
- filter widthpad_h
- pad heightpad_w
- pad widthstride_h
- stride heightstride_w
- stride widthP
- output activation heightQ
- output activation widthintermediateMemoryBudget
- intermediate memory budgetDMLRuntimeException
- if DMLRuntimeException occurspublic static void conv2dBackwardData(GPUContext gCtx, String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter, org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q, double intermediateMemoryBudget) throws DMLRuntimeException
gCtx
- a valid GPUContext
instName
- the invoking instruction's name for record Statistics
.filter
- filter used in conv2ddout
- errors from next layeroutput
- output errorsN
- number of imagesC
- number of channelsH
- heightW
- widthK
- number of filtersR
- filter heightS
- filter widthpad_h
- pad heightpad_w
- pad widthstride_h
- stride heightstride_w
- stride widthP
- output activation heightQ
- output activation widthintermediateMemoryBudget
- intermediate memory budgetDMLRuntimeException
- if DMLRuntimeException occurspublic static void maxpooling(GPUContext gCtx, String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q, double intermediateMemoryBudget) throws DMLRuntimeException
gCtx
- a valid GPUContext
instName
- the invoking instruction's name for record Statistics
.image
- image as matrix objectoutputBlock
- output matrixN
- batch sizeC
- number of channelsH
- height of imageW
- width of imageK
- number of filtersR
- height of filterS
- width of filterpad_h
- vertical paddingpad_w
- horizontal paddingstride_h
- horizontal stridestride_w
- vertical strideP
- (H - R + 1 + 2*pad_h)/stride_hQ
- (W - S + 1 + 2*pad_w)/stride_wintermediateMemoryBudget
- intermediate memory budgetDMLRuntimeException
- if DMLRuntimeException occurspublic static void maxpoolingBackward(GPUContext gCtx, String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout, org.apache.sysml.runtime.controlprogram.caching.MatrixObject maxpoolOutput, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q, double intermediateMemoryBudget) throws DMLRuntimeException
gCtx
- a valid GPUContext
instName
- the invoking instruction's name for record Statistics
.image
- image as matrix objectdout
- delta matrix, output of previous layermaxpoolOutput
- (optional and can be null) output of maxpool forward functionoutputBlock
- output matrixN
- batch sizeC
- number of channelsH
- height of imageW
- width of imageK
- number of filtersR
- height of filterS
- width of filterpad_h
- vertical paddingpad_w
- horizontal paddingstride_h
- horizontal stridestride_w
- vertical strideP
- (H - R + 1 + 2*pad_h)/stride_hQ
- (W - S + 1 + 2*pad_w)/stride_wintermediateMemoryBudget
- intermediate memory budgetDMLRuntimeException
- if DMLRuntimeException occurspublic static void relu(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec, GPUContext gCtx, String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject in, String outputName) throws DMLRuntimeException
ec
- currently active ExecutionContext
gCtx
- a valid GPUContext
instName
- the invoking instruction's name for record Statistics
.in
- input matrixoutputName
- name of the output matrixDMLRuntimeException
- if an error occursprotected static jcuda.Pointer getDensePointerForCuDNN(GPUContext gCtx, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, String instName) throws DMLRuntimeException
gCtx
- a valid GPUContext
image
- input matrix objectinstName
- name of the instructionDMLRuntimeException
- if error occurs while sparse to dense conversionprotected static void checkStatus(int status) throws DMLRuntimeException
status
- status returned by CuDNNDMLRuntimeException
- if status is not CUDNN_STATUS_SUCCESSCopyright © 2017 The Apache Software Foundation. All rights reserved.