23.11
|
Go to the documentation of this file.
46 const ITensorInfo *block_info,
47 const ITensorInfo *paddings,
48 const ITensorInfo *output)
60 if (output->total_size() != 0)
71 Status validate_arguments_static(
const ITensorInfo *
input,
72 const int block_shape_x,
73 const int block_shape_y,
74 const Size2D &padding_left,
75 const Size2D &padding_right,
76 const ITensorInfo *output)
84 if (output->total_size() != 0)
87 input, block_shape_x, block_shape_y, padding_left, padding_right);
99 _block_shape(nullptr),
119 _block_shape = block_shape;
120 _paddings = paddings;
122 _data_layout =
input->info()->data_layout();
126 ICPPKernel::configure(win);
130 const int block_shape_x,
131 const int block_shape_y,
132 const Size2D &padding_left,
133 const Size2D &padding_right,
139 input->info(), block_shape_x, block_shape_y, padding_left, padding_right);
141 input->info()->quantization_info());
144 padding_right, output->
info()));
148 _block_shape_x = block_shape_x;
149 _block_shape_y = block_shape_y;
150 _padding_left = padding_left;
151 _data_layout =
input->info()->data_layout();
155 INEKernel::configure(win);
167 const int block_shape_x,
168 const int block_shape_y,
169 const Size2D &padding_left,
170 const Size2D &padding_right,
174 validate_arguments_static(
input, block_shape_x, block_shape_y, padding_left, padding_right, output));
184 if (_block_shape !=
nullptr)
187 _block_shape_x = *(
reinterpret_cast<const int *
>(_block_shape->
ptr_to_element(0)));
188 _block_shape_y = *(
reinterpret_cast<const int *
>(_block_shape->
ptr_to_element(1)));
191 if (_paddings !=
nullptr)
193 const size_t pad_left_x = *
reinterpret_cast<const size_t *
>(_paddings->
ptr_to_element({0, 0}));
194 const size_t pad_left_y = *
reinterpret_cast<const size_t *
>(_paddings->
ptr_to_element({1, 0}));
195 _padding_left =
Size2D(pad_left_x, pad_left_y);
204 const size_t batch_size = _input->
info()->
dimension(batch_idx);
220 const size_t out_x =
id.
x();
221 const size_t out_y =
id.y();
222 const size_t z =
id.z();
223 const size_t pos_x = out_x * _block_shape_x + (batch_id / batch_size) % _block_shape_x;
224 const size_t pos_y = out_y * _block_shape_y + (batch_id / batch_size) / _block_shape_x;
225 if (pos_y >= _padding_left.
y() && pos_y < _padding_left.
y() + height &&
226 pos_x >= _padding_left.
x() && pos_x < _padding_left.
x() + width)
228 const int w = batch_id % batch_size;
229 const int in_x = pos_x - _padding_left.
x();
230 const int in_y = pos_y - _padding_left.
y();
248 const size_t out_x =
id.
y();
249 const size_t out_y =
id.z();
250 const size_t z =
id.x();
251 const size_t pos_x = out_x * _block_shape_x + (batch_id / batch_size) % _block_shape_x;
252 const size_t pos_y = out_y * _block_shape_y + (batch_id / batch_size) / _block_shape_x;
253 if (pos_y >= _padding_left.
y() && pos_y < _padding_left.
y() + height &&
254 pos_x >= _padding_left.
x() && pos_x < _padding_left.
x() + width)
256 const int w = batch_id % batch_size;
257 const int in_x = pos_x - _padding_left.
x();
258 const int in_y = pos_y - _padding_left.
y();
@ NCHW
Num samples, channels, height, width.
Class to describe a number of elements in each dimension.
size_t y() const
Semantic accessor for height as y.
DataLayout
[DataLayout enum definition]
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
Class for specifying the size of an image or rectangle.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Interface for CPU tensor.
Includes all wrapper headers at once.
#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.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&...iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Iterator updated by execute_window_loop for each window element.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
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...
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
void configure(const ITensor *input, const ITensor *block_shape, const ITensor *paddings, ITensor *output)
Initialise the kernel's inputs and output.
size_t x() const
Semantic accessor for width as x.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
TensorShape compute_space_to_batch_shape(const ITensorInfo *input, int block_x, int block_y, const Size2D &padding_left, const Size2D &padding_right)
Calculate the space to batch output shape of a tensor.
Window first_slice_window_3D() const
First 3D slice of the window.
const Window & window() const
The maximum window the kernel can be executed on.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(...)
Information about executing thread and CPU.
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
static Status validate(const ITensorInfo *input, const ITensorInfo *block_shape, const ITensorInfo *paddings, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NESpaceToBatchLayerKerne...
NESpaceToBatchLayerKernel()
Default constructor.
Describe a multidimensional execution window.
Copyright (c) 2017-2023 Arm Limited.
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...)
@ UNKNOWN
Unknown CL kernel type.
@ S32
signed 32-bit number
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Store the tensor's metadata.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
@ UNKNOWN
Unknown data type.
constexpr const Dimension & x() const
Alias to access the first dimension of the window.