mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
Merge pull request #28714 from ShiyuXie0116:fix/onnx-dispatch-and-rotary-embedding-bugs
dnn: fix missing ONNX dispatch entries and RotaryEmbedding bugs #28714 - Wire RMSNormalization and RotaryEmbedding parsers into the ONNX dispatch map. Both parse functions were declared and implemented but never registered, causing the importer to fall through to the generic path and skip constant-folding of cos/sin caches. - Fix NonMaxSuppression dispatch key typo ("NonMaxSuprression" -> "NonMaxSuppression") so the ONNX op name matches the registered layer class. Also fix the type string set inside the parser. - Fix tautological self-comparison in RotaryEmbeddingLayer::getMemoryShapes (cos_cache_shape.dims == cos_cache_shape.dims -> sin_cache_shape.dims). - Fix typo in RotaryEmbedding error message ("cos_cahe" -> "cos_cache"). ### 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 - [ ] 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
This commit is contained in:
@@ -231,10 +231,10 @@ class RotaryEmbeddingLayerImpl CV_FINAL : public RotaryEmbeddingLayer {
|
||||
);
|
||||
CV_CheckTrue(
|
||||
cos_cache_shape.dims == 3 || inputs.size() > 3,
|
||||
"RotaryEmbeddingLayer: provide position_ids or specify sin_cache and cos_cahe in format BxTxD"
|
||||
"RotaryEmbeddingLayer: provide position_ids or specify sin_cache and cos_cache in format BxTxD"
|
||||
);
|
||||
CV_CheckTrue(
|
||||
cos_cache_shape.dims == cos_cache_shape.dims,
|
||||
cos_cache_shape.dims == sin_cache_shape.dims,
|
||||
"RotaryEmbeddingLayer: cos_cache and sin_cache must have the same number of dimensions"
|
||||
);
|
||||
for (int i = 0; i < cos_cache_shape.dims; ++i)
|
||||
|
||||
@@ -2726,6 +2726,8 @@ void ONNXImporter2::buildDispatchMap_ONNX_AI()
|
||||
dispatch["Tile"] = &ONNXImporter2::parseTile;
|
||||
dispatch["LayerNormalization"] = &ONNXImporter2::parseLayerNorm;
|
||||
dispatch["GroupNormalization"] = &ONNXImporter2::parseInstanceNormalization;
|
||||
dispatch["RMSNormalization"] = &ONNXImporter2::parseRMSNormalization;
|
||||
dispatch["RotaryEmbedding"] = &ONNXImporter2::parseRotaryEmbedding;
|
||||
dispatch["NegativeLogLikelihoodLoss"] = &ONNXImporter2::parseNegativeLogLikelihoodLoss;
|
||||
dispatch["SoftmaxCrossEntropyLoss"] = &ONNXImporter2::parseSoftmaxCrossEntropyLoss;
|
||||
// @TODO@ONNX: Add support for SDPA
|
||||
|
||||
Reference in New Issue
Block a user