23.11
|
Go to the documentation of this file.
43 const ITensorInfo *output,
44 const Coordinates &starts,
45 const Coordinates &ends,
49 int32_t shrink_axis_mask)
59 std::any_of(strides.cbegin(), strides.cbegin() + strides.num_dimensions(), [](
int i) { return i == 0; }));
63 *
input, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask);
67 if (output->total_size() != 0)
69 const TensorInfo exp_output_info = output->clone()->set_tensor_shape(exp_output_shape);
79 const Coordinates &starts,
80 const Coordinates &ends,
84 int32_t shrink_axis_mask)
88 *
input, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask);
94 return std::make_pair(Status{}, win);
109 int32_t shrink_axis_mask)
114 _shrink_mask = shrink_axis_mask;
117 std::tie(_starts_abs, ends_abs, _final_strides) =
119 begin_mask, end_mask, shrink_axis_mask);
124 INEKernel::configure(win_config.second);
134 int32_t shrink_axis_mask)
139 strides, begin_mask, end_mask, shrink_axis_mask)
154 size_t width_size =
input->info()->element_size();
161 unsigned int index = 0;
162 const int idx_x = is_shrink_x ? 0 : index++;
163 const int idx_y = is_shrink_y ? 0 : index++;
164 const int idx_z = is_shrink_z ? 0 : index++;
165 const int idx_w = is_shrink_w ? 0 : index;
168 shrinked_strides.
set(0, is_shrink_x ? 0 : _final_strides[0]);
169 shrinked_strides.
set(1, is_shrink_y ? 0 : _final_strides[1]);
170 shrinked_strides.
set(2, is_shrink_z ? 0 : _final_strides[2]);
171 shrinked_strides.
set(3, is_shrink_w ? 0 : _final_strides[3]);
175 size_t length_x = win.
shape()[0];
177 if (_final_strides[0] == 1 && !is_shrink_x)
180 width_size = width_size * length_x;
185 const int start_0 = _starts_abs[0];
186 const int start_1 = _starts_abs[1];
187 const int start_2 = _starts_abs[2];
188 const int start_3 = _starts_abs[3];
190 const int shrinked_stride_0 = shrinked_strides[0];
191 const int shrinked_stride_1 = shrinked_strides[1];
192 const int shrinked_stride_2 = shrinked_strides[2];
193 const int shrinked_stride_3 = shrinked_strides[3];
195 const int byte_increment_0 =
static_cast<int>(
input->info()->strides_in_bytes()[0]);
196 const int byte_increment_1 =
static_cast<int>(
input->info()->strides_in_bytes()[1]);
197 const int byte_increment_2 =
static_cast<int>(
input->info()->strides_in_bytes()[2]);
198 const int byte_increment_3 =
static_cast<int>(
input->info()->strides_in_bytes()[3]);
207 cur_ptr = input_base;
208 cur_ptr += (start_0 + (
id[idx_x] * shrinked_stride_0)) * byte_increment_0;
209 cur_ptr += (start_1 + (
id[idx_y] * shrinked_stride_1)) * byte_increment_1;
210 cur_ptr += (start_2 + (
id[idx_z] * shrinked_stride_2)) * byte_increment_2;
211 cur_ptr += (start_3 + (
id[idx_w] * shrinked_stride_3)) * byte_increment_3;
213 std::copy_n(cur_ptr, width_size, output_it.
ptr());
TensorShape compute_strided_slice_shape(const ITensorInfo &input, const Coordinates &starts, const Coordinates &ends, const Coordinates &strides, int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask)
Calculate the strided slice output shape of a tensor.
Coordinates BiStrides
Bidirectional strides.
void set(size_t dimension, T value, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
void configure(const ITensorInfo *input, ITensorInfo *output, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask)
Configure kernel.
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)
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends, const BiStrides &strides, int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask)
Static function to check if given info will lead to a valid configuration of NEStridedSliceKernel.
Interface for CPU tensor.
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
#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...
bool is_bit_set(T v, unsigned int idx)
Checks if the idx-th bit is set in an integral type.
TensorShape shape() const
Return the shape of the window in number of steps.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *src, ITensorInfo *dst)
NEStridedSliceKernel()
Default constructor.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Describe one of the image's dimensions with a start, end and step.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
TensorShape input_shape
Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros we use to check the validity of given a...
const Window & window() const
The maximum window the kernel can be executed on.
Information about executing thread and CPU.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
Describe a multidimensional execution window.
Copyright (c) 2017-2023 Arm Limited.
#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.