Add support (limited, based on Interpolate-1) to Resize-11 ONNX op (#1364)
* Implementation of Resize-11 * Added support to sizes input * Add tests to sizes input * Added missing comment * fixed tests * fixed tests * Fixed test. part 2. * review remaks. part 1. * review remarks. part 2. Co-authored-by: Tomasz Socha <tomasz.socha@intel.com> * Added more tests Co-authored-by: Tomasz Socha <tomasz.socha@intel.com>
This commit is contained in:
parent
0846f2050e
commit
5ff59eb711
@ -18,6 +18,7 @@
|
||||
#include "default_opset.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "ngraph/op/util/op_types.hpp"
|
||||
#include "utils/common.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
@ -25,17 +26,49 @@ namespace ngraph
|
||||
{
|
||||
namespace op
|
||||
{
|
||||
namespace set_1
|
||||
namespace
|
||||
{
|
||||
NodeVector resize(const onnx_import::Node& node)
|
||||
std::shared_ptr<ngraph::Node> calculate_output_shape_based_on_scales(
|
||||
const std::shared_ptr<ngraph::Node>& data,
|
||||
const std::shared_ptr<ngraph::Node>& scales)
|
||||
{
|
||||
const auto inputs = node.get_ng_inputs();
|
||||
const auto data = inputs.at(0);
|
||||
const auto scales = inputs.at(1);
|
||||
const auto& data_shape = data->get_output_partial_shape(0);
|
||||
const auto& scales_shape = scales->get_output_partial_shape(0);
|
||||
|
||||
const auto data_shape = data->get_output_partial_shape(0);
|
||||
const auto scales_shape = scales->get_output_partial_shape(0);
|
||||
if (ngraph::op::is_constant(scales) && data_shape.is_static())
|
||||
{
|
||||
const auto scales_const =
|
||||
as_type_ptr<default_opset::Constant>(scales->shared_from_this());
|
||||
|
||||
const auto scales_vector = scales_const->cast_vector<float>();
|
||||
const auto data_static_shape = data_shape.to_shape();
|
||||
|
||||
std::vector<int64_t> output_shape;
|
||||
for (size_t i = 0; i < data_static_shape.size(); ++i)
|
||||
{
|
||||
output_shape.push_back(
|
||||
std::floor(data_static_shape.at(i) * scales_vector.at(i)));
|
||||
}
|
||||
auto output_shape_const = default_opset::Constant::create(
|
||||
element::u64, Shape({output_shape.size()}), output_shape);
|
||||
|
||||
return output_shape_const;
|
||||
}
|
||||
|
||||
const auto shape_of_data = std::make_shared<default_opset::Convert>(
|
||||
std::make_shared<default_opset::ShapeOf>(data), scales->get_element_type());
|
||||
const auto multiply =
|
||||
std::make_shared<default_opset::Multiply>(shape_of_data, scales);
|
||||
const auto output_shape =
|
||||
std::make_shared<default_opset::Convert>(multiply, ngraph::element::i64);
|
||||
|
||||
return output_shape;
|
||||
}
|
||||
|
||||
NodeVector build_resize(const Node& node,
|
||||
const std::shared_ptr<ngraph::Node>& output_shape,
|
||||
const AxisSet& axes)
|
||||
{
|
||||
const auto mode = node.get_attribute_value<std::string>("mode", "nearest");
|
||||
|
||||
std::unordered_set<std::string> supported_modes = {"nearest", "linear"};
|
||||
@ -58,54 +91,123 @@ namespace ngraph
|
||||
supported_modes_str);
|
||||
}
|
||||
|
||||
CHECK_VALID_NODE(
|
||||
node,
|
||||
(scales_shape.is_static() || data_shape.rank().is_static()),
|
||||
" Data rank or shape of Scales input is required to be static.");
|
||||
|
||||
size_t axes_size = scales_shape.is_static() ? scales_shape.to_shape().at(0)
|
||||
: data_shape.rank().get_length();
|
||||
AxisSet axes;
|
||||
for (int ax = 0; ax < axes_size; ++ax)
|
||||
{
|
||||
axes.insert(ax);
|
||||
}
|
||||
|
||||
auto attrs = ngraph::op::v0::InterpolateAttrs();
|
||||
attrs.axes = axes;
|
||||
attrs.mode = mode;
|
||||
attrs.align_corners = false;
|
||||
|
||||
if (ngraph::op::is_constant(scales) && data_shape.is_static())
|
||||
{
|
||||
const auto scales_const =
|
||||
as_type_ptr<default_opset::Constant>(scales->shared_from_this());
|
||||
const auto inputs = node.get_ng_inputs();
|
||||
const auto& data = inputs.at(0);
|
||||
|
||||
auto scales_vector = scales_const->cast_vector<float>();
|
||||
auto data_static_shape = data_shape.to_shape();
|
||||
|
||||
std::vector<int64_t> output_shape;
|
||||
for (size_t i = 0; i < data_static_shape.size(); ++i)
|
||||
{
|
||||
output_shape.push_back(
|
||||
std::floor(data_static_shape.at(i) * scales_vector.at(i)));
|
||||
}
|
||||
auto output_shape_const = default_opset::Constant::create(
|
||||
element::u64, Shape({output_shape.size()}), output_shape);
|
||||
|
||||
return {std::make_shared<default_opset::Interpolate>(
|
||||
data, output_shape_const, attrs)};
|
||||
}
|
||||
|
||||
auto shape_of_data = std::make_shared<default_opset::Convert>(
|
||||
std::make_shared<default_opset::ShapeOf>(data), ngraph::element::f32);
|
||||
auto multiply =
|
||||
std::make_shared<default_opset::Multiply>(shape_of_data, scales);
|
||||
auto output_shape = std::make_shared<default_opset::Convert>(
|
||||
std::make_shared<default_opset::Floor>(multiply), ngraph::element::i64);
|
||||
return {
|
||||
std::make_shared<default_opset::Interpolate>(data, output_shape, attrs)};
|
||||
}
|
||||
}
|
||||
|
||||
namespace set_11
|
||||
{
|
||||
NodeVector resize(const onnx_import::Node& node)
|
||||
{
|
||||
// cubic_coeff_a, extrapolation_value attributes are ignored
|
||||
// (they do not have influence on supported modes)
|
||||
const auto coordinate_transformation_mode =
|
||||
node.get_attribute_value<std::string>("coordinate_transformation_mode",
|
||||
"half_pixel");
|
||||
CHECK_VALID_NODE(
|
||||
node,
|
||||
coordinate_transformation_mode == "asymmetric",
|
||||
coordinate_transformation_mode,
|
||||
" - this type of coordinate transformation mode is not supported."
|
||||
" Only asymmetric mode is supported by current version.");
|
||||
|
||||
const auto exclude_outside =
|
||||
node.get_attribute_value<int64_t>("exclude_outside ", 0);
|
||||
CHECK_VALID_NODE(node,
|
||||
exclude_outside == 0,
|
||||
"Expected exclude_outside=",
|
||||
exclude_outside,
|
||||
" mode is not supported. ",
|
||||
"Current version supports only exclude_outside equals `0`.");
|
||||
|
||||
const auto mode = node.get_attribute_value<std::string>("mode", "nearest");
|
||||
if (mode == "nearest")
|
||||
{
|
||||
const auto nearest_mode = node.get_attribute_value<std::string>(
|
||||
"nearest_mode", "round_prefer_floor");
|
||||
CHECK_VALID_NODE(
|
||||
node,
|
||||
nearest_mode == "floor",
|
||||
"Expected nearest_mode=",
|
||||
nearest_mode,
|
||||
" mode is not supported. ",
|
||||
"Current version support only nearest_mode equals `floor`");
|
||||
}
|
||||
|
||||
// roi input (inputs.at(2)) is ignored because it is used only
|
||||
// in "tf_crop_and_resize" which is not handled now
|
||||
const auto inputs = node.get_ng_inputs();
|
||||
const auto& data = inputs.at(0);
|
||||
const auto& data_shape = data->get_output_partial_shape(0);
|
||||
|
||||
if (inputs.size() == 4) // sizes input is provided
|
||||
{
|
||||
const auto& sizes = inputs.at(3);
|
||||
const auto& sizes_shape = sizes->get_output_partial_shape(0);
|
||||
|
||||
CHECK_VALID_NODE(
|
||||
node,
|
||||
(sizes_shape.is_static() || data_shape.rank().is_static()),
|
||||
" Data rank or shape of sizes input is required to be static.");
|
||||
|
||||
size_t axes_size = sizes_shape.is_static() ? sizes_shape[0].get_length()
|
||||
: data_shape.rank().get_length();
|
||||
|
||||
return build_resize(
|
||||
node, sizes, AxisSet(common::get_monotonic_range(axes_size)));
|
||||
}
|
||||
|
||||
const auto& scales = inputs.at(2);
|
||||
const auto& scales_shape = scales->get_output_partial_shape(0);
|
||||
|
||||
CHECK_VALID_NODE(
|
||||
node,
|
||||
(scales_shape.is_static() || data_shape.rank().is_static()),
|
||||
" Data rank or shape of scales input is required to be static.");
|
||||
|
||||
size_t axes_size = scales_shape.is_static() ? scales_shape[0].get_length()
|
||||
: data_shape.rank().get_length();
|
||||
|
||||
const auto output_shape = calculate_output_shape_based_on_scales(data, scales);
|
||||
|
||||
return build_resize(
|
||||
node, output_shape, AxisSet(common::get_monotonic_range(axes_size)));
|
||||
}
|
||||
} // namespace set_11
|
||||
|
||||
namespace set_1
|
||||
{
|
||||
NodeVector resize(const onnx_import::Node& node)
|
||||
{
|
||||
const auto inputs = node.get_ng_inputs();
|
||||
const auto& data = inputs.at(0);
|
||||
const auto& scales = inputs.at(1);
|
||||
|
||||
const auto& data_shape = data->get_output_partial_shape(0);
|
||||
const auto& scales_shape = scales->get_output_partial_shape(0);
|
||||
|
||||
CHECK_VALID_NODE(
|
||||
node,
|
||||
(scales_shape.is_static() || data_shape.rank().is_static()),
|
||||
" Data rank or shape of scales input is required to be static.");
|
||||
|
||||
size_t axes_size = scales_shape.is_static() ? scales_shape[0].get_length()
|
||||
: data_shape.rank().get_length();
|
||||
|
||||
const auto output_shape = calculate_output_shape_based_on_scales(data, scales);
|
||||
|
||||
return build_resize(
|
||||
node, output_shape, AxisSet(common::get_monotonic_range(axes_size)));
|
||||
}
|
||||
|
||||
} // namespace set_1
|
||||
|
||||
|
@ -31,6 +31,11 @@ namespace ngraph
|
||||
|
||||
} // namespace set_1
|
||||
|
||||
namespace set_11
|
||||
{
|
||||
NodeVector resize(const Node& node);
|
||||
}
|
||||
|
||||
} // namespace op
|
||||
|
||||
} // namespace onnx_import
|
||||
|
@ -356,6 +356,7 @@ namespace ngraph
|
||||
REGISTER_OPERATOR("Relu", 1, relu);
|
||||
REGISTER_OPERATOR("Reshape", 1, reshape);
|
||||
REGISTER_OPERATOR("Resize", 1, resize);
|
||||
REGISTER_OPERATOR("Resize", 11, resize);
|
||||
REGISTER_OPERATOR("ReverseSequence", 1, reverse_sequence);
|
||||
REGISTER_OPERATOR("RNN", 1, rnn);
|
||||
REGISTER_OPERATOR("RoiAlign", 1, roi_align);
|
||||
|
@ -305,6 +305,7 @@ set(MULTI_TEST_SRC
|
||||
backend/gather.in.cpp
|
||||
backend/gelu.in.cpp
|
||||
backend/group_convolution.in.cpp
|
||||
backend/interpolate.in.cpp
|
||||
backend/log.in.cpp
|
||||
backend/logical_or.in.cpp
|
||||
backend/logical_xor.in.cpp
|
||||
|
62
ngraph/test/backend/interpolate.in.cpp
Normal file
62
ngraph/test/backend/interpolate.in.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
//*****************************************************************************
|
||||
// Copyright 2017-2020 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//*****************************************************************************
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "ngraph/runtime/tensor.hpp"
|
||||
#include "runtime/backend.hpp"
|
||||
#include "util/all_close.hpp"
|
||||
#include "util/all_close_f.hpp"
|
||||
#include "util/engine/test_engines.hpp"
|
||||
#include "util/known_element_types.hpp"
|
||||
#include "util/ndarray.hpp"
|
||||
#include "util/test_case.hpp"
|
||||
#include "util/test_control.hpp"
|
||||
#include "util/test_tools.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
|
||||
static string s_manifest = "${MANIFEST}";
|
||||
|
||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, interpolate_down_scales_const_linear)
|
||||
{
|
||||
Shape input_shape{1, 1, 2, 4};
|
||||
Shape output_shape{1, 1, 1, 2};
|
||||
op::v0::InterpolateAttrs attrs;
|
||||
attrs.axes = AxisSet{0, 1, 2, 3};
|
||||
attrs.mode = "linear";
|
||||
attrs.align_corners = false;
|
||||
const auto input = make_shared<op::Parameter>(element::f32, input_shape);
|
||||
const auto output_shape_input = op::Constant::create(element::i64, {4}, {1, 1, 1, 2});
|
||||
std::vector<float> intput_data{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
|
||||
|
||||
auto interpolate = make_shared<op::Interpolate>(input, output_shape_input, attrs);
|
||||
auto f = make_shared<Function>(interpolate, ParameterVector{input});
|
||||
|
||||
auto backend = runtime::Backend::create("IE_CPU");
|
||||
auto input_tensor = backend->create_tensor(element::f32, input_shape);
|
||||
auto result_tensor = backend->create_tensor(element::f32, output_shape);
|
||||
auto handle = backend->compile(f);
|
||||
copy_data(input_tensor, intput_data);
|
||||
|
||||
handle->call_with_validate({result_tensor}, {input_tensor});
|
||||
|
||||
vector<float> expected_output{1.0f, 2.66666651f};
|
||||
EXPECT_TRUE(test::all_close_f(expected_output, read_vector<float>(result_tensor)));
|
||||
}
|
124
ngraph/test/models/onnx/resize11_scales_down_linear.prototxt
Normal file
124
ngraph/test/models/onnx/resize11_scales_down_linear.prototxt
Normal file
@ -0,0 +1,124 @@
|
||||
ir_version: 7
|
||||
producer_name: "onnx-importer-test"
|
||||
graph {
|
||||
node {
|
||||
output: "scales"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 4
|
||||
data_type: 1
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 0.6
|
||||
float_data: 0.6
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
output: "roi"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 8
|
||||
data_type: 1
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
input: "X"
|
||||
input: "roi"
|
||||
input: "scales"
|
||||
output: "Y"
|
||||
op_type: "Resize"
|
||||
attribute {
|
||||
name: "coordinate_transformation_mode"
|
||||
s: "asymmetric"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "cubic_coeff_a"
|
||||
f: -0.75
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "exclude_outside"
|
||||
i: 0
|
||||
type: INT
|
||||
}
|
||||
attribute {
|
||||
name: "extrapolation_value"
|
||||
f: 0
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "mode"
|
||||
s: "linear"
|
||||
type: STRING
|
||||
}
|
||||
}
|
||||
name: "test-model"
|
||||
input {
|
||||
name: "X"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
output {
|
||||
name: "Y"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
domain: ""
|
||||
version: 11
|
||||
}
|
||||
|
@ -0,0 +1,129 @@
|
||||
ir_version: 7
|
||||
producer_name: "onnx-importer-test"
|
||||
graph {
|
||||
node {
|
||||
output: "scales"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 4
|
||||
data_type: 1
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 2.0
|
||||
float_data: 0.5
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
output: "roi"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 8
|
||||
data_type: 1
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
input: "X"
|
||||
input: "roi"
|
||||
input: "scales"
|
||||
output: "Y"
|
||||
op_type: "Resize"
|
||||
attribute {
|
||||
name: "coordinate_transformation_mode"
|
||||
s: "asymmetric"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "cubic_coeff_a"
|
||||
f: -0.75
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "exclude_outside"
|
||||
i: 0
|
||||
type: INT
|
||||
}
|
||||
attribute {
|
||||
name: "extrapolation_value"
|
||||
f: 0
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "mode"
|
||||
s: "nearest"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "nearest_mode"
|
||||
s: "floor"
|
||||
type: STRING
|
||||
}
|
||||
}
|
||||
name: "test-model"
|
||||
input {
|
||||
name: "X"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
output {
|
||||
name: "Y"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 4
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
domain: ""
|
||||
version: 11
|
||||
}
|
||||
|
@ -0,0 +1,117 @@
|
||||
ir_version: 7
|
||||
producer_name: "onnx-importer-test"
|
||||
graph {
|
||||
node {
|
||||
input: "X"
|
||||
input: "roi"
|
||||
input: "scales"
|
||||
output: "Y"
|
||||
op_type: "Resize"
|
||||
attribute {
|
||||
name: "coordinate_transformation_mode"
|
||||
s: "asymmetric"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "cubic_coeff_a"
|
||||
f: -0.75
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "exclude_outside"
|
||||
i: 0
|
||||
type: INT
|
||||
}
|
||||
attribute {
|
||||
name: "extrapolation_value"
|
||||
f: 0
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "mode"
|
||||
s: "nearest"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "nearest_mode"
|
||||
s: "floor"
|
||||
type: STRING
|
||||
}
|
||||
}
|
||||
name: "test-model"
|
||||
input {
|
||||
name: "X"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
input {
|
||||
name: "roi"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 8
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
input {
|
||||
name: "scales"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
output {
|
||||
name: "Y"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 4
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
domain: ""
|
||||
version: 11
|
||||
}
|
||||
|
@ -0,0 +1,129 @@
|
||||
ir_version: 7
|
||||
producer_name: "onnx-importer-test"
|
||||
graph {
|
||||
node {
|
||||
output: "scales"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 4
|
||||
data_type: 1
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 2.0
|
||||
float_data: 4.0
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
output: "roi"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 8
|
||||
data_type: 1
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
input: "X"
|
||||
input: "roi"
|
||||
input: "scales"
|
||||
output: "Y"
|
||||
op_type: "Resize"
|
||||
attribute {
|
||||
name: "coordinate_transformation_mode"
|
||||
s: "asymmetric"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "cubic_coeff_a"
|
||||
f: -0.75
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "exclude_outside"
|
||||
i: 0
|
||||
type: INT
|
||||
}
|
||||
attribute {
|
||||
name: "extrapolation_value"
|
||||
f: 0
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "mode"
|
||||
s: "linear"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "nearest_mode"
|
||||
s: "floor"
|
||||
type: STRING
|
||||
}
|
||||
}
|
||||
name: "test-model"
|
||||
input {
|
||||
name: "X"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
output {
|
||||
name: "Y"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 4
|
||||
}
|
||||
dim {
|
||||
dim_value: 8
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
domain: ""
|
||||
version: 11
|
||||
}
|
||||
|
139
ngraph/test/models/onnx/resize11_sizes_linear.prototxt
Normal file
139
ngraph/test/models/onnx/resize11_sizes_linear.prototxt
Normal file
@ -0,0 +1,139 @@
|
||||
ir_version: 7
|
||||
producer_name: "onnx-importer-test"
|
||||
graph {
|
||||
node {
|
||||
output: "scales"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 1
|
||||
float_data: 1.0
|
||||
data_type: 1
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
output: "sizes"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 4
|
||||
data_type: 7
|
||||
int64_data: 2
|
||||
int64_data: 1
|
||||
int64_data: 4
|
||||
int64_data: 8
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
output: "roi"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 8
|
||||
data_type: 1
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
input: "X"
|
||||
input: "roi"
|
||||
input: "scales"
|
||||
input: "sizes"
|
||||
output: "Y"
|
||||
op_type: "Resize"
|
||||
attribute {
|
||||
name: "coordinate_transformation_mode"
|
||||
s: "asymmetric"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "cubic_coeff_a"
|
||||
f: -0.75
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "exclude_outside"
|
||||
i: 0
|
||||
type: INT
|
||||
}
|
||||
attribute {
|
||||
name: "extrapolation_value"
|
||||
f: 0
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "mode"
|
||||
s: "linear"
|
||||
type: STRING
|
||||
}
|
||||
}
|
||||
name: "test-model"
|
||||
input {
|
||||
name: "X"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
output {
|
||||
name: "Y"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 4
|
||||
}
|
||||
dim {
|
||||
dim_value: 8
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
domain: ""
|
||||
version: 11
|
||||
}
|
||||
|
@ -0,0 +1,144 @@
|
||||
ir_version: 7
|
||||
producer_name: "onnx-importer-test"
|
||||
graph {
|
||||
node {
|
||||
output: "scales"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 1
|
||||
float_data: 1.0
|
||||
data_type: 1
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
output: "sizes"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 4
|
||||
data_type: 7
|
||||
int64_data: 2
|
||||
int64_data: 1
|
||||
int64_data: 4
|
||||
int64_data: 1
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
output: "roi"
|
||||
op_type: "Constant"
|
||||
attribute {
|
||||
name: "value"
|
||||
t {
|
||||
dims: 8
|
||||
data_type: 1
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
float_data: 1.0
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
node {
|
||||
input: "X"
|
||||
input: "roi"
|
||||
input: "scales"
|
||||
input: "sizes"
|
||||
output: "Y"
|
||||
op_type: "Resize"
|
||||
attribute {
|
||||
name: "coordinate_transformation_mode"
|
||||
s: "asymmetric"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "cubic_coeff_a"
|
||||
f: -0.75
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "exclude_outside"
|
||||
i: 0
|
||||
type: INT
|
||||
}
|
||||
attribute {
|
||||
name: "extrapolation_value"
|
||||
f: 0
|
||||
type: FLOAT
|
||||
}
|
||||
attribute {
|
||||
name: "mode"
|
||||
s: "nearest"
|
||||
type: STRING
|
||||
}
|
||||
attribute {
|
||||
name: "nearest_mode"
|
||||
s: "floor"
|
||||
type: STRING
|
||||
}
|
||||
}
|
||||
name: "test-model"
|
||||
input {
|
||||
name: "X"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
output {
|
||||
name: "Y"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 2
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 4
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
domain: ""
|
||||
version: 11
|
||||
}
|
||||
|
@ -1148,6 +1148,113 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_up_scales_const_nearest)
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_down_linear)
|
||||
{
|
||||
const auto function = onnx_import::import_onnx_model(
|
||||
file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_scales_down_linear.prototxt"));
|
||||
|
||||
const Shape expected_output_shape{1, 1, 1, 2};
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
const size_t input_size = 8;
|
||||
std::vector<float> input_data(input_size);
|
||||
std::iota(std::begin(input_data), std::end(input_data), 1.0f);
|
||||
test_case.add_input<float>(input_data);
|
||||
test_case.add_expected_output<float>(expected_output_shape, {1.0f, 2.66666651f});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_up_linear_asymmetric)
|
||||
{
|
||||
const auto function = onnx_import::import_onnx_model(
|
||||
file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_scales_up_linear_asymmetric.prototxt"));
|
||||
|
||||
const Shape expected_output_shape{2, 1, 4, 8};
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
const size_t input_size = 8;
|
||||
std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
|
||||
test_case.add_input<float>(input_data);
|
||||
test_case.add_expected_output<float>(
|
||||
expected_output_shape,
|
||||
{1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 2.5f, 3.25f, 4.0f,
|
||||
4.75f, 5.5f, 5.5f, 5.5f, 5.5f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 8.0f,
|
||||
8.0f, 8.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 8.0f, 8.0f, 8.0f,
|
||||
|
||||
6.0f, 5.0f, 4.0f, 3.0f, 2.0f, 2.0f, 2.0f, 2.0f, 6.5f, 6.5f, 6.5f,
|
||||
6.5f, 6.5f, 6.5f, 6.5f, 6.5f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f,
|
||||
11.0f, 11.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 11.0f, 11.0f, 11.0f});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_nearest_asymmetric_floor)
|
||||
{
|
||||
const auto function = onnx_import::import_onnx_model(file_util::path_join(
|
||||
SERIALIZED_ZOO, "onnx/resize11_scales_nearest_asymmetric_floor.prototxt"));
|
||||
|
||||
const Shape expected_output_shape{2, 1, 4, 1};
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
const std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
|
||||
test_case.add_input<float>(input_data);
|
||||
test_case.add_expected_output<float>(expected_output_shape,
|
||||
{1.0f, 1.0f, 4.0f, 4.0f, 6.0f, 6.0f, 7.0f, 7.0f});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_scales_nearest_asymmetric_floor_dynamic_sizes)
|
||||
{
|
||||
const auto function = onnx_import::import_onnx_model(file_util::path_join(
|
||||
SERIALIZED_ZOO, "onnx/resize11_scales_nearest_asymmetric_floor_dynamic_scales.prototxt"));
|
||||
|
||||
const Shape expected_output_shape{2, 1, 4, 1};
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
const std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
|
||||
test_case.add_input<float>(input_data);
|
||||
test_case.add_input<float>(
|
||||
std::vector<float>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}); // roi
|
||||
test_case.add_input<float>(std::vector<float>{1.0f, 1.0f, 2.0f, 0.5f}); // scales
|
||||
test_case.add_expected_output<float>(expected_output_shape,
|
||||
{1.0f, 1.0f, 4.0f, 4.0f, 6.0f, 6.0f, 7.0f, 7.0f});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_sizes_nearest_asymmetric_floor)
|
||||
{
|
||||
const auto function = onnx_import::import_onnx_model(file_util::path_join(
|
||||
SERIALIZED_ZOO, "onnx/resize11_sizes_nearest_asymmetric_floor.prototxt"));
|
||||
|
||||
const Shape expected_output_shape{2, 1, 4, 1};
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
std::vector<float> input_data{1.0f, 3.0f, 4.0f, 8.0f, 6.0f, 2.0f, 7.0f, 11.0f};
|
||||
test_case.add_input<float>(input_data);
|
||||
test_case.add_expected_output<float>(expected_output_shape,
|
||||
{1.0f, 1.0f, 4.0f, 4.0f, 6.0f, 6.0f, 7.0f, 7.0f});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_sizes_linear)
|
||||
{
|
||||
const auto function = onnx_import::import_onnx_model(
|
||||
file_util::path_join(SERIALIZED_ZOO, "onnx/resize11_sizes_linear.prototxt"));
|
||||
|
||||
const Shape expected_output_shape{2, 1, 4, 8};
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
std::vector<float> input_data{2.0f, 4.0f, 1.0f, 3.0f, 7.0f, 8.0f, 9.0f, 6.0f};
|
||||
test_case.add_input<float>(input_data);
|
||||
test_case.add_expected_output<float>(
|
||||
expected_output_shape,
|
||||
{2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.0f, 4.0f, 4.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.5f,
|
||||
3.5f, 3.5f, 3.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 1.0f, 1.5f,
|
||||
2.0f, 2.5f, 3.0f, 3.0f, 3.0f, 3.0f, 7.0f, 7.25f, 7.5f, 7.75f, 8.0f, 8.0f, 8.0f,
|
||||
8.0f, 8.0f, 7.75f, 7.5f, 7.25f, 7.0f, 7.0f, 7.0f, 7.0f, 9.0f, 8.25f, 7.5f, 6.75f,
|
||||
6.0f, 6.0f, 6.0f, 6.0f, 9.0f, 8.25f, 7.5f, 6.75f, 6.0f, 6.0f, 6.0f, 6.0f});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_shape)
|
||||
{
|
||||
auto function =
|
||||
|
@ -1087,8 +1087,17 @@ IE_CPU.atanh
|
||||
IE_CPU.asinh
|
||||
IE_CPU.acosh
|
||||
|
||||
# Interpolate-1 in linear mode
|
||||
# 2.666666507720947266 is not close to 3 at index 1
|
||||
IE_CPU.interpolate_down_scales_const_linear
|
||||
|
||||
# Result mismatch 2.666666507720947266 is not close to 3 at index 1
|
||||
IE_CPU.onnx_resize10_down_scales_const_linear
|
||||
IE_CPU.onnx_resize11_scales_down_linear
|
||||
|
||||
# C++ exception with description "Interpolate operation should be converted to Interp
|
||||
# not constant output_shape passed to Interpolate-1
|
||||
IE_CPU.onnx_resize11_scales_nearest_asymmetric_floor_dynamic_sizes
|
||||
|
||||
# GRUCell operation has a form that is not supported
|
||||
IE_CPU.onnx_model_gru_defaults_fwd
|
||||
|
@ -20,6 +20,13 @@ INTERPRETER.onnx_upsample8_linear_infer
|
||||
INTERPRETER.onnx_upsample9_scales_const_nearest_infer
|
||||
INTERPRETER.onnx_upsample9_scales_const_linear_infer
|
||||
INTERPRETER.onnx_upsample9_scales_input_nearest_infer
|
||||
INTERPRETER.onnx_resize11_scales_down_linear
|
||||
INTERPRETER.onnx_resize11_scales_up_linear_asymmetric
|
||||
INTERPRETER.onnx_resize11_scales_nearest_asymmetric_floor
|
||||
INTERPRETER.onnx_resize11_sizes_nearest_asymmetric_floor
|
||||
INTERPRETER.onnx_resize11_sizes_linear
|
||||
INTERPRETER.onnx_resize11_scales_nearest_asymmetric_floor_dynamic_sizes
|
||||
INTERPRETER.interpolate_down_scales_const_linear
|
||||
|
||||
# ONNX Loop
|
||||
onnx_controlflow_loop_2d_add_execution
|
||||
|
Loading…
Reference in New Issue
Block a user