Skip to content

Fix negative starts in Slice and add no-op Expand for consts#21542

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
rogday:split_expand
Feb 28, 2022
Merged

Fix negative starts in Slice and add no-op Expand for consts#21542
opencv-pushbot merged 1 commit intoopencv:3.4from
rogday:split_expand

Conversation

@rogday
Copy link
Copy Markdown
Member

@rogday rogday commented Jan 31, 2022

Merge with extra: opencv/opencv_extra#956

opencv_extra=split_expand

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@rogday rogday added bug test category: dnn category: dnn (onnx) ONNX suport issues in DNN module labels Jan 31, 2022
@rogday rogday marked this pull request as draft January 31, 2022 08:10
@rogday rogday marked this pull request as ready for review February 3, 2022 16:44
@rogday rogday marked this pull request as draft February 4, 2022 15:08
@rogday rogday marked this pull request as ready for review February 17, 2022 15:48
@rogday rogday mentioned this pull request Feb 17, 2022
6 tasks
@rogday rogday changed the title Fix negative starts in Split and add no-op Expand for consts Fix negative starts in Slice and add no-op Expand for consts Feb 17, 2022
Comment on lines +65 to +75
range.start = std::min(std::max(range.start, -n), n - 1);
range.start = (n + range.start) % n;

range.end = std::min(std::max(range.end, -n - 1), n);
bool neg = range.end < 0;
range.end = (n + 1 + range.end) % (n + 1);
if (neg)
{
range.end = (range.end + n) % (n + 1);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have different expressions for the .start and the .end?
What is the difference between them? What is the difference against Python slicing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no difference from python slicing.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@opencv-pushbot opencv-pushbot merged commit 5cc27fd into opencv:3.4 Feb 28, 2022
@alalek alalek mentioned this pull request Mar 5, 2022
@rogday rogday deleted the split_expand branch April 16, 2022 16:24
@opencv-pushbot opencv-pushbot mentioned this pull request Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants