From 15dc9351905ceebeb397fa5f1e20ac683eeaaba1 Mon Sep 17 00:00:00 2001 From: nklskyoy <31723634+nklskyoy@users.noreply.github.com> Date: Tue, 18 Nov 2025 14:29:19 +0100 Subject: [PATCH] Merge pull request #28032 from nklskyoy:onnx-importer2-dispatch-map Onnx importer2 dispatch map #28032 in the new onnx_importer all domains in the dispatch map should be included per default. See https://github.com/opencv/opencv/pull/27988#issuecomment-3521140872 ### 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 - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the 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 --- modules/dnn/src/onnx/onnx_importer2.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/modules/dnn/src/onnx/onnx_importer2.cpp b/modules/dnn/src/onnx/onnx_importer2.cpp index ab7449e838..9b449c3263 100644 --- a/modules/dnn/src/onnx/onnx_importer2.cpp +++ b/modules/dnn/src/onnx/onnx_importer2.cpp @@ -269,6 +269,7 @@ protected: void parseOperatorSet(); const std::string str_domain_ai_onnx = "ai.onnx"; + const std::string str_domain_com_microsoft = "com.microsoft"; bool useLegacyNames; bool getParamUseLegacyNames() @@ -592,20 +593,16 @@ void ONNXImporter2::parseOperatorSet() CV_LOG_INFO(NULL, "DNN/ONNX: ONNX opset version = " << onnx_opset); buildDispatchMap_ONNX_AI(onnx_opset); + buildDispatchMap_COM_MICROSOFT(onnx_opset); + for (const auto& pair : onnx_opset_map) { - if (pair.first == str_domain_ai_onnx) - { - continue; // done above - } - else if (pair.first == "com.microsoft") - { - buildDispatchMap_COM_MICROSOFT(pair.second); - } - else - { - CV_LOG_INFO(NULL, "DNN/ONNX: unknown domain='" << pair.first << "' version=" << pair.second << ". No dispatch map, you may need to register 'custom' layers."); - } + if ((pair.first != str_domain_ai_onnx) && (pair.first != str_domain_com_microsoft)) + CV_LOG_INFO( + NULL, + "DNN/ONNX: unknown domain='" << pair.first << "' version=" << pair.second << ". No dispatch map, you may need to register 'custom' layers." + ); + } } @@ -2736,7 +2733,7 @@ void ONNXImporter2::buildDispatchMap_COM_MICROSOFT(int opset_version) //dispatch["QLinearSoftmax"] = &ONNXImporter2::parseQSoftmax; dispatch["Attention"] = &ONNXImporter2::parseAttention; - domain_dispatch_map["com.microsoft"] = dispatch; + domain_dispatch_map[str_domain_com_microsoft] = dispatch; }