Compute Library
 22.05
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...
 
virtual size_t get_mws (const CPUInfo &platform, size_t thread_count) const
 Return minimum workload size of the relevant kernel. 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...
 

Additional Inherited Members

- Static Public Attributes inherited from ICPPKernel
static constexpr size_t default_mws = 1
 

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 126 of file NEMeanStdDevNormalizationKernel.cpp.

Referenced by NEMeanStdDevNormalizationKernel::name().

127  : _input(nullptr), _output(nullptr), _epsilon(1e-8f)
128 {
129 }

◆ 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 131 of file NEMeanStdDevNormalizationKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::quantization::epsilon, ITensor::info(), arm_compute::test::validation::input, NEMeanStdDevNormalizationKernel::validate(), and arm_compute::cpu::kernels::validate_and_configure_window().

Referenced by NEMeanStdDevNormalizationKernel::name().

132 {
134 
135  ARM_COMPUTE_ERROR_THROW_ON(NEMeanStdDevNormalizationKernel::validate(input->info(), (output != nullptr) ? output->info() : nullptr, epsilon));
136 
137  _input = input;
138  _output = (output == nullptr) ? input : output;
139  _epsilon = epsilon;
140 
141  // Configure kernel window
142  auto win_config = validate_and_configure_window(input->info(), (output == nullptr) ? nullptr : output->info());
143  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
144  ICPPKernel::configure(win_config.second);
145 }
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
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...
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *src, ITensorInfo *dst)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ 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 154 of file NEMeanStdDevNormalizationKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::data_type(), ITensor::info(), and IKernel::window().

Referenced by NEMeanStdDevNormalizationKernel::name().

155 {
159 
160  const auto *uk = get_implementation(MeanStdDevNormSelectorData{ _output->info()->data_type() });
161  ARM_COMPUTE_ERROR_ON(uk == nullptr || uk->ukernel == nullptr);
162 
163  uk->ukernel(_input, _output, _epsilon, window);
164 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#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
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
#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 147 of file NEMeanStdDevNormalizationKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), arm_compute::cpu::kernels::validate_and_configure_window(), and arm_compute::cpu::kernels::validate_arguments().

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

148 {
150  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), (output != nullptr) ? output->clone().get() : nullptr).first);
151  return Status{};
152 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *src, ITensorInfo *dst)

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