Ishita Singh b1e9563dd6 dnn: keep the GatherElements axis attribute unchanged in finalize
GatherElementsLayerImpl::finalize previously normalized the axis attribute
by overwriting this->axis with normalize_axis(axis, data.dims).
When the layer was created with a negative axis (such as -1, supported by
the ONNX GatherElements specification), this replaced the relative index
with a positive index fixed to the rank of the first input.

Subsequent evaluations on an input of different rank on the same layer then:
- evaluated GatherElements along the wrong axis (e.g. axis 1 instead of axis 2
  when moving from a 2D tensor to a 3D tensor), leading to silent data corruption, or
- triggered an assertion failure in normalize_axis (e.g. axis 2 on a 2D tensor
  when moving from a 3D tensor to a 2D tensor).

Fix this by keeping this->axis unmodified and storing the normalized axis
separately for execution. Add regression tests covering both decreasing and
increasing rank on the same GatherElements layer instance.
2026-11-30 19:25:45 +05:30
2026-09-17 12:00:11 +03:00
2020-02-26 15:12:45 +03:00
2018-10-11 17:57:51 +00:00
2025-08-01 09:50:10 +03:00

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read the contribution guidelines before starting work on a pull request.

Summary of the guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.

Additional Resources

Description
Languages
C++ 87.7%
C 3.1%
Python 2.9%
CMake 2%
Java 1.5%
Other 2.6%