Normalize Class Reference

Normalize Class Reference#

3 min read time

Applies to Linux

rocCV: roccv::Normalize Class Reference
roccv::Normalize Class Referencefinal

Class for managing the Normalize operator. More...

#include <op_normalize.hpp>

Inheritance diagram for roccv::Normalize:
roccv::IOperator

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...
 
- Public Member Functions inherited from roccv::IOperator
virtual ~IOperator ()
 

Detailed Description

Class for managing the Normalize operator.

Constructor & Destructor Documentation

◆ Normalize()

roccv::Normalize::Normalize ( )
inline

Constructs an OpNormalize object.

◆ ~Normalize()

roccv::Normalize::~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]streamThe HIP stream to run this operation on.
[in]inputInput tensor.
[in]baseA 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]scaleA tensor containing scale values. This tensor exhibits the same rules as the base tensor.
[out]outputOutput tensor.
[in]global_scaleScales the output by a constant value after normalization.
[in]shiftShifts the value after scaling.
[in]epsilonAn epsilon value to add to the standard deviation to ensure numerical stability.
[in]flagsFlags 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]deviceThe 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