Compute Library
 22.11
CLBatchNormalizationLayerKernel Class Reference

Interface for the BatchNormalization layer kernel. More...

#include <CLBatchNormalizationLayerKernel.h>

Collaboration diagram for CLBatchNormalizationLayerKernel:
[legend]

Public Member Functions

 CLBatchNormalizationLayerKernel ()
 Constructor. More...
 
 CLBatchNormalizationLayerKernel (const CLBatchNormalizationLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLBatchNormalizationLayerKerneloperator= (const CLBatchNormalizationLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLBatchNormalizationLayerKernel (CLBatchNormalizationLayerKernel &&)=default
 Default Move Constructor. More...
 
CLBatchNormalizationLayerKerneloperator= (CLBatchNormalizationLayerKernel &&)=default
 Default move assignment operator. More...
 
 ~CLBatchNormalizationLayerKernel ()=default
 Default destructor. More...
 
void configure (ICLTensor *input, ICLTensor *output, const ICLTensor *mean, const ICLTensor *var, const ICLTensor *beta=nullptr, const ICLTensor *gamma=nullptr, float epsilon=0.001f, ActivationLayerInfo act_info=ActivationLayerInfo())
 Set the input and output tensors. More...
 
void configure (const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, const ICLTensor *mean, const ICLTensor *var, const ICLTensor *beta=nullptr, const ICLTensor *gamma=nullptr, float epsilon=0.001f, ActivationLayerInfo act_info=ActivationLayerInfo())
 Set the input and output tensors. More...
 
void run (const Window &window, cl::CommandQueue &queue) override
 Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue. More...
 
- Public Member Functions inherited from ICLKernel
 ICLKernel ()
 Constructor. More...
 
cl::Kernel & kernel ()
 Returns a reference to the OpenCL kernel of this object. More...
 
CLKernelType type () const
 Returns the CL kernel type. More...
 
template<typename T >
void add_1D_array_argument (unsigned int &idx, const ICLArray< T > *array, const Strides &strides, unsigned int num_dimensions, const Window &window)
 Add the passed 1D array's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_1D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_1D_tensor_argument_if (bool cond, unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx if the condition is true. More...
 
void add_2D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_2D_tensor_argument_if (bool cond, unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx if the condition is true. More...
 
void add_3D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_4D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 4D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_5D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 5D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_3d_tensor_nhw_argument (unsigned int &idx, const ICLTensor *tensor)
 Add the passed NHW 3D tensor's parameters to the object's kernel's arguments by passing strides, dimensions and the offset to the first valid element in bytes. More...
 
void add_4d_tensor_nhwc_argument (unsigned int &idx, const ICLTensor *tensor)
 Add the passed NHWC 4D tensor's parameters to the object's kernel's arguments by passing strides, dimensions and the offset to the first valid element in bytes. More...
 
virtual void run_op (ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
 Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue. More...
 
virtual void run_composite_op (ITensorPack &tensors, const Window &window, cl::CommandQueue &queue, const experimental::dynamic_fusion::ClExecutionDescriptor &exec_desc)
 The execution is carried out through run_op method. But the run_op method needs to be extended to include ClExecutionDescriptor as now LWS GWS tuning will be separated from the IKernel. More...
 
template<typename T >
void add_argument (unsigned int &idx, T value)
 Add the passed parameters to the object's kernel's arguments starting from the index idx. More...
 
void set_lws_hint (const cl::NDRange &lws_hint)
 Set the Local-Workgroup-Size hint. More...
 
cl::NDRange lws_hint () const
 Return the Local-Workgroup-Size hint. More...
 
void set_wbsm_hint (const cl_int &wbsm_hint)
 Set the workgroup batch size modifier hint. More...
 
cl_int wbsm_hint () const
 Return the workgroup batch size modifier hint. More...
 
const std::string & config_id () const
 Get the configuration ID. More...
 
void set_target (GPUTarget target)
 Set the targeted GPU architecture. More...
 
void set_target (cl::Device &device)
 Set the targeted GPU architecture according to the CL device. More...
 
GPUTarget get_target () const
 Get the targeted GPU architecture. More...
 
size_t get_max_workgroup_size ()
 Get the maximum workgroup size for the device the CLKernelLibrary uses. More...
 
template<unsigned int dimension_size>
void add_tensor_argument (unsigned &idx, const ICLTensor *tensor, const Window &window)
 
template<typename T , unsigned int dimension_size>
void add_array_argument (unsigned &idx, const ICLArray< T > *array, const Strides &strides, unsigned int num_dimensions, const Window &window)
 Add the passed array's parameters to the object's kernel's arguments starting from the index idx. 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 ITensorInfo *mean, const ITensorInfo *var, const ITensorInfo *beta=nullptr, const ITensorInfo *gamma=nullptr, float epsilon=0.001f, ActivationLayerInfo act_info=ActivationLayerInfo())
 Static function to check if given info will lead to a valid configuration of CLBatchNormalizationLayerKernel. More...
 
- Static Public Member Functions inherited from ICLKernel
static constexpr unsigned int num_arguments_per_3d_tensor_nhw ()
 Returns the number of arguments enqueued per NHW 3D Tensor object. More...
 
static constexpr unsigned int num_arguments_per_4d_tensor_nhwc ()
 Returns the number of arguments enqueued per NHWC 4D Tensor object. More...
 
static constexpr unsigned int num_arguments_per_1D_array ()
 Returns the number of arguments enqueued per 1D array object. More...
 
static constexpr unsigned int num_arguments_per_1D_tensor ()
 Returns the number of arguments enqueued per 1D tensor object. More...
 
static constexpr unsigned int num_arguments_per_2D_tensor ()
 Returns the number of arguments enqueued per 2D tensor object. More...
 
static constexpr unsigned int num_arguments_per_3D_tensor ()
 Returns the number of arguments enqueued per 3D tensor object. More...
 
static constexpr unsigned int num_arguments_per_4D_tensor ()
 Returns the number of arguments enqueued per 4D tensor object. More...
 
static cl::NDRange gws_from_window (const Window &window)
 Get the global work size given an execution window. More...
 

Detailed Description

Interface for the BatchNormalization layer kernel.

Definition at line 35 of file CLBatchNormalizationLayerKernel.h.

Constructor & Destructor Documentation

◆ CLBatchNormalizationLayerKernel() [1/3]

Constructor.

Definition at line 109 of file CLBatchNormalizationLayerKernel.cpp.

References arm_compute::ELEMENTWISE.

110  : _input(nullptr), _output(nullptr), _mean(nullptr), _var(nullptr), _beta(nullptr), _gamma(nullptr), _epsilon(0), _run_in_place(false)
111 {
113 }
Elementwise CL kernel type.
Definition: CLTypes.h:85

◆ CLBatchNormalizationLayerKernel() [2/3]

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

◆ CLBatchNormalizationLayerKernel() [3/3]

Default Move Constructor.

◆ ~CLBatchNormalizationLayerKernel()

Default destructor.

Member Function Documentation

◆ configure() [1/2]

void configure ( ICLTensor input,
ICLTensor output,
const ICLTensor mean,
const ICLTensor var,
const ICLTensor beta = nullptr,
const ICLTensor gamma = nullptr,
float  epsilon = 0.001f,
ActivationLayerInfo  act_info = ActivationLayerInfo() 
)

Set the input and output tensors.

Note
If the output tensor is a nullptr, the batch normalization function will be performed in-place
Parameters
[in,out]inputSource tensor. In case of output tensor = nullptr, this tensor will store the result. 3 lower dimensions represent a single input with dimensions [width, height, FM]. The rest are optional and used for representing batches. Data types supported: F16/F32. Data layouts supported: NCHW/NHWC.
[out]outputDestination tensor. Output will have the same number of dimensions as input. Data type supported: same as input
[in]meanMean values tensor. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]varVariance values tensor. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]beta(Optional) Beta values tensor info. 1 dimension with size equal to the feature maps [FM]. If not provided, default value for beta is 0. Data types supported: Same as input
[in]gamma(Optional) Gamma values tensor info. 1 dimension with size equal to the feature maps [FM]. If not provided, default value for gamma is 1. Data types supported: Same as input
[in]epsilon(Optional) Small value to avoid division with zero. Default value is 0.001f.
[in]act_info(Optional) Activation layer information in case of a fused activation. Only RELU, BOUNDED_RELU and LU_BOUNDED_RELU supported.

Definition at line 115 of file CLBatchNormalizationLayerKernel.cpp.

References CLKernelLibrary::get().

117 {
118  configure(CLKernelLibrary::get().get_compile_context(), input, output, mean, var, beta, gamma, epsilon, act_info);
119 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(ICLTensor *input, ICLTensor *output, const ICLTensor *mean, const ICLTensor *var, const ICLTensor *beta=nullptr, const ICLTensor *gamma=nullptr, float epsilon=0.001f, ActivationLayerInfo act_info=ActivationLayerInfo())
Set the input and output tensors.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
ICLTensor input,
ICLTensor output,
const ICLTensor mean,
const ICLTensor var,
const ICLTensor beta = nullptr,
const ICLTensor gamma = nullptr,
float  epsilon = 0.001f,
ActivationLayerInfo  act_info = ActivationLayerInfo() 
)

Set the input and output tensors.

Note
If the output tensor is a nullptr, the batch normalization function will be performed in-place
Parameters
[in]compile_contextThe compile context to be used.
[in,out]inputSource tensor. In case of output tensor = nullptr, this tensor will store the result. 3 lower dimensions represent a single input with dimensions [width, height, FM]. The rest are optional and used for representing batches. Data types supported: F16/F32. Data layouts supported: NCHW/NHWC.
[out]outputDestination tensor. Output will have the same number of dimensions as input. Data type supported: same as input
[in]meanMean values tensor. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]varVariance values tensor. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]beta(Optional) Beta values tensor info. 1 dimension with size equal to the feature maps [FM]. If not provided, default value for beta is 0. Data types supported: Same as input
[in]gamma(Optional) Gamma values tensor info. 1 dimension with size equal to the feature maps [FM]. If not provided, default value for gamma is 1. Data types supported: Same as input
[in]epsilon(Optional) Small value to avoid division with zero. Default value is 0.001f.
[in]act_info(Optional) Activation layer information in case of a fused activation. Only RELU, BOUNDED_RELU and LU_BOUNDED_RELU supported.

