paleo/third_party/libcudnn.py
def cudnnConvolutionForward(handle, alpha, srcDesc, srcData, wDesc, w,
                            convDesc, algo, workspace, workSpaceSizeInBytes,
                            beta, destDesc, destData):
    """"
    Perform forward convolution. All of the form "output = alpha * Op(inputs) + beta * output".

    This function executes convolutions or cross-correlations over src using the specified
    filters, returning results in dest. Scaling factors alpha and beta can be used to scale
    the input tensor and the output tensor respectively.

    Parameters
    ----------
    handle : cudnnHandle
        Handle to a previously created cuDNN context.
    alpha: float
        Scaling factor with which every element of the input tensor is multiplied.
    srcDesc : cudnnTensorDescriptor
        Handle to a previously initialized tensor descriptor.
    srcData : void_p
        Data pointer to GPU memory associated with the tensor descriptor srcDesc.
    wDesc : cudnnFilterDescriptor
        Handle to a previously initialized filter descriptor.
    w : void_p
        Data pointer to GPU memory associated with the filter descriptor wDesc.
    convDesc : cudnnConvolutionDescriptor
        Previously initialized convolution descriptor.
    algo: cudnnConvolutionFwdAlgo
        Enumerant that specifies which convolution algorithm shoud be used to
        compute the results.
    workSpace: void_p
        Data pointer to GPU memory to a workspace needed to able to execute
        the specified algorithm. If no workspace is needed for a particular
        algorithm, that pointer can be nil.
    workSpaceSizeInBytes: long
        Specifies the size in bytes of the provided workSpace.
    beta: float
        Scaling factor which is applied on every element of the output tensor prior
        to adding the result of the convolution.
    destDesc : cudnnTensorDescriptor
        Handle to a previously initialized tensor descriptor.
    destData : void_p
        Data pointer to GPU memory associated with the tensor descriptor destDesc.
    """

    dataType = cudnnGetTensor4dDescriptor(destDesc)[0]
    if dataType == cudnnDataType['CUDNN_DATA_DOUBLE']:
        alphaRef = ctypes.byref(ctypes.c_double(alpha))
        betaRef = ctypes.byref(ctypes.c_double(beta))
    else:
        alphaRef = ctypes.byref(ctypes.c_float(alpha))
        betaRef = ctypes.byref(ctypes.c_float(beta))

    status = _libcudnn.cudnnConvolutionForward(
        handle, alphaRef, srcDesc, srcData, wDesc, w, convDesc, algo,
        workspace, ctypes.c_size_t(workSpaceSizeInBytes), betaRef, destDesc,
        destData)
    cudnnCheckStatus(status)

    Perform forward convolution. All of the form "output = alpha * Op(inputs) + beta * output".

    This function executes convolutions or cross-correlations over src using the specified
    filters, returning results in dest. Scaling factors alpha and beta can be used to scale
    the input tensor and the output tensor respectively.

    Parameters
    ----------
    handle : cudnnHandle
        Handle to a previously created cuDNN context.
    alpha: float
        Scaling factor with which every element of the input tensor is multiplied.
    srcDesc : cudnnTensorDescriptor
        Handle to a previously initialized tensor descriptor.
    srcData : void_p
        Data pointer to GPU memory associated with the tensor descriptor srcDesc.
    wDesc : cudnnFilterDescriptor
        Handle to a previously initialized filter descriptor.
    w : void_p
        Data pointer to GPU memory associated with the filter descriptor wDesc.
    convDesc : cudnnConvolutionDescriptor
        Previously initialized convolution descriptor.
    algo: cudnnConvolutionFwdAlgo
        Enumerant that specifies which convolution algorithm shoud be used to
        compute the results.
    workSpace: void_p
        Data pointer to GPU memory to a workspace needed to able to execute
        the specified algorithm. If no workspace is needed for a particular
        algorithm, that pointer can be nil.
    workSpaceSizeInBytes: long
        Specifies the size in bytes of the provided workSpace.
    beta: float
        Scaling factor which is applied on every element of the output tensor prior
        to adding the result of the convolution.
    destDesc : cudnnTensorDescriptor
        Handle to a previously initialized tensor descriptor.
    destData : void_p
        Data pointer to GPU memory associated with the tensor descriptor destDesc.
    
Perform forward convolution. All of the form "output = alpha * Op(inputs) + beta * output".
This function executes convolutions or cross-correlations over src using the specified
filters, returning results in dest. Scaling factors alpha and beta can be used to scale
the input tensor and the output tensor respectively.

Parameters

handle : cudnnHandle
Handle to a previously created cuDNN context.
alpha: float
Scaling factor with which every element of the input tensor is multiplied.
srcDesc : cudnnTensorDescriptor
Handle to a previously initialized tensor descriptor.
srcData : void_p
Data pointer to GPU memory associated with the tensor descriptor srcDesc.
wDesc : cudnnFilterDescriptor
Handle to a previously initialized filter descriptor.
w : void_p
Data pointer to GPU memory associated with the filter descriptor wDesc.
convDesc : cudnnConvolutionDescriptor
Previously initialized convolution descriptor.
algo: cudnnConvolutionFwdAlgo
Enumerant that specifies which convolution algorithm shoud be used to
compute the results.
workSpace: void_p
Data pointer to GPU memory to a workspace needed to able to execute
the specified algorithm. If no workspace is needed for a particular
algorithm, that pointer can be nil.
workSpaceSizeInBytes: long
Specifies the size in bytes of the provided workSpace.
beta: float
Scaling factor which is applied on every element of the output tensor prior
to adding the result of the convolution.
destDesc : cudnnTensorDescriptor
Handle to a previously initialized tensor descriptor.
destData : void_p
Data pointer to GPU memory associated with the tensor descriptor destDesc.
Perform forward convolution . All of the form " output = alpha * Op ( inputs ) + beta * output " . This function executes convolutions or cross - correlations over src using the specified filters returning results in dest . Scaling factors alpha and beta can be used to scale the input tensor and the output tensor respectively . Parameters handle : cudnnHandle Handle to a previously created cuDNN context . alpha : float Scaling factor with which every element of the input tensor is multiplied . srcDesc : cudnnTensorDescriptor Handle to a previously initialized tensor descriptor . srcData : void_p Data pointer to GPU memory associated with the tensor descriptor srcDesc . wDesc : cudnnFilterDescriptor Handle to a previously initialized filter descriptor . w : void_p Data pointer to GPU memory associated with the filter descriptor wDesc . convDesc : cudnnConvolutionDescriptor Previously initialized convolution descriptor . algo : cudnnConvolutionFwdAlgo Enumerant that specifies which convolution algorithm shoud be used to compute the results . workSpace : void_p Data pointer to GPU memory to a workspace needed to able to execute the specified algorithm . If no workspace is needed for a particular algorithm that pointer can be nil . workSpaceSizeInBytes : long Specifies the size in bytes of the provided workSpace . beta : float Scaling factor which is applied on every element of the output tensor prior to adding the result of the convolution . destDesc : cudnnTensorDescriptor Handle to a previously initialized tensor descriptor . destData : void_p Data pointer to GPU memory associated with the tensor descriptor destDesc .
def cudnnConvolutionForward(handle, alpha, srcDesc, srcData, wDesc, w,
                            convDesc, algo, workspace, workSpaceSizeInBytes,
                            beta, destDesc, destData):
    dataType = cudnnGetTensor4dDescriptor(destDesc)[0]
    if dataType == cudnnDataType['CUDNN_DATA_DOUBLE']:
        alphaRef = ctypes.byref(ctypes.c_double(alpha))
        betaRef = ctypes.byref(ctypes.c_double(beta))
    else:
        alphaRef = ctypes.byref(ctypes.c_float(alpha))
        betaRef = ctypes.byref(ctypes.c_float(beta))
    status = _libcudnn.cudnnConvolutionForward(
        handle, alphaRef, srcDesc, srcData, wDesc, w, convDesc, algo,
        workspace, ctypes.c_size_t(workSpaceSizeInBytes), betaRef, destDesc,
        destData)
    cudnnCheckStatus(status)
def cudnnConvolutionForward ( handle , alpha , srcDesc , srcData , wDesc , w , convDesc , algo , workspace , workSpaceSizeInBytes , beta , destDesc , destData ) : dataType = cudnnGetTensor4dDescriptor ( destDesc ) [ 0 ] if dataType == cudnnDataType [ 'CUDNN_DATA_DOUBLE' ] : alphaRef = ctypes . byref ( ctypes . c_double ( alpha ) ) betaRef = ctypes . byref ( ctypes . c_double ( beta ) ) else : alphaRef = ctypes . byref ( ctypes . c_float ( alpha ) ) betaRef = ctypes . byref ( ctypes . c_float ( beta ) ) status = _libcudnn . cudnnConvolutionForward ( handle , alphaRef , srcDesc , srcData , wDesc , w , convDesc , algo , workspace , ctypes . c_size_t ( workSpaceSizeInBytes ) , betaRef , destDesc , destData ) cudnnCheckStatus ( status )
Perform forward convolution.
Perform forward convolution .
""""
    Perform forward convolution. All of the form "output = alpha * Op(inputs) + beta * output".

    This function executes convolutions or cross-correlations over src using the specified
    filters, returning results in dest. Scaling factors alpha and beta can be used to scale
    the input tensor and the output tensor respectively.

    Parameters
    ----------
    handle : cudnnHandle
        Handle to a previously created cuDNN context.
    alpha: float
        Scaling factor with which every element of the input tensor is multiplied.
    srcDesc : cudnnTensorDescriptor
        Handle to a previously initialized tensor descriptor.
    srcData : void_p
        Data pointer to GPU memory associated with the tensor descriptor srcDesc.
    wDesc : cudnnFilterDescriptor
        Handle to a previously initialized filter descriptor.
    w : void_p
        Data pointer to GPU memory associated with the filter descriptor wDesc.
    convDesc : cudnnConvolutionDescriptor
        Previously initialized convolution descriptor.
    algo: cudnnConvolutionFwdAlgo
        Enumerant that specifies which convolution algorithm shoud be used to
        compute the results.
    workSpace: void_p
        Data pointer to GPU memory to a workspace needed to able to execute
        the specified algorithm. If no workspace is needed for a particular
        algorithm, that pointer can be nil.
    workSpaceSizeInBytes: long
        Specifies the size in bytes of the provided workSpace.
    beta: float
        Scaling factor which is applied on every element of the output tensor prior
        to adding the result of the convolution.
    destDesc : cudnnTensorDescriptor
        Handle to a previously initialized tensor descriptor.
    destData : void_p
        Data pointer to GPU memory associated with the tensor descriptor destDesc.
    """
handle
alpha
srcDesc
srcData
wDesc
w
convDesc
algo
workspace
workSpaceSizeInBytes
beta
destDesc
destData