Library/ManagedCuda/CudaDNN/CudaDNNContext.cs
/// <summary>
/// This function applies a bias and then an activation to the convolutions or crosscorrelations
/// of cudnnConvolutionForward(), returning results in y.The full computation
/// follows the equation y = act(alpha1* conv(x) + alpha2* z + bias ).<para/>
/// The routine cudnnGetConvolution2dForwardOutputDim or
/// cudnnGetConvolutionNdForwardOutputDim can be used to determine the proper
/// dimensions of the output tensor descriptor yDesc with respect to xDesc, convDesc and wDesc.
/// </summary>
/// <param name="alpha1">Pointers to scaling factors (in host memory) used to blend the computation
/// result with prior value in the output layer as described by the above equation.</param>
/// <param name="xDesc">Handle to a previously initialized tensor descriptor.</param>
/// <param name="x">Data pointer to GPU memory associated with the tensor descriptor xDesc.</param>
/// <param name="wDesc">Handle to a previously initialized filter descriptor.</param>
/// <param name="w">Data pointer to GPU memory associated with the filter descriptor wDesc.</param>
/// <param name="convDesc">Previously initialized convolution descriptor.</param>
/// <param name="algo">Enumerant that specifies which convolution algorithm shoud be used to compute the results</param>
/// <param name="workSpace">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</param>
/// <param name="alpha2">Pointers to scaling factors (in host memory) used to blend the computation
/// result with prior value in the output layer as described by the above equation.</param>
/// <param name="zDesc">Handle to a previously initialized tensor descriptor.</param>
/// <param name="z">Data pointer to GPU memory associated with the tensor descriptor zDesc.</param>
/// <param name="biasDesc">Handle to a previously initialized tensor descriptor.</param>
/// <param name="bias">Data pointer to GPU memory associated with the tensor descriptor biasDesc.</param>
/// <param name="activationDesc">Handle to a previously initialized activation descriptor.</param>
/// <param name="yDesc">Handle to a previously initialized tensor descriptor.</param>
/// <param name="y">Data pointer to GPU memory associated with the tensor descriptor yDesc
/// that carries the result of the convolution.</param>
This function applies a bias and then an activation to the convolutions or crosscorrelations
of cudnnConvolutionForward(), returning results in y.The full computation
follows the equation y = act(alpha1* conv(x) + alpha2* z + bias ).
The routine cudnnGetConvolution2dForwardOutputDim or
cudnnGetConvolutionNdForwardOutputDim can be used to determine the proper
dimensions of the output tensor descriptor yDesc with respect to xDesc, convDesc and wDesc.
This function applies a bias and then an activation to the convolutions or crosscorrelations of cudnnConvolutionForward () returning results in y . The full computation follows the equation y = act ( alpha1 * conv ( x ) + alpha2 * z + bias ) . The routine cudnnGetConvolution2dForwardOutputDim or cudnnGetConvolutionNdForwardOutputDim can be used to determine the proper dimensions of the output tensor descriptor yDesc with respect to xDesc convDesc and wDesc .
public void ConvolutionBiasActivationForward(
                                float alpha1,
                                TensorDescriptor xDesc,
                                CudaDeviceVariable<float> x,
                                FilterDescriptor wDesc,
                                CudaDeviceVariable<float> w,
                                ConvolutionDescriptor convDesc,
                                cudnnConvolutionFwdAlgo algo,
                                CudaDeviceVariable<byte> workSpace,
                                float alpha2,
                                TensorDescriptor zDesc,
                                CudaDeviceVariable<float> z,
                                TensorDescriptor biasDesc,
                                CudaDeviceVariable<float> bias,
                                ActivationDescriptor activationDesc,
                                TensorDescriptor yDesc,
                                CudaDeviceVariable<float> y)
        {
            res = CudaDNNNativeMethods.cudnnConvolutionBiasActivationForward(_handle, ref alpha1,
                xDesc.Desc, x.DevicePointer,
                wDesc.Desc, w.DevicePointer,
                convDesc.Desc, algo, workSpace.DevicePointer, workSpace.SizeInBytes,
                ref alpha2, zDesc.Desc, z.DevicePointer,
                biasDesc.Desc, bias.DevicePointer, activationDesc.Desc, 
                yDesc.Desc, y.DevicePointer);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnConvolutionBiasActivationForward", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
public void ConvolutionBiasActivationForward ( float alpha1 , TensorDescriptor xDesc , CudaDeviceVariable < float > x , FilterDescriptor wDesc , CudaDeviceVariable < float > w , ConvolutionDescriptor convDesc , cudnnConvolutionFwdAlgo algo , CudaDeviceVariable < byte > workSpace , float alpha2 , TensorDescriptor zDesc , CudaDeviceVariable < float > z , TensorDescriptor biasDesc , CudaDeviceVariable < float > bias , ActivationDescriptor activationDesc , TensorDescriptor yDesc , CudaDeviceVariable < float > y ) { res = CudaDNNNativeMethods . cudnnConvolutionBiasActivationForward ( _handle , ref alpha1 , xDesc . Desc , x . DevicePointer , wDesc . Desc , w . DevicePointer , convDesc . Desc , algo , workSpace . DevicePointer , workSpace . SizeInBytes , ref alpha2 , zDesc . Desc , z . DevicePointer , biasDesc . Desc , bias . DevicePointer , activationDesc . Desc , yDesc . Desc , y . DevicePointer ) ; Debug . WriteLine ( String . Format ( " " , DateTime . Now , " " , res ) ) ; if ( res != cudnnStatus . Success ) throw new CudaDNNException ( res ) ; }
This function applies a bias and then an activation to the convolutions or crosscorrelations
of cudnnConvolutionForward(), returning results in y.The full computation
follows the equation y = act(alpha1* conv(x) + alpha2* z + bias ).
This function applies a bias and then an activation to the convolutions or crosscorrelations of cudnnConvolutionForward () returning results in y . The full computation follows the equation y = act ( alpha1 * conv ( x ) + alpha2 * z + bias ) .
alpha1
float
Pointers to scaling factors (in host memory) used to blend the computation
result with prior value in the output layer as described by the above equation.
Pointers to scaling factors ( in host memory ) used to blend the computation result with prior value in the output layer as described by the above equation .
xDesc
TensorDescriptor
Handle to a previously initialized tensor descriptor.
Handle to a previously initialized tensor descriptor .
x
CudaDeviceVariable<float>
Data pointer to GPU memory associated with the tensor descriptor xDesc.
Data pointer to GPU memory associated with the tensor descriptor xDesc .
wDesc
FilterDescriptor
Handle to a previously initialized filter descriptor.
Handle to a previously initialized filter descriptor .
w
CudaDeviceVariable<float>
Data pointer to GPU memory associated with the filter descriptor wDesc.
Data pointer to GPU memory associated with the filter descriptor wDesc .
convDesc
ConvolutionDescriptor
Previously initialized convolution descriptor.
Previously initialized convolution descriptor .
algo
cudnnConvolutionFwdAlgo
Enumerant that specifies which convolution algorithm shoud be used to compute the results
Enumerant that specifies which convolution algorithm shoud be used to compute the results
workSpace
CudaDeviceVariable<byte>
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
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
alpha2
float
Pointers to scaling factors (in host memory) used to blend the computation
result with prior value in the output layer as described by the above equation.
Pointers to scaling factors ( in host memory ) used to blend the computation result with prior value in the output layer as described by the above equation .
zDesc
TensorDescriptor
Handle to a previously initialized tensor descriptor.
Handle to a previously initialized tensor descriptor .
z
CudaDeviceVariable<float>
Data pointer to GPU memory associated with the tensor descriptor zDesc.
Data pointer to GPU memory associated with the tensor descriptor zDesc .
biasDesc
TensorDescriptor
Handle to a previously initialized tensor descriptor.
Handle to a previously initialized tensor descriptor .
bias
CudaDeviceVariable<float>
Data pointer to GPU memory associated with the tensor descriptor biasDesc.
Data pointer to GPU memory associated with the tensor descriptor biasDesc .
activationDesc
ActivationDescriptor
Handle to a previously initialized activation descriptor.
Handle to a previously initialized activation descriptor .
yDesc
TensorDescriptor
Handle to a previously initialized tensor descriptor.
Handle to a previously initialized tensor descriptor .
y
CudaDeviceVariable<float>
Data pointer to GPU memory associated with the tensor descriptor yDesc
that carries the result of the convolution.
Data pointer to GPU memory associated with the tensor descriptor yDesc that carries the result of the convolution .