Definition at line 121 of file CLBatchNormalizationLayerKernel.cpp.

References ActivationLayerInfo::a(), ActivationLayerInfo::activation(), CLBuildOptions::add_option(), arm_compute::adjust_vec_size(), ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), ActivationLayerInfo::b(), arm_compute::calculate_max_window(), ICloneable< T >::clone(), arm_compute::create_kernel(), ITensorInfo::data_layout(), ITensorInfo::data_type(), ITensorInfo::dimension(), ITensorInfo::element_size(), ActivationLayerInfo::enabled(), arm_compute::quantization::epsilon, arm_compute::float_to_string_with_full_precision(), arm_compute::get_cl_type_from_data_type(), arm_compute::get_padding_info(), arm_compute::has_padding_changed(), ITensor::info(), arm_compute::test::validation::input, arm_compute::lower_string(), arm_compute::NHWC, ICLKernel::num_arguments_per_1D_tensor(), ICLKernel::num_arguments_per_3D_tensor(), num_elems_processed_per_iteration, arm_compute::string_from_activation_func(), arm_compute::string_from_data_layout(), arm_compute::string_from_data_type(), arm_compute::support::cpp11::to_string(), and arm_compute::cpu::kernels::validate_arguments().

124 {
125  ARM_COMPUTE_ERROR_ON_NULLPTR(input, mean, var);
126 
127  auto padding_info = get_padding_info({ input, output, mean, var, beta, gamma });
128  _input = input;
129  _output = output;
130  _mean = mean;
131  _var = var;
132  _beta = beta;
133  _gamma = gamma;
134  _epsilon = epsilon;
135 
136  _run_in_place = (output == nullptr) || (output == input);
137 
138  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), (output != nullptr) ? output->info() : nullptr,
139  mean->info(), var->info(), (beta != nullptr) ? beta->info() : nullptr,
140  (gamma != nullptr) ? gamma->info() : nullptr, epsilon, act_info));
141 
142  unsigned int num_elems_processed_per_iteration = adjust_vec_size(16 / input->info()->element_size(), input->info()->dimension(0));
143 
144  // Set build options
145  CLBuildOptions build_opts;
146  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type()));
147  build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(num_elems_processed_per_iteration));
148  build_opts.add_option("-DVEC_SIZE_LEFTOVER=" + support::cpp11::to_string(input->info()->dimension(0) % num_elems_processed_per_iteration));
149  build_opts.add_option("-DACTIVATION_TYPE=" + lower_string(string_from_activation_func(act_info.activation())));
150  build_opts.add_option_if(act_info.enabled(), "-DA_VAL=" + float_to_string_with_full_precision(act_info.a()));
151  build_opts.add_option_if(act_info.enabled(), "-DB_VAL=" + float_to_string_with_full_precision(act_info.b()));
152  build_opts.add_option_if(_run_in_place, "-DIN_PLACE");
153  build_opts.add_option_if(beta == nullptr, "-DUSE_DEFAULT_BETA");
154  build_opts.add_option_if(gamma == nullptr, "-DUSE_DEFAULT_GAMMA");
155 
156  // Create kernel
157  _kernel = create_kernel(compile_context, "batchnormalization_layer_" + lower_string(string_from_data_layout(input->info()->data_layout())), build_opts.options());
158 
159  // Set kernel static arguments
160  unsigned int include_output = (!_run_in_place) ? 1 : 0;
161  unsigned int idx = (1 + include_output) * num_arguments_per_3D_tensor() + 2 * num_arguments_per_1D_tensor(); // Skip the input and output parameters
162  if(_beta != nullptr)
163  {
164  idx += num_arguments_per_1D_tensor(); // Skip beta parameter
165  }
166  if(_gamma != nullptr)
167  {
168  idx += num_arguments_per_1D_tensor(); // Skip gamma parameter
169  }
170  _kernel.setArg<cl_float>(idx++, _epsilon);
171 
172  if(output != nullptr)
173  {
174  // Output tensor auto initialization if not yet initialized
175  auto_init_if_empty(*output->info(), *input->info()->clone());
176  }
177 
178  // Configure kernel window
179  if(input->info()->data_layout() == DataLayout::NHWC)
180  {
181  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration));
182  ICLKernel::configure_internal(win);
183  }
184  else
185  {
186  auto win_config = validate_and_configure_window_nchw(input->info(), (_run_in_place) ? nullptr : output->info());
187  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
188  ICLKernel::configure_internal(win_config.second);
189  }
190 
192 
193  _config_id = "batch_normalization_layer_";
194  _config_id += string_from_data_type(input->info()->data_type());
195  _config_id += "_";
196  _config_id += support::cpp11::to_string(input->info()->dimension(0));
197  _config_id += "_";
198  _config_id += support::cpp11::to_string(input->info()->dimension(1));
199  _config_id += "_";
200  _config_id += support::cpp11::to_string(input->info()->dimension(2));
201  _config_id += "_";
202  _config_id += lower_string(string_from_data_layout(input->info()->data_layout()));
203 }
static constexpr unsigned int num_arguments_per_1D_tensor()
Returns the number of arguments enqueued per 1D tensor object.
Definition: ICLKernel.h:297
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
bool enabled() const
Check if initialised.
Definition: Types.h:1694
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
float a() const
Get the alpha value.
Definition: Types.h:1684
std::string to_string(T &&value)
Convert integer and float values to string.
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
const std::string & string_from_activation_func(ActivationLayerInfo::ActivationFunction act)
Translates a given activation function to a string.
Definition: Utils.cpp:163
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
std::string lower_string(const std::string &val)
Lower a given string.
Definition: Utils.cpp:353
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
void add_option(std::string option)
Adds option to the existing build option list.
cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set< std::string > &build_opts=std::set< std::string >())
Creates an opencl kernel using a compile context.
Definition: CLHelpers.cpp:404
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
Definition: Utils.cpp:135
static constexpr unsigned int num_arguments_per_3D_tensor()
Returns the number of arguments enqueued per 3D tensor object.
Definition: ICLKernel.h:313
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
Definition: Utils.h:1124
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
unsigned int num_elems_processed_per_iteration
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
Definition: CLHelpers.cpp:39
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
bool has_padding_changed(const std::unordered_map< const ITensorInfo *, PaddingSize > &padding_map)
Check if the previously stored padding info has changed after configuring a kernel.
Definition: Utils.cpp:603
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
Definition: Utils.cpp:123
Num samples, height, width, channels.
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo *> infos)
Stores padding information before configuring a kernel.
Definition: Utils.cpp:588
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
unsigned int adjust_vec_size(unsigned int vec_size, size_t dim0)
Returns the adjusted vector size in case it is less than the input&#39;s first dimension, getting rounded down to its closest valid vector size.
Definition: Utils.h:1222
ActivationFunction activation() const
Get the type of activation function.
Definition: Types.h:1679
float b() const
Get the beta value.
Definition: Types.h:1689
Describe a multidimensional execution window.
Definition: Window.h:39
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

