Skip to content

cuda4dnn(padding): fix assertion to allow input effective rank to be lower than output effective rank#20695

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
YashasSamaga:cuda4dnn-fix-padding-effrank
Sep 14, 2021
Merged

cuda4dnn(padding): fix assertion to allow input effective rank to be lower than output effective rank#20695
opencv-pushbot merged 1 commit intoopencv:masterfrom
YashasSamaga:cuda4dnn-fix-padding-effrank

Conversation

@YashasSamaga
Copy link
Copy Markdown
Contributor

@YashasSamaga YashasSamaga commented Sep 13, 2021

The existing assertion asserts that the effective ranks (after removing leading singleton axes) of the input tensor and output tensor are equal. This assertion fails in two tests:

[  FAILED  ] Test_ONNX_layers.CalculatePads/0, where GetParam() = CUDA/CUDA
[  FAILED  ] Test_ONNX_layers.CalculatePads/1, where GetParam() = CUDA/CUDA_FP16

The effective rank of the input may be smaller than the effective rank of the output but the converse is never true. For example,

input: [1, 1, 1, 3]; effective rank = 1
output: [1, 1, 3, 3]; effective rank = 2

There is padding for axis 2 which is a singleton axis in the input tensor.

The correct assertion is to check that the input effective rank is less than or equal to the output effective rank. This PR fixes the assertion and the tests pass.

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • [] There is reference to 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

@YashasSamaga YashasSamaga force-pushed the cuda4dnn-fix-padding-effrank branch from 9a57b59 to 50462dc Compare September 13, 2021 17:36
Copy link
Copy Markdown
Contributor

@JulieBar JulieBar left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you 👍

@opencv-pushbot opencv-pushbot merged commit 3d7670a into opencv:master Sep 14, 2021
@alalek alalek mentioned this pull request Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug category: dnn category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants