-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[G-API]: Add Fluid bitwise operations implementation for (GMat, GScalar) #18257
[G-API]: Add Fluid bitwise operations implementation for (GMat, GScalar) #18257
Conversation
- simple loop implementation for Fluid used (no `hal`); - `Scalar` is casted to `int` in the beginning - tests just modified to work with `Scalar` - expected output in operators' tests fixed (operators can't change Mat's depth) - `float` `Scalar` `RNG` added, `RNG` reworked (`time` is used now), initialization of test fixtures reworked - if input or output is `float` Scalar is initialized by `float` - some problems with Fluid/OCV floating-point comparison difference stashed by `AbsSimilarPoints()` usage, FIXME added - divide-by-zero is now fixed differently and everywhere
- due to errors of Fluid floating-point comparison operations, added support of different validation in Cmp perf_tests; added FIXME - reworked integral initialization of Scalar
@anna-khakimova Welcome to review! |
@smirnov-alexey please review |
Looks good. Thanks for your detailed PR descriptions. Please, assign a reviewer |
- NULL -> nullptr - Scalar convertion moved to the function - avoid -> avoiding
@anna-khakimova Welcome to review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Looks good. |
@dmatveev please take a look |
@@ -426,7 +422,7 @@ PERF_TEST_P_(DivRCPerfTest, TestPerformance) | |||
} | |||
|
|||
// Comparison //////////////////////////////////////////////////////////// | |||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv)); | |||
// FIXIT unrealiable check: EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No new keywords please, we mainly use FIXME or TODO, but not FIXIT.
The idea is to grep by the keyword one day and fix what's found. Not sure anybody remembers about FIXIT
at that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what has started failing? Does it fail in accuracy tests too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is FIXIT
is used all over the perf_tests files, so I just wanted to keep consistency. Should I change all the FIXIT
-> FIXME
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison is unreliable due to potential division by zero. In accuracy tests I fixed it so you can see it in gapi_core_tests_inl.hpp
and gapi_operators_tests_inl.hpp
(you started a conversation at one of those spots), debugged and tested it to be sure the tests don't fail
It has to be done for performance tests too, but I chose to put this task to backlog as it is not so important to check the accuracy of the performance tests when there are reliable accuracy tests themselves
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIR OpenCV divides by zero safely, so we should follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite the fact OCV backend follows OpenCV and doesn't cause any accuracy problems, Fluid and GPU backends diverge from OpenCV, so these workarounds are necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
- refactored convertScalarForBitwise() - removed unnecessary braces for switch
- switch via `enum` implemented - infrastructure for that refactored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
…wise_and_scalar [G-API]: Add Fluid bitwise operations implementation for (GMat, GScalar) * Added Fluid `bitwise` with `Scalar` + acc.tests - simple loop implementation for Fluid used (no `hal`); - `Scalar` is casted to `int` in the beginning - tests just modified to work with `Scalar` - expected output in operators' tests fixed (operators can't change Mat's depth) - `float` `Scalar` `RNG` added, `RNG` reworked (`time` is used now), initialization of test fixtures reworked - if input or output is `float` Scalar is initialized by `float` - some problems with Fluid/OCV floating-point comparison difference stashed by `AbsSimilarPoints()` usage, FIXME added - divide-by-zero is now fixed differently and everywhere * - Added perf_tests for bitwise_Scalar operations - due to errors of Fluid floating-point comparison operations, added support of different validation in Cmp perf_tests; added FIXME - reworked integral initialization of Scalar * Addressing comments - NULL -> nullptr - Scalar convertion moved to the function - avoid -> avoiding * Addressing comments * CV_assert -> GAPI_assert * Addressed DM comments - refactored convertScalarForBitwise() - removed unnecessary braces for switch * Changed the operators tests - switch via `enum` implemented - infrastructure for that refactored
These changes:
bitwise
operations implementation for (GMat
,GScalar
) + accuracy and performance testshal
)Scalar
is cast toint
in the beginning due to no reason for doing bitwise operations with floating-point numbersBesides:
Scalar
initialization for tests - add floating-point initialization (from tests ofcore
module)comparison
Fluid operations comparing with OpenCV, so their tests' validations are changedPull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.