-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Extend ONNX FE with Col2Im operator
#33386
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
Open
daehyun99
wants to merge
7
commits into
openvinotoolkit:master
Choose a base branch
from
daehyun99:ENH/30144-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+817
−9
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0dfd2f0
Feat: Extend ONNX FE with `Com2Im` operator (#30144)
daehyun99 3b79646
Merge branch 'master' into ENH/30144-1
daehyun99 8b92aee
Merge branch 'master' into ENH/30144-1
daehyun99 0e9393f
Merge branch 'master' into ENH/30144-1
daehyun99 aef8327
Merge branch 'master' into ENH/30144-1
daehyun99 1392cd0
Merge branch 'master' into ENH/30144-1
daehyun99 89ac812
Merge branch 'master' into ENH/30144-1
daehyun99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright (C) 2018-2026 Intel Corporation | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| #include "openvino/op/col2im.hpp" | ||
|
|
||
| #include "core/operator_set.hpp" | ||
| #include "exceptions.hpp" | ||
| #include "utils/common.hpp" | ||
|
|
||
| namespace ov { | ||
| namespace frontend { | ||
| namespace onnx { | ||
| namespace ai_onnx { | ||
| namespace opset_18 { | ||
| ov::OutputVector col2im(const ov::frontend::onnx::Node& node) { | ||
| // 1. get inputs | ||
| common::default_op_checks(node, 3); | ||
| const auto inputs = node.get_ov_inputs(); | ||
| const auto& data = inputs[0]; // input | ||
| const auto& output_size = inputs[1]; // image_shape | ||
| const auto& kernel_size = inputs[2]; // block_shape | ||
|
|
||
| // 2. get attributes | ||
| const size_t spatial_rank = 2; | ||
|
|
||
| std::vector<size_t> default_attr_vals(spatial_rank, 1); | ||
| auto dilations = node.get_attribute_value<std::vector<size_t>>("dilations", default_attr_vals); | ||
| auto strides = node.get_attribute_value<std::vector<size_t>>("strides", default_attr_vals); | ||
|
|
||
| std::vector<size_t> default_pads(spatial_rank * 2, 0); | ||
| auto pads = node.get_attribute_value<std::vector<size_t>>("pads", default_pads); | ||
| std::vector<size_t> pads_begin; | ||
| std::vector<size_t> pads_end; | ||
|
|
||
| // ov::op::v15::Col2Im only supports 2D spatial dimensions | ||
| CHECK_VALID_NODE(node, | ||
| dilations.size() == spatial_rank, | ||
| "Col2Im 'dilations' attribute must have size [2]. Got: ", | ||
| dilations.size()); | ||
| CHECK_VALID_NODE(node, | ||
| strides.size() == spatial_rank, | ||
| "Col2Im 'strides' attribute must have size [2]. Got: ", | ||
| strides.size()); | ||
| CHECK_VALID_NODE(node, | ||
| pads.size() == spatial_rank * 2, | ||
| "Col2Im 'pads' attribute must have size [4]. Got: ", | ||
| pads.size()); | ||
|
|
||
| // spatial_rank == pads.size() / 2 | ||
| pads_begin.assign(pads.begin(), pads.begin() + spatial_rank); | ||
| pads_end.assign(pads.begin() + spatial_rank, pads.end()); | ||
|
|
||
| // 3. return Col2Im | ||
| return { | ||
| std::make_shared<ov::op::v15::Col2Im>(data, output_size, kernel_size, strides, dilations, pads_begin, pads_end) | ||
| ->outputs()}; | ||
| } | ||
|
|
||
| ONNX_OP("Col2Im", OPSET_SINCE(1), ai_onnx::opset_18::col2im); | ||
daehyun99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } // namespace opset_18 | ||
| } // namespace ai_onnx | ||
| } // namespace onnx | ||
| } // namespace frontend | ||
| } // namespace ov | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/frontends/onnx/tests/models/col2im_2D_batch_opset_18.prototxt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| ir_version: 8 | ||
| producer_name: "OpenVINO ONNX Frontend" | ||
| graph { | ||
| node { | ||
| input: "input" | ||
| input: "image_shape" | ||
| input: "block_shape" | ||
| output: "output" | ||
| name: "col2im_2D_batch_opset_18" | ||
| op_type: "Col2Im" | ||
| attribute { | ||
| name: "dilations" | ||
| ints: 1 | ||
| ints: 1 | ||
| type: INTS | ||
| } | ||
| attribute { | ||
| name: "pads" | ||
| ints: 0 | ||
| ints: 0 | ||
| ints: 0 | ||
| ints: 0 | ||
| type: INTS | ||
| } | ||
| attribute { | ||
| name: "strides" | ||
| ints: 1 | ||
| ints: 1 | ||
| type: INTS | ||
| } | ||
| } | ||
| name: "col2im_2D_batch_opset_18" | ||
| input { | ||
| name: "input" | ||
| type { | ||
| tensor_type { | ||
| elem_type: 1 | ||
| shape { | ||
| dim { | ||
| dim_value: 2 | ||
| } | ||
| dim { | ||
| dim_value: 4 | ||
| } | ||
| dim { | ||
| dim_value: 4 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| input { | ||
| name: "image_shape" | ||
| type { | ||
| tensor_type { | ||
| elem_type: 7 | ||
| shape { | ||
| dim { | ||
| dim_value: 2 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| input { | ||
| name: "block_shape" | ||
| type { | ||
| tensor_type { | ||
| elem_type: 7 | ||
| shape { | ||
| dim { | ||
| dim_value: 2 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| output { | ||
| name: "output" | ||
| type { | ||
| tensor_type { | ||
| elem_type: 1 | ||
| shape { | ||
| dim { | ||
| dim_value: 2 | ||
| } | ||
| dim { | ||
| dim_value: 1 | ||
| } | ||
| dim { | ||
| dim_value: 3 | ||
| } | ||
| dim { | ||
| dim_value: 3 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| opset_import { | ||
| version: 18 | ||
| } |
103 changes: 103 additions & 0 deletions
103
src/frontends/onnx/tests/models/col2im_2D_channel_opset_18.prototxt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| ir_version: 8 | ||
| producer_name: "OpenVINO ONNX Frontend" | ||
| graph { | ||
| node { | ||
| input: "input" | ||
| input: "image_shape" | ||
| input: "block_shape" | ||
| output: "output" | ||
| name: "col2im_2D_channel_opset_18" | ||
| op_type: "Col2Im" | ||
| attribute { | ||
| name: "dilations" | ||
| ints: 1 | ||
| ints: 1 | ||
| type: INTS | ||
| } | ||
| attribute { | ||
| name: "pads" | ||
| ints: 0 | ||
| ints: 0 | ||
| ints: 0 | ||
| ints: 0 | ||
| type: INTS | ||
| } | ||
| attribute { | ||
| name: "strides" | ||
| ints: 1 | ||
| ints: 1 | ||
| type: INTS | ||
| } | ||
| } | ||
| name: "col2im_2D_channel_opset_18" | ||
| input { | ||
| name: "input" | ||
| type { | ||
| tensor_type { | ||
| elem_type: 1 | ||
| shape { | ||
| dim { | ||
| dim_value: 1 | ||
| } | ||
| dim { | ||
| dim_value: 12 | ||
| } | ||
| dim { | ||
| dim_value: 4 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| input { | ||
| name: "image_shape" | ||
| type { | ||
| tensor_type { | ||
| elem_type: 7 | ||
| shape { | ||
| dim { | ||
| dim_value: 2 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| input { | ||
| name: "block_shape" | ||
| type { | ||
| tensor_type { | ||
| elem_type: 7 | ||
| shape { | ||
| dim { | ||
| dim_value: 2 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| output { | ||
| name: "output" | ||
| type { | ||
| tensor_type { | ||
| elem_type: 1 | ||
| shape { | ||
| dim { | ||
| dim_value: 1 | ||
| } | ||
| dim { | ||
| dim_value: 3 | ||
| } | ||
| dim { | ||
| dim_value: 3 | ||
| } | ||
| dim { | ||
| dim_value: 3 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| opset_import { | ||
| version: 18 | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.