Compute Library
 21.11
ClPool2dKernel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
25 
29 #include "src/core/CL/CLValidate.h"
32 #include "support/Cast.h"
33 
34 namespace arm_compute
35 {
36 namespace opencl
37 {
38 namespace kernels
39 {
41 
42 namespace
43 {
44 Status validate_arguments(const ITensorInfo *src, const ITensorInfo *dst, const PoolingLayerInfo &pool_info, const ITensorInfo *indices)
45 {
49  ARM_COMPUTE_RETURN_ERROR_ON_MSG((is_data_type_quantized_asymmetric(src->data_type()) && pool_info.pool_type == PoolingType::L2),
50  "Unsupported combination of parameters!");
51 
52  const auto data_layout = pool_info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : pool_info.data_layout;
55  const bool is_global_pooling = pool_info.is_global_pooling;
56  unsigned int pool_size_x = is_global_pooling ? src->dimension(idx_width) : pool_info.pool_size.width;
57  unsigned int pool_size_y = is_global_pooling ? src->dimension(idx_height) : pool_info.pool_size.height;
58  int output_width = 0;
59  int output_height = 0;
60  std::tie(output_width, output_height) = scaled_dimensions_signed(src->tensor_shape()[idx_width], src->tensor_shape()[idx_height],
61  pool_size_x, pool_size_y, pool_info.pad_stride_info);
62  ARM_COMPUTE_RETURN_ERROR_ON_MSG((output_width < 1 || output_height < 1), "Calculated output dimension size is invalid");
63 
64  // Check indices
65  if(indices)
66  {
68  ARM_COMPUTE_RETURN_ERROR_ON_MSG(pool_info.pool_type != PoolingType::MAX, "Pooling indices only supported for MAX pooling method");
69  ARM_COMPUTE_RETURN_ERROR_ON_MSG((pool_info.pool_size != Size2D(2, 2)), "Pooling indices only supported for pool size 2x2");
70 
71  if(indices->total_size() != 0)
72  {
73  TensorInfo idx_info(TensorInfo(compute_pool_shape(*src, pool_info), 1, DataType::U32));
75  }
76  }
77 
78  // Checks performed when dst is configured
79  if(dst->total_size() != 0)
80  {
83  TensorInfo out_info(TensorInfo(compute_pool_shape(*src, pool_info), 1, dst->data_type()));
85  }
86 
87  return Status{};
88 }
89 } // namespace
90 
92 {
93  _type = CLKernelType::POOL;
94 }
95 
96 void ClPool2dKernel::configure(const ClCompileContext &compile_context, ITensorInfo *src, ITensorInfo *dst, const PoolingLayerInfo &pool_info, ITensorInfo *indices)
97 {
99  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst, pool_info, indices));
100 
101  auto padding_info = get_padding_info({ src, dst, indices });
102 
103  // Auto init if empty
104  TensorShape out_shape = compute_pool_shape(*src, pool_info);
105  auto_init_if_empty(*dst, src->clone()->set_tensor_shape(out_shape));
106  if(indices)
107  {
108  auto_init_if_empty(*indices, src->clone()->set_tensor_shape(out_shape).set_data_type(DataType::U32));
109  }
110 
111  // Set instance variables
112  _pool_info = pool_info;
113  _data_layout = pool_info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : pool_info.data_layout;
114  _num_elems_processed_per_iteration = (_data_layout == DataLayout::NCHW) ? 1 : ((dst->data_type() == DataType::F32) ? 2 : 4);
115  _num_elems_processed_per_iteration = adjust_vec_size(_num_elems_processed_per_iteration, dst->dimension(0));
116 
117  int pool_stride_x = 0;
118  int pool_stride_y = 0;
119  const PoolingType pool_type = pool_info.pool_type;
120  const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH);
121  const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
122  const int idx_channel = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL);
123  const int idx_batch_size = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::BATCHES);
124  const int pool_size_x = pool_info.is_global_pooling ? src->dimension(idx_width) : pool_info.pool_size.width;
125  const int pool_size_y = pool_info.is_global_pooling ? src->dimension(idx_height) : pool_info.pool_size.height;
126  const PadStrideInfo pad_stride_info = pool_info.pad_stride_info;
127  const bool exclude_padding = pool_info.exclude_padding;
128  std::tie(pool_stride_x, pool_stride_y) = pad_stride_info.stride();
129  const int pool_pad_top = pad_stride_info.pad_top();
130  const int pool_pad_left = pad_stride_info.pad_left();
131  const DataType data_type = src->data_type();
132 
133  // Set build options
134  CLBuildOptions build_opts;
135  build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(_num_elems_processed_per_iteration));
136  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type));
137  build_opts.add_option("-DPOOL_" + string_from_pooling_type(pool_type));
138  build_opts.add_option("-DSTRIDE_X=" + support::cpp11::to_string(pool_stride_x));
139  build_opts.add_option("-DSTRIDE_Y=" + support::cpp11::to_string(pool_stride_y));
140  build_opts.add_option("-DPAD_X=" + support::cpp11::to_string(pool_pad_left));
141  build_opts.add_option("-DPAD_Y=" + support::cpp11::to_string(pool_pad_top));
142  build_opts.add_option("-DPOOL_SIZE_X=" + support::cpp11::to_string(pool_size_x));
143  build_opts.add_option("-DPOOL_SIZE_Y=" + support::cpp11::to_string(pool_size_y));
144  build_opts.add_option("-DSRC_WIDTH=" + support::cpp11::to_string(src->dimension(idx_width)));
145  build_opts.add_option("-DSRC_HEIGHT=" + support::cpp11::to_string(src->dimension(idx_height)));
146  build_opts.add_option("-DMAX_WIDTH=" + support::cpp11::to_string(src->dimension(idx_width) + (exclude_padding ? 0 : pool_pad_left)));
147  build_opts.add_option("-DMAX_HEIGHT=" + support::cpp11::to_string(src->dimension(idx_height) + (exclude_padding ? 0 : pool_pad_top)));
148 
149  // Tensor paddings are used to calculate the indicies for MAX pooling
150  if(pool_info.pool_size == Size2D(2, 2) && pool_type == PoolingType::MAX && indices && is_data_type_float(data_type))
151  {
152  build_opts.add_option("-DSRC_BATCH=" + support::cpp11::to_string(src->tensor_shape().total_size_lower(3)));
153  }
154 
155  if(is_data_type_quantized_asymmetric(data_type))
156  {
157  build_opts.add_option("-DQUANTIZED");
158 
159  if(src->quantization_info() != dst->quantization_info())
160  {
161  const UniformQuantizationInfo iq_info = src->quantization_info().uniform();
162  const UniformQuantizationInfo oq_info = dst->quantization_info().uniform();
163 
164  build_opts.add_option("-DOFFSET_IN1=" + float_to_string_with_full_precision(iq_info.offset));
165  build_opts.add_option("-DOFFSET_OUT=" + float_to_string_with_full_precision(oq_info.offset));
166  build_opts.add_option("-DSCALE_IN1=" + float_to_string_with_full_precision(iq_info.scale));
167  build_opts.add_option("-DSCALE_OUT=" + float_to_string_with_full_precision(oq_info.scale));
168  }
169  }
170 
171  // Set the initial value for the pooling operation accordingly with the data type
172  if(pool_type == PoolingType::MAX)
173  {
174  if(is_data_type_quantized(data_type))
175  {
176  PixelValue type_min{};
177  std::tie(type_min, std::ignore) = get_min_max(data_type);
178  build_opts.add_option("-DINITIAL_VALUE=" + support::cpp11::to_string(type_min.get<int32_t>()));
179  }
180  else
181  {
183  }
184  }
185  else
186  {
187  // Pool AVG and Pool L2 initial value
188  build_opts.add_option("-DINITIAL_VALUE=0");
189  }
190 
191  // Create kernel
192  switch(_data_layout)
193  {
194  case DataLayout::NCHW:
195  {
196  const auto use_fp_mixed_precision = (data_type == DataType::F16) && pool_info.fp_mixed_precision;
197  const auto use_wider_accumulator = use_fp_mixed_precision && (pool_type != PoolingType::MAX);
198  const auto acc_data_type = get_cl_type_from_data_type(use_wider_accumulator ? DataType::F32 : (is_data_type_quantized(data_type) ? DataType::S32 : data_type));
199  build_opts.add_option("-DACC_DATA_TYPE=" + acc_data_type);
200  build_opts.add_option_if(use_wider_accumulator, "-DFP_MIXED_PRECISION");
201 
202  if(pool_type != PoolingType::MAX)
203  {
204  build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING");
205  }
206 
207  if(pool_info.pool_size == Size2D(2, 2) && pool_type == PoolingType::MAX && indices && is_data_type_float(data_type))
208  {
209  // For max pooling with pool2x2, store indicies which will be used in max unpooling
210  std::string kernel_name = "pooling_layer_2_nchw_indices";
211  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
212  }
213  else // Run general case
214  {
215  std::string kernel_name = "pooling_layer_MxN_nchw";
216  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
217  }
218  break;
219  }
220  case DataLayout::NHWC:
221  {
222  // Floating point mixed precision is support on F16 only
223  const auto use_fp_mixed_precision = (data_type == DataType::F16) && pool_info.fp_mixed_precision && pool_type != PoolingType::MAX;
224 
225  // Wider accumulation is required to avoid accuracy loss
226  // Case 1: Floating point mixed precision (fp16 src data and fp32 accumulation)
227  // Cast 2: Quantized (int8/uint8 src data and int32 accumulation )
228  DataType acc_data_type = data_type;
229 
230  if(use_fp_mixed_precision)
231  {
232  acc_data_type = DataType::F32;
233  }
234  else if(is_data_type_quantized(data_type) && pool_type != PoolingType::MAX)
235  {
236  acc_data_type = DataType::S32;
237  }
238 
239  build_opts.add_option("-DACC_DATA_TYPE=" + get_cl_type_from_data_type(acc_data_type));
240  build_opts.add_option_if(use_fp_mixed_precision, "-DFP_MIXED_PRECISION");
241  build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING");
242  build_opts.add_option("-DSRC_WIDTH=" + support::cpp11::to_string(src->dimension(idx_width)));
243  build_opts.add_option("-DSRC_HEIGHT=" + support::cpp11::to_string(src->dimension(idx_height)));
244  build_opts.add_option("-DDST_HEIGHT=" + support::cpp11::to_string(dst->dimension(idx_height)));
245  build_opts.add_option("-DDST_CHANNELS=" + support::cpp11::to_string(dst->dimension(idx_channel)));
246  build_opts.add_option("-DDST_BATCH_SIZE=" + support::cpp11::to_string(dst->dimension(idx_batch_size)));
247  build_opts.add_option("-DVEC_SIZE_LEFTOVER=" + support::cpp11::to_string(src->dimension(0) % _num_elems_processed_per_iteration));
248  if(pool_info.pool_size == Size2D(2, 2) && is_data_type_float(data_type))
249  {
250  build_opts.add_option_if(indices != nullptr && pool_type == PoolingType::MAX, "-DEXTRACT_MAX_INDEX");
251 
252  std::string kernel_name = "pooling_layer_2x2_nhwc";
253  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
254  }
255  else
256  {
257  std::string kernel_name = is_data_type_quantized_asymmetric(data_type) ? "pooling_layer_MxN_quantized_nhwc" : "pooling_layer_MxN_nhwc";
258  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
259  }
260  break;
261  }
262  default:
263  ARM_COMPUTE_ERROR("Not implemented");
264  }
265 
266  // Configure kernel window
267  Window win = calculate_max_window(*dst, Steps(_num_elems_processed_per_iteration));
268  ICLKernel::configure_internal(win);
269 
270  // Set config_id for enabling LWS tuning
271  _config_id = "pooling_layer_";
272  _config_id += lower_string(string_from_data_type(data_type));
273  _config_id += "_";
274  _config_id += lower_string(string_from_data_layout(_data_layout));
275  _config_id += "_";
276  _config_id += support::cpp11::to_string(dst->dimension(idx_width));
277  _config_id += "_";
278  _config_id += support::cpp11::to_string(dst->dimension(idx_height));
279  _config_id += "_";
280  _config_id += support::cpp11::to_string(dst->dimension(idx_channel));
281  _config_id += "_";
282  _config_id += lower_string(string_from_data_layout(src->data_layout()));
283 
285 }
286 
287 Status ClPool2dKernel::validate(const ITensorInfo *src, const ITensorInfo *dst, const PoolingLayerInfo &pool_info, const ITensorInfo *indices)
288 {
289  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, dst, pool_info, indices));
290  return Status{};
291 }
292 
293 void ClPool2dKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
294 {
297 
298  unsigned int pool_stride_x = 0;
299  unsigned int pool_stride_y = 0;
300  std::tie(pool_stride_x, pool_stride_y) = _pool_info.pad_stride_info.stride();
301 
302  const auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
303  auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST_0));
304  auto indices = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST_1));
305 
306  // Collapse window
307  Window window_collapsed = window.collapse_if_possible(ICLKernel::window(), Window::DimZ);
308 
309  switch(_data_layout)
310  {
311  case DataLayout::NCHW:
312  {
313  Window slice = window_collapsed.first_slice_window_3D();
314  do
315  {
316  // Set srcs
317  unsigned int idx = 0;
318  add_3D_tensor_argument(idx, src, slice);
319  add_3D_tensor_argument(idx, dst, slice);
320  if(indices && is_data_type_float(src->info()->data_type()) && (_pool_info.pool_size == Size2D(2, 2)))
321  {
322  add_3D_tensor_argument(idx, indices, slice);
323  }
324  enqueue(queue, *this, slice, lws_hint());
325  }
326  while(window_collapsed.slide_window_slice_3D(slice));
327  break;
328  }
329  case DataLayout::NHWC:
330  {
331  const size_t batch_size = dst->info()->tensor_shape().total_size_upper(3);
332 
333  Window slice = window_collapsed.first_slice_window_4D();
334  Window in_slice = window_collapsed.first_slice_window_4D();
335  in_slice.set(Window::DimX, Window::Dimension(0, src->info()->dimension(0), _num_elems_processed_per_iteration));
336  in_slice.set(Window::DimY, Window::Dimension(0, src->info()->dimension(1), pool_stride_x));
337  in_slice.set(Window::DimZ, Window::Dimension(0, src->info()->dimension(2), pool_stride_y));
338  in_slice.set(3, Window::Dimension(0, batch_size, 1));
339  do
340  {
341  // Set srcs
342  unsigned int idx = 0;
343  add_4D_tensor_argument(idx, src, in_slice);
344  add_4D_tensor_argument(idx, dst, slice);
345  if(indices && is_data_type_float(src->info()->data_type()) && (_pool_info.pool_type == PoolingType::MAX) && (_pool_info.pool_size == Size2D(2, 2)))
346  {
347  add_4D_tensor_argument(idx, indices, slice);
348  }
349  enqueue(queue, *this, slice, lws_hint());
350  }
351  while(window.slide_window_slice_4D(slice) && window.slide_window_slice_4D(in_slice));
352  break;
353  }
354  default:
355  ARM_COMPUTE_ERROR("Not implemented");
356  }
357 }
358 } // namespace kernels
359 } // namespace opencl
360 } // namespace arm_compute
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:981
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(tensor)
Definition: CLValidate.h:35
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
Shape of a tensor.
Definition: TensorShape.h:39
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
Definition: Validate.h:490
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
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
const StringSet & options() const
Gets the current options list set.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
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.
1 channel, 1 F32 per channel
#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
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Quantization info when assuming per layer quantization.
Describe one of the image&#39;s dimensions with a start, end and step.
Definition: Window.h:77
unsigned int pad_top() const
Get the top padding.
Definition: Types.h:740
Status class.
Definition: Error.h:52
std::string lower_string(const std::string &val)
Lower a given string.
Definition: Utils.cpp:326
size_t total_size_lower(size_t dimension) const
Compute size of dimensions lower than the given one.
Definition: TensorShape.h:194
SimpleTensor< float > src
Definition: DFT.cpp:155
Copyright (c) 2017-2021 Arm Limited.
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:91
1 channel, 1 F16 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
1 channel, 1 S32 per channel
void add_option(std::string option)
Adds option to the existing build option list.
std::pair< int, int > scaled_dimensions_signed(int width, int height, int kernel_width, int kernel_height, const PadStrideInfo &pad_stride_info)
Returns calculated width and height of output scaled tensor depending on dimensions rounding mode...
Definition: Utils.cpp:429
TensorShape compute_pool_shape(const ITensorInfo &input, PoolingLayerInfo pool_info)
Calculate the output pool shape of a tensor.
const DataType data_type
Definition: Im2Col.cpp:150
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
Definition: ITensorPack.cpp:54
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:391
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
Definition: Utils.cpp:135
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
Definition: Window.inl:68
1 channel, 1 U32 per channel
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
Definition: Utils.h:1075
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
quantized, asymmetric fixed-point 8-bit number unsigned
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
Definition: Types.h:704
Pooling Layer Information struct.
Definition: Types.h:1173
Pool CL kernel type.
Definition: CLTypes.h:86
UniformQuantizationInfo uniform() const
Return per layer quantization info.
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.
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
Padding and stride information class.
Definition: Types.h:656
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
void configure(const ClCompileContext &compile_context, ITensorInfo *src, ITensorInfo *dst, const PoolingLayerInfo &pool_info, ITensorInfo *indices=nullptr)
Configure kernel for a given list of arguments.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
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:533
Num samples, channels, height, width.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const PoolingLayerInfo &pool_info, const ITensorInfo *indices=nullptr)
Static function to check if given info will lead to a valid configuration.
CLCompileContext class.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1003
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
PoolingType
Available pooling types.
Definition: Types.h:544
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
Definition: ITensorPack.cpp:64
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
Definition: Utils.cpp:123
PadStrideInfo pad_stride_info
Definition: Types.h:1261
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:439
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:90
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:193
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:541
Num samples, height, width, channels.
int pool_stride_x
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:788
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:518
Window first_slice_window_4D() const
First 4D slice of the window.
Definition: Window.h:299
bool slide_window_slice_4D(Window &slice) const
Slide the passed 4D window slice.
Definition: Window.h:347
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Definition: Error.h:244
Tensor packing service.
Definition: ITensorPack.h:39
#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:1171
quantized, asymmetric fixed-point 8-bit number signed
std::string kernel_name
DataType
Available data types.
Definition: Types.h:79
unsigned int pad_left() const
Get the left padding.
Definition: Types.h:730
const std::string & string_from_pooling_type(PoolingType type)
Translates a given pooling type to a string.
Definition: Utils.cpp:223
std::tuple< PixelValue, PixelValue > get_min_max(DataType dt)
Compute the mininum and maximum values a data type can take.
Definition: Utils.h:564
Describe a multidimensional execution window.
Definition: Window.h:39
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
Definition: Utils.h:961
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.