Closed dgurulev closed 4 months ago
Hi @dgurulev
Thanks for reporting this.
Could you please submit your patch for review, please see the section How to submit a patch in https://arm-software.github.io/ComputeLibrary/latest/contribution_guidelines.xhtml
Output of 'strings libarm_compute.so | grep arm_compute_version':
arm_compute_version=v22.08 Build options: {'Werror': '1', 'debug': '1', 'neon': '1', 'opencl': '0', 'os': 'linux', 'arch': 'armv8a'} Git hash=b'aabef6c0584f06f4c0f4b61fb787d80374240619'
Platform/Operating System: qemu-aarch64 version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.5) on Ubuntu 22.04 LTS
Problem description:
Accordingly to specification of NESlice:
End coordinates can be negative, which represents the number of elements before the end of that dimension.
This behavior is aligned with both popular AI frameworks like _TensorFlow_, PyTorch and NumPy. For example,NESlice.patch.txt
So, for given tensor input: { 6 } starts: { 1 } ends: { -1 } we expect output: { 4 }. Actually we got validation failure since NESlice::validate expects output: { 5 }. This is because negative value at ends coordinate(s) is interpreted as a non-zero bit(s) at _endmask passed to NEStridedSliceKernel what, in turn, is interpreted as "ends[i] is ignored and the fullest possible range in that dimension is used".
Details: NESlice working though NEStridedSliceKernel and calculates _exp_outputshape in this way NESlice::validate => NEStridedSliceKernel::validate => validate_arguments => compute_strided_slice_shape => compute_strided_slice_output_shape => calculate_end_on_index =>
So, stop is calculated as input's full range and this matches specification of NEStridedSliceKernel. The thing is the way how NESlice generates _endmask by construct_slice_end_mask function to be passed to NEStridedSliceKernel:
Finally, we either need to fix NESlice behavior or make a correction in the documentation to describe actual one. A fix may be quite quick and simple - just get rid off end_mask calculation and pass zero as _endmask to NEStridedSliceKernel:: validate/configure, see attached patch.
Reproducer (slice.cpp, no test case w/ negative value at ends found at tests/validation/NEON/Slice.cpp):