paleo/third_party/libcudnn.py
def cudnnConvolutionBackwardBias(handle, alpha, srcDesc, srcData, beta,
                                 destDesc, destData):
    """"
    Compute the gradient wrt the bias.

    This function computes the convolution gradient with respect to the bias, which is the
    sum of every element belonging to the same feature map across all of the images of the
    input tensor. Therefore, the number of elements produced is equal to the number of
    features maps of the input tensor.

    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 the previously initialized input tensor descriptor.
    srcData : void_p
        Data pointer to GPU memory associated with the tensor descriptor
        srcDesc.
    beta: float
        Scaling factor which is applied on every element of the output tensor prior
        to adding the result of the convolution gradient. Note that if beta is zero,
        the output is not read and can contain any uninitialized data (including
        Nan numbers).
    destDesc : cudnnTensorDescriptor
        Handle to the previously initialized output tensor descriptor.
    destData : void_p
        Data pointer to GPU memory associated with the output 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.cudnnConvolutionBackwardBias(
        handle, alphaRef, srcDesc, srcData, betaRef, destDesc, destData)
    cudnnCheckStatus(status)

    Compute the gradient wrt the bias.

    This function computes the convolution gradient with respect to the bias, which is the
    sum of every element belonging to the same feature map across all of the images of the
    input tensor. Therefore, the number of elements produced is equal to the number of
    features maps of the input tensor.

    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 the previously initialized input tensor descriptor.
    srcData : void_p
        Data pointer to GPU memory associated with the tensor descriptor
        srcDesc.
    beta: float
        Scaling factor which is applied on every element of the output tensor prior
        to adding the result of the convolution gradient. Note that if beta is zero,
        the output is not read and can contain any uninitialized data (including
        Nan numbers).
    destDesc : cudnnTensorDescriptor
        Handle to the previously initialized output tensor descriptor.
    destData : void_p
        Data pointer to GPU memory associated with the output tensor descriptor
        destDesc.
    
Compute the gradient wrt the bias.
This function computes the convolution gradient with respect to the bias, which is the
sum of every element belonging to the same feature map across all of the images of the
input tensor. Therefore, the number of elements produced is equal to the number of
features maps of the input tensor.

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 the previously initialized input tensor descriptor.
srcData : void_p
Data pointer to GPU memory associated with the tensor descriptor
srcDesc.
beta: float
Scaling factor which is applied on every element of the output tensor prior
to adding the result of the convolution gradient. Note that if beta is zero,
the output is not read and can contain any uninitialized data (including
Nan numbers).
destDesc : cudnnTensorDescriptor
Handle to the previously initialized output tensor descriptor.
destData : void_p
Data pointer to GPU memory associated with the output tensor descriptor
destDesc.
Compute the gradient wrt the bias . This function computes the convolution gradient with respect to the bias which is the sum of every element belonging to the same feature map across all of the images of the input tensor . Therefore the number of elements produced is equal to the number of features maps of the input tensor . 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 the previously initialized input tensor descriptor . srcData : void_p Data pointer to GPU memory associated with the tensor descriptor srcDesc . beta : float Scaling factor which is applied on every element of the output tensor prior to adding the result of the convolution gradient . Note that if beta is zero the output is not read and can contain any uninitialized data ( including Nan numbers ) . destDesc : cudnnTensorDescriptor Handle to the previously initialized output tensor descriptor . destData : void_p Data pointer to GPU memory associated with the output tensor descriptor destDesc .
def cudnnConvolutionBackwardBias(handle, alpha, srcDesc, srcData, 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.cudnnConvolutionBackwardBias(
        handle, alphaRef, srcDesc, srcData, betaRef, destDesc, destData)
    cudnnCheckStatus(status)
def cudnnConvolutionBackwardBias ( handle , alpha , srcDesc , srcData , 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 . cudnnConvolutionBackwardBias ( handle , alphaRef , srcDesc , srcData , betaRef , destDesc , destData ) cudnnCheckStatus ( status )
Compute the gradient wrt the bias.
Compute the gradient wrt the bias .
""""
    Compute the gradient wrt the bias.

    This function computes the convolution gradient with respect to the bias, which is the
    sum of every element belonging to the same feature map across all of the images of the
    input tensor. Therefore, the number of elements produced is equal to the number of
    features maps of the input tensor.

    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 the previously initialized input tensor descriptor.
    srcData : void_p
        Data pointer to GPU memory associated with the tensor descriptor
        srcDesc.
    beta: float
        Scaling factor which is applied on every element of the output tensor prior
        to adding the result of the convolution gradient. Note that if beta is zero,
        the output is not read and can contain any uninitialized data (including
        Nan numbers).
    destDesc : cudnnTensorDescriptor
        Handle to the previously initialized output tensor descriptor.
    destData : void_p
        Data pointer to GPU memory associated with the output tensor descriptor
        destDesc.
    """
handle
alpha
srcDesc
srcData
beta
destDesc
destData