Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/frontends/onnx/docs/supported_ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ OpenVINO provides support for operations of Default Opset (empty in table below)
| |Celu |12 |12 | |
| |CenterCropPad |18 |18 | |
| |Clip |11, 1 |13, 12, 11, 6, 1 | |
| |Col2Im | |18 | |
| |Col2Im |18 |18 | |
| |Compress |9 |11, 9 | |
| |Concat |1 |13, 11, 4, 1 | |
| |ConcatFromSequence |11 |11 |Supported only in certain patterns|
Expand Down
65 changes: 65 additions & 0 deletions src/frontends/onnx/frontend/src/op/col2im.cpp
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);
} // namespace opset_18
} // namespace ai_onnx
} // namespace onnx
} // namespace frontend
} // namespace ov
3 changes: 1 addition & 2 deletions src/frontends/onnx/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# -*- coding: utf-8 -*-

import pytest

Expand Down Expand Up @@ -52,7 +52,6 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True):
"Axes input must be constant")
skip_bitwise_ui64 = pytest.mark.skip(reason="AssertionError: Not equal to tolerance rtol=0.001, atol=1e-07")
xfail_issue_99950 = xfail_test(reason="CenterCropPad func is not supported")
xfail_issue_99952 = xfail_test(reason="Col2Im operator is not supported")
xfail_issue_99954 = xfail_test(reason="Constant Pad - RuntimeError: Shape inference of Reference node with name y failed")
xfail_issue_99955 = xfail_test(reason="GroupNorm is not supported")
xfail_issue_99957 = xfail_test(reason="LayerNorm - RuntimeError: While validating node '<Node(Reshape): Mean>'")
Expand Down
103 changes: 103 additions & 0 deletions src/frontends/onnx/tests/models/col2im_2D_batch_opset_18.prototxt
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 src/frontends/onnx/tests/models/col2im_2D_channel_opset_18.prototxt
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
}
Loading
Loading