Skip to content

DNN: support the split node of onnx opset >= 13#23482

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
zihaomu:onnx_opset13_split
Apr 14, 2023
Merged

DNN: support the split node of onnx opset >= 13#23482
asmorkalov merged 1 commit intoopencv:4.xfrom
zihaomu:onnx_opset13_split

Conversation

@zihaomu
Copy link
Copy Markdown
Member

@zihaomu zihaomu commented Apr 11, 2023

Merge with test case: opencv/opencv_extra#1053.

The attribute of split in Split layer has been moved from attribute to input.
Related link: https://github.com/onnx/onnx/blob/main/docs/Operators.md#inputs-1---2-12
The purpose of this PR is to support the split with input type.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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

@zihaomu zihaomu added bug test category: dnn (onnx) ONNX suport issues in DNN module labels Apr 11, 2023
@zihaomu zihaomu linked an issue Apr 11, 2023 that may be closed by this pull request
@zihaomu zihaomu force-pushed the onnx_opset13_split branch from bf33fe5 to 51281f8 Compare April 11, 2023 08:19
@zihaomu zihaomu requested review from asmorkalov and rogday April 11, 2023 08:22
@asmorkalov asmorkalov added this to the 4.8.0 milestone Apr 11, 2023
Copy link
Copy Markdown
Member

@rogday rogday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
layerParams.set("slice_point", DictValue::arrayInt(&slicePoints[0], slicePoints.size()));
}
else if (node_proto.input_size() == 2) // opset >= 13, the split will be stored at the second input, instead of the attribute.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, there onnx_opset field to avoid guessing using the number of inputs (that is not reliable).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for your code review. I agree with you, but currently, I have no better solution for this.
Since we can not get the info of opset version.
And from onnx's doc, the split has only input when the opset < 13.
https://github.com/onnx/onnx/blob/main/docs/Changelog.md#split-11
And when opset >= 13, input may have the second input, and it's used only for split.
https://github.com/onnx/onnx/blob/main/docs/Operators.md#split.

@asmorkalov asmorkalov removed their request for review April 14, 2023 06:20
@vpisarev vpisarev self-requested a review April 14, 2023 08:28
@asmorkalov asmorkalov merged commit aa17f88 into opencv:4.x Apr 14, 2023
@asmorkalov asmorkalov mentioned this pull request May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug category: dnn (onnx) ONNX suport issues in DNN module test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot load yolov8n-pose ONNX model

6 participants