-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
dnn: fix HAVE_TIMVX macro definition in dnn test #24425
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
Conversation
modules/dnn/CMakeLists.txt
Outdated
ocv_option(OPENCV_TEST_DNN_TIMVX "Build test with TIM-VX" (TARGET ocv.3rdparty.timvx)) | ||
if(TARGET ocv.3rdparty.timvx AND OPENCV_TEST_DNN_TIMVX) | ||
if(TARGET opencv_test_dnn) | ||
ocv_target_link_libraries(opencv_test_dnn ocv.3rdparty.timvx) |
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.
Why do you need it? It's internal detail of implementation and user code should not depend on it, including tests. libopencv_dnn should have dependency from TIMVX.
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.
Test does not work with missing HAVE_TIMVX
macro:
opencv/modules/dnn/test/test_int8_layers.cpp
Lines 11 to 22 in 240b245
testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargetsInt8() | |
{ | |
std::vector< tuple<Backend, Target> > targets; | |
targets.push_back(make_tuple(DNN_BACKEND_OPENCV, DNN_TARGET_CPU)); | |
#ifdef HAVE_TIMVX | |
targets.push_back(make_tuple(DNN_BACKEND_TIMVX, DNN_TARGET_NPU)); | |
#endif | |
#ifdef HAVE_INF_ENGINE | |
targets.push_back(make_tuple(DNN_BACKEND_INFERENCE_ENGINE_NGRAPH, DNN_TARGET_CPU)); | |
#endif | |
return testing::ValuesIn(targets); | |
} |
Basically I need HAVE_TIMVX=1
.
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.
We don't need that.
There is registry API:
opencv/modules/dnn/include/opencv2/dnn/dnn.hpp
Lines 125 to 126 in 240b245
CV_EXPORTS std::vector< std::pair<Backend, Target> > getAvailableBackends(); | |
CV_EXPORTS_W std::vector<Target> getAvailableTargets(dnn::Backend be); |
And usage in tests:
opencv/modules/dnn/test/test_common.impl.hpp
Lines 291 to 296 in 240b245
if (withVkCom) | |
{ | |
available = getAvailableTargets(DNN_BACKEND_VKCOM); | |
for (std::vector< Target >::const_iterator i = available.begin(); i != available.end(); ++i) | |
targets.push_back(make_tuple(DNN_BACKEND_VKCOM, *i)); | |
} |
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.
DNN_BACKEND_TIMVX
is not in opencv/modules/dnn/test/test_common.impl.hpp.
The mentioned macro is used in tests in 2 places and both of them may be replaced with runtime check like Alexander suggested. |
So why these happen? See opencv/modules/dnn/CMakeLists.txt Lines 290 to 295 in 6e4280e
and opencv/modules/dnn/test/test_int8_layers.cpp Lines 11 to 22 in 6e4280e
(see line 18). The TIM-VX backend is only for int8-quantized models. |
Also @asmorkalov could you provide a key via email for me to set up a GitHub Actions connection with my Khadas VIM3? |
Because tests use OpenVINO API directly to test IR models (as a reference result). opencv/modules/dnn/test/test_ie_models.cpp Lines 185 to 210 in 6e4280e
Tests doesn't use special TIM-VX API |
modules/dnn/CMakeLists.txt
Outdated
ocv_option(OPENCV_TEST_DNN_TIMVX "Build test with TIM-VX" (HAVE_TIMVX)) | ||
if(OPENCV_TEST_DNN_TIMVX) | ||
if(TARGET opencv_test_dnn) | ||
ocv_target_compile_definitions(opencv_test_dnn PRIVATE "HAVE_TIMVX=1") |
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.
indentation
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.
Thank you for finding this! Meanwhile please hold merging this PR until the hardware is in the CI running the tests.
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.
Resolved.
The log shows tim-vx backend works fine with this patch, https://github.com/opencv/opencv/actions/runs/6586141510/job/17893901244?pr=24425 Ready to be merged once all tests are done. |
@fengyuentau I see VIM3 build passed on CI. Is it ready? May I merge the pr? |
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.
👍
Yes, it is ready and you can merge it. |
dnn: fix HAVE_TIMVX macro definition in dnn test opencv#24425 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
dnn: fix HAVE_TIMVX macro definition in dnn test opencv#24425 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
dnn: fix HAVE_TIMVX macro definition in dnn test opencv#24425 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Pull 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.