Normalize Class Reference#
3 min read time
Class for managing the Normalize operator. More...
#include <op_normalize.hpp>

Public Member Functions | |
Normalize () | |
Constructs an OpNormalize object. More... | |
void | operator() (hipStream_t stream, const Tensor &input, const Tensor &base, const Tensor &scale, const Tensor &output, float global_scale, float shift, float epsilon, uint32_t flags, const eDeviceType device=eDeviceType::GPU) const |
Executes the Normalize operation on the given HIP stream. More... | |
~Normalize () | |
Destroy the Op Normalize object. More... | |
![]() | |
virtual | ~IOperator () |
Detailed Description
Class for managing the Normalize operator.
Constructor & Destructor Documentation
◆ Normalize()
|
inline |
Constructs an OpNormalize object.
◆ ~Normalize()
|
inline |
Destroy the Op Normalize object.
Member Function Documentation
◆ operator()()
void roccv::Normalize::operator() | ( | hipStream_t | stream, |
const Tensor & | input, | ||
const Tensor & | base, | ||
const Tensor & | scale, | ||
const Tensor & | output, | ||
float | global_scale, | ||
float | shift, | ||
float | epsilon, | ||
uint32_t | flags, | ||
const eDeviceType | device = eDeviceType::GPU |
||
) | const |
Executes the Normalize operation on the given HIP stream.
Normalization subtracts the base and multiplies by a provided scale value. It is calculated as follows:
output[idx] = (input[idx] - base[param_idx]) * scale[param_idx] * global_scale + shift
Optionally, if the ROCCV_NORMALIZE_SCALE_IS_STDDEV flag is set, the scale tensor is interpreted as the standard deviation and will be calculated as follows (where epsilon is provided to ensure numerical stability):
output[idx] = (input[idx] - base[param_idx]) * (1 / sqrt(sqr(scale[param_idx]) + epsilon)) * global_scale + shift.
Limitations:
Input: Supported TensorLayout(s): [NHWC, HWC] Supported DataType(s): [U8, S8, U16, S16, U32, S32, F32]
Output: Supported TensorLayout(s): [NHWC, HWC] Supported DataType(s): [U8, S8, U16, S16, U32, S32, F32]
base: Supported TensorLayout(s): [NHWC, HWC] Supported DataType(s): [F32]
scale: Supported TensorLayout(s): [NHWC, HWC] Supported DataType(s): [F32]
Input/Output dependency:
Property | Input == Output -------------- | ------------- TensorLayout | Yes DataType | Yes Channels | Yes Width | Yes Height | Yes Batch | Yes
- Parameters
-
[in] stream The HIP stream to run this operation on. [in] input Input tensor. [in] base A tensor containing base values. Layout must match that of the input/output tensors. Shape dimensions can either be 1, signifying that the base will be masked across that dimension, or match the corresponding dimension of the input/output tensor's shape in the image. For example, a shape of [1, 1, 1, C] will apply the base value across the channel dimension of the image, and a shape of [1, 1, W, C] will apply the base value across the width and channel dimensions (where W corresponds to the image width and C corresponds to the channel count). The channel count must match that of the input/output images. [in] scale A tensor containing scale values. This tensor exhibits the same rules as the base tensor. [out] output Output tensor. [in] global_scale Scales the output by a constant value after normalization. [in] shift Shifts the value after scaling. [in] epsilon An epsilon value to add to the standard deviation to ensure numerical stability. [in] flags Flags to specify the behavior of the normalization. If ROCCV_NORMALIZE_SCALE_IS_STDDEV is set, the scale tensor will be interpreted at the standard deviation values rather than the scale. [in] device The device which this operation should run on. (Default: eDeviceType::GPU)
The documentation for this class was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-roccv/checkouts/latest/include/op_normalize.hpp