Added bool support to dnn #25605
Added bool support to dnn pipeline (CPU, OpenVINO and CUDA pipelines).
Added bool support to these layers(CPU and OpenVINO):
- Equal, Greater, GreaterOrEqual, Less, LessOrEqual
- Not
- And, Or, Xor
- Where
Enabled all the conformance tests for these layers.
### 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
- [ ] 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
@ -90,7 +90,7 @@ Ptr<BackendWrapper> wrapMat(int backendId, int targetId, cv::Mat& m)
CV_Assert(haveCUDA());
#ifdef HAVE_CUDA
CV_CheckType(m.depth(),m.depth()==CV_32F||m.depth()==CV_8S||m.depth()==CV_8U||m.depth()==CV_32S||m.depth()==CV_64S,"Unsupported type for CUDA");
CV_CheckType(m.depth(),m.depth()==CV_32F||m.depth()==CV_8S||m.depth()==CV_8U||m.depth()==CV_32S||m.depth()==CV_64S||m.depth()==CV_Bool,"Unsupported type for CUDA");
CV_Assert(IS_DNN_CUDA_TARGET(targetId));
switch(m.depth())
{
@ -107,6 +107,8 @@ Ptr<BackendWrapper> wrapMat(int backendId, int targetId, cv::Mat& m)
returnCUDABackendWrapperINT32::create(m);
caseCV_64S:
returnCUDABackendWrapperINT64::create(m);
caseCV_Bool:
returnCUDABackendWrapperBOOL::create(m);
default:
CV_Error(Error::BadDepth,"Unsupported mat type for CUDA");
CV_CheckType(host.depth(),host.depth()==CV_32F||host.depth()==CV_8S||host.depth()==CV_8U||host.depth()==CV_32S||host.depth()==CV_64S,"Unsupported type for CUDA");
CV_CheckType(host.depth(),host.depth()==CV_32F||host.depth()==CV_8S||host.depth()==CV_8U||host.depth()==CV_32S||host.depth()==CV_64S||host.depth()==CV_Bool,"Unsupported type for CUDA");
"test_eyelike_populate_off_main_diagonal",// Issues::Layer::Can't create layer::Can't create layer "onnx_node_output_0!y" of type "EyeLike" in function 'getLayerInstance'
"test_greater",// Issue:: Unsupported data type BOOL
"test_greater_bcast",// ---- same as above ---
"test_greater_equal",// ---- same as above ---
"test_greater_equal_bcast",// ---- same as above ---
"test_greater_equal_bcast_expanded",// ---- same as above ---
"test_greater_equal_expanded",// ---- same as above ---
"test_gridsample",// Issues::Layer::Can't create layer "onnx_node_output_0!Y" of type "GridSample" in function 'getLayerInstance'
"test_gridsample_aligncorners_true",// ---- same as above ---
"test_gridsample_bicubic",// ---- same as above ---
@ -155,12 +139,6 @@
"test_isinf_negative",// Issue:: Unsupported data type BOOL
"test_isinf_positive",// Issue:: Unsupported data type BOOL
"test_isnan",// Issue:: Unsupported data type BOOL
"test_less",// Issue:: Unsupported data type BOOL
"test_less_bcast",// Issue:: Unsupported data type BOOL
"test_less_equal",// Issue:: Unsupported data type BOOL
"test_less_equal_bcast",// Issue:: Unsupported data type BOOL
"test_less_equal_bcast_expanded",// Issue:: Unsupported data type BOOL
"test_less_equal_expanded",// Issue:: Unsupported data type BOOL
"test_loop11",// Issue:: Unsupported data type BOOL
"test_loop13_seq",// Issue:: Unsupported data type BOOL
"test_loop16_seq_none",// Issue:: Unsupported data type BOOL
@ -228,9 +206,6 @@
"test_nonmaxsuppression_two_batches",// ---- same as above ---
"test_nonmaxsuppression_two_classes",// ---- same as above ---
"test_nonzero_example",// Issue:: Unsupported data type: BOOL
"test_not_2d",// ---- same as above ---
"test_not_3d",// ---- same as above ---
"test_not_4d",// ---- same as above ---
"test_onehot_negative_indices",// Issue:: Layer does not exist (OneHot) :: Can't create layer "onnx_node_output_0!y" of type "OneHot" in function 'getLayerInstance'
"test_onehot_with_axis",// ---- same as above ---
"test_onehot_with_negative_axis",// ---- same as above ---
@ -239,14 +214,6 @@
"test_optional_get_element_sequence",// ---- same as above ---
"test_optional_has_element",// Issue:: Unsupported data type BOOL
"test_optional_has_element_empty",// ---- same as above ---
"test_or2d",
"test_or3d",// ---- same as above ---
"test_or4d",// ---- same as above ---
"test_or_bcast3v1d",
"test_or_bcast3v2d",// ---- same as above ---
"test_or_bcast4v2d",// ---- same as above ---
"test_or_bcast4v3d",// ---- same as above ---
"test_or_bcast4v4d",// ---- same as above ---
"test_pow_types_float",// Issue:: Unsupported data type
"test_pow_types_float32_int32",// ---- same as above ---
"test_pow_types_float32_int64",// ---- same as above ---
@ -471,16 +438,6 @@
"test_unsqueeze_three_axes",// ---- same as above ---
"test_unsqueeze_two_axes",// ---- same as above ---)
"test_unsqueeze_unsorted_axes",// ---- same as above ---)
"test_where_example",// Issue:: Parser: Unsupported data type: BOOL in function 'getMatFromTensor'
"test_where_long_example",// ---- same as above ---
"test_xor2d",// Issue:: Parser: Unsupported data type: BOOL in function 'getMatFromTensor'
"test_xor3d",// ---- same as above ---
"test_xor4d",// ---- same as above ---
"test_xor_bcast3v1d",// ---- same as above ---
"test_xor_bcast3v2d",// ---- same as above ---
"test_xor_bcast4v2d",// ---- same as above ---
"test_xor_bcast4v3d",// ---- same as above ---
"test_xor_bcast4v4d",// ---- same as above ---
// // Cumsum related issue: https://github.com/opencv/opencv/issues/24437