| 88 | } |
| 89 | |
| 90 | void CLStridedSliceKernel::configure(const CLCompileContext &compile_context, |
| 91 | const ITensorInfo *input, |
| 92 | ITensorInfo *output, |
| 93 | const Coordinates &starts, |
| 94 | const Coordinates &ends, |
| 95 | const BiStrides &strides, |
| 96 | int32_t begin_mask, |
| 97 | int32_t end_mask, |
| 98 | int32_t shrink_axis_mask) |
| 99 | { |
| 100 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); |
| 101 | auto padding_info = get_padding_info({input, output}); |
| 102 | ARM_COMPUTE_ERROR_THROW_ON( |
| 103 | validate_arguments(input, output, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask)); |
| 104 | |
| 105 | const TensorShape &input_shape = input->tensor_shape(); |
| 106 | |
| 107 | Coordinates starts_abs; |
| 108 | Coordinates ends_abs; |
| 109 | Coordinates final_strides; |
| 110 | std::tie(starts_abs, ends_abs, final_strides) = |
| 111 | arm_compute::helpers::tensor_transform::calculate_strided_slice_coords(input_shape, starts, ends, strides, |
| 112 | begin_mask, end_mask, shrink_axis_mask); |
| 113 | |
| 114 | // Configure kernel window |
| 115 | const TensorShape output_shape = arm_compute::misc::shape_calculator::compute_strided_slice_shape( |
| 116 | *input, starts, ends, strides, begin_mask, end_mask, shrink_axis_mask); |
| 117 | auto_init_if_empty(*output, input->clone()->set_tensor_shape(output_shape)); |
| 118 | Window win = calculate_max_window(*output, Steps()); |
| 119 | |
| 120 | // Enable multiple elements processing along x if stride_x is 1 and output width greater than the access vector size |
| 121 | const int vec_size_x = 16 / input->element_size(); |
| 122 | const int output_width_x = output->tensor_shape().x(); |
| 123 | const bool is_shrink_on_x = arm_compute::helpers::bit_ops::is_bit_set(shrink_axis_mask, 0); |
| 124 | const bool multi_access_x = !is_shrink_on_x && (final_strides.x() == 1) && (output_width_x / vec_size_x > 0); |
| 125 | |
| 126 | // Update window if needed |
| 127 | if (multi_access_x) |
| 128 | { |
| 129 | Window &updated_window = win; |
| 130 | updated_window.set(Window::DimX, |
| 131 | Window::Dimension(updated_window.x().start(), |
| 132 | ceil_to_multiple(updated_window.x().end(), vec_size_x), vec_size_x)); |
| 133 | } |
| 134 | ICLKernel::configure_internal(win); |
| 135 | |
| 136 | // Create build options |
| 137 | CLBuildOptions build_opts; |
| 138 | build_opts.add_option("-DDATA_TYPE=" + |
| 139 | get_cl_unsigned_type_from_element_size(data_size_from_type(input->data_type()))); |
| 140 | for (unsigned int i = 0; i < input_shape.num_dimensions(); ++i) |
| 141 | { |
| 142 | const bool is_shrink = arm_compute::helpers::bit_ops::is_bit_set(shrink_axis_mask, i); |
| 143 | build_opts.add_option("-DSTART_" + support::cpp11::to_string(i) + "=" + |
| 144 | support::cpp11::to_string(starts_abs[i])); |
| 145 | build_opts.add_option("-DSTRIDE_" + support::cpp11::to_string(i) + "=" + |
| 146 | support::cpp11::to_string(final_strides[i])); |
| 147 | build_opts.add_option_if(is_shrink, "-DSHRINK_" + support::cpp11::to_string(i)); |
nothing calls this directly
no test coverage detected