Skip to content

cudaarithm: use only even number for inplace flip#18348

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
tomoaki0705:fixNppFlipInplace
Sep 17, 2020
Merged

cudaarithm: use only even number for inplace flip#18348
opencv-pushbot merged 1 commit intoopencv:3.4from
tomoaki0705:fixNppFlipInplace

Conversation

@tomoaki0705
Copy link
Copy Markdown
Contributor

@tomoaki0705 tomoaki0705 commented Sep 16, 2020

resolves #18347

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
force_builders=Custom
buildworker:Custom=linux-4
build_image:Custom=ubuntu-cuda:18.04

CUDA_TEST_P(Flip, AccuracyInplace)
{
size.width = (size.width >> 1) << 1; // in-place version only accepts even number
size.height = (size.height >> 1) << 1; // in-place version only accepts even number
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I propose to split tests for in-place and general cases and instantiate in-place cases with even size. It's more obvious behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@asmorkalov , do you mean create DIFFERENT_EVEN_SIZES list here and instantiate inplace tests separately? I think it would make this test unnecessary complex.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's something debatable. I first had the same feeling with @asmorkalov , since the log shows 113x113 which is not correct.
Then I saw the the line that @mshabunin pointed, and thought the same thing. "It's only a single test which uses DIFFERENT_EVEN_SIZES "
Merging the idea will lead me to add single define in the test_core.cpp rather in cuda_test.hpp, but I need someone as an arbitor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, but I again changed my mind.
I thought it would be simple, but it's really making a another copy of flip test code just for the in-place version.
Now, there are one Flip test, but asmorkalov suggestion is to create Flip and Flip_inplace test case, which I don't prefer.
Can I keep the current implementation as-is, since it'll make things much easier ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another idea is to keep sizes intact but add bad args handling to the test:

if (/* size is not even */)
{
    EXPECT_THROW(...);
    return;
}
// current test body

@asmorkalov asmorkalov added the category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib label Sep 17, 2020
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.

Thank you for contribution!

CV_Error(Error::BadROISize, "In-place version of flip only accepts even width/height");

if (src.refcount != dst.refcount)
if (src.data != dst.data)
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.

BTW, refcount is a pointer to reference counter which is allocated with underlying buffer/data and it is shared between GpuMats.
At least, it is more reliable check in case of image ROIs.

But it doesn't work if refcount == NULL (non-managed buffers).

Better check should compare both values:

bool isInplace = (src.data == dst.data) || (src.refcount == dst.refcount);

(however there are still some non-covered cases)

@opencv-pushbot opencv-pushbot merged commit e668cff into opencv:3.4 Sep 17, 2020
@tomoaki0705 tomoaki0705 deleted the fixNppFlipInplace branch September 17, 2020 20:22
This was referenced Sep 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 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