Compute Library
 21.08
NEMeanStdDevNormalizationKernel Class Reference

Interface for the kernel to normalize the input 2D tensor across the first dimension with respect to mean and standard deviation of the same dimension. More...

#include <NEMeanStdDevNormalizationKernel.h>

Collaboration diagram for NEMeanStdDevNormalizationKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEMeanStdDevNormalizationKernel ()
 Default constructor. More...
 
 NEMeanStdDevNormalizationKernel (const NEMeanStdDevNormalizationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEMeanStdDevNormalizationKerneloperator= (const NEMeanStdDevNormalizationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEMeanStdDevNormalizationKernel (NEMeanStdDevNormalizationKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEMeanStdDevNormalizationKerneloperator= (NEMeanStdDevNormalizationKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEMeanStdDevNormalizationKernel ()=default
 Default destructor. More...
 
void configure (ITensor *input, ITensor *output=nullptr, float epsilon=1e-8f)
 Initialise the kernel's input and outputs. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
virtual void run_nd (const Window &window, const ThreadInfo &info, const Window &thread_locator)
 legacy compatibility layer for implemantions which do not support thread_locator In these cases we simply narrow the interface down the legacy version More...
 
virtual void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. More...
 
virtual bool is_parallelisable () const
 Indicates whether or not the kernel is parallelisable. More...
 
virtual BorderSize border_size () const
 The size of the border for that kernel. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output=nullptr, float epsilon=1e-8f)
 Static function to check if given info will lead to a valid configuration of NEMeanStdDevNormalizationKernel. More...
 

Detailed Description

Interface for the kernel to normalize the input 2D tensor across the first dimension with respect to mean and standard deviation of the same dimension.

Definition at line 38 of file NEMeanStdDevNormalizationKernel.h.

Constructor & Destructor Documentation

◆ NEMeanStdDevNormalizationKernel() [1/3]

Default constructor.

Definition at line 147 of file NEMeanStdDevNormalizationKernel.cpp.

Referenced by NEMeanStdDevNormalizationKernel::name().

148  : _input(nullptr), _output(nullptr), _epsilon(1e-8f), _func(nullptr)
149 {
150 }

◆ NEMeanStdDevNormalizationKernel() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ NEMeanStdDevNormalizationKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEMeanStdDevNormalizationKernel()

Default destructor.

Referenced by NEMeanStdDevNormalizationKernel::name().

Member Function Documentation

◆ configure()

void configure ( ITensor input,
ITensor output = nullptr,
float  epsilon = 1e-8f 
)

Initialise the kernel's input and outputs.

Note
If the output tensor is a nullptr, the normalization will be performed in-place.
Parameters
[in,out]inputSource tensor with 2 dimensions. In case of output tensor = nullptr, this tensor will store the result of the normalization. Data types supported: F16/F32.
[out]output(Optional) Destination tensor. It can be nullptr in case of in-place computation. Data type supported: same as input
[in]epsilon(Optional) Small float to avoid division by zero in case of zero standard deviation. Defaults to 1e-8.

Definition at line 152 of file NEMeanStdDevNormalizationKernel.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::test::validation::data_type, ITensorInfo::data_type(), arm_compute::quantization::epsilon, arm_compute::F16, arm_compute::F32, ITensor::info(), arm_compute::test::validation::input, and NEMeanStdDevNormalizationKernel::validate().

Referenced by NEMeanStdDevNormalizationKernel::name().

153 {
155 
156  ARM_COMPUTE_ERROR_THROW_ON(NEMeanStdDevNormalizationKernel::validate(input->info(), (output != nullptr) ? output->info() : nullptr, epsilon));
157 
158  _input = input;
159  _output = (output == nullptr) ? input : output;
160  _epsilon = epsilon;
161 
162  // Configure kernel window
163  auto win_config = validate_and_configure_window(input->info(), (output == nullptr) ? nullptr : output->info());
164  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
165  ICPPKernel::configure(win_config.second);
166 
167  // Configure function to run based on different data types
168  const DataType data_type = input->info()->data_type();
169  switch(data_type)
170  {
171  case DataType::F32:
172  _func = &NEMeanStdDevNormalizationKernel::mean_stddev_normalization<float, 4>;
173  break;
174 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
175  case DataType::F16:
176  _func = &NEMeanStdDevNormalizationKernel::mean_stddev_normalization<float16_t, 8>;
177  break;
178 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
179  default:
180  ARM_COMPUTE_ERROR("Not Supported");
181  break;
182  }
183 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
1 channel, 1 F16 per channel
const DataType data_type
Definition: Im2Col.cpp:150
static Status validate(const ITensorInfo *input, const ITensorInfo *output=nullptr, float epsilon=1e-8f)
Static function to check if given info will lead to a valid configuration of NEMeanStdDevNormalizatio...
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
DataType
Available data types.
Definition: Types.h:77

◆ name()

◆ operator=() [1/2]

Prevent instances of this class from being copied (As this class contains pointers)

Referenced by NEMeanStdDevNormalizationKernel::name().

◆ operator=() [2/2]

Allow instances of this class to be moved.

◆ run()

void run ( const Window window,
const ThreadInfo info 
)
overridevirtual

Execute the kernel on the passed window.

Warning
If is_parallelisable() returns false then the passed window must be equal to window()
Note
The window has to be a region within the window returned by the window() method
The width of the window has to be a multiple of num_elems_processed_per_iteration().
Parameters
[in]windowRegion on which to execute the kernel. (Must be a region of the window returned by window())
[in]infoInfo about executing thread and CPU.

Reimplemented from ICPPKernel.

Definition at line 192 of file NEMeanStdDevNormalizationKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, and IKernel::window().

Referenced by NEMeanStdDevNormalizationKernel::name().

193 {
197  ARM_COMPUTE_ERROR_ON(_func == nullptr);
198 
199  (this->*_func)(window);
200 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output = nullptr,
float  epsilon = 1e-8f 
)
static

Static function to check if given info will lead to a valid configuration of NEMeanStdDevNormalizationKernel.

Parameters
[in]inputSource tensor info with 2 dimensions. In case of output tensor info = nullptr, this tensor will store the result of the normalization. Data types supported: F16/F32.
[in]output(Optional) Destination tensor info. It can be nullptr in case of in-place computation. Data type supported: same as input
[in]epsilon(Optional) Small float to avoid division by zero in case of zero standard deviation. Defaults to 1e-8.
Returns
a status

Definition at line 185 of file NEMeanStdDevNormalizationKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR, and ICloneable< T >::clone().

Referenced by NEMeanStdDevNormalizationKernel::configure(), NEMeanStdDevNormalizationKernel::name(), and NEMeanStdDevNormalizationLayer::validate().

186 {
187  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, epsilon));
188  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), (output != nullptr) ? output->clone().get() : nullptr).first);
189  return Status{};
190 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204

The documentation for this class was generated from the following files: