[ONNX] Set configuration for NEAREST interpolate mode (#6413)
This commit is contained in:
parent
a1eb5b1fd5
commit
9d93c09e24
@ -224,7 +224,13 @@ namespace ngraph
|
||||
const auto& scales_shape = scales.get_partial_shape();
|
||||
|
||||
auto attrs = get_resize_attrs(node);
|
||||
if (attrs.mode == InterpolateMode::linear_onnx)
|
||||
|
||||
if (attrs.mode == InterpolateMode::nearest)
|
||||
{
|
||||
attrs.nearest_mode = Nearest_mode::floor;
|
||||
attrs.coordinate_transformation_mode = Transform_mode::asymmetric;
|
||||
}
|
||||
else if (attrs.mode == InterpolateMode::linear_onnx)
|
||||
{
|
||||
attrs.coordinate_transformation_mode = Transform_mode::asymmetric;
|
||||
}
|
||||
|
@ -0,0 +1,82 @@
|
||||
ir_version: 7
|
||||
producer_name: "backend-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: 1.9
|
||||
float_data: 1.0
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
input: "X"
|
||||
input: "scales"
|
||||
output: "Y"
|
||||
op_type: "Resize"
|
||||
attribute {
|
||||
name: "mode"
|
||||
s: "nearest"
|
||||
type: STRING
|
||||
}
|
||||
}
|
||||
name: "test_resize_downsample_scales_nearest"
|
||||
input {
|
||||
name: "X"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 10
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
output {
|
||||
name: "Y"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 19
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
version: 10
|
||||
}
|
82
ngraph/test/models/onnx/resize10_asymertic_last_dim.prototxt
Normal file
82
ngraph/test/models/onnx/resize10_asymertic_last_dim.prototxt
Normal file
@ -0,0 +1,82 @@
|
||||
ir_version: 7
|
||||
producer_name: "backend-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: 1.0
|
||||
float_data: 1.9
|
||||
name: "const_tensor"
|
||||
}
|
||||
type: TENSOR
|
||||
}
|
||||
}
|
||||
|
||||
node {
|
||||
input: "X"
|
||||
input: "scales"
|
||||
output: "Y"
|
||||
op_type: "Resize"
|
||||
attribute {
|
||||
name: "mode"
|
||||
s: "nearest"
|
||||
type: STRING
|
||||
}
|
||||
}
|
||||
name: "test_resize_downsample_scales_nearest"
|
||||
input {
|
||||
name: "X"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 1
|
||||
}
|
||||
dim {
|
||||
dim_value: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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: 19
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
version: 10
|
||||
}
|
@ -1398,6 +1398,37 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_reduce_sum_13_axes_empty_without_noop)
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_asymertic_last_dim)
|
||||
{
|
||||
const auto function = onnx_import::import_onnx_model(
|
||||
file_util::path_join(SERIALIZED_ZOO, "onnx/resize10_asymertic_last_dim.prototxt"));
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
std::vector<float> input_data{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f};
|
||||
test_case.add_input<float>(input_data);
|
||||
test_case.add_expected_output<float>(
|
||||
Shape{1,1,1,19},{1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f, 7.0f, 7.0f, 8.0f, 8.0f, 9.0f, 9.0f, 10.0f});
|
||||
test_case.run();
|
||||
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_resize10_asymertic_dim_in_the_middle)
|
||||
{
|
||||
const auto function = onnx_import::import_onnx_model(
|
||||
file_util::path_join(SERIALIZED_ZOO, "onnx/resize10_asymertic_dim_in_the_middle.prototxt"));
|
||||
|
||||
auto test_case = test::TestCase<TestEngine>(function);
|
||||
std::vector<float> input_data{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f};
|
||||
test_case.add_input<float>(input_data);
|
||||
test_case.add_expected_output<float>(
|
||||
Shape{1,1,19,1},{1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 4.0f, 4.0f, 5.0f, 5.0f, 6.0f, 6.0f, 7.0f, 7.0f, 8.0f, 8.0f, 9.0f, 9.0f, 10.0f});
|
||||
test_case.run();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_resize11_empty_constant_as_input)
|
||||
{
|
||||
// this model contains a Constant node with an empty underlying tensor
|
||||
|
Loading…
Reference in New Issue
Block a user