paleo/third_party/libcudnn.py
def cudnnActivationForward(handle, mode, alpha, srcDesc, srcData, beta,
                           destDesc, destData):
    """"
    Apply activation function.

    This routine applies a specified neuron activation function element-wise over each input
    value.

    In-place operation is allowed for this routine; i.e., srcData and destData pointers
    may be equal. However, this requires srcDesc and destDesc descriptors to be
    identical (particularly, the strides of the input and output must match for in-place
    operation to be allowed).

    Parameters
    ----------
    handle : cudnnHandle
        Handle to a previously created cuDNN context.
    mode : cudnnActivationMode
        Enumerant to specify the activation mode.
    alpha: float
        Scaling factor with which every element of the input tensor is multiplied.
    srcDesc : cudnnTensor4dDescription
        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 activation Note that if beta is zero, the output
        is not read and can contain any uninitialized data (including Nan numbers).
    destDesc : cudnnTensor4dDescription
        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.cudnnActivationForward(
        handle, mode, alphaRef, srcDesc, srcData, betaRef, destDesc, destData)
    cudnnCheckStatus(status)

    Apply activation function.

    This routine applies a specified neuron activation function element-wise over each input
    value.

    In-place operation is allowed for this routine; i.e., srcData and destData pointers
    may be equal. However, this requires srcDesc and destDesc descriptors to be
    identical (particularly, the strides of the input and output must match for in-place
    operation to be allowed).

    Parameters
    ----------
    handle : cudnnHandle
        Handle to a previously created cuDNN context.
    mode : cudnnActivationMode
        Enumerant to specify the activation mode.
    alpha: float
        Scaling factor with which every element of the input tensor is multiplied.
    srcDesc : cudnnTensor4dDescription
        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 activation Note that if beta is zero, the output
        is not read and can contain any uninitialized data (including Nan numbers).
    destDesc : cudnnTensor4dDescription
        Handle to the previously initialized output tensor descriptor.
    destData : void_p
        Data pointer to GPU memory associated with the output tensor descriptor
        destDesc.
    
Apply activation function.
This routine applies a specified neuron activation function element-wise over each input
value.

In-place operation is allowed for this routine; i.e., srcData and destData pointers
may be equal. However, this requires srcDesc and destDesc descriptors to be
identical (particularly, the strides of the input and output must match for in-place
operation to be allowed).

Parameters

handle : cudnnHandle
Handle to a previously created cuDNN context.
mode : cudnnActivationMode
Enumerant to specify the activation mode.
alpha: float
Scaling factor with which every element of the input tensor is multiplied.
srcDesc : cudnnTensor4dDescription
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 activation Note that if beta is zero, the output
is not read and can contain any uninitialized data (including Nan numbers).
destDesc : cudnnTensor4dDescription
Handle to the previously initialized output tensor descriptor.
destData : void_p
Data pointer to GPU memory associated with the output tensor descriptor
destDesc.
Apply activation function . This routine applies a specified neuron activation function element - wise over each input value . In - place operation is allowed for this routine ; i . e . srcData and destData pointers may be equal . However this requires srcDesc and destDesc descriptors to be identical ( particularly the strides of the input and output must match for in - place operation to be allowed ) . Parameters handle : cudnnHandle Handle to a previously created cuDNN context . mode : cudnnActivationMode Enumerant to specify the activation mode . alpha : float Scaling factor with which every element of the input tensor is multiplied . srcDesc : cudnnTensor4dDescription 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 activation Note that if beta is zero the output is not read and can contain any uninitialized data ( including Nan numbers ) . destDesc : cudnnTensor4dDescription Handle to the previously initialized output tensor descriptor . destData : void_p Data pointer to GPU memory associated with the output tensor descriptor destDesc .
def cudnnActivationForward(handle, mode, 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.cudnnActivationForward(
        handle, mode, alphaRef, srcDesc, srcData, betaRef, destDesc, destData)
    cudnnCheckStatus(status)
def cudnnActivationForward ( handle , mode , 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 . cudnnActivationForward ( handle , mode , alphaRef , srcDesc , srcData , betaRef , destDesc , destData ) cudnnCheckStatus ( status )
Apply activation function.
Apply activation function .
""""
    Apply activation function.

    This routine applies a specified neuron activation function element-wise over each input
    value.

    In-place operation is allowed for this routine; i.e., srcData and destData pointers
    may be equal. However, this requires srcDesc and destDesc descriptors to be
    identical (particularly, the strides of the input and output must match for in-place
    operation to be allowed).

    Parameters
    ----------
    handle : cudnnHandle
        Handle to a previously created cuDNN context.
    mode : cudnnActivationMode
        Enumerant to specify the activation mode.
    alpha: float
        Scaling factor with which every element of the input tensor is multiplied.
    srcDesc : cudnnTensor4dDescription
        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 activation Note that if beta is zero, the output
        is not read and can contain any uninitialized data (including Nan numbers).
    destDesc : cudnnTensor4dDescription
        Handle to the previously initialized output tensor descriptor.
    destData : void_p
        Data pointer to GPU memory associated with the output tensor descriptor
        destDesc.
    """
handle
mode
alpha
srcDesc
srcData
beta
destDesc
destData