44 Status
validate_arguments(
const ITensorInfo *
input,
const ITensorInfo *block_info,
const ITensorInfo *paddings,
const ITensorInfo *output)
56 if(output->total_size() != 0)
67 Status validate_arguments_static(
const ITensorInfo *
input,
const int block_shape_x,
const int block_shape_y,
const Size2D &padding_left,
const Size2D &padding_right,
68 const ITensorInfo *output)
76 if(output->total_size() != 0)
89 : _input(nullptr), _block_shape(nullptr), _paddings(nullptr), _output(nullptr), _data_layout(
DataLayout::
UNKNOWN), _padding_left(), _block_shape_x(), _block_shape_y()
99 _block_shape = block_shape;
100 _paddings = paddings;
102 _data_layout =
input->info()->data_layout();
106 ICPPKernel::configure(win);
121 _block_shape_x = block_shape_x;
122 _block_shape_y = block_shape_y;
123 _padding_left = padding_left;
124 _data_layout =
input->info()->data_layout();
128 INEKernel::configure(win);
149 if(_block_shape !=
nullptr)
152 _block_shape_x = *(reinterpret_cast<const int *>(_block_shape->
ptr_to_element(0)));
153 _block_shape_y = *(reinterpret_cast<const int *>(_block_shape->
ptr_to_element(1)));
156 if(_paddings !=
nullptr)
158 const size_t pad_left_x = *reinterpret_cast<const size_t *>(_paddings->
ptr_to_element({ 0, 0 }));
159 const size_t pad_left_y = *reinterpret_cast<const size_t *>(_paddings->
ptr_to_element({ 1, 0 }));
160 _padding_left =
Size2D(pad_left_x, pad_left_y);
169 const size_t batch_size = _input->
info()->
dimension(batch_idx);
183 const size_t out_x =
id.
x();
184 const size_t out_y =
id.y();
185 const size_t z =
id.z();
186 const size_t pos_x = out_x * _block_shape_x + (batch_id / batch_size) % _block_shape_x;
187 const size_t pos_y = out_y * _block_shape_y + (batch_id / batch_size) / _block_shape_x;
188 if(pos_y >= _padding_left.
y() && pos_y < _padding_left.
y() + height && pos_x >= _padding_left.
x() && pos_x < _padding_left.
x() + width)
190 const int w = batch_id % batch_size;
191 const int in_x = pos_x - _padding_left.
x();
192 const int in_y = pos_y - _padding_left.
y();
209 const size_t out_x =
id.
y();
210 const size_t out_y =
id.z();
211 const size_t z =
id.x();
212 const size_t pos_x = out_x * _block_shape_x + (batch_id / batch_size) % _block_shape_x;
213 const size_t pos_y = out_y * _block_shape_y + (batch_id / batch_size) / _block_shape_x;
214 if(pos_y >= _padding_left.
y() && pos_y < _padding_left.
y() + height && pos_x >= _padding_left.
x() && pos_x < _padding_left.
x() + width)
216 const int w = batch_id % batch_size;
217 const int in_x = pos_x - _padding_left.
x();
218 const int in_y = pos_y - _padding_left.
y();
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
const Window & window() const
The maximum window the kernel can be executed on.
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(...)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
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...
TensorShape compute_space_to_batch_shape(const ITensorInfo *input, const int block_x, const int block_y, const Size2D &padding_left, const Size2D &padding_right)
Calculate the space to batch output shape of a tensor.
const DataLayout data_layout
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
size_t x() const
Semantic accessor for width as x.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Interface for CPU tensor.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...)
Copyright (c) 2017-2021 Arm Limited.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
1 channel, 1 S32 per channel
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
void configure(const ITensor *input, const ITensor *block_shape, const ITensor *paddings, ITensor *output)
Initialise the kernel's inputs and output.
Class to describe a number of elements in each dimension.
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 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.
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Num samples, channels, height, width.
size_t y() const
Semantic accessor for height as y.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
Class for specifying the size of an image or rectangle.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
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...
Includes all wrapper headers at once.
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Iterator updated by execute_window_loop for each window element.
Window first_slice_window_3D() const
First 3D slice of the window.
DataLayout
[DataLayout enum definition]
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
NESpaceToBatchLayerKernel()
Default constructor.
constexpr const Dimension & x() const
Alias to access the first dimension of the window.