org.apache.sysds.runtime.matrix.data

## Class LibMatrixCuDNNConvolutionAlgorithm

- java.lang.Object
- - org.apache.sysds.runtime.matrix.data.LibMatrixCuDNNConvolutionAlgorithm

All Implemented Interfaces:
  AutoCloseable

    public class LibMatrixCuDNNConvolutionAlgorithm
    extends Object
    implements AutoCloseable

This class is a wrapper that contain necessary data structures to invoke a cudnn convolution* functions (such as cudnnConvolutionForward, etc) It implements autocloseable to simplify the LibMatrixCuDNN code and also avoids potential memory leaks. The caller has to use the factory methods: cudnnGetConvolutionForwardAlgorithm, cudnnGetConvolutionBackwardFilterAlgorithm and cudnnGetConvolutionBackwardDataAlgorithm to get the LibMatrixCuDNNConvolutionAlgorithm object. The naming of this methods is consistent with that of CuDNN library.

### Field Summary

Fields
`int` `algo`
`long` `sizeInBytes`
`jcuda.Pointer` `workSpace`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `close()` Deallocates the tensor and filter descriptors as well as allocated workspace
`static LibMatrixCuDNNConvolutionAlgorithm` `cudnnGetConvolutionBackwardDataAlgorithm(GPUContext gCtx, String instName, 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, long workspaceLimit)` Factory method to get the algorithm wrapper for convolution backward data
`static LibMatrixCuDNNConvolutionAlgorithm` `cudnnGetConvolutionBackwardFilterAlgorithm(GPUContext gCtx, String instName, 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, long workspaceLimit)` Factory method to get the algorithm wrapper for convolution backward filter
`static LibMatrixCuDNNConvolutionAlgorithm` `cudnnGetConvolutionForwardAlgorithm(GPUContext gCtx, String instName, 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, long workspaceLimit)` Factory method to get the algorithm wrapper for convolution forward

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### algo

    public int algo

#### workSpace

    public jcuda.Pointer workSpace

#### sizeInBytes

    public long sizeInBytes

### Method Detail

#### close

    public void close()

Deallocates the tensor and filter descriptors as well as allocated workspace

Specified by:
  `close` in interface `AutoCloseable`

#### cudnnGetConvolutionForwardAlgorithm

    public static LibMatrixCuDNNConvolutionAlgorithm cudnnGetConvolutionForwardAlgorithm(GPUContext gCtx,
                                                                                         String instName,
                                                                                         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,
                                                                                         long workspaceLimit)

Factory method to get the algorithm wrapper for convolution forward

Parameters:
  `gCtx` - a valid `GPUContext`
  `instName` - the invoking instruction's name for record `Statistics`.
  `N` - number of input images
  `C` - number of channels
  `H` - height of each image
  `W` - width of each image
  `K` - number of output "channels"
  `R` - height of filter
  `S` - width of filter
  `pad_h` - padding height
  `pad_w` - padding width
  `stride_h` - stride height
  `stride_w` - string width
  `P` - output height
  `Q` - output width
  `workspaceLimit` - maximum intermediate memory to use
Returns:
  algorithm wrapper

#### cudnnGetConvolutionBackwardFilterAlgorithm

    public static LibMatrixCuDNNConvolutionAlgorithm cudnnGetConvolutionBackwardFilterAlgorithm(GPUContext gCtx,
                                                                                                String instName,
                                                                                                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,
                                                                                                long workspaceLimit)

Factory method to get the algorithm wrapper for convolution backward filter

Parameters:
  `gCtx` - a valid `GPUContext`
  `instName` - the invoking instruction's name for record `Statistics`.
  `N` - number of input images
  `C` - number of channels
  `H` - height of each image
  `W` - width of each image
  `K` - number of output "channels"
  `R` - height of filter
  `S` - width of filter
  `pad_h` - padding height
  `pad_w` - padding width
  `stride_h` - stride height
  `stride_w` - string width
  `P` - output height
  `Q` - output width
  `workspaceLimit` - maximum intermediate memory to use
Returns:
  algorithm wrapper

#### cudnnGetConvolutionBackwardDataAlgorithm

    public static LibMatrixCuDNNConvolutionAlgorithm cudnnGetConvolutionBackwardDataAlgorithm(GPUContext gCtx,
                                                                                              String instName,
                                                                                              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,
                                                                                              long workspaceLimit)

Factory method to get the algorithm wrapper for convolution backward data

Parameters:
  `gCtx` - a valid `GPUContext`
  `instName` - the invoking instruction's name for record `Statistics`.
  `N` - number of input images
  `C` - number of channels
  `H` - height of each image
  `W` - width of each image
  `K` - number of output "channels"
  `R` - height of filter
  `S` - width of filter
  `pad_h` - padding height
  `pad_w` - padding width
  `stride_h` - stride height
  `stride_w` - string width
  `P` - output height
  `Q` - output width
  `workspaceLimit` - maximum intermediate memory to use
Returns:
  algorithm wrapper