Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Abdurrahheem
Copy link
Contributor

Pull Request Readiness Checklist

All test data and models for PR are located #1188

This PR fixes issue reised when importing batched vanilla Attention layer from PyTorch via ONNX. Currently batched version of Attention layer in PyTorch has unflatten operation inside. unflatten operation causes issue in reshape layer (see the Reshape_2 in the graph below) due to incorrect output of slice layer. This PR particularly fixes slice and concat layers to handle unflatten operation.

image

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

if (range.start < 0)
{
range.start += n;
if (!(range.start == n)){
Copy link
Member

Choose a reason for hiding this comment

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

if (range.start != n)

Copy link
Member

Choose a reason for hiding this comment

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

If range.start == n doe it mean uninitialized value?

Copy link
Contributor Author

@Abdurrahheem Abdurrahheem Jul 3, 2024

Choose a reason for hiding this comment

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

no, it means that start index is equal to the last dimention of the input, in which case we do not want it to be (n-1)

@asmorkalov
Copy link
Contributor

@Abdurrahheem Should it be back-ported to 4.x too?

@asmorkalov
Copy link
Contributor

Replaced by #25861

@asmorkalov asmorkalov closed this Jul 4, 2024
@asmorkalov asmorkalov mentioned this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants