Normalize

group NVCV_C_ALGORITHM_NORMALIZE

Unnamed Group

NVCVStatus cvcudaNormalizeSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle base, NVCVTensorHandle scale, NVCVTensorHandle out, float global_scale, float shift, float epsilon, uint32_t flags)

Executes the normalize operation on the given cuda stream. This operation does not wait for completion.

Data normalization is done using externally provided base (typically: mean or min) and scale (typically reciprocal of standard deviation or 1/(max-min)). The normalization follows the formula:

out[data_idx] = (in[data_idx] - base[param_idx]) * scale[param_idx] * global_scale + shift
Where data_idx is a position in the data tensor (in, out) and param_idx is a position in the base and scale tensors (see below for details). The two additional constants, global_scale and shift can be used to adjust the result to the dynamic range and resolution of the output type.

The scale parameter may also be interpreted as standard deviation - in that case, its reciprocal is used and optionally, a regularizing term is added to the variance.

m = 1 / sqrt(square(stddev[param_idx]) + epsilon)
out[data_idx] = (in[data_idx] - mean[param_idx]) * m * global_scale + shift

param_idx is calculated as follows (where axis = N,H,W,C):

param_idx[axis] = param_shape[axis] == 1 ? 0 : data_idx[axis]

Limitations:

Input: Data Layout: [kNHWC, kHWC] Channels: [1, 3, 4]

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

Yes

16bit Unsigned

Yes

16bit Signed

Yes

32bit Unsigned

No

32bit Signed

Yes

32bit Float

Yes

64bit Float

No

Output: Data Layout: [kNHWC, kHWC] Channels: [1, 3, 4]

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

Yes

16bit Unsigned

Yes

16bit Signed

Yes

32bit Unsigned

No

32bit Signed

Yes

32bit Float

Yes

64bit Float

No

Input/Output dependency

 Property      |  Input == Output
-------------- | -------------
 Data Layout   | Yes
 Data Type     | Yes
 Number        | Yes
 Channels      | Yes
 Width         | Yes
 Height        | Yes
Scale/Base Tensor:
 Scale and Base may be a tensor the same shape as the input/output tensors, or it can be a scalar each dimension.

 For varshape variant, scale and base may represent either a scalar with shape [1,1,1,1],
 or a tensor with shape [1,1,1,C], where C is the number of channels in the input format.

Parameters:
  • handle[in] Handle to the operator.

    • Must not be NULL.

  • stream[in] Handle to a valid CUDA stream.

  • in[in] input tensor.

  • base[in] Base tensor.

  • scale[in] Scale tensor.

  • out[out] Output tensor.

  • global_scale[in] Additional scale value to be used in addition to scale.

  • shift[in] Additional bias value to be used in addition to base.

  • epsilon[in] Epsilon to use when CVCUDA_NORMALIZE_SCALE_IS_STDDEV flag is set as a regularizing term to be added to variance.

  • flags[in] Algorithm flags, use CVCUDA_NORMALIZE_SCALE_IS_STDDEV if scale passed as argument is standard deviation instead or 0 if it is scaling.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.

  • NVCV_ERROR_INTERNAL – Internal error in the operator, invalid types passed in.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus cvcudaNormalizeVarShapeSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVImageBatchHandle in, NVCVTensorHandle base, NVCVTensorHandle scale, NVCVImageBatchHandle out, float global_scale, float shift, float epsilon, uint32_t flags)

Defines

CVCUDA_NORMALIZE_SCALE_IS_STDDEV

Functions

NVCVStatus cvcudaNormalizeCreate(NVCVOperatorHandle *handle)

Constructs and an instance of the normalize operator.

Parameters:

handle[out] Where the image instance handle will be written to.

  • Must not be NULL.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Handle is null.

  • NVCV_ERROR_OUT_OF_MEMORY – Not enough memory to create the operator.

  • NVCV_SUCCESS – Operation executed successfully.