/* * Copyright 2014-2023 NVIDIA Corporation. All rights reserved. * * NOTICE TO LICENSEE: * * This source code and/or documentation ("Licensed Deliverables") are * subject to NVIDIA intellectual property rights under U.S. and * international Copyright laws. * * These Licensed Deliverables contained herein is PROPRIETARY and * CONFIDENTIAL to NVIDIA and is being provided under the terms and * conditions of a form of NVIDIA software license agreement by and * between NVIDIA and Licensee ("License Agreement") or electronically * accepted by Licensee. Notwithstanding any terms or conditions to * the contrary in the License Agreement, reproduction or disclosure * of the Licensed Deliverables to any third party without the express * written consent of NVIDIA is prohibited. * * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THESE LICENSED DELIVERABLES. * * U.S. Government End Users. These Licensed Deliverables are a * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT * 1995), consisting of "commercial computer software" and "commercial * computer software documentation" as such terms are used in 48 * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government * only as a commercial end item. Consistent with 48 C.F.R.12.212 and * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all * U.S. Government End Users acquire the Licensed Deliverables with * only those rights set forth herein. * * Any use of the Licensed Deliverables in individual and commercial * software must include, in the user documentation and internal * comments to the code, the above Disclaimer and U.S. Government End * Users Notice. */ /** * @file cudnn_ops.h * @brief cuDNN Operations library - tensor descriptors, basic operations, batch normalization, pooling, etc. */ /* * cudnn_ops : cuDNN's basic definitions and basic operations. */ #if !defined(CUDNN_OPS_H_) #define CUDNN_OPS_H_ #include #include "cudnn_version.h" #include "cudnn_graph.h" /* These version numbers are autogenerated, do not edit manually. */ #define CUDNN_OPS_MAJOR 9 #define CUDNN_OPS_MINOR 22 #define CUDNN_OPS_PATCH 0 #if (CUDNN_OPS_MAJOR != CUDNN_MAJOR) || (CUDNN_OPS_MINOR != CUDNN_MINOR) || (CUDNN_OPS_PATCH != CUDNN_PATCHLEVEL) #error Version mismatch in cuDNN OPS INFER!!! #endif #if defined(__cplusplus) extern "C" { #endif /* Data structures to represent Image/Filter and the Neural Network Layer */ /** @brief Opaque descriptor for a tensor. @since cuDNN 9.0.0 */ typedef struct cudnnTensorStruct *cudnnTensorDescriptor_t; /** @brief Opaque descriptor for a pooling operation. @since cuDNN 9.0.0 @deprecated Since cuDNN 9.0.0. Use graph API instead. */ typedef struct cudnnPoolingStruct *cudnnPoolingDescriptor_t CUDNN_DEPRECATED; /** @brief Opaque descriptor for a filter (convolution kernel). @since cuDNN 9.0.0 @deprecated Since cuDNN 9.0.0. Use graph API instead. */ typedef struct cudnnFilterStruct *cudnnFilterDescriptor_t CUDNN_DEPRECATED; /** @brief Opaque descriptor for Local Response Normalization (LRN). @since cuDNN 9.0.0 */ typedef struct cudnnLRNStruct *cudnnLRNDescriptor_t; /** @brief Opaque descriptor for an activation function. @since cuDNN 9.0.0 @deprecated Since cuDNN 9.0.0. Use graph API instead. */ typedef struct cudnnActivationStruct *cudnnActivationDescriptor_t CUDNN_DEPRECATED; /** @brief Opaque descriptor for a spatial transformer network. @since cuDNN 9.0.0 */ typedef struct cudnnSpatialTransformerStruct *cudnnSpatialTransformerDescriptor_t; /** @brief Opaque descriptor for an element-wise tensor operation. @since cuDNN 9.0.0 @deprecated Since cuDNN 9.0.0. Use graph API instead. */ typedef struct cudnnOpTensorStruct *cudnnOpTensorDescriptor_t CUDNN_DEPRECATED; /** @brief Opaque descriptor for a tensor reduction operation. @since cuDNN 9.0.0 @deprecated Since cuDNN 9.0.0. Use graph API instead. */ typedef struct cudnnReduceTensorStruct *cudnnReduceTensorDescriptor_t CUDNN_DEPRECATED; /** @brief Opaque descriptor for a CTC loss function. @since cuDNN 9.0.0 */ typedef struct cudnnCTCLossStruct *cudnnCTCLossDescriptor_t; /** @brief Opaque descriptor for tensor transform operations. @since cuDNN 9.0.0 @deprecated Since cuDNN 9.0.0. Use graph API instead. */ typedef struct cudnnTensorTransformStruct *cudnnTensorTransformDescriptor_t CUDNN_DEPRECATED; /** * @brief Indicates whether results are guaranteed to be reproducible across runs. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_NON_DETERMINISTIC = 0, /**< Results may vary across runs. @since cuDNN 9.0.0 */ CUDNN_DETERMINISTIC = 1, /**< Results are guaranteed to be reproducible. @since cuDNN 9.0.0 */ } cudnnDeterminism_t; /** * @brief Creates a tensor descriptor. * * Allocates and initializes a new tensor descriptor object. * * @param[out] tensorDesc Pointer to the newly created tensor descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @see cudnnDestroyTensorDescriptor, cudnnSetTensor4dDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnCreateTensorDescriptor(cudnnTensorDescriptor_t *tensorDesc); /** * @brief Sets a 4D tensor descriptor. * * Initializes a previously created tensor descriptor with the specified format, * data type, and dimensions. Strides are computed automatically based on the format. * * @param[in,out] tensorDesc Tensor descriptor to initialize. * @param[in] format Memory layout format (e.g., NCHW or NHWC). * @param[in] dataType Data type of the tensor elements. * @param[in] n Number of images (batch size). * @param[in] c Number of feature maps (channels). * @param[in] h Height of each feature map. * @param[in] w Width of each feature map. * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSetTensor4dDescriptorEx, cudnnGetTensor4dDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnSetTensor4dDescriptor(cudnnTensorDescriptor_t tensorDesc, cudnnTensorFormat_t format, cudnnDataType_t dataType, /* image data type */ int n, /* number of inputs (batch size) */ int c, /* number of input feature maps */ int h, /* height of input section */ int w); /* width of input section */ /** * @brief Sets a 4D tensor descriptor with explicit strides. * * Initializes a previously created tensor descriptor with the specified data type, * dimensions, and explicit stride values for each dimension. * * @param[in,out] tensorDesc Tensor descriptor to initialize. * @param[in] dataType Data type of the tensor elements. * @param[in] n Number of images (batch size). * @param[in] c Number of feature maps (channels). * @param[in] h Height of each feature map. * @param[in] w Width of each feature map. * @param[in] nStride Stride between images. * @param[in] cStride Stride between feature maps. * @param[in] hStride Stride between rows. * @param[in] wStride Stride between columns. * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSetTensor4dDescriptor, cudnnGetTensor4dDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnSetTensor4dDescriptorEx(cudnnTensorDescriptor_t tensorDesc, cudnnDataType_t dataType, /* image data type */ int n, /* number of inputs (batch size) */ int c, /* number of input feature maps */ int h, /* height of input section */ int w, /* width of input section */ int nStride, int cStride, int hStride, int wStride); /** * @brief Retrieves the settings of a previously initialized 4D tensor descriptor. * * @param[in] tensorDesc Tensor descriptor to query. * @param[out] dataType Data type of the tensor. * @param[out] n Number of images (batch size). * @param[out] c Number of feature maps (channels). * @param[out] h Height of each feature map. * @param[out] w Width of each feature map. * @param[out] nStride Stride between images. * @param[out] cStride Stride between feature maps. * @param[out] hStride Stride between rows. * @param[out] wStride Stride between columns. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @see cudnnSetTensor4dDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnGetTensor4dDescriptor(const cudnnTensorDescriptor_t tensorDesc, cudnnDataType_t *dataType, /* image data type */ int *n, /* number of inputs (batch size) */ int *c, /* number of input feature maps */ int *h, /* height of input section */ int *w, /* width of input section */ int *nStride, int *cStride, int *hStride, int *wStride); /** * @brief Sets an N-dimensional tensor descriptor. * * Initializes a tensor descriptor with arbitrary dimensionality, data type, dimensions, and strides. * * @param[in,out] tensorDesc Tensor descriptor to initialize. * @param[in] dataType Data type of the tensor elements. * @param[in] nbDims Number of dimensions. * @param[in] dimA Array of dimension sizes (length nbDims). * @param[in] strideA Array of strides (length nbDims). * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnGetTensorNdDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnSetTensorNdDescriptor(cudnnTensorDescriptor_t tensorDesc, cudnnDataType_t dataType, int nbDims, const int dimA[], const int strideA[]); /** * @brief Sets an N-dimensional tensor descriptor with automatic stride computation. * * Initializes a tensor descriptor with the specified format; strides are computed * automatically from the format and dimensions. * * @param[in,out] tensorDesc Tensor descriptor to initialize. * @param[in] format Memory layout format. * @param[in] dataType Data type of the tensor elements. * @param[in] nbDims Number of dimensions. * @param[in] dimA Array of dimension sizes (length nbDims). * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSetTensorNdDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnSetTensorNdDescriptorEx(cudnnTensorDescriptor_t tensorDesc, cudnnTensorFormat_t format, cudnnDataType_t dataType, int nbDims, const int dimA[]); /** * @brief Retrieves the settings of a previously initialized N-dimensional tensor descriptor. * * @param[in] tensorDesc Tensor descriptor to query. * @param[in] nbDimsRequested Number of dimensions to retrieve. * @param[out] dataType Data type of the tensor. * @param[out] nbDims Actual number of dimensions in the descriptor. * @param[out] dimA Array to receive dimension sizes (length nbDimsRequested). * @param[out] strideA Array to receive strides (length nbDimsRequested). * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @see cudnnSetTensorNdDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnGetTensorNdDescriptor(const cudnnTensorDescriptor_t tensorDesc, int nbDimsRequested, cudnnDataType_t *dataType, int *nbDims, int dimA[], int strideA[]); /** * @brief Returns the memory size in bytes required by a tensor. * * @param[in] tensorDesc Tensor descriptor to query. * @param[out] size Memory size in bytes. * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 */ cudnnStatus_t CUDNNWINAPI cudnnGetTensorSizeInBytes(const cudnnTensorDescriptor_t tensorDesc, size_t *size); /* PixelOffset( n, c, h, w ) = n *input_stride + c * feature_stride + h * h_stride + w * w_stride 1)Example of all images in row major order one batch of features after the other (with an optional padding on row) input_stride : c x h x h_stride feature_stride : h x h_stride h_stride : >= w ( h_stride = w if no padding) w_stride : 1 2)Example of all images in row major with features maps interleaved input_stride : c x h x h_stride feature_stride : 1 h_stride : w x c w_stride : c 3)Example of all images in column major order one batch of features after the other (with optional padding on column) input_stride : c x w x w_stride feature_stride : w x w_stride h_stride : 1 w_stride : >= h */ /** * @brief Destroys a tensor descriptor. * * Releases the resources associated with a tensor descriptor object. * * @param[in] tensorDesc Tensor descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @see cudnnCreateTensorDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnDestroyTensorDescriptor(cudnnTensorDescriptor_t tensorDesc); /** * @brief Specifies the direction for tensor transform folding operations. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_TRANSFORM_FOLD = 0U, /**< Fold the tensor. @since cuDNN 9.0.0 */ CUDNN_TRANSFORM_UNFOLD = 1U, /**< Unfold the tensor. @since cuDNN 9.0.0 */ } cudnnFoldingDirection_t; /** * @brief Initializes the destination tensor descriptor for a tensor transform. * * Computes the destination tensor dimensions and size based on the transform and source descriptors. * * @param[in] transformDesc Transform descriptor specifying the operation. * @param[in] srcDesc Source tensor descriptor. * @param[in,out] destDesc Destination tensor descriptor to be initialized. * @param[out] destSizeInBytes Memory size in bytes of the destination tensor. * * @retval CUDNN_STATUS_SUCCESS The destination descriptor was initialized successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnTransformTensorEx */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnInitTransformDest(const cudnnTensorTransformDescriptor_t transformDesc, const cudnnTensorDescriptor_t srcDesc, cudnnTensorDescriptor_t destDesc, size_t *destSizeInBytes); /** * @brief Creates a tensor transform descriptor. * * Allocates and initializes a new tensor transform descriptor object. * * @param[out] transformDesc Pointer to the newly created transform descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnDestroyTensorTransformDescriptor, cudnnSetTensorTransformDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnCreateTensorTransformDescriptor(cudnnTensorTransformDescriptor_t *transformDesc); /** * @brief Configures a tensor transform descriptor. * * Sets the parameters of a previously created tensor transform descriptor including * padding, folding, and destination format. * * @param[in,out] transformDesc Transform descriptor to configure. * @param[in] nbDims Number of dimensions. * @param[in] destFormat Destination tensor format. * @param[in] padBeforeA Array of padding values before each dimension. * @param[in] padAfterA Array of padding values after each dimension. * @param[in] foldA Array of fold parameters per dimension. * @param[in] direction Folding direction (fold or unfold). * * @retval CUDNN_STATUS_SUCCESS The descriptor was configured successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetTensorTransformDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnSetTensorTransformDescriptor(cudnnTensorTransformDescriptor_t transformDesc, const uint32_t nbDims, const cudnnTensorFormat_t destFormat, const int32_t padBeforeA[], const int32_t padAfterA[], const uint32_t foldA[], const cudnnFoldingDirection_t direction); /** * @brief Retrieves the settings of a previously initialized tensor transform descriptor. * * @param[in] transformDesc Transform descriptor to query. * @param[in] nbDimsRequested Number of dimensions to retrieve. * @param[out] destFormat Destination tensor format. * @param[out] padBeforeA Array to receive pre-padding values. * @param[out] padAfterA Array to receive post-padding values. * @param[out] foldA Array to receive fold parameters. * @param[out] direction Folding direction. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetTensorTransformDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetTensorTransformDescriptor(cudnnTensorTransformDescriptor_t transformDesc, uint32_t nbDimsRequested, cudnnTensorFormat_t *destFormat, int32_t padBeforeA[], int32_t padAfterA[], uint32_t foldA[], cudnnFoldingDirection_t *direction); /** * @brief Destroys a tensor transform descriptor. * * Releases the resources associated with a tensor transform descriptor. * * @param[in] transformDesc Transform descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnCreateTensorTransformDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnDestroyTensorTransformDescriptor(cudnnTensorTransformDescriptor_t transformDesc); /** * @brief Copies and converts tensor data between layouts with alpha/beta blending. * * Performs y = alpha * x + beta * y, converting between tensor formats as needed. * * @param[in] handle cuDNN library handle. * @param[in] alpha Scaling factor for the source tensor. * @param[in] xDesc Source tensor descriptor. * @param[in] x Pointer to source tensor data. * @param[in] beta Scaling factor for the destination tensor. * @param[in] yDesc Destination tensor descriptor. * @param[in,out] y Pointer to destination tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnTransformTensorEx */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnTransformTensor(cudnnHandle_t handle, const void *alpha, const cudnnTensorDescriptor_t xDesc, const void *x, const void *beta, const cudnnTensorDescriptor_t yDesc, void *y); /** * @brief Extended tensor transform with folding/padding support. * * Performs dest = alpha * transform(src) + beta * dest, using the specified * transform descriptor for padding and folding configuration. * * @param[in] handle cuDNN library handle. * @param[in] transDesc Transform descriptor specifying the operation. * @param[in] alpha Scaling factor for the source tensor. * @param[in] srcDesc Source tensor descriptor. * @param[in] srcData Pointer to source tensor data. * @param[in] beta Scaling factor for the destination tensor. * @param[in] destDesc Destination tensor descriptor. * @param[in,out] destData Pointer to destination tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnTransformTensor, cudnnSetTensorTransformDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnTransformTensorEx(cudnnHandle_t handle, const cudnnTensorTransformDescriptor_t transDesc, const void *alpha, const cudnnTensorDescriptor_t srcDesc, const void *srcData, const void *beta, const cudnnTensorDescriptor_t destDesc, void *destData); /** * @brief Adds a scaled bias tensor to a destination tensor with broadcasting. * * Performs C = alpha * A + beta * C, where A is broadcast to match C dimensions. * * @param[in] handle cuDNN library handle. * @param[in] alpha Scaling factor for the bias tensor A. * @param[in] aDesc Bias tensor descriptor. * @param[in] A Pointer to bias tensor data. * @param[in] beta Scaling factor for the destination tensor C. * @param[in] cDesc Destination tensor descriptor. * @param[in,out] C Pointer to destination tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnAddTensor(cudnnHandle_t handle, const void *alpha, const cudnnTensorDescriptor_t aDesc, const void *A, const void *beta, const cudnnTensorDescriptor_t cDesc, void *C); /** * @brief Enumerates the element-wise tensor operations supported by cudnnOpTensor. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_OP_TENSOR_ADD = 0, /**< Element-wise addition. @since cuDNN 9.0.0 */ CUDNN_OP_TENSOR_MUL = 1, /**< Element-wise multiplication. @since cuDNN 9.0.0 */ CUDNN_OP_TENSOR_MIN = 2, /**< Element-wise minimum. @since cuDNN 9.0.0 */ CUDNN_OP_TENSOR_MAX = 3, /**< Element-wise maximum. @since cuDNN 9.0.0 */ CUDNN_OP_TENSOR_SQRT = 4, /**< Element-wise square root (unary, B tensor ignored). @since cuDNN 9.0.0 */ CUDNN_OP_TENSOR_NOT = 5, /**< Element-wise logical NOT (unary, B tensor ignored). @since cuDNN 9.0.0 */ } cudnnOpTensorOp_t; /** * @brief Creates an op tensor descriptor. * * @param[out] opTensorDesc Pointer to the newly created op tensor descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnDestroyOpTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnCreateOpTensorDescriptor(cudnnOpTensorDescriptor_t *opTensorDesc); /** * @brief Configures an op tensor descriptor. * * @param[in,out] opTensorDesc Op tensor descriptor to configure. * @param[in] opTensorOp Tensor operation to perform. * @param[in] opTensorCompType Computation data type. * @param[in] opTensorNanOpt NaN propagation policy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetOpTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnSetOpTensorDescriptor(cudnnOpTensorDescriptor_t opTensorDesc, cudnnOpTensorOp_t opTensorOp, cudnnDataType_t opTensorCompType, cudnnNanPropagation_t opTensorNanOpt); /** * @brief Retrieves the settings of an op tensor descriptor. * * @param[in] opTensorDesc Op tensor descriptor to query. * @param[out] opTensorOp Tensor operation type. * @param[out] opTensorCompType Computation data type. * @param[out] opTensorNanOpt NaN propagation policy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetOpTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetOpTensorDescriptor(const cudnnOpTensorDescriptor_t opTensorDesc, cudnnOpTensorOp_t *opTensorOp, cudnnDataType_t *opTensorCompType, cudnnNanPropagation_t *opTensorNanOpt); /** * @brief Destroys an op tensor descriptor. * * @param[in] opTensorDesc Op tensor descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnCreateOpTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnDestroyOpTensorDescriptor(cudnnOpTensorDescriptor_t opTensorDesc); /** * @brief Performs element-wise tensor operations. * * Computes C = op(alpha1 * A, alpha2 * B) + beta * C. The B tensor is ignored * for CUDNN_OP_TENSOR_SQRT and CUDNN_OP_TENSOR_NOT (unary operations). * * @param[in] handle cuDNN library handle. * @param[in] opTensorDesc Op tensor descriptor specifying the operation. * @param[in] alpha1 Scaling factor for tensor A. * @param[in] aDesc Descriptor for tensor A. * @param[in] A Pointer to tensor A data. * @param[in] alpha2 Scaling factor for tensor B. * @param[in] bDesc Descriptor for tensor B. * @param[in] B Pointer to tensor B data. * @param[in] beta Scaling factor for tensor C. * @param[in] cDesc Descriptor for tensor C. * @param[in,out] C Pointer to tensor C data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetOpTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnOpTensor(cudnnHandle_t handle, const cudnnOpTensorDescriptor_t opTensorDesc, const void *alpha1, const cudnnTensorDescriptor_t aDesc, const void *A, const void *alpha2, const cudnnTensorDescriptor_t bDesc, const void *B, const void *beta, const cudnnTensorDescriptor_t cDesc, void *C); /** * @brief Specifies whether indices are computed during a reduction operation. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_REDUCE_TENSOR_NO_INDICES = 0, /**< Do not compute indices. @since cuDNN 9.0.0 */ CUDNN_REDUCE_TENSOR_FLATTENED_INDICES = 1, /**< Compute flattened indices of min/max values. @since cuDNN 9.0.0 */ } cudnnReduceTensorIndices_t CUDNN_DEPRECATED; /** * @brief Data type used for reduction indices (all unsigned). * * Currently only 32-bit unsigned is fully supported; other sizes are reserved. * * @since cuDNN 9.0.0 */ typedef enum { CUDNN_32BIT_INDICES = 0, /**< 32-bit unsigned indices. @since cuDNN 9.0.0 */ CUDNN_64BIT_INDICES = 1, /**< 64-bit unsigned indices. @since cuDNN 9.0.0 */ CUDNN_16BIT_INDICES = 2, /**< 16-bit unsigned indices. @since cuDNN 9.0.0 */ CUDNN_8BIT_INDICES = 3, /**< 8-bit unsigned indices. @since cuDNN 9.0.0 */ } cudnnIndicesType_t CUDNN_DEPRECATED; /** * @brief Creates a reduce tensor descriptor. * * @param[out] reduceTensorDesc Pointer to the newly created reduce tensor descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnDestroyReduceTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnCreateReduceTensorDescriptor(cudnnReduceTensorDescriptor_t *reduceTensorDesc); /** * @brief Configures a reduce tensor descriptor. * * @param[in,out] reduceTensorDesc Reduce tensor descriptor to configure. * @param[in] reduceTensorOp Reduction operation to perform. * @param[in] reduceTensorCompType Computation data type. * @param[in] reduceTensorNanOpt NaN propagation policy (applies to min/max only). * @param[in] reduceTensorIndices Whether to compute indices. * @param[in] reduceTensorIndicesType Data type for computed indices. * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetReduceTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnSetReduceTensorDescriptor(cudnnReduceTensorDescriptor_t reduceTensorDesc, cudnnReduceTensorOp_t reduceTensorOp, cudnnDataType_t reduceTensorCompType, cudnnNanPropagation_t reduceTensorNanOpt, cudnnReduceTensorIndices_t reduceTensorIndices, cudnnIndicesType_t reduceTensorIndicesType); /** * @brief Retrieves the settings of a reduce tensor descriptor. * * @param[in] reduceTensorDesc Reduce tensor descriptor to query. * @param[out] reduceTensorOp Reduction operation type. * @param[out] reduceTensorCompType Computation data type. * @param[out] reduceTensorNanOpt NaN propagation policy. * @param[out] reduceTensorIndices Whether indices are computed. * @param[out] reduceTensorIndicesType Data type for computed indices. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetReduceTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetReduceTensorDescriptor(const cudnnReduceTensorDescriptor_t reduceTensorDesc, cudnnReduceTensorOp_t *reduceTensorOp, cudnnDataType_t *reduceTensorCompType, cudnnNanPropagation_t *reduceTensorNanOpt, cudnnReduceTensorIndices_t *reduceTensorIndices, cudnnIndicesType_t *reduceTensorIndicesType); /** * @brief Destroys a reduce tensor descriptor. * * @param[in] reduceTensorDesc Reduce tensor descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnCreateReduceTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnDestroyReduceTensorDescriptor(cudnnReduceTensorDescriptor_t reduceTensorDesc); /** * @brief Returns the minimum size of the index space for a reduction operation. * * @param[in] handle cuDNN library handle. * @param[in] reduceTensorDesc Reduce tensor descriptor. * @param[in] aDesc Input tensor descriptor. * @param[in] cDesc Output tensor descriptor. * @param[out] sizeInBytes Minimum index space size in bytes. * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnReduceTensor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetReductionIndicesSize(cudnnHandle_t handle, const cudnnReduceTensorDescriptor_t reduceTensorDesc, const cudnnTensorDescriptor_t aDesc, const cudnnTensorDescriptor_t cDesc, size_t *sizeInBytes); /** * @brief Returns the minimum workspace size required for a reduction operation. * * @param[in] handle cuDNN library handle. * @param[in] reduceTensorDesc Reduce tensor descriptor. * @param[in] aDesc Input tensor descriptor. * @param[in] cDesc Output tensor descriptor. * @param[out] sizeInBytes Minimum workspace size in bytes. * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnReduceTensor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetReductionWorkspaceSize(cudnnHandle_t handle, const cudnnReduceTensorDescriptor_t reduceTensorDesc, const cudnnTensorDescriptor_t aDesc, const cudnnTensorDescriptor_t cDesc, size_t *sizeInBytes); /** * @brief Performs a tensor reduction operation. * * Computes C = reduce_op(alpha * A) + beta * C. NaN propagation applies only * to min and max operations. The indices space is ignored for operations other * than min or max. * * @param[in] handle cuDNN library handle. * @param[in] reduceTensorDesc Reduce tensor descriptor. * @param[out] indices Pointer to index space (for min/max ops). * @param[in] indicesSizeInBytes Size of the index space in bytes. * @param[out] workspace Pointer to workspace memory. * @param[in] workspaceSizeInBytes Size of the workspace in bytes. * @param[in] alpha Scaling factor for the input tensor. * @param[in] aDesc Input tensor descriptor. * @param[in] A Pointer to input tensor data. * @param[in] beta Scaling factor for the output tensor. * @param[in] cDesc Output tensor descriptor. * @param[in,out] C Pointer to output tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetReductionWorkspaceSize, cudnnGetReductionIndicesSize */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnReduceTensor(cudnnHandle_t handle, const cudnnReduceTensorDescriptor_t reduceTensorDesc, void *indices, size_t indicesSizeInBytes, void *workspace, size_t workspaceSizeInBytes, const void *alpha, const cudnnTensorDescriptor_t aDesc, const void *A, const void *beta, const cudnnTensorDescriptor_t cDesc, void *C); /** * @brief Fills a tensor with a constant value. * * Sets every element of the tensor to the specified value: y[i] = value[0]. * * @param[in] handle cuDNN library handle. * @param[in] yDesc Tensor descriptor. * @param[out] y Pointer to tensor data. * @param[in] valuePtr Pointer to the fill value (type matches tensor data type). * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnScaleTensor */ cudnnStatus_t CUDNNWINAPI cudnnSetTensor(cudnnHandle_t handle, const cudnnTensorDescriptor_t yDesc, void *y, const void *valuePtr); /** * @brief Scales all elements of a tensor by a constant factor. * * Performs y[i] = alpha * y[i] for every element. * * @param[in] handle cuDNN library handle. * @param[in] yDesc Tensor descriptor. * @param[in,out] y Pointer to tensor data. * @param[in] alpha Scaling factor (type matches tensor computation type). * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetTensor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnScaleTensor(cudnnHandle_t handle, const cudnnTensorDescriptor_t yDesc, void *y, const void *alpha); /** * @brief Creates a filter descriptor. * * Allocates and initializes a new filter (convolution kernel) descriptor. * * @param[out] filterDesc Pointer to the newly created filter descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnDestroyFilterDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnCreateFilterDescriptor(cudnnFilterDescriptor_t *filterDesc); /** * @brief Sets a 4D filter descriptor. * * Initializes a filter descriptor with the specified data type, format, and dimensions. * * @param[in,out] filterDesc Filter descriptor to initialize. * @param[in] dataType Data type of the filter elements. * @param[in] format Memory layout format. * @param[in] k Number of output feature maps. * @param[in] c Number of input feature maps. * @param[in] h Height of each filter. * @param[in] w Width of each filter. * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetFilter4dDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnSetFilter4dDescriptor(cudnnFilterDescriptor_t filterDesc, cudnnDataType_t dataType, /* image data type */ cudnnTensorFormat_t format, int k, /* number of output feature maps */ int c, /* number of input feature maps */ int h, /* height of each input filter */ int w); /* width of each input filter */ /** * @brief Retrieves the settings of a 4D filter descriptor. * * @param[in] filterDesc Filter descriptor to query. * @param[out] dataType Data type of the filter. * @param[out] format Memory layout format. * @param[out] k Number of output feature maps. * @param[out] c Number of input feature maps. * @param[out] h Height of each filter. * @param[out] w Width of each filter. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetFilter4dDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetFilter4dDescriptor(const cudnnFilterDescriptor_t filterDesc, cudnnDataType_t *dataType, /* image data type */ cudnnTensorFormat_t *format, int *k, /* number of output feature maps */ int *c, /* number of input feature maps */ int *h, /* height of each input filter */ int *w); /* width of each input filter */ /** * @brief Sets an N-dimensional filter descriptor. * * @param[in,out] filterDesc Filter descriptor to initialize. * @param[in] dataType Data type of the filter elements. * @param[in] format Memory layout format. * @param[in] nbDims Number of dimensions. * @param[in] filterDimA Array of filter dimension sizes (length nbDims). * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetFilterNdDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnSetFilterNdDescriptor(cudnnFilterDescriptor_t filterDesc, cudnnDataType_t dataType, /* image data type */ cudnnTensorFormat_t format, int nbDims, const int filterDimA[]); /** * @brief Retrieves the settings of an N-dimensional filter descriptor. * * @param[in] filterDesc Filter descriptor to query. * @param[in] nbDimsRequested Number of dimensions to retrieve. * @param[out] dataType Data type of the filter. * @param[out] format Memory layout format. * @param[out] nbDims Actual number of dimensions. * @param[out] filterDimA Array to receive dimension sizes. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetFilterNdDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetFilterNdDescriptor(const cudnnFilterDescriptor_t filterDesc, int nbDimsRequested, cudnnDataType_t *dataType, /* image data type */ cudnnTensorFormat_t *format, int *nbDims, int filterDimA[]); /** * @brief Returns the memory size in bytes required by a filter. * * @param[in] filterDesc Filter descriptor to query. * @param[out] size Memory size in bytes. * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetFilterSizeInBytes(const cudnnFilterDescriptor_t filterDesc, size_t *size); /** * @brief Transforms filter data between layouts. * * Converts filter data from one format to another using the specified transform descriptor. * * @param[in] handle cuDNN library handle. * @param[in] transDesc Transform descriptor specifying the operation. * @param[in] alpha Scaling factor for the source filter. * @param[in] srcDesc Source filter descriptor. * @param[in] srcData Pointer to source filter data. * @param[in] beta Scaling factor for the destination filter. * @param[in] destDesc Destination filter descriptor. * @param[in,out] destData Pointer to destination filter data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnTransformTensorEx */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnTransformFilter(cudnnHandle_t handle, const cudnnTensorTransformDescriptor_t transDesc, const void *alpha, const cudnnFilterDescriptor_t srcDesc, const void *srcData, const void *beta, const cudnnFilterDescriptor_t destDesc, void *destData); /** * @brief Destroys a filter descriptor. * * @param[in] filterDesc Filter descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnCreateFilterDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnDestroyFilterDescriptor(cudnnFilterDescriptor_t filterDesc); /** * @brief Selects the softmax implementation algorithm. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_SOFTMAX_FAST = 0, /**< Straightforward softmax without overflow protection. @since cuDNN 9.0.0 */ CUDNN_SOFTMAX_ACCURATE = 1, /**< Scales by max value to avoid floating-point overflow. @since cuDNN 9.0.0 */ CUDNN_SOFTMAX_LOG = 2 /**< Log-softmax with max-value scaling for overflow protection. @since cuDNN 9.0.0 */ } cudnnSoftmaxAlgorithm_t; /** * @brief Selects the scope over which the softmax computation is performed. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_SOFTMAX_MODE_INSTANCE = 0, /**< Compute softmax over all C, H, W for each image (N). @since cuDNN 9.0.0 */ CUDNN_SOFTMAX_MODE_CHANNEL = 1 /**< Compute softmax over channel (C) for each spatial location (H, W) and image (N). @since cuDNN 9.0.0 */ } cudnnSoftmaxMode_t; /* Softmax functions: All of the form "output = alpha * Op(inputs) + beta * output" */ /** * @brief Performs forward softmax computation. * * Computes y = alpha * softmax(x) + beta * y. * * @param[in] handle cuDNN library handle. * @param[in] algo Softmax algorithm to use. * @param[in] mode Softmax computation scope. * @param[in] alpha Scaling factor for the result. * @param[in] xDesc Input tensor descriptor. * @param[in] x Pointer to input tensor data. * @param[in] beta Scaling factor for the destination tensor. * @param[in] yDesc Output tensor descriptor. * @param[in,out] y Pointer to output tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSoftmaxBackward */ cudnnStatus_t CUDNNWINAPI cudnnSoftmaxForward(cudnnHandle_t handle, cudnnSoftmaxAlgorithm_t algo, cudnnSoftmaxMode_t mode, const void *alpha, const cudnnTensorDescriptor_t xDesc, const void *x, const void *beta, const cudnnTensorDescriptor_t yDesc, void *y); /** * @brief Selects the pooling method used in pooling operations. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_POOLING_MAX = 0, /**< Maximum value in the pooling window. @since cuDNN 9.0.0 */ CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING = 1, /**< Average pooling; element count includes padded positions. @since cuDNN 9.0.0 */ CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING = 2, /**< Average pooling; element count excludes padded positions. @since cuDNN 9.0.0 */ CUDNN_POOLING_MAX_DETERMINISTIC = 3 /**< Deterministic max pooling (reproducible results). @since cuDNN 9.0.0 */ } cudnnPoolingMode_t CUDNN_DEPRECATED; /** * @brief Creates a pooling descriptor. * * @param[out] poolingDesc Pointer to the newly created pooling descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnDestroyPoolingDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnCreatePoolingDescriptor(cudnnPoolingDescriptor_t *poolingDesc); /** * @brief Configures a 2D pooling descriptor. * * @param[in,out] poolingDesc Pooling descriptor to configure. * @param[in] mode Pooling mode (max, average, etc.). * @param[in] maxpoolingNanOpt NaN propagation policy for max pooling. * @param[in] windowHeight Height of the pooling window. * @param[in] windowWidth Width of the pooling window. * @param[in] verticalPadding Vertical padding size. * @param[in] horizontalPadding Horizontal padding size. * @param[in] verticalStride Vertical stride. * @param[in] horizontalStride Horizontal stride. * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetPooling2dDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t poolingDesc, cudnnPoolingMode_t mode, cudnnNanPropagation_t maxpoolingNanOpt, int windowHeight, int windowWidth, int verticalPadding, int horizontalPadding, int verticalStride, int horizontalStride); /** * @brief Retrieves the settings of a 2D pooling descriptor. * * @param[in] poolingDesc Pooling descriptor to query. * @param[out] mode Pooling mode. * @param[out] maxpoolingNanOpt NaN propagation policy. * @param[out] windowHeight Height of the pooling window. * @param[out] windowWidth Width of the pooling window. * @param[out] verticalPadding Vertical padding size. * @param[out] horizontalPadding Horizontal padding size. * @param[out] verticalStride Vertical stride. * @param[out] horizontalStride Horizontal stride. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetPooling2dDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetPooling2dDescriptor(const cudnnPoolingDescriptor_t poolingDesc, cudnnPoolingMode_t *mode, cudnnNanPropagation_t *maxpoolingNanOpt, int *windowHeight, int *windowWidth, int *verticalPadding, int *horizontalPadding, int *verticalStride, int *horizontalStride); /** * @brief Configures an N-dimensional pooling descriptor. * * @param[in,out] poolingDesc Pooling descriptor to configure. * @param[in] mode Pooling mode. * @param[in] maxpoolingNanOpt NaN propagation policy for max pooling. * @param[in] nbDims Number of dimensions. * @param[in] windowDimA Array of pooling window sizes (length nbDims). * @param[in] paddingA Array of padding sizes (length nbDims). * @param[in] strideA Array of strides (length nbDims). * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetPoolingNdDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnSetPoolingNdDescriptor(cudnnPoolingDescriptor_t poolingDesc, const cudnnPoolingMode_t mode, const cudnnNanPropagation_t maxpoolingNanOpt, int nbDims, const int windowDimA[], const int paddingA[], const int strideA[]); /** * @brief Retrieves the settings of an N-dimensional pooling descriptor. * * @param[in] poolingDesc Pooling descriptor to query. * @param[in] nbDimsRequested Number of dimensions to retrieve. * @param[out] mode Pooling mode. * @param[out] maxpoolingNanOpt NaN propagation policy. * @param[out] nbDims Actual number of dimensions. * @param[out] windowDimA Array to receive window sizes. * @param[out] paddingA Array to receive padding sizes. * @param[out] strideA Array to receive strides. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetPoolingNdDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetPoolingNdDescriptor(const cudnnPoolingDescriptor_t poolingDesc, int nbDimsRequested, cudnnPoolingMode_t *mode, cudnnNanPropagation_t *maxpoolingNanOpt, int *nbDims, int windowDimA[], int paddingA[], int strideA[]); /** * @brief Computes the output dimensions of an N-dimensional pooling operation. * * @param[in] poolingDesc Pooling descriptor. * @param[in] inputTensorDesc Input tensor descriptor. * @param[in] nbDims Number of dimensions. * @param[out] outputTensorDimA Array to receive output dimension sizes. * * @retval CUDNN_STATUS_SUCCESS The dimensions were computed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetPoolingNdForwardOutputDim(const cudnnPoolingDescriptor_t poolingDesc, const cudnnTensorDescriptor_t inputTensorDesc, int nbDims, int outputTensorDimA[]); /** * @brief Computes the output dimensions of a 2D pooling operation. * * @param[in] poolingDesc Pooling descriptor. * @param[in] inputTensorDesc Input tensor descriptor. * @param[out] n Output batch size. * @param[out] c Output number of channels. * @param[out] h Output height. * @param[out] w Output width. * * @retval CUDNN_STATUS_SUCCESS The dimensions were computed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetPooling2dForwardOutputDim(const cudnnPoolingDescriptor_t poolingDesc, const cudnnTensorDescriptor_t inputTensorDesc, int *n, int *c, int *h, int *w); /** * @brief Destroys a pooling descriptor. * * @param[in] poolingDesc Pooling descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnCreatePoolingDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnDestroyPoolingDescriptor(cudnnPoolingDescriptor_t poolingDesc); /* Pooling functions: All of the form "output = alpha * Op(inputs) + beta * output" */ /** * @brief Performs forward pooling. * * Computes y = alpha * pool(x) + beta * y. * * @param[in] handle cuDNN library handle. * @param[in] poolingDesc Pooling descriptor. * @param[in] alpha Scaling factor for the pooling result. * @param[in] xDesc Input tensor descriptor. * @param[in] x Pointer to input tensor data. * @param[in] beta Scaling factor for the destination tensor. * @param[in] yDesc Output tensor descriptor. * @param[in,out] y Pointer to output tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnPoolingBackward */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnPoolingForward(cudnnHandle_t handle, const cudnnPoolingDescriptor_t poolingDesc, const void *alpha, const cudnnTensorDescriptor_t xDesc, const void *x, const void *beta, const cudnnTensorDescriptor_t yDesc, void *y); /* Activation functions: All of the form "output = alpha * Op(inputs) + beta * output" */ /** * @brief Creates an activation descriptor. * * @param[out] activationDesc Pointer to the newly created activation descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnDestroyActivationDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnCreateActivationDescriptor(cudnnActivationDescriptor_t *activationDesc); /** * @brief Configures an activation descriptor. * * @param[in,out] activationDesc Activation descriptor to configure. * @param[in] mode Activation function type. * @param[in] reluNanOpt NaN propagation policy for ReLU. * @param[in] coef Ceiling for clipped ReLU, or alpha for ELU. * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetActivationDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnSetActivationDescriptor(cudnnActivationDescriptor_t activationDesc, cudnnActivationMode_t mode, cudnnNanPropagation_t reluNanOpt, double coef); /* ceiling for clipped RELU, alpha for ELU */ /** * @brief Retrieves the settings of an activation descriptor. * * @param[in] activationDesc Activation descriptor to query. * @param[out] mode Activation function type. * @param[out] reluNanOpt NaN propagation policy. * @param[out] coef Ceiling for clipped ReLU, or alpha for ELU. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetActivationDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetActivationDescriptor(const cudnnActivationDescriptor_t activationDesc, cudnnActivationMode_t *mode, cudnnNanPropagation_t *reluNanOpt, double *coef); /* ceiling for clipped RELU, alpha for ELU */ /** * @brief Sets the beta parameter for Swish activation. * * @param[in,out] activationDesc Activation descriptor to modify. * @param[in] swish_beta Beta value for the Swish activation function. * * @retval CUDNN_STATUS_SUCCESS The parameter was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnGetActivationDescriptorSwishBeta */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnSetActivationDescriptorSwishBeta(cudnnActivationDescriptor_t activationDesc, double swish_beta); /** * @brief Retrieves the beta parameter for Swish activation. * * @param[in] activationDesc Activation descriptor to query. * @param[out] swish_beta Beta value for the Swish activation function. * * @retval CUDNN_STATUS_SUCCESS The parameter was retrieved successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnSetActivationDescriptorSwishBeta */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetActivationDescriptorSwishBeta(cudnnActivationDescriptor_t activationDesc, double *swish_beta); /** * @brief Destroys an activation descriptor. * * @param[in] activationDesc Activation descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnCreateActivationDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnDestroyActivationDescriptor(cudnnActivationDescriptor_t activationDesc); /** * @brief Performs forward activation. * * Computes y = alpha * activation(x) + beta * y. * * @param[in] handle cuDNN library handle. * @param[in] activationDesc Activation descriptor. * @param[in] alpha Scaling factor for the activation result. * @param[in] xDesc Input tensor descriptor. * @param[in] x Pointer to input tensor data. * @param[in] beta Scaling factor for the destination tensor. * @param[in] yDesc Output tensor descriptor. * @param[in,out] y Pointer to output tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnActivationBackward */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnActivationForward(cudnnHandle_t handle, cudnnActivationDescriptor_t activationDesc, const void *alpha, const cudnnTensorDescriptor_t xDesc, const void *x, const void *beta, const cudnnTensorDescriptor_t yDesc, void *y); /** * @brief Creates a Local Response Normalization (LRN) descriptor. * * Uses lrnN=5, lrnAlpha=1e-4, lrnBeta=0.75, lrnK=2.0 as defaults from * Krizhevsky'12 ImageNet paper. * * @param[out] normDesc Pointer to the newly created LRN descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @see cudnnDestroyLRNDescriptor, cudnnSetLRNDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnCreateLRNDescriptor(cudnnLRNDescriptor_t *normDesc); #define CUDNN_LRN_MIN_N 1 /* minimum allowed lrnN */ #define CUDNN_LRN_MAX_N 16 /* maximum allowed lrnN */ #define CUDNN_LRN_MIN_K 1e-5 /* minimum allowed lrnK */ #define CUDNN_LRN_MIN_BETA 0.01 /* minimum allowed lrnBeta */ /** * @brief Selects the Local Response Normalization (LRN) mode. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_LRN_CROSS_CHANNEL_DIM1 = 0, /**< LRN computed across tensor dimension dimA[1]. @since cuDNN 9.0.0 */ } cudnnLRNMode_t; /** * @brief Configures an LRN descriptor. * * Uses a window [center-lookBehind, center+lookAhead], where * lookBehind = floor((lrnN-1)/2), lookAhead = lrnN-lookBehind-1. * Values of double parameters are cast to the tensor data type. * * @param[in,out] normDesc LRN descriptor to configure. * @param[in] lrnN Normalization window size (must be in [CUDNN_LRN_MIN_N, CUDNN_LRN_MAX_N]). * @param[in] lrnAlpha Alpha parameter (must be >= CUDNN_LRN_MIN_K). * @param[in] lrnBeta Beta parameter (must be >= CUDNN_LRN_MIN_BETA). * @param[in] lrnK K parameter. * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnGetLRNDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnSetLRNDescriptor(cudnnLRNDescriptor_t normDesc, unsigned lrnN, double lrnAlpha, double lrnBeta, double lrnK); /** * @brief Retrieves the settings of an LRN descriptor. * * Any of the output pointers can be NULL (the corresponding value will not be returned). * * @param[in] normDesc LRN descriptor to query. * @param[out] lrnN Normalization window size. * @param[out] lrnAlpha Alpha parameter. * @param[out] lrnBeta Beta parameter. * @param[out] lrnK K parameter. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @see cudnnSetLRNDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnGetLRNDescriptor(cudnnLRNDescriptor_t normDesc, unsigned *lrnN, double *lrnAlpha, double *lrnBeta, double *lrnK); /** * @brief Destroys an LRN descriptor. * * @param[in] lrnDesc LRN descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @see cudnnCreateLRNDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnDestroyLRNDescriptor(cudnnLRNDescriptor_t lrnDesc); /* LRN functions: output = alpha * normalize(x) + beta * old_y */ /** * @brief Performs forward LRN cross-channel normalization. * * Computes y = alpha * normalize(x) + beta * y. Double parameters are cast * to the tensor data type. * * @param[in] handle cuDNN library handle. * @param[in] normDesc LRN descriptor. * @param[in] lrnMode LRN mode. * @param[in] alpha Scaling factor for the normalization result. * @param[in] xDesc Input tensor descriptor. * @param[in] x Pointer to input tensor data. * @param[in] beta Scaling factor for the destination tensor. * @param[in] yDesc Output tensor descriptor. * @param[in,out] y Pointer to output tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnLRNCrossChannelBackward */ cudnnStatus_t CUDNNWINAPI cudnnLRNCrossChannelForward(cudnnHandle_t handle, cudnnLRNDescriptor_t normDesc, cudnnLRNMode_t lrnMode, const void *alpha, const cudnnTensorDescriptor_t xDesc, const void *x, const void *beta, const cudnnTensorDescriptor_t yDesc, void *y); /** * @brief Selects the divisive normalization mode. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_DIVNORM_PRECOMPUTED_MEANS = 0, /**< Use precomputed means for divisive normalization. @since cuDNN 9.0.0 */ } cudnnDivNormMode_t; /** * @brief Performs forward divisive normalization. * * Computes y = alpha * normalize(x) + beta * y. If means is NULL, means are * assumed to be zero. The xDesc is used for means, temp, and temp2 as well. * * @param[in] handle cuDNN library handle. * @param[in] normDesc LRN descriptor (shared with LRN functions). * @param[in] mode Divisive normalization mode. * @param[in] alpha Scaling factor for the normalization result. * @param[in] xDesc Input tensor descriptor (also used for means, temp, temp2). * @param[in] x Pointer to input tensor data. * @param[in] means Pointer to means tensor data (NULL for zero means). * @param[out] temp Temporary workspace tensor. * @param[out] temp2 Temporary workspace tensor. * @param[in] beta Scaling factor for the destination tensor. * @param[in] yDesc Output tensor descriptor. * @param[in,out] y Pointer to output tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnDivisiveNormalizationBackward */ cudnnStatus_t CUDNNWINAPI cudnnDivisiveNormalizationForward(cudnnHandle_t handle, cudnnLRNDescriptor_t normDesc, cudnnDivNormMode_t mode, const void *alpha, const cudnnTensorDescriptor_t xDesc, /* same desc for means, temp, temp2 */ const void *x, const void *means, /* if NULL, means are assumed to be zero */ void *temp, void *temp2, const void *beta, const cudnnTensorDescriptor_t yDesc, void *y); /** * @brief Selects the batch normalization mode. * @since cuDNN 9.0.0 */ typedef enum { /** @brief Per-activation: bnScale/bnBias dims are 1xCxHxWx.. (normalized over N). @since cuDNN 9.0.0 */ CUDNN_BATCHNORM_PER_ACTIVATION = 0, /**< Per-activation: bnScale/bnBias shape 1xCxHxW, normalized over N. @since cuDNN 9.0.0 */ /** @brief Spatial: bnScale/bnBias dims are 1xCx1x1 (normalized over NxHxW). @since cuDNN 9.0.0 */ CUDNN_BATCHNORM_SPATIAL = 1, /**< Spatial: bnScale/bnBias shape 1xCx1x1, normalized over N+spatial dims. @since cuDNN 9.0.0 */ /** * @brief Spatial persistent: same as SPATIAL but may be faster with limits on value range. * @since cuDNN 9.0.0 */ CUDNN_BATCHNORM_SPATIAL_PERSISTENT = 2, /**< Like SPATIAL but faster via scaled atomic int reduction. NCHW, CC>=6.0. @since cuDNN 9.0.0 */ } cudnnBatchNormMode_t CUDNN_DEPRECATED; #define CUDNN_BN_MIN_EPSILON 0.0 /* Minimum epsilon allowed to be used in the Batch Normalization formula */ /** * @brief Derives a tensor descriptor for batch normalization parameters. * * Computes the dimensions for bnScale, bnBias, mean, and variance tensors based * on the input tensor descriptor and batch normalization mode. Use this for * bnScaleBiasMeanVarDesc and bnScaleBiasDiffDesc parameters. * * @param[in,out] derivedBnDesc Tensor descriptor to be derived. * @param[in] xDesc Input tensor descriptor. * @param[in] mode Batch normalization mode. * * @retval CUDNN_STATUS_SUCCESS The descriptor was derived successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnBatchNormalizationForwardTraining */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnDeriveBNTensorDescriptor(cudnnTensorDescriptor_t derivedBnDesc, const cudnnTensorDescriptor_t xDesc, cudnnBatchNormMode_t mode); /** * @brief Selects the extended batch normalization operation mode. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_BATCHNORM_OPS_BN = 0, /**< Batch normalization only. @since cuDNN 9.0.0 */ CUDNN_BATCHNORM_OPS_BN_ACTIVATION = 1, /**< Batch normalization followed by activation. @since cuDNN 9.0.0 */ CUDNN_BATCHNORM_OPS_BN_ADD_ACTIVATION = 2, /**< Batch normalization, element-wise add, then activation. @since cuDNN 9.0.0 */ } cudnnBatchNormOps_t CUDNN_DEPRECATED; /** * @brief Performs batch normalization during inference. * * Computes y[i] = bnScale[k]*(x[i]-estimatedMean[k])/sqrt(epsilon+estimatedVariance[k]) + bnBias[k], * with tensors indexed according to spatial or per-activation mode. * * @param[in] handle cuDNN library handle. * @param[in] mode Batch normalization mode. * @param[in] alpha Result blend factor. * @param[in] beta Destination layer blend factor. * @param[in] xDesc Input tensor descriptor. * @param[in] x Pointer to input tensor data (NxCxHxW). * @param[in] yDesc Output tensor descriptor. * @param[in,out] y Pointer to output tensor data (NxCxHxW). * @param[in] bnScaleBiasMeanVarDesc Descriptor for scale, bias, mean, variance tensors. * @param[in] bnScale Pointer to scale (gamma) tensor data. * @param[in] bnBias Pointer to bias (beta) tensor data. * @param[in] estimatedMean Pointer to running mean tensor data. * @param[in] estimatedVariance Pointer to running variance tensor data. * @param[in] epsilon Epsilon value (must be >= CUDNN_BN_MIN_EPSILON). * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnBatchNormalizationForwardTraining, cudnnDeriveBNTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnBatchNormalizationForwardInference(cudnnHandle_t handle, cudnnBatchNormMode_t mode, const void *alpha, /* alpha[0] = result blend factor */ const void *beta, /* beta[0] = dest layer blend factor */ const cudnnTensorDescriptor_t xDesc, const void *x, /* NxCxHxW */ const cudnnTensorDescriptor_t yDesc, void *y, /* NxCxHxW */ const cudnnTensorDescriptor_t bnScaleBiasMeanVarDesc, const void *bnScale, const void *bnBias, const void *estimatedMean, const void *estimatedVariance, double epsilon); /** * @brief Selects the normalization mode. * @since cuDNN 9.0.0 */ typedef enum { /** @brief Per-activation: normScale/normBias dims are 1xCxHxWx.. (normalized over N). @since cuDNN 9.0.0 */ CUDNN_NORM_PER_ACTIVATION = 0, /**< Norm per activation. @since cuDNN 9.0.0 */ /** @brief Per-channel: normScale/normBias dims are 1xCx1x1 (normalized over NxHxW). @since cuDNN 9.0.0 */ CUDNN_NORM_PER_CHANNEL = 1, /**< Norm per channel. @since cuDNN 9.0.0 */ } cudnnNormMode_t CUDNN_DEPRECATED; /** * @brief Selects the normalization algorithm. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_NORM_ALGO_STANDARD = 0, /**< Standard normalization algorithm. @since cuDNN UNPUBLISHED */ CUDNN_NORM_ALGO_PERSIST = 1 /**< Persistent normalization (requires compute capability 6.0+). @since cuDNN UNPUBLISHED */ } cudnnNormAlgo_t CUDNN_DEPRECATED; /** * @brief Derives tensor descriptors for normalization parameters. * * Computes the dimensions for normScale, normBias, mean, and variance tensors based * on the input tensor descriptor and normalization mode. * * @param[in,out] derivedNormScaleBiasDesc Descriptor to be derived for scale/bias tensors. * @param[in,out] derivedNormMeanVarDesc Descriptor to be derived for mean/variance tensors. * @param[in] xDesc Input tensor descriptor. * @param[in] mode Normalization mode. * @param[in] groupCnt Group count (reserved, should be set to 1). * * @retval CUDNN_STATUS_SUCCESS The descriptors were derived successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnNormalizationForwardTraining */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnDeriveNormTensorDescriptor(cudnnTensorDescriptor_t derivedNormScaleBiasDesc, cudnnTensorDescriptor_t derivedNormMeanVarDesc, const cudnnTensorDescriptor_t xDesc, cudnnNormMode_t mode, int groupCnt); /* Place hold for future work, should be set to 1 now*/ /** * @brief Selects the extended normalization operation mode. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_NORM_OPS_NORM = 0, /**< Normalization only. @since cuDNN 9.0.0 */ CUDNN_NORM_OPS_NORM_ACTIVATION = 1, /**< Normalization followed by activation. @since cuDNN 9.0.0 */ CUDNN_NORM_OPS_NORM_ADD_ACTIVATION = 2, /**< Normalization, element-wise add, then activation. @since cuDNN 9.0.0 */ } cudnnNormOps_t CUDNN_DEPRECATED; /** * @brief Performs normalization during inference. * * Computes y[i] = normScale[k]*(x[i]-estimatedMean[k])/sqrt(epsilon+estimatedVariance[k]) + normBias[k], * with tensors indexed according to per-channel or per-activation mode. * * @param[in] handle cuDNN library handle. * @param[in] mode Normalization mode. * @param[in] normOps Extended normalization operation mode. * @param[in] algo Normalization algorithm. * @param[in] alpha Result blend factor. * @param[in] beta Destination layer blend factor. * @param[in] xDesc Input tensor descriptor. * @param[in] x Pointer to input tensor data (NxCxHxW). * @param[in] normScaleBiasDesc Descriptor for normalization scale/bias tensors. * @param[in] normScale Pointer to normalization scale tensor data. * @param[in] normBias Pointer to normalization bias tensor data. * @param[in] normMeanVarDesc Descriptor for mean/variance tensors. * @param[in] estimatedMean Pointer to running mean tensor data. * @param[in] estimatedVariance Pointer to running variance tensor data. * @param[in] zDesc Descriptor for z tensor (used with add operations). * @param[in] z Pointer to z tensor data. * @param[in] activationDesc Activation descriptor (used with activation operations). * @param[in] yDesc Output tensor descriptor. * @param[in,out] y Pointer to output tensor data (NxCxHxW). * @param[in] epsilon Epsilon value (must be >= 0). * @param[in] groupCnt Group count (reserved, should be set to 1). * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnNormalizationForwardTraining, cudnnDeriveNormTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnNormalizationForwardInference(cudnnHandle_t handle, cudnnNormMode_t mode, cudnnNormOps_t normOps, cudnnNormAlgo_t algo, const void *alpha, /* alpha[0] = result blend factor */ const void *beta, /* beta[0] = dest layer blend factor */ const cudnnTensorDescriptor_t xDesc, const void *x, /* NxCxHxW */ const cudnnTensorDescriptor_t normScaleBiasDesc, const void *normScale, const void *normBias, const cudnnTensorDescriptor_t normMeanVarDesc, const void *estimatedMean, const void *estimatedVariance, const cudnnTensorDescriptor_t zDesc, const void *z, cudnnActivationDescriptor_t activationDesc, const cudnnTensorDescriptor_t yDesc, void *y, /* NxCxHxW */ double epsilon, int groupCnt); /* Place hold for future work*/ /* APIs for spatial transformer network*/ /** * @brief Selects the spatial sampler type for spatial transformer networks. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_SAMPLER_BILINEAR = 0, /**< Bilinear sampler. @since cuDNN 9.0.0 */ } cudnnSamplerType_t; /** * @brief Creates a spatial transformer descriptor. * * @param[out] stDesc Pointer to the newly created spatial transformer descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @see cudnnDestroySpatialTransformerDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnCreateSpatialTransformerDescriptor(cudnnSpatialTransformerDescriptor_t *stDesc); /** * @brief Configures an N-dimensional spatial transformer descriptor. * * @param[in,out] stDesc Spatial transformer descriptor to configure. * @param[in] samplerType Type of sampler to use. * @param[in] dataType Data type of the tensors. * @param[in] nbDims Number of dimensions. * @param[in] dimA Array of dimension sizes (length nbDims). * * @retval CUDNN_STATUS_SUCCESS The descriptor was set successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSpatialTfGridGeneratorForward, cudnnSpatialTfSamplerForward */ cudnnStatus_t CUDNNWINAPI cudnnSetSpatialTransformerNdDescriptor(cudnnSpatialTransformerDescriptor_t stDesc, cudnnSamplerType_t samplerType, cudnnDataType_t dataType, const int nbDims, const int dimA[]); /** * @brief Destroys a spatial transformer descriptor. * * @param[in] stDesc Spatial transformer descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @see cudnnCreateSpatialTransformerDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnDestroySpatialTransformerDescriptor(cudnnSpatialTransformerDescriptor_t stDesc); /** * @brief Generates a sampling grid for a spatial transformer (forward). * * Generates a grid of sampling coordinates from the affine transformation matrix theta. * * @param[in] handle cuDNN library handle. * @param[in] stDesc Spatial transformer descriptor. * @param[in] theta Pointer to affine transformation matrices. * @param[out] grid Pointer to output sampling grid data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSpatialTfGridGeneratorBackward */ cudnnStatus_t CUDNNWINAPI cudnnSpatialTfGridGeneratorForward(cudnnHandle_t handle, const cudnnSpatialTransformerDescriptor_t stDesc, const void *theta, void *grid); /** * @brief Performs spatial transformer sampling (forward). * * Samples the input tensor at the grid coordinates to produce the output tensor. * * @param[in] handle cuDNN library handle. * @param[in] stDesc Spatial transformer descriptor. * @param[in] alpha Scaling factor for the sampled result. * @param[in] xDesc Input tensor descriptor. * @param[in] x Pointer to input tensor data. * @param[in] grid Pointer to sampling grid data. * @param[in] beta Scaling factor for the destination tensor. * @param[in] yDesc Output tensor descriptor. * @param[in,out] y Pointer to output tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSpatialTfSamplerBackward */ cudnnStatus_t CUDNNWINAPI cudnnSpatialTfSamplerForward(cudnnHandle_t handle, cudnnSpatialTransformerDescriptor_t stDesc, const void *alpha, const cudnnTensorDescriptor_t xDesc, const void *x, const void *grid, const void *beta, cudnnTensorDescriptor_t yDesc, void *y); /** @brief Opaque descriptor for dropout operations. @since cuDNN 9.0.0 */ typedef struct cudnnDropoutStruct *cudnnDropoutDescriptor_t; /** * @brief Creates a dropout descriptor. * * @param[out] dropoutDesc Pointer to the newly created dropout descriptor. * * @retval CUDNN_STATUS_SUCCESS The descriptor was created successfully. * @retval CUDNN_STATUS_ALLOC_FAILED Memory allocation failed. * * @since cuDNN 9.0.0 * @see cudnnDestroyDropoutDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnCreateDropoutDescriptor(cudnnDropoutDescriptor_t *dropoutDesc); /** * @brief Destroys a dropout descriptor. * * @param[in] dropoutDesc Dropout descriptor to destroy. * * @retval CUDNN_STATUS_SUCCESS The descriptor was destroyed successfully. * * @since cuDNN 9.0.0 * @see cudnnCreateDropoutDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnDestroyDropoutDescriptor(cudnnDropoutDescriptor_t dropoutDesc); /** * @brief Returns the size of the states buffer required for dropout. * * @param[in] handle cuDNN library handle. * @param[out] sizeInBytes Size of the required states buffer in bytes. * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @see cudnnSetDropoutDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnDropoutGetStatesSize(cudnnHandle_t handle, size_t *sizeInBytes); /** * @brief Returns the size of the reserve space required for dropout forward/backward. * * @param[in] xdesc Input tensor descriptor. * @param[out] sizeInBytes Size of the required reserve space in bytes. * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @see cudnnDropoutForward, cudnnDropoutBackward */ cudnnStatus_t CUDNNWINAPI cudnnDropoutGetReserveSpaceSize(cudnnTensorDescriptor_t xdesc, size_t *sizeInBytes); /** * @brief Configures a dropout descriptor and initializes random state. * * @param[in,out] dropoutDesc Dropout descriptor to configure. * @param[in] handle cuDNN library handle. * @param[in] dropout Probability of dropping (0 = no dropout, 1 = all dropped). * @param[in,out] states Pointer to device memory for RNG state storage. * @param[in] stateSizeInBytes Size of the states buffer in bytes. * @param[in] seed Seed for the random number generator. * * @retval CUDNN_STATUS_SUCCESS The descriptor was configured successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnGetDropoutDescriptor, cudnnRestoreDropoutDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnSetDropoutDescriptor(cudnnDropoutDescriptor_t dropoutDesc, cudnnHandle_t handle, float dropout, void *states, size_t stateSizeInBytes, unsigned long long seed); /** * @brief Restores a dropout descriptor to a previously saved state. * * @param[in,out] dropoutDesc Dropout descriptor to restore. * @param[in] handle cuDNN library handle. * @param[in] dropout Dropout probability. * @param[in] states Pointer to previously saved RNG state. * @param[in] stateSizeInBytes Size of the states buffer in bytes. * @param[in] seed Seed used to initialize the original state. * * @retval CUDNN_STATUS_SUCCESS The descriptor was restored successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSetDropoutDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnRestoreDropoutDescriptor(cudnnDropoutDescriptor_t dropoutDesc, cudnnHandle_t handle, float dropout, void *states, size_t stateSizeInBytes, unsigned long long seed); /** * @brief Retrieves the settings of a dropout descriptor. * * @param[in] dropoutDesc Dropout descriptor to query. * @param[in] handle cuDNN library handle. * @param[out] dropout Dropout probability. * @param[out] states Pointer to RNG state memory. * @param[out] seed Seed used for the RNG. * * @retval CUDNN_STATUS_SUCCESS The descriptor was queried successfully. * * @since cuDNN 9.0.0 * @see cudnnSetDropoutDescriptor */ cudnnStatus_t CUDNNWINAPI cudnnGetDropoutDescriptor(cudnnDropoutDescriptor_t dropoutDesc, cudnnHandle_t handle, float *dropout, void **states, unsigned long long *seed); /** * @brief Performs forward dropout. * * Randomly sets elements to zero based on the dropout probability. The reserve * space stores the mask for use in the backward pass. * * @param[in] handle cuDNN library handle. * @param[in] dropoutDesc Dropout descriptor. * @param[in] xdesc Input tensor descriptor. * @param[in] x Pointer to input tensor data. * @param[in] ydesc Output tensor descriptor. * @param[out] y Pointer to output tensor data. * @param[out] reserveSpace Pointer to reserve space for the dropout mask. * @param[in] reserveSpaceSizeInBytes Size of reserve space in bytes. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnDropoutBackward, cudnnDropoutGetReserveSpaceSize */ cudnnStatus_t CUDNNWINAPI cudnnDropoutForward(cudnnHandle_t handle, const cudnnDropoutDescriptor_t dropoutDesc, const cudnnTensorDescriptor_t xdesc, const void *x, const cudnnTensorDescriptor_t ydesc, void *y, void *reserveSpace, size_t reserveSpaceSizeInBytes); /* TODO: move these enums out to the appropriate submodule */ /** * @brief Enumerates convolution forward algorithms. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_GEMM = 0, /**< Implicit GEMM: matrix product without forming input matrix. No extra workspace. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_FWD_ALGO_IMPLICIT_PRECOMP_GEMM = 1, /**< Implicit GEMM with precomputed indices. Needs workspace for index precomputation. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_FWD_ALGO_GEMM = 2, /**< Explicit GEMM: forms input matrix explicitly. Requires significant workspace. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_FWD_ALGO_DIRECT = 3, /**< Direct convolution without matrix multiplication. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_FWD_ALGO_FFT = 4, /**< FFT-based convolution. Requires significant workspace. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_FWD_ALGO_FFT_TILING = 5, /**< FFT with tiled inputs. Significant workspace but less than FFT for large inputs. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD = 6, /**< Winograd transform. Moderate workspace. Not supported on Hopper+. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_FWD_ALGO_WINOGRAD_NONFUSED = 7, /**< Winograd non-fused variant. May require significant workspace. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_FWD_ALGO_COUNT = 8 /**< Number of forward convolution algorithms. @since cuDNN 9.0.0 */ } cudnnConvolutionFwdAlgo_t; /** * @brief Enumerates convolution backward filter algorithms. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0 = 0, /**< Sum of matrix products with atomic adds. Non-deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1 = 1, /**< Implicit GEMM without forming input matrix. Deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT = 2, /**< FFT-based. Significant workspace. Deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_FILTER_ALGO_3 = 3, /**< Like ALGO_0 with precomputed indices. Non-deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD = 4, /**< Winograd transform (not implemented). @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED = 5, /**< Winograd non-fused. Significant workspace. Deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT_TILING = 6, /**< FFT with tiling. Significant workspace. Deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_FILTER_ALGO_COUNT = 7 /**< Number of backward filter algorithms. @since cuDNN 9.0.0 */ } cudnnConvolutionBwdFilterAlgo_t; /** * @brief Enumerates convolution backward data algorithms. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_CONVOLUTION_BWD_DATA_ALGO_0 = 0, /**< Sum of matrix products with atomic adds. Non-deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_DATA_ALGO_1 = 1, /**< Implicit GEMM without forming input matrix. Deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT = 2, /**< FFT-based. Significant workspace. Deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT_TILING = 3, /**< FFT with tiling. Significant workspace. Deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD = 4, /**< Winograd transform. Moderate workspace. Deterministic. Not on Hopper+. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED = 5, /**< Winograd non-fused. Significant workspace. Deterministic. @since cuDNN 9.0.0 */ CUDNN_CONVOLUTION_BWD_DATA_ALGO_COUNT = 6 /**< Number of backward data algorithms. @since cuDNN 9.0.0 */ } cudnnConvolutionBwdDataAlgo_t; /** * @brief Enumerates CTC loss computation algorithms. * @since cuDNN 9.0.0 */ typedef enum { CUDNN_CTC_LOSS_ALGO_DETERMINISTIC = 0, /**< Deterministic CTC loss. @since cuDNN UNPUBLISHED */ CUDNN_CTC_LOSS_ALGO_NON_DETERMINISTIC = 1 /**< Non-deterministic CTC loss. @since cuDNN UNPUBLISHED */ } cudnnCTCLossAlgo_t; /** * @brief Cross-library version checker for the ops sub-library. * * This function is implemented differently in each sub-library. Each sub-library * checks whether its own version matches that of its dependencies. * * @retval CUDNN_STATUS_SUCCESS The version check passed. * @retval CUDNN_STATUS_SUBLIBRARY_VERSION_MISMATCH The versions are inconsistent. * * @since cuDNN 9.0.0 */ cudnnStatus_t CUDNNWINAPI cudnnOpsVersionCheck(void); /** * @brief Performs backward softmax computation. * * Computes the gradient of the softmax function. * * @param[in] handle cuDNN library handle. * @param[in] algo Softmax algorithm used in the forward pass. * @param[in] mode Softmax computation scope. * @param[in] alpha Scaling factor for the result. * @param[in] yDesc Output tensor descriptor (from forward pass). * @param[in] y Pointer to output tensor data (from forward pass). * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dy Pointer to output gradient tensor data. * @param[in] beta Scaling factor for the destination tensor. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in,out] dx Pointer to input gradient tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSoftmaxForward */ cudnnStatus_t CUDNNWINAPI cudnnSoftmaxBackward(cudnnHandle_t handle, cudnnSoftmaxAlgorithm_t algo, cudnnSoftmaxMode_t mode, const void *alpha, const cudnnTensorDescriptor_t yDesc, const void *y, const cudnnTensorDescriptor_t dyDesc, const void *dy, const void *beta, const cudnnTensorDescriptor_t dxDesc, void *dx); /** * @brief Performs backward pooling. * * Computes the gradient of the pooling operation. * * @param[in] handle cuDNN library handle. * @param[in] poolingDesc Pooling descriptor. * @param[in] alpha Scaling factor for the result. * @param[in] yDesc Output tensor descriptor (from forward pass). * @param[in] y Pointer to output tensor data (from forward pass). * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dy Pointer to output gradient tensor data. * @param[in] xDesc Input tensor descriptor (from forward pass). * @param[in] x Pointer to input tensor data (from forward pass). * @param[in] beta Scaling factor for the destination tensor. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in,out] dx Pointer to input gradient tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnPoolingForward */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnPoolingBackward(cudnnHandle_t handle, const cudnnPoolingDescriptor_t poolingDesc, const void *alpha, const cudnnTensorDescriptor_t yDesc, const void *y, const cudnnTensorDescriptor_t dyDesc, const void *dy, const cudnnTensorDescriptor_t xDesc, const void *x, const void *beta, const cudnnTensorDescriptor_t dxDesc, void *dx); /** * @brief Performs backward activation. * * Computes the gradient of the activation function. * * @param[in] handle cuDNN library handle. * @param[in] activationDesc Activation descriptor. * @param[in] alpha Scaling factor for the result. * @param[in] yDesc Output tensor descriptor (from forward pass). * @param[in] y Pointer to output tensor data (from forward pass). * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dy Pointer to output gradient tensor data. * @param[in] xDesc Input tensor descriptor (from forward pass). * @param[in] x Pointer to input tensor data (from forward pass). * @param[in] beta Scaling factor for the destination tensor. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in,out] dx Pointer to input gradient tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnActivationForward */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnActivationBackward(cudnnHandle_t handle, cudnnActivationDescriptor_t activationDesc, const void *alpha, const cudnnTensorDescriptor_t yDesc, const void *y, const cudnnTensorDescriptor_t dyDesc, const void *dy, const cudnnTensorDescriptor_t xDesc, const void *x, const void *beta, const cudnnTensorDescriptor_t dxDesc, void *dx); /** * @brief Performs backward LRN cross-channel normalization. * * Computes the gradient of the LRN cross-channel normalization. Double * parameters are cast to the tensor data type. * * @param[in] handle cuDNN library handle. * @param[in] normDesc LRN descriptor. * @param[in] lrnMode LRN mode. * @param[in] alpha Scaling factor for the result. * @param[in] yDesc Output tensor descriptor (from forward pass). * @param[in] y Pointer to output tensor data (from forward pass). * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dy Pointer to output gradient tensor data. * @param[in] xDesc Input tensor descriptor (from forward pass). * @param[in] x Pointer to input tensor data (from forward pass). * @param[in] beta Scaling factor for the destination tensor. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in,out] dx Pointer to input gradient tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnLRNCrossChannelForward */ cudnnStatus_t CUDNNWINAPI cudnnLRNCrossChannelBackward(cudnnHandle_t handle, cudnnLRNDescriptor_t normDesc, cudnnLRNMode_t lrnMode, const void *alpha, const cudnnTensorDescriptor_t yDesc, const void *y, const cudnnTensorDescriptor_t dyDesc, const void *dy, const cudnnTensorDescriptor_t xDesc, const void *x, const void *beta, const cudnnTensorDescriptor_t dxDesc, void *dx); /** * @brief Performs backward divisive normalization. * * Computes the gradients of the divisive normalization operation. If means is NULL, * means are assumed to be zero. * * @param[in] handle cuDNN library handle. * @param[in] normDesc LRN descriptor (shared with LRN functions). * @param[in] mode Divisive normalization mode. * @param[in] alpha Scaling factor for the result. * @param[in] xDesc Input tensor descriptor (also used for means, dy, temp, temp2). * @param[in] x Pointer to input tensor data. * @param[in] means Pointer to means tensor data (NULL for zero means). * @param[in] dy Pointer to output gradient tensor data. * @param[out] temp Temporary workspace tensor. * @param[out] temp2 Temporary workspace tensor. * @param[in] beta Scaling factor for the destination tensors. * @param[in] dXdMeansDesc Descriptor for dx and dMeans tensors. * @param[in,out] dx Pointer to input gradient tensor data. * @param[in,out] dMeans Pointer to means gradient tensor data (can be NULL). * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnDivisiveNormalizationForward */ cudnnStatus_t CUDNNWINAPI cudnnDivisiveNormalizationBackward(cudnnHandle_t handle, cudnnLRNDescriptor_t normDesc, cudnnDivNormMode_t mode, const void *alpha, const cudnnTensorDescriptor_t xDesc, /* same desc for x, means, dy, temp, temp2 */ const void *x, const void *means, /* if NULL, means are assumed to be zero */ const void *dy, void *temp, void *temp2, const void *beta, const cudnnTensorDescriptor_t dXdMeansDesc, /* same desc for dx, dMeans */ void *dx, /* output x differential */ void *dMeans); /* output means differential, can be NULL */ /** * @brief Returns the workspace size for extended batch normalization forward training. * * @param[in] handle cuDNN library handle. * @param[in] mode Batch normalization mode. * @param[in] bnOps Extended batch normalization operation. * @param[in] xDesc Input tensor descriptor. * @param[in] zDesc Z tensor descriptor (for add operations). * @param[in] yDesc Output tensor descriptor. * @param[in] bnScaleBiasMeanVarDesc Descriptor for BN parameter tensors. * @param[in] activationDesc Activation descriptor. * @param[out] sizeInBytes Required workspace size in bytes. * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnBatchNormalizationForwardTrainingEx */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetBatchNormalizationForwardTrainingExWorkspaceSize(cudnnHandle_t handle, cudnnBatchNormMode_t mode, cudnnBatchNormOps_t bnOps, const cudnnTensorDescriptor_t xDesc, const cudnnTensorDescriptor_t zDesc, const cudnnTensorDescriptor_t yDesc, const cudnnTensorDescriptor_t bnScaleBiasMeanVarDesc, const cudnnActivationDescriptor_t activationDesc, size_t *sizeInBytes); /** * @brief Returns the workspace size for extended batch normalization backward. * * @param[in] handle cuDNN library handle. * @param[in] mode Batch normalization mode. * @param[in] bnOps Extended batch normalization operation. * @param[in] xDesc Input tensor descriptor. * @param[in] yDesc Output tensor descriptor. * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dzDesc Z gradient tensor descriptor. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in] dBnScaleBiasDesc Descriptor for BN parameter gradient tensors. * @param[in] activationDesc Activation descriptor. * @param[out] sizeInBytes Required workspace size in bytes. * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnBatchNormalizationBackwardEx */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetBatchNormalizationBackwardExWorkspaceSize(cudnnHandle_t handle, cudnnBatchNormMode_t mode, cudnnBatchNormOps_t bnOps, const cudnnTensorDescriptor_t xDesc, const cudnnTensorDescriptor_t yDesc, const cudnnTensorDescriptor_t dyDesc, const cudnnTensorDescriptor_t dzDesc, const cudnnTensorDescriptor_t dxDesc, const cudnnTensorDescriptor_t dBnScaleBiasDesc, const cudnnActivationDescriptor_t activationDesc, size_t *sizeInBytes); /** * @brief Returns the reserve space size for extended batch normalization training. * * @param[in] handle cuDNN library handle. * @param[in] mode Batch normalization mode. * @param[in] bnOps Extended batch normalization operation. * @param[in] activationDesc Activation descriptor. * @param[in] xDesc Input tensor descriptor. * @param[out] sizeInBytes Required reserve space size in bytes. * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnBatchNormalizationForwardTrainingEx */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetBatchNormalizationTrainingExReserveSpaceSize(cudnnHandle_t handle, cudnnBatchNormMode_t mode, cudnnBatchNormOps_t bnOps, const cudnnActivationDescriptor_t activationDesc, const cudnnTensorDescriptor_t xDesc, size_t *sizeInBytes); /** * @brief Performs batch normalization forward training. * * Computes y = BN(x). Also accumulates moving averages of mean and inverse variances. * * @param[in] handle cuDNN library handle. * @param[in] mode Batch normalization mode. * @param[in] alpha Result blend factor. * @param[in] beta Destination layer blend factor. * @param[in] xDesc Input tensor descriptor. * @param[in] x Pointer to input tensor data (NxCxHxW). * @param[in] yDesc Output tensor descriptor. * @param[out] y Pointer to output tensor data (NxCxHxW). * @param[in] bnScaleBiasMeanVarDesc Descriptor for BN parameter tensors. * @param[in] bnScale Pointer to scale (gamma) tensor data. * @param[in] bnBias Pointer to bias (beta) tensor data. * @param[in] exponentialAverageFactor Factor for computing running averages. * @param[in,out] resultRunningMean Running mean (updated with exponential average). * @param[in,out] resultRunningVariance Running variance (updated with exponential average). * @param[in] epsilon Epsilon value (must be >= CUDNN_BN_MIN_EPSILON). * @param[out] resultSaveMean Optionally cached mean for backward pass (NULL if unused). * @param[out] resultSaveInvVariance Optionally cached inverse variance for backward pass (NULL if unused). * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnBatchNormalizationBackward, cudnnDeriveBNTensorDescriptor */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnBatchNormalizationForwardTraining( cudnnHandle_t handle, cudnnBatchNormMode_t mode, const void *alpha, /* alpha[0] = result blend factor */ const void *beta, /* beta[0] = dest layer blend factor */ const cudnnTensorDescriptor_t xDesc, const void *x, /* NxCxHxW */ const cudnnTensorDescriptor_t yDesc, void *y, /* NxCxHxW */ /* Shared desc for the next 6 tensors in the argument list. Data type to be set as follows: type = (typeOf(x) == double) ? double : float Dimensions for this descriptor depend on normalization mode - Spatial Normalization : tensors are expected to have dims 1xCx1x1 (normalization is performed across NxHxW) - Per-Activation Normalization : tensors are expected to have dims of 1xCxHxW (normalization is performed across N) */ const cudnnTensorDescriptor_t bnScaleBiasMeanVarDesc, /* 'Gamma' and 'Beta' respectively in Ioffe and Szegedy's paper's notation */ const void *bnScale, const void *bnBias, /* MUST use factor=1 in the very first call of a complete training cycle. Use a factor=1/(1+n) at N-th call to the function to get Cumulative Moving Average (CMA) behavior CMA[n] = (x[1]+...+x[n])/n Since CMA[n+1] = (n*CMA[n]+x[n+1])/(n+1) = ((n+1)*CMA[n]-CMA[n])/(n+1) + x[n+1]/(n+1) = CMA[n]*(1-1/(n+1)) + x[n+1]*1/(n+1) */ double exponentialAverageFactor, /* Used in Training phase only. runningMean = newMean*factor + runningMean*(1-factor) */ void *resultRunningMean, /* Output in training mode, input in inference. Is the moving average of variance[x] (factor is applied in the same way as for runningMean) */ void *resultRunningVariance, /* Has to be >= CUDNN_BN_MIN_EPSILON. Should be the same in forward and backward functions. */ double epsilon, /* Optionally save intermediate results from the forward pass here - can be reused to speed up backward pass. NULL if unused */ void *resultSaveMean, void *resultSaveInvVariance); /** * @brief Performs extended batch normalization forward training with optional activation. * * Computes y = relu(BN(x) + z). Also accumulates moving averages of mean and inverse variances. * Supports fused batch normalization + activation and batch normalization + add + activation. * * @param[in] handle cuDNN library handle. * @param[in] mode Batch normalization mode. * @param[in] bnOps Extended batch normalization operation. * @param[in] alpha Result blend factor. * @param[in] beta Destination layer blend factor. * @param[in] xDesc Input tensor descriptor. * @param[in] xData Pointer to input tensor data. * @param[in] zDesc Z tensor descriptor (for add operations). * @param[in] zData Pointer to z tensor data. * @param[in] yDesc Output tensor descriptor. * @param[out] yData Pointer to output tensor data. * @param[in] bnScaleBiasMeanVarDesc Descriptor for BN parameter tensors. * @param[in] bnScale Pointer to scale tensor data. * @param[in] bnBias Pointer to bias tensor data. * @param[in] exponentialAverageFactor Factor for computing running averages. * @param[in,out] resultRunningMean Running mean. * @param[in,out] resultRunningVariance Running variance. * @param[in] epsilon Epsilon value (must be >= CUDNN_BN_MIN_EPSILON). * @param[out] resultSaveMean Cached mean for backward pass (NULL if unused). * @param[out] resultSaveInvVariance Cached inverse variance for backward pass (NULL if unused). * @param[in] activationDesc Activation descriptor. * @param[in,out] workspace Pointer to workspace memory. * @param[in] workSpaceSizeInBytes Size of workspace in bytes. * @param[in,out] reserveSpace Pointer to reserve space memory. * @param[in] reserveSpaceSizeInBytes Size of reserve space in bytes. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnBatchNormalizationBackwardEx, cudnnGetBatchNormalizationForwardTrainingExWorkspaceSize */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnBatchNormalizationForwardTrainingEx( cudnnHandle_t handle, cudnnBatchNormMode_t mode, cudnnBatchNormOps_t bnOps, const void *alpha, /* alpha[0] = result blend factor */ const void *beta, /* beta[0] = dest layer blend factor */ const cudnnTensorDescriptor_t xDesc, const void *xData, const cudnnTensorDescriptor_t zDesc, const void *zData, const cudnnTensorDescriptor_t yDesc, void *yData, const cudnnTensorDescriptor_t bnScaleBiasMeanVarDesc, const void *bnScale, const void *bnBias, double exponentialAverageFactor, void *resultRunningMean, void *resultRunningVariance, /* Has to be >= CUDNN_BN_MIN_EPSILON. Should be the same in forward and backward functions. */ double epsilon, /* Optionally save intermediate results from the forward pass here - can be reused to speed up backward pass. NULL if unused */ void *resultSaveMean, void *resultSaveInvVariance, cudnnActivationDescriptor_t activationDesc, void *workspace, size_t workSpaceSizeInBytes, void *reserveSpace, size_t reserveSpaceSizeInBytes); /** * @brief Performs backward batch normalization. * * Computes gradients for x, bnScale, and bnBias. * * @param[in] handle cuDNN library handle. * @param[in] mode Batch normalization mode. * @param[in] alphaDataDiff Scaling factor for dx result. * @param[in] betaDataDiff Scaling factor for dx destination. * @param[in] alphaParamDiff Scaling factor for parameter gradient results. * @param[in] betaParamDiff Scaling factor for parameter gradient destinations. * @param[in] xDesc Input tensor descriptor (same for x, dx, dy). * @param[in] x Pointer to input tensor data. * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dy Pointer to output gradient tensor data. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in,out] dx Pointer to input gradient tensor data. * @param[in] dBnScaleBiasDesc Shared descriptor for parameter gradient tensors. * @param[in] bnScale Pointer to scale tensor data. * @param[out] dBnScaleResult Pointer to scale gradient result. * @param[out] dBnBiasResult Pointer to bias gradient result. * @param[in] epsilon Same epsilon as forward pass. * @param[in] savedMean Optionally cached mean from forward pass. * @param[in] savedInvVariance Optionally cached inverse variance from forward pass. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnBatchNormalizationForwardTraining */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnBatchNormalizationBackward(cudnnHandle_t handle, cudnnBatchNormMode_t mode, const void *alphaDataDiff, const void *betaDataDiff, const void *alphaParamDiff, const void *betaParamDiff, const cudnnTensorDescriptor_t xDesc, /* same desc for x, dx, dy */ const void *x, const cudnnTensorDescriptor_t dyDesc, const void *dy, const cudnnTensorDescriptor_t dxDesc, void *dx, /* Shared tensor desc for the 4 tensors below */ const cudnnTensorDescriptor_t dBnScaleBiasDesc, const void *bnScale, /* bnBias doesn't affect backpropagation */ /* scale and bias diff are not backpropagated below this layer */ void *dBnScaleResult, void *dBnBiasResult, /* Same epsilon as forward pass */ double epsilon, /* Optionally cached intermediate results from forward pass */ const void *savedMean, const void *savedInvVariance); /** * @brief Performs extended backward batch normalization with optional activation. * * Computes gradients for the fused batch normalization + activation operations. * * @param[in] handle cuDNN library handle. * @param[in] mode Batch normalization mode. * @param[in] bnOps Extended batch normalization operation. * @param[in] alphaDataDiff Scaling factor for data gradient results. * @param[in] betaDataDiff Scaling factor for data gradient destinations. * @param[in] alphaParamDiff Scaling factor for parameter gradient results. * @param[in] betaParamDiff Scaling factor for parameter gradient destinations. * @param[in] xDesc Input tensor descriptor. * @param[in] xData Pointer to input tensor data. * @param[in] yDesc Output tensor descriptor. * @param[in] yData Pointer to output tensor data. * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dyData Pointer to output gradient tensor data. * @param[in] dzDesc Z gradient tensor descriptor. * @param[in,out] dzData Pointer to z gradient tensor data. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in,out] dxData Pointer to input gradient tensor data. * @param[in] dBnScaleBiasDesc Shared descriptor for parameter gradient tensors. * @param[in] bnScaleData Pointer to scale tensor data. * @param[in] bnBiasData Pointer to bias tensor data (needed for activation). * @param[out] dBnScaleData Pointer to scale gradient result. * @param[out] dBnBiasData Pointer to bias gradient result. * @param[in] epsilon Same epsilon as forward pass. * @param[in] savedMean Optionally cached mean from forward pass. * @param[in] savedInvVariance Optionally cached inverse variance from forward pass. * @param[in] activationDesc Activation descriptor. * @param[in,out] workSpace Pointer to workspace memory. * @param[in] workSpaceSizeInBytes Size of workspace in bytes. * @param[in,out] reserveSpace Pointer to reserve space memory. * @param[in] reserveSpaceSizeInBytes Size of reserve space in bytes. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnBatchNormalizationForwardTrainingEx */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnBatchNormalizationBackwardEx(cudnnHandle_t handle, cudnnBatchNormMode_t mode, cudnnBatchNormOps_t bnOps, const void *alphaDataDiff, const void *betaDataDiff, const void *alphaParamDiff, const void *betaParamDiff, const cudnnTensorDescriptor_t xDesc, const void *xData, const cudnnTensorDescriptor_t yDesc, const void *yData, const cudnnTensorDescriptor_t dyDesc, const void *dyData, const cudnnTensorDescriptor_t dzDesc, void *dzData, const cudnnTensorDescriptor_t dxDesc, void *dxData, /* Shared tensor desc for the 4 tensors below */ const cudnnTensorDescriptor_t dBnScaleBiasDesc, const void *bnScaleData, const void *bnBiasData, /* needed if there is activation */ void *dBnScaleData, void *dBnBiasData, double epsilon, /* Same epsilon as forward pass */ /* Optionally cached intermediate results from forward pass */ const void *savedMean, const void *savedInvVariance, cudnnActivationDescriptor_t activationDesc, void *workSpace, size_t workSpaceSizeInBytes, void *reserveSpace, size_t reserveSpaceSizeInBytes); /** * @brief Returns the workspace size for normalization forward training. * * @param[in] handle cuDNN library handle. * @param[in] mode Normalization mode. * @param[in] normOps Extended normalization operation. * @param[in] algo Normalization algorithm. * @param[in] xDesc Input tensor descriptor. * @param[in] zDesc Z tensor descriptor (for add operations). * @param[in] yDesc Output tensor descriptor. * @param[in] normScaleBiasDesc Descriptor for normalization scale/bias tensors. * @param[in] activationDesc Activation descriptor. * @param[in] normMeanVarDesc Descriptor for mean/variance tensors. * @param[out] sizeInBytes Required workspace size in bytes. * @param[in] groupCnt Group count (reserved, should be set to 1). * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnNormalizationForwardTraining */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetNormalizationForwardTrainingWorkspaceSize(cudnnHandle_t handle, cudnnNormMode_t mode, cudnnNormOps_t normOps, cudnnNormAlgo_t algo, const cudnnTensorDescriptor_t xDesc, const cudnnTensorDescriptor_t zDesc, const cudnnTensorDescriptor_t yDesc, const cudnnTensorDescriptor_t normScaleBiasDesc, const cudnnActivationDescriptor_t activationDesc, const cudnnTensorDescriptor_t normMeanVarDesc, size_t *sizeInBytes, int groupCnt); /* Place hold for future work, should be set to 1 now*/ /** * @brief Returns the workspace size for normalization backward. * * @param[in] handle cuDNN library handle. * @param[in] mode Normalization mode. * @param[in] normOps Extended normalization operation. * @param[in] algo Normalization algorithm. * @param[in] xDesc Input tensor descriptor. * @param[in] yDesc Output tensor descriptor. * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dzDesc Z gradient tensor descriptor. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in] dNormScaleBiasDesc Descriptor for normalization parameter gradient tensors. * @param[in] activationDesc Activation descriptor. * @param[in] normMeanVarDesc Descriptor for mean/variance tensors. * @param[out] sizeInBytes Required workspace size in bytes. * @param[in] groupCnt Group count (reserved, should be set to 1). * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnNormalizationBackward */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetNormalizationBackwardWorkspaceSize(cudnnHandle_t handle, cudnnNormMode_t mode, cudnnNormOps_t normOps, cudnnNormAlgo_t algo, const cudnnTensorDescriptor_t xDesc, const cudnnTensorDescriptor_t yDesc, const cudnnTensorDescriptor_t dyDesc, const cudnnTensorDescriptor_t dzDesc, const cudnnTensorDescriptor_t dxDesc, const cudnnTensorDescriptor_t dNormScaleBiasDesc, const cudnnActivationDescriptor_t activationDesc, const cudnnTensorDescriptor_t normMeanVarDesc, size_t *sizeInBytes, int groupCnt); /* Place hold for future work, should be set to 1 now*/ /** * @brief Returns the reserve space size for normalization training. * * @param[in] handle cuDNN library handle. * @param[in] mode Normalization mode. * @param[in] normOps Extended normalization operation. * @param[in] algo Normalization algorithm. * @param[in] activationDesc Activation descriptor. * @param[in] xDesc Input tensor descriptor. * @param[out] sizeInBytes Required reserve space size in bytes. * @param[in] groupCnt Group count (reserved, should be set to 1). * * @retval CUDNN_STATUS_SUCCESS The size was returned successfully. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnNormalizationForwardTraining */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnGetNormalizationTrainingReserveSpaceSize(cudnnHandle_t handle, cudnnNormMode_t mode, cudnnNormOps_t normOps, cudnnNormAlgo_t algo, const cudnnActivationDescriptor_t activationDesc, const cudnnTensorDescriptor_t xDesc, size_t *sizeInBytes, int groupCnt); /* Place hold for future work, should be set to 1 now*/ /** * @brief Performs normalization forward training with optional activation. * * Computes y = relu(Norm(x) + z). Also accumulates moving averages of mean * and inverse variances. * * @param[in] handle cuDNN library handle. * @param[in] mode Normalization mode. * @param[in] normOps Extended normalization operation. * @param[in] algo Normalization algorithm. * @param[in] alpha Result blend factor. * @param[in] beta Destination layer blend factor. * @param[in] xDesc Input tensor descriptor. * @param[in] xData Pointer to input tensor data. * @param[in] normScaleBiasDesc Descriptor for normalization scale/bias tensors. * @param[in] normScale Pointer to scale tensor data. * @param[in] normBias Pointer to bias tensor data. * @param[in] exponentialAverageFactor Factor for computing running averages. * @param[in] normMeanVarDesc Descriptor for mean/variance tensors. * @param[in,out] resultRunningMean Running mean. * @param[in,out] resultRunningVariance Running variance. * @param[in] epsilon Epsilon value (must be >= 0). * @param[out] resultSaveMean Cached mean for backward pass (NULL if unused). * @param[out] resultSaveInvVariance Cached inverse variance for backward pass (NULL if unused). * @param[in] activationDesc Activation descriptor. * @param[in] zDesc Z tensor descriptor (for add operations). * @param[in] zData Pointer to z tensor data. * @param[in] yDesc Output tensor descriptor. * @param[out] yData Pointer to output tensor data. * @param[in,out] workspace Pointer to workspace memory. * @param[in] workSpaceSizeInBytes Size of workspace in bytes. * @param[in,out] reserveSpace Pointer to reserve space memory. * @param[in] reserveSpaceSizeInBytes Size of reserve space in bytes. * @param[in] groupCnt Group count (reserved, should be set to 1). * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnNormalizationBackward, cudnnGetNormalizationForwardTrainingWorkspaceSize */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnNormalizationForwardTraining(cudnnHandle_t handle, cudnnNormMode_t mode, cudnnNormOps_t normOps, cudnnNormAlgo_t algo, const void *alpha, /* alpha[0] = result blend factor */ const void *beta, /* beta[0] = dest layer blend factor */ const cudnnTensorDescriptor_t xDesc, const void *xData, const cudnnTensorDescriptor_t normScaleBiasDesc, const void *normScale, const void *normBias, double exponentialAverageFactor, const cudnnTensorDescriptor_t normMeanVarDesc, void *resultRunningMean, void *resultRunningVariance, /* Has to be >= 0. Should be the same in forward and backward functions. */ double epsilon, /* Optionally save intermediate results from the forward pass here - can be reused to speed up backward pass. NULL if unused */ void *resultSaveMean, void *resultSaveInvVariance, cudnnActivationDescriptor_t activationDesc, const cudnnTensorDescriptor_t zDesc, const void *zData, const cudnnTensorDescriptor_t yDesc, void *yData, void *workspace, size_t workSpaceSizeInBytes, void *reserveSpace, size_t reserveSpaceSizeInBytes, int groupCnt); /* Place hold for future work, should be set to 1 now*/ /** * @brief Performs backward normalization. * * Computes gradients for the normalization operation, including optional activation * and element-wise add gradients. * * @param[in] handle cuDNN library handle. * @param[in] mode Normalization mode. * @param[in] normOps Extended normalization operation. * @param[in] algo Normalization algorithm. * @param[in] alphaDataDiff Scaling factor for data gradient results. * @param[in] betaDataDiff Scaling factor for data gradient destinations. * @param[in] alphaParamDiff Scaling factor for parameter gradient results. * @param[in] betaParamDiff Scaling factor for parameter gradient destinations. * @param[in] xDesc Input tensor descriptor. * @param[in] xData Pointer to input tensor data. * @param[in] yDesc Output tensor descriptor. * @param[in] yData Pointer to output tensor data. * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dyData Pointer to output gradient tensor data. * @param[in] dzDesc Z gradient tensor descriptor. * @param[in,out] dzData Pointer to z gradient tensor data. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in,out] dxData Pointer to input gradient tensor data. * @param[in] dNormScaleBiasDesc Shared descriptor for parameter gradient tensors. * @param[in] normScaleData Pointer to scale tensor data. * @param[in] normBiasData Pointer to bias tensor data (needed for activation). * @param[out] dNormScaleData Pointer to scale gradient result. * @param[out] dNormBiasData Pointer to bias gradient result. * @param[in] epsilon Same epsilon as forward pass. * @param[in] normMeanVarDesc Descriptor for mean/variance tensors. * @param[in] savedMean Optionally cached mean from forward pass. * @param[in] savedInvVariance Optionally cached inverse variance from forward pass. * @param[in] activationDesc Activation descriptor. * @param[in,out] workSpace Pointer to workspace memory. * @param[in] workSpaceSizeInBytes Size of workspace in bytes. * @param[in,out] reserveSpace Pointer to reserve space memory. * @param[in] reserveSpaceSizeInBytes Size of reserve space in bytes. * @param[in] groupCnt Group count (reserved, should be set to 1). * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @deprecated Since cuDNN 9.0.0. Use graph API instead. * @see cudnnNormalizationForwardTraining */ CUDNN_DEPRECATED cudnnStatus_t CUDNNWINAPI cudnnNormalizationBackward(cudnnHandle_t handle, cudnnNormMode_t mode, cudnnNormOps_t normOps, cudnnNormAlgo_t algo, const void *alphaDataDiff, const void *betaDataDiff, const void *alphaParamDiff, const void *betaParamDiff, const cudnnTensorDescriptor_t xDesc, const void *xData, const cudnnTensorDescriptor_t yDesc, const void *yData, const cudnnTensorDescriptor_t dyDesc, const void *dyData, const cudnnTensorDescriptor_t dzDesc, void *dzData, const cudnnTensorDescriptor_t dxDesc, void *dxData, /* Shared tensor desc for the 4 tensors below */ const cudnnTensorDescriptor_t dNormScaleBiasDesc, const void *normScaleData, const void *normBiasData, /* needed if there is activation */ void *dNormScaleData, void *dNormBiasData, double epsilon, /* Same epsilon as forward pass */ const cudnnTensorDescriptor_t normMeanVarDesc, /* Optionally cached intermediate results from forward pass */ const void *savedMean, const void *savedInvVariance, cudnnActivationDescriptor_t activationDesc, void *workSpace, size_t workSpaceSizeInBytes, void *reserveSpace, size_t reserveSpaceSizeInBytes, int groupCnt); /* Place hold for future work, should be set to 1 now*/ /** * @brief Computes the gradient of the spatial transformer grid generator (backward). * * @param[in] handle cuDNN library handle. * @param[in] stDesc Spatial transformer descriptor. * @param[in] dgrid Pointer to the grid gradient data. * @param[out] dtheta Pointer to the theta gradient data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSpatialTfGridGeneratorForward */ cudnnStatus_t CUDNNWINAPI cudnnSpatialTfGridGeneratorBackward(cudnnHandle_t handle, const cudnnSpatialTransformerDescriptor_t stDesc, const void *dgrid, void *dtheta); /** * @brief Performs spatial transformer sampling backward. * * Computes the gradients of the spatial transformer sampler. * * @param[in] handle cuDNN library handle. * @param[in] stDesc Spatial transformer descriptor. * @param[in] alpha Scaling factor for the dx result. * @param[in] xDesc Input tensor descriptor. * @param[in] x Pointer to input tensor data. * @param[in] beta Scaling factor for the dx destination. * @param[in] dxDesc Input gradient tensor descriptor. * @param[in,out] dx Pointer to input gradient tensor data. * @param[in] alphaDgrid Scaling factor for the dgrid result. * @param[in] dyDesc Output gradient tensor descriptor. * @param[in] dy Pointer to output gradient tensor data. * @param[in] grid Pointer to sampling grid data. * @param[in] betaDgrid Scaling factor for the dgrid destination. * @param[in,out] dgrid Pointer to grid gradient tensor data. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnSpatialTfSamplerForward */ cudnnStatus_t CUDNNWINAPI cudnnSpatialTfSamplerBackward(cudnnHandle_t handle, cudnnSpatialTransformerDescriptor_t stDesc, const void *alpha, const cudnnTensorDescriptor_t xDesc, const void *x, const void *beta, const cudnnTensorDescriptor_t dxDesc, void *dx, const void *alphaDgrid, const cudnnTensorDescriptor_t dyDesc, const void *dy, const void *grid, const void *betaDgrid, void *dgrid); /** * @brief Performs backward dropout. * * Applies the same dropout mask from the forward pass (stored in reserveSpace) * to the gradient tensor. * * @param[in] handle cuDNN library handle. * @param[in] dropoutDesc Dropout descriptor. * @param[in] dydesc Output gradient tensor descriptor. * @param[in] dy Pointer to output gradient tensor data. * @param[in] dxdesc Input gradient tensor descriptor. * @param[out] dx Pointer to input gradient tensor data. * @param[in] reserveSpace Pointer to reserve space from forward pass. * @param[in] reserveSpaceSizeInBytes Size of reserve space in bytes. * * @retval CUDNN_STATUS_SUCCESS The operation completed successfully. * @retval CUDNN_STATUS_BAD_PARAM An invalid parameter was provided. * * @since cuDNN 9.0.0 * @see cudnnDropoutForward */ cudnnStatus_t CUDNNWINAPI cudnnDropoutBackward(cudnnHandle_t handle, const cudnnDropoutDescriptor_t dropoutDesc, const cudnnTensorDescriptor_t dydesc, const void *dy, const cudnnTensorDescriptor_t dxdesc, void *dx, void *reserveSpace, size_t reserveSpaceSizeInBytes); #if defined(__cplusplus) } #endif #endif /* CUDNN_OPS_H_ */