24.02.1
|
Go to the documentation of this file.
55 (pool_info.stride.x() == 0 || pool_info.stride.y() == 0 || pool_info.stride.z() == 0),
56 "Strides cannot be zero.");
61 "Exclude padding is unsupported for non-float types for Avg op");
67 const bool is_global_pooling = pool_info.is_global_pooling;
68 const unsigned int pool_size_x = is_global_pooling ?
src->dimension(
idx_width) : pool_info.pool_size.width;
69 const unsigned int pool_size_y = is_global_pooling ?
src->dimension(
idx_height) : pool_info.pool_size.height;
70 const unsigned int pool_size_z = is_global_pooling ?
src->dimension(idx_depth) : pool_info.pool_size.depth;
72 int output_height = 0;
75 bool round_type_ceil_with_asymm_padding =
78 "Cannot use dimension round type CEIL when padding is asymmetric.");
81 "Pooling region that is entirely outside input tensor is unsupported");
82 std::tie(output_width, output_height, output_depth) =
84 src->tensor_shape()[idx_depth], pool_size_x, pool_size_y, pool_size_z, pool_info);
87 "Calculated output dimension size is invalid");
89 if (
dst->total_size() != 0)
120 _pool_info = pool_info;
121 _data_layout =
src->data_layout();
123 _num_elems_processed_per_iteration = (
dst->data_type() ==
DataType::F32) ? 2 : 4;
124 _num_elems_processed_per_iteration =
adjust_vec_size(_num_elems_processed_per_iteration,
dst->dimension(0));
136 const int pool_stride_x = pool_info.
stride.
x();
137 const int pool_stride_y = pool_info.
stride.
y();
138 const int pool_stride_z = pool_info.
stride.
z();
139 const int pool_pad_top = pool_info.
padding.
top;
196 const auto use_fp_mixed_precision =
202 if (use_fp_mixed_precision)
213 build_opts.
add_option_if(use_fp_mixed_precision,
"-DFP_MIXED_PRECISION");
214 build_opts.
add_option_if(exclude_padding,
"-DEXCLUDE_PADDING");
219 build_opts.
add_option(
"-DVEC_SIZE_LEFTOVER=" +
224 :
"pooling_3d_layer_MxN_ndhwc");
229 ICLKernel::configure_internal(win);
232 _config_id =
"pooling_layer_3d";
267 unsigned int idx = 0;
269 add_5D_tensor_argument(idx,
src, window);
270 add_5D_tensor_argument(idx,
dst, window);
271 enqueue(queue, *
this, window_collapsed, lws_hint());
Class to describe a number of elements in each dimension.
TensorShape compute_pool3d_shape(const TensorShape &src, Pooling3dLayerInfo pool3d_info)
Calculate the output pool3d shape of a tensor.
std::string to_string(T &&value)
Convert integer and float values to string.
SimpleTensor< float > src
const std::string & string_from_pooling_type(PoolingType type)
Translates a given pooling type to a string.
bool is_pool_3d_region_entirely_outside_input(const Pooling3dLayerInfo &info)
Check if the 3d pool region is entirely outside the input tensor.
Class describing the value of a pixel for any image format.
const StringSet & options() const
Gets the current options list set.
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
@ POOL
Pool CL kernel type.
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
std::string lower_string(const std::string &val)
Lower a given string.
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
bool is_symmetric(const Padding3D &info)
Check if the 3D padding is symmetric i.e.
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.
size_t x() const
Semantic accessor for width as x.
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
size_t width
Width of the 3D shape or object.
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
constexpr auto data_layout
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
size_t y() const
Semantic accessor for height as y.
size_t height
Height of the 3D shape or object.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
size_t depth
Depth of the 3D shape or object.
void add_option(std::string option)
Adds option to the existing build option list.
size_t top
Padding across the height dimenstion on the top, in elements.
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...
#define ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(tensor)
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.
@ QASYMM8_SIGNED
quantized, asymmetric fixed-point 8-bit number signed
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
PoolingType
Available pooling types.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
size_t front
Padding across the depth dimenstion on the front, in elements.
size_t z() const
Semantic accessor for depth as z.
Pooling Layer Information struct.
const Window & window() const
The maximum window the kernel can be executed on.
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
size_t left
Padding across the width dimenstion on the left, in elements.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const Pooling3dLayerInfo &pool_info)
Static function to check if given info will lead to a valid configuration.
Describe a multidimensional execution window.
void configure(const ClCompileContext &compile_context, const ITensorInfo *src, ITensorInfo *dst, const Pooling3dLayerInfo &pool_info)
Configure kernel for a given list of arguments.
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_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2024 Arm Limited.
std::tuple< int, int, int > scaled_3d_dimensions_signed(int width, int height, int depth, int kernel_width, int kernel_height, int kernel_depth, const Pooling3dLayerInfo &pool3d_info)
Returns calculated width, height and depth of output scaled tensor depending on dimensions rounding m...
@ F16
16-bit floating-point number
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's first dimension,...
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.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
@ S32
signed 32-bit number
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Store the tensor's metadata.
@ F32
32-bit floating-point number
std::tuple< PixelValue, PixelValue > get_min_max(DataType dt)
Compute the mininum and maximum values a data type can take.
DataType
Available data types.
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo * > infos)
Stores padding information before configuring a kernel.
@ NDHWC
Num samples, depth, height, width, channels.
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.