Default move assignment operator.

◆ run()

void run ( const Window window,
cl::CommandQueue &  queue 
)
overridevirtual

Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.

Note
The queue is not flushed by this method, and therefore the kernel will not have been executed by the time this method returns.
Parameters
[in]windowRegion on which to execute the kernel. (Must be a valid region of the window returned by window()).
[in,out]queueCommand queue on which to enqueue the kernel.

Reimplemented from ICLKernel.

Definition at line 222 of file CLBatchNormalizationLayerKernel.cpp.

References ICLKernel::add_1D_tensor_argument(), ICLKernel::add_3D_tensor_argument(), ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, Window::DimX, arm_compute::enqueue(), Window::first_slice_window_1D(), Window::first_slice_window_3D(), ICLKernel::lws_hint(), ICLKernel::num_arguments_per_3D_tensor(), Window::set(), arm_compute::test::validation::reference::slice(), Window::slide_window_slice_3D(), and IKernel::window().

223 {
226 
228 
229  Window vector_slice = window.first_slice_window_1D();
230  vector_slice.set(Window::DimX, Window::Dimension(0, 0, 0));
231 
232  unsigned int include_output = (!_run_in_place) ? 1 : 0;
233  unsigned int idx = (1 + include_output) * num_arguments_per_3D_tensor();
234  add_1D_tensor_argument(idx, _mean, vector_slice);
235  add_1D_tensor_argument(idx, _var, vector_slice);
236  if(_beta != nullptr)
237  {
238  add_1D_tensor_argument(idx, _beta, vector_slice);
239  }
240  if(_gamma != nullptr)
241  {
242  add_1D_tensor_argument(idx, _gamma, vector_slice);
243  }
244 
245  do
246  {
247  idx = 0;
248  add_3D_tensor_argument(idx, _input, slice);
249  if(!_run_in_place)
250  {
251  add_3D_tensor_argument(idx, _output, slice);
252  }
253  enqueue(queue, *this, slice, lws_hint());
254  }
255  while(window.slide_window_slice_3D(slice));
256 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint=CLKernelLibrary::get().default_ndrange(), bool use_dummy_work_items=false)
Add the kernel to the command queue with the given window.
Definition: ICLKernel.cpp:32
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
Definition: ICLKernel.h:383
Describe one of the image&#39;s dimensions with a start, end and step.
Definition: Window.h:79
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor&#39;s parameters to the object&#39;s kernel&#39;s arguments starting from the index idx...
Definition: ICLKernel.h:226
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
static constexpr unsigned int num_arguments_per_3D_tensor()
Returns the number of arguments enqueued per 3D tensor object.
Definition: ICLKernel.h:313
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:349
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
void add_1D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 1D tensor&#39;s parameters to the object&#39;s kernel&#39;s arguments starting from the index idx...
Definition: ICLKernel.h:178
Window first_slice_window_3D() const
First 3D slice of the window.
Definition: Window.h:305
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201
Window first_slice_window_1D() const
First 1D slice of the window.
Definition: Window.h:289
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const ITensorInfo mean,
const ITensorInfo var,
const ITensorInfo beta = nullptr,
const ITensorInfo gamma = nullptr,
float  epsilon = 0.001f,
ActivationLayerInfo  act_info = ActivationLayerInfo() 
)
static

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

Parameters
[in]inputSource tensor info. In case of output tensor info = nullptr, this tensor will store the result. 3 lower dimensions represent a single input with dimensions [width, height, FM]. The rest are optional and used for representing batches. Data types supported: F16/F32. Data layouts supported: NCHW/NHWC.
[in]outputDestination tensor info. Output will have the same number of dimensions as input. Data type supported: same as input
[in]meanMean values tensor info. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]varVariance values tensor info. 1 dimension with size equal to the feature maps [FM]. Data types supported: Same as input
[in]beta(Optional) Beta values tensor info. 1 dimension with size equal to the feature maps [FM]. If not provided, default value for beta is 0. Data types supported: Same as input
[in]gamma(Optional) Gamma values tensor info. 1 dimension with size equal to the feature maps [FM]. If not provided, default value for gamma is 1. Data types supported: Same as input
[in]epsilon(Optional) Small value to avoid division with zero. Default value is 0.001f.
[in]act_info(Optional) Activation layer information in case of a fused activation. Only RELU, BOUNDED_RELU and LU_BOUNDED_RELU supported.
Returns
a status

Definition at line 205 of file CLBatchNormalizationLayerKernel.cpp.

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

Referenced by CLBatchNormalizationLayer::validate().

209 {
210  const bool run_in_place = (output == nullptr) || (output == input);
211  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, mean, var, beta, gamma, epsilon, act_info));
212 
213  if(input->data_layout() != DataLayout::NHWC)
214  {
215  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_nchw(input->clone().get(), (run_in_place) ? nullptr : output->clone().get())
216  .first);
217  }
218 
219  return Status{};
220 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
Status class.
Definition: Error.h:52
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
Num samples, height, width, channels.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

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