[ONNX] Use ov::v12::pad in ONNX FE Pad (#18460)
* Update ONNX FE Pad to use Pad-12 * Add negative pads test * Use default_opset(opset12) for Pad
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
#include "ngraph/shape.hpp"
|
||||
#include "onnx_import/core/null_node.hpp"
|
||||
#include "op/pad.hpp"
|
||||
#include "openvino/opsets/opset11.hpp"
|
||||
#include "utils/convpool.hpp"
|
||||
#include "utils/reshape.hpp"
|
||||
|
||||
@@ -56,7 +55,7 @@ OutputVector pad(const Node& node) {
|
||||
ngraph::CoordinateDiff padding_below = paddings.first;
|
||||
ngraph::CoordinateDiff padding_above = paddings.second;
|
||||
|
||||
return {std::make_shared<ov::opset11::Pad>(
|
||||
return {std::make_shared<default_opset::Pad>(
|
||||
data,
|
||||
std::make_shared<default_opset::Constant>(element::i64, ngraph::Shape{padding_below.size()}, padding_below),
|
||||
std::make_shared<default_opset::Constant>(element::i64, ngraph::Shape{padding_above.size()}, padding_above),
|
||||
@@ -100,7 +99,7 @@ OutputVector pad(const Node& node) {
|
||||
const std::string mode = node.get_attribute_value<std::string>("mode", "constant");
|
||||
ngraph::op::PadMode pad_mode = get_pad_mode(mode);
|
||||
|
||||
return {std::make_shared<ov::opset11::Pad>(data, padding_begin, padding_end, values, pad_mode)};
|
||||
return {std::make_shared<default_opset::Pad>(data, padding_begin, padding_end, values, pad_mode)};
|
||||
}
|
||||
|
||||
} // namespace set_11
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
ir_version: 8
|
||||
producer_name: "onnx-frontend-test"
|
||||
graph {
|
||||
node {
|
||||
input: "x"
|
||||
input: "pads"
|
||||
output: "Y"
|
||||
op_type: "Pad"
|
||||
attribute {
|
||||
name: "mode"
|
||||
s: "constant"
|
||||
type: STRING
|
||||
}
|
||||
}
|
||||
name: "test-model"
|
||||
input {
|
||||
name: "x"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 6
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 3
|
||||
}
|
||||
dim {
|
||||
dim_value: 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
input {
|
||||
name: "pads"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 7
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
output {
|
||||
name: "Y"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 6
|
||||
shape {
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
domain: ""
|
||||
version: 18
|
||||
}
|
||||
@@ -3542,6 +3542,19 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_pad_optional_constant) {
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_pad_constant_negative_begin_end) {
|
||||
const auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(),
|
||||
SERIALIZED_ZOO,
|
||||
"onnx/pad_negative_begin_end.onnx"));
|
||||
auto test_case = test::TestCase(function, s_device);
|
||||
|
||||
test_case.add_input<int32_t>({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
|
||||
test_case.add_input<int64_t>({-1, -1, -1, -1});
|
||||
test_case.add_expected_output<int32_t>(Shape{1, 2}, {6, 7});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_pow_float32_float32) {
|
||||
const auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(),
|
||||
SERIALIZED_ZOO,
|
||||
|
||||
Reference in New Issue
Block a user