42 const Coordinates &starts,
const Coordinates &ends,
const BiStrides &strides,
43 int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask)
59 starts, ends, strides,
60 begin_mask, end_mask, shrink_axis_mask);
64 if(output->total_size() != 0)
66 const TensorInfo exp_output_info = output->clone()->set_tensor_shape(exp_output_shape);
74 std::pair<Status, Window> validate_and_configure_window(
const ITensorInfo *
input, ITensorInfo *output,
75 const Coordinates &starts,
const Coordinates &ends,
const BiStrides &strides,
76 int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask)
80 starts, ends, strides,
81 begin_mask, end_mask, shrink_axis_mask);
87 return std::make_pair(Status{}, win);
90 void strided_slice_generic(
const ITensor *
input, ITensor *output,
91 const Coordinates &starts,
const BiStrides &strides, int32_t shrink_axis_mask,
94 Iterator output_it(output, window);
95 const size_t width_size =
input->info()->element_size();
102 unsigned int index = 0;
103 const int idx_w = is_shrink_w ? 0 : index++;
104 const int idx_h = is_shrink_h ? 0 : index++;
105 const int idx_c = is_shrink_c ? 0 : index++;
106 const int idx_n = is_shrink_n ? 0 : index;
109 shrinked_strides.
set(0, is_shrink_w ? 0 : strides[0]);
110 shrinked_strides.set(1, is_shrink_h ? 0 : strides[1]);
111 shrinked_strides.set(2, is_shrink_c ? 0 : strides[2]);
112 shrinked_strides.set(3, is_shrink_n ? 0 : strides[3]);
116 const int w_coord = starts[0] + (
id[idx_w] * shrinked_strides[0]);
117 const int h_coord = starts[1] + (
id[idx_h] * shrinked_strides[1]);
118 const int c_coord = starts[2] + (
id[idx_c] * shrinked_strides[2]);
119 const int n_coord = starts[3] + (
id[idx_n] * shrinked_strides[3]);
121 Coordinates in_coords(w_coord, h_coord, c_coord, n_coord);
122 std::copy_n(
input->ptr_to_element(in_coords), width_size, output_it.ptr());
129 : _starts_abs(), _final_strides(), _shrink_mask()
135 int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask)
140 _shrink_mask = shrink_axis_mask;
147 starts, ends, strides,
148 begin_mask, end_mask, shrink_axis_mask);
151 auto win_config = validate_and_configure_window(
input, output, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask);
153 INEKernel::configure(win_config.second);
158 int32_t begin_mask, int32_t end_mask, int32_t shrink_axis_mask)
162 starts, ends, strides, begin_mask, end_mask, shrink_axis_mask)
177 _starts_abs, _final_strides, _shrink_mask,
window);
void set(size_t dimension, T value, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
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.
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.
bool is_bit_set(T v, unsigned int idx)
Checks if the idx-th bit is set in an integral type.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Coordinates BiStrides
Bidirectional strides.
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Copyright (c) 2017-2021 Arm Limited.
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.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
TensorShape input_shape
Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros we use to check the validity of given a...
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
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.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
Information about executing thread and CPU.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
NEStridedSliceKernel()
Default constructor.
#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...
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.
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)