Compute Library
 22.11
NEInstanceNormalizationLayerKernel Class Reference

Interface for performing an instance normalization. More...

#include <NEInstanceNormalizationLayerKernel.h>

Collaboration diagram for NEInstanceNormalizationLayerKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEInstanceNormalizationLayerKernel ()
 Default constructor. More...
 
 NEInstanceNormalizationLayerKernel (const NEInstanceNormalizationLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEInstanceNormalizationLayerKerneloperator= (const NEInstanceNormalizationLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEInstanceNormalizationLayerKernel (NEInstanceNormalizationLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEInstanceNormalizationLayerKerneloperator= (NEInstanceNormalizationLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEInstanceNormalizationLayerKernel ()=default
 Default destructor. More...
 
void configure (ITensor *input, ITensor *output, const InstanceNormalizationLayerKernelInfo &info)
 Set the input and output tensors. 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, const InstanceNormalizationLayerKernelInfo &info)
 Static function to check if given info will lead to a valid configuration of NEInstanceNormalizationLayer. More...
 

Additional Inherited Members

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

Detailed Description

Interface for performing an instance normalization.

Definition at line 35 of file NEInstanceNormalizationLayerKernel.h.

Constructor & Destructor Documentation

◆ NEInstanceNormalizationLayerKernel() [1/3]

Default constructor.

Definition at line 130 of file NEInstanceNormalizationLayerKernel.cpp.

Referenced by NEInstanceNormalizationLayerKernel::name().

131  : _input(nullptr), _output(nullptr), _gamma(1), _beta(0), _epsilon(1e-12)
132 {
133 }

◆ NEInstanceNormalizationLayerKernel() [2/3]

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

◆ NEInstanceNormalizationLayerKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEInstanceNormalizationLayerKernel()

Default destructor.

Referenced by NEInstanceNormalizationLayerKernel::name().

Member Function Documentation

◆ configure()

void configure ( ITensor input,
ITensor output,
const InstanceNormalizationLayerKernelInfo info 
)

Set the input and output tensors.

Parameters
[in,out]inputSource tensor. Data types supported: F16/F32. Data layout supported: NCHW In case of output tensor = nullptr this tensor will store the result of the normalization.
[out]outputDestination tensor. Data types and data layouts supported: same as input.
[in]infoKernel meta-data descriptor

Definition at line 135 of file NEInstanceNormalizationLayerKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, InstanceNormalizationLayerKernelInfo::beta, InstanceNormalizationLayerKernelInfo::epsilon, InstanceNormalizationLayerKernelInfo::gamma, ITensor::info(), arm_compute::test::validation::input, InstanceNormalizationLayerKernelInfo::use_mixed_precision, arm_compute::cpu::kernels::validate_and_configure_window(), and arm_compute::cpu::kernels::validate_arguments().

Referenced by NEInstanceNormalizationLayerKernel::name().

136 {
138 
139  _input = input;
140  _output = output == nullptr ? input : output;
141  _gamma = info.gamma;
142  _beta = info.beta;
143  _epsilon = info.epsilon;
144  _use_mixed_precision = info.use_mixed_precision;
145 
146  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(_input->info(), _output->info(), _gamma, _beta, _epsilon));
147 
148  // Configure kernel window
149  auto win_config = validate_and_configure_window(_input->info(), _output->info());
150  ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
151 
152  INEKernel::configure(std::get<1>(win_config));
153 }
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
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 NEInstanceNormalizationLayerKernel::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 162 of file NEInstanceNormalizationLayerKernel.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 NEInstanceNormalizationLayerKernel::name().

163 {
167 
168  const auto *uk = get_implementation(InstanceNormSelectorData{ _input->info()->data_type() });
169  ARM_COMPUTE_ERROR_ON(uk == nullptr || uk->ukernel == nullptr);
170 
171  uk->ukernel(_input, _output, _gamma, _beta, _epsilon, _use_mixed_precision, window);
172 }
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,
const InstanceNormalizationLayerKernelInfo info 
)
static

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

Parameters
[in]inputSource tensor info. Data types supported: F16/F32. Data layout supported: NCHW
[in]outputDestination tensor info. Data types and data layouts supported: same as input.
[in]infoKernel meta-data descriptor
Returns
a status

Definition at line 155 of file NEInstanceNormalizationLayerKernel.cpp.

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

Referenced by NEInstanceNormalizationLayerKernel::name(), and NEInstanceNormalizationLayer::validate().

156 {
157  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, info.gamma, info.beta, info.epsilon));
158  ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), (output == nullptr ? input->clone().get() : output->clone().get()))));
159  return Status{};
160 }
#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)
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *src, ITensorInfo *dst)

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