From af8dc644a81f91bc45b55aab555bafe3d1180917 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Fri, 13 Aug 2021 09:16:47 +0300 Subject: [PATCH] Enabled NCC for enums (#7038) * Enabled NCC for enums * Fixed enum values * Marked lower case enum as deprecated * Fixed deprecated enums * Disable deprecation for Windows and GCC < 6 * Try to fix build --- .../ncc_naming_style/openvino.style | 6 +- .../src/cldnn_engine/ops/interpolate.cpp | 32 ++--- .../src/interpolate.cpp | 6 +- .../src/markup_precisions.cpp | 2 +- .../convert_interpolate1_to_interpolate4.cpp | 24 ++-- .../interpolate_transformation.cpp | 28 ++-- ...vert_interpolate1_to_interpolate4_test.cpp | 12 +- .../single_layer_tests/interpolate.cpp | 34 ++--- .../subgraph_tests/concat_resize_concat.cpp | 8 +- .../cpu/single_layer_tests/interpolate.cpp | 26 ++-- .../single_layer_tests/interpolate.cpp | 16 +-- .../single_layer_tests/interpolate.cpp | 4 +- .../src/utils/ngraph_helpers.cpp | 32 ++--- ngraph/core/include/ngraph/deprecated.hpp | 11 +- ngraph/core/include/ngraph/op/interpolate.hpp | 87 +++++++++--- .../ngraph/runtime/reference/interpolate.hpp | 28 ++-- ngraph/core/src/op/interpolate.cpp | 44 +++--- .../frontend/onnx/frontend/src/op/resize.cpp | 41 +++--- .../onnx/frontend/src/op/upsample.cpp | 13 +- .../frontend/paddlepaddle/src/op/interp.cpp | 24 ++-- ngraph/test/op_eval/interpolate.cpp | 130 +++++++++--------- ngraph/test/type_prop/interpolate.cpp | 64 ++++----- 22 files changed, 363 insertions(+), 309 deletions(-) diff --git a/cmake/developer_package/ncc_naming_style/openvino.style b/cmake/developer_package/ncc_naming_style/openvino.style index 1dc5316712936b..6832847ae3a0c9 100644 --- a/cmake/developer_package/ncc_naming_style/openvino.style +++ b/cmake/developer_package/ncc_naming_style/openvino.style @@ -18,9 +18,11 @@ FunctionTemplate: '^(operator.+|\w+)$' TypeAliasName: '^\w+$' VariableReference: '^\w+$' +EnumName: '^[A-Z][\w]+$' +# excepts element_type +# TODO: Fix interpolate +EnumConstantName: '^([A-Z\d_]+|undefined|dynamic|boolean|bf16|f16|f32|f64|i4|i8|i16|i32|i64|u1|u4|u8|u16|u32|u64|asymmetric|align_corners|round_prefer_floor|round_prefer_ceil|floor|ceil|simple|nearest|linear|linear_onnx|cubic|area|scales|sizes|half_pixel|tf_half_pixel_for_nn|pytorch_half_pixel|asymetric)$' # TODO: align -EnumConstantName: '^.*$' -EnumName: '^.*$' UsingDeclaration: '^.*$' TypedefName: '^.*$' diff --git a/inference-engine/src/cldnn_engine/ops/interpolate.cpp b/inference-engine/src/cldnn_engine/ops/interpolate.cpp index b77999289c631b..df99e6972eefbf 100644 --- a/inference-engine/src/cldnn_engine/ops/interpolate.cpp +++ b/inference-engine/src/cldnn_engine/ops/interpolate.cpp @@ -15,15 +15,15 @@ namespace CLDNNPlugin { static cldnn::coordinate_transformation_mode GetCoordinateTransformationMode(ngraph::op::v4::Interpolate::CoordinateTransformMode mode) { switch (mode) { - case ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL: return cldnn::coordinate_transformation_mode::half_pixel; - case ngraph::op::v4::Interpolate::CoordinateTransformMode::pytorch_half_pixel: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::PYTORCH_HALF_PIXEL: return cldnn::coordinate_transformation_mode::pytorch_half_pixel; - case ngraph::op::v4::Interpolate::CoordinateTransformMode::asymmetric: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::ASYMMETRIC: return cldnn::coordinate_transformation_mode::asymmetric; - case ngraph::op::v4::Interpolate::CoordinateTransformMode::tf_half_pixel_for_nn: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN: return cldnn::coordinate_transformation_mode::tf_half_pixel_for_nn; - case ngraph::op::v4::Interpolate::CoordinateTransformMode::align_corners: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS: return cldnn::coordinate_transformation_mode::align_corners; } @@ -32,15 +32,15 @@ static cldnn::coordinate_transformation_mode GetCoordinateTransformationMode(ngr static cldnn::nearest_mode GetNearestMode(ngraph::op::v4::Interpolate::NearestMode mode) { switch (mode) { - case ngraph::op::v4::Interpolate::NearestMode::round_prefer_floor: + case ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR: return cldnn::nearest_mode::round_prefer_floor; - case ngraph::op::v4::Interpolate::NearestMode::round_prefer_ceil: + case ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_CEIL: return cldnn::nearest_mode::round_prefer_ceil; - case ngraph::op::v4::Interpolate::NearestMode::floor: + case ngraph::op::v4::Interpolate::NearestMode::FLOOR: return cldnn::nearest_mode::floor; - case ngraph::op::v4::Interpolate::NearestMode::ceil: + case ngraph::op::v4::Interpolate::NearestMode::CEIL: return cldnn::nearest_mode::ceil; - case ngraph::op::v4::Interpolate::NearestMode::simple: + case ngraph::op::v4::Interpolate::NearestMode::SIMPLE: return cldnn::nearest_mode::simple; } @@ -49,18 +49,18 @@ static cldnn::nearest_mode GetNearestMode(ngraph::op::v4::Interpolate::NearestMo static cldnn::shape_calculation_mode GetShapeCalculationMode(ngraph::op::v4::Interpolate::ShapeCalcMode mode) { switch (mode) { - case ngraph::op::v4::Interpolate::ShapeCalcMode::sizes: return cldnn::shape_calculation_mode::sizes; - case ngraph::op::v4::Interpolate::ShapeCalcMode::scales: return cldnn::shape_calculation_mode::scales; + case ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES: return cldnn::shape_calculation_mode::sizes; + case ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES: return cldnn::shape_calculation_mode::scales; } IE_THROW() << "Unknown shape calculation mode: " << static_cast(mode); } static cldnn::resample_type GetResampleType(ngraph::op::v4::Interpolate::InterpolateMode mode) { switch (mode) { - case ngraph::op::v4::Interpolate::InterpolateMode::nearest: return cldnn::resample_type::nearest; - case ngraph::op::v4::Interpolate::InterpolateMode::linear: return cldnn::resample_type::caffe_bilinear; - case ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx: return cldnn::resample_type::linear_onnx; - case ngraph::op::v4::Interpolate::InterpolateMode::cubic: return cldnn::resample_type::cubic; + case ngraph::op::v4::Interpolate::InterpolateMode::NEAREST: return cldnn::resample_type::nearest; + case ngraph::op::v4::Interpolate::InterpolateMode::LINEAR: return cldnn::resample_type::caffe_bilinear; + case ngraph::op::v4::Interpolate::InterpolateMode::LINEAR_ONNX: return cldnn::resample_type::linear_onnx; + case ngraph::op::v4::Interpolate::InterpolateMode::CUBIC: return cldnn::resample_type::cubic; } IE_THROW() << "Unknown interpolation mode: " << static_cast(mode); } diff --git a/inference-engine/src/low_precision_transformations/src/interpolate.cpp b/inference-engine/src/low_precision_transformations/src/interpolate.cpp index b8538bfd14b5d1..c167a6713b642f 100644 --- a/inference-engine/src/low_precision_transformations/src/interpolate.cpp +++ b/inference-engine/src/low_precision_transformations/src/interpolate.cpp @@ -72,7 +72,7 @@ bool InterpolateTransformation::isPrecisionPreserved(std::shared_ptr layer std::shared_ptr interpolate4 = as_type_ptr(layer); if (interpolate4) { const auto attrs = interpolate4->get_attrs(); - return attrs.mode == op::v4::Interpolate::InterpolateMode::nearest; + return attrs.mode == op::v4::Interpolate::InterpolateMode::NEAREST; } return false; @@ -108,7 +108,7 @@ bool InterpolateTransformation::canBeTransformed(const TransformationContext& co if (interpolate4) { const auto interpAttrs = interpolate4->get_attrs(); - if (interpAttrs.mode != op::v4::Interpolate::InterpolateMode::nearest) { + if (interpAttrs.mode != op::v4::Interpolate::InterpolateMode::NEAREST) { return false; } @@ -126,7 +126,7 @@ bool InterpolateTransformation::canBeTransformed(const TransformationContext& co } } - if (interpAttrs.coordinate_transformation_mode == op::v4::Interpolate::CoordinateTransformMode::align_corners) { + if (interpAttrs.coordinate_transformation_mode == op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS) { return false; } } diff --git a/inference-engine/src/low_precision_transformations/src/markup_precisions.cpp b/inference-engine/src/low_precision_transformations/src/markup_precisions.cpp index 17747179345c1f..64ff58addc01a0 100644 --- a/inference-engine/src/low_precision_transformations/src/markup_precisions.cpp +++ b/inference-engine/src/low_precision_transformations/src/markup_precisions.cpp @@ -166,7 +166,7 @@ bool ngraph::pass::low_precision::MarkupPrecisions::isPrecisionPreserved(const s std::shared_ptr interpolate4 = as_type_ptr(node); if (interpolate4) { const auto attrs = interpolate4->get_attrs(); - return attrs.mode == op::v4::Interpolate::InterpolateMode::nearest; + return attrs.mode == op::v4::Interpolate::InterpolateMode::NEAREST; } } diff --git a/inference-engine/src/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp b/inference-engine/src/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp index 36a58551a68a03..a8b45668461a65 100644 --- a/inference-engine/src/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp +++ b/inference-engine/src/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp @@ -44,7 +44,7 @@ ngraph::pass::ConvertInterpolate1ToInterpolate4::ConvertInterpolate1ToInterpolat ngraph::opset4::Interpolate::InterpolateAttrs attrsV4; if (attrsV0.mode == "nearest") { - attrsV4.mode = ngraph::opset4::Interpolate::InterpolateMode::nearest; + attrsV4.mode = ngraph::opset4::Interpolate::InterpolateMode::NEAREST; } else if (attrsV0.mode == "linear") { // If we write only // attrsV4.mode = ngraph::op::v4::Interpolate::InterpolateMode::linear; @@ -54,34 +54,34 @@ ngraph::pass::ConvertInterpolate1ToInterpolate4::ConvertInterpolate1ToInterpolat // TODO: delete this conditional statement, when CPU will have // optimized version of the 'linear' mode. if (input_shape_rank < 5) { - attrsV4.mode = ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx; + attrsV4.mode = ngraph::op::v4::Interpolate::InterpolateMode::LINEAR_ONNX; } else if (input_shape_rank == 5) { - attrsV4.mode = ngraph::op::v4::Interpolate::InterpolateMode::linear; + attrsV4.mode = ngraph::op::v4::Interpolate::InterpolateMode::LINEAR; } else { return false; } } else if (attrsV0.mode == "cubic") { - attrsV4.mode = ngraph::opset4::Interpolate::InterpolateMode::cubic; + attrsV4.mode = ngraph::opset4::Interpolate::InterpolateMode::CUBIC; } else if (attrsV0.mode == "linear_onnx") { - attrsV4.mode = ngraph::opset4::Interpolate::InterpolateMode::linear_onnx; + attrsV4.mode = ngraph::opset4::Interpolate::InterpolateMode::LINEAR_ONNX; } else { return false; } - attrsV4.shape_calculation_mode = ngraph::opset4::Interpolate::ShapeCalcMode::sizes; - attrsV4.nearest_mode = ngraph::opset4::Interpolate::NearestMode::simple; + attrsV4.shape_calculation_mode = ngraph::opset4::Interpolate::ShapeCalcMode::SIZES; + attrsV4.nearest_mode = ngraph::opset4::Interpolate::NearestMode::SIMPLE; attrsV4.pads_begin = attrsV0.pads_begin; attrsV4.pads_end = attrsV0.pads_end; attrsV4.antialias = attrsV0.antialias; - attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::asymmetric; + attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::ASYMMETRIC; attrsV4.cube_coeff = -0.75f; if (attrsV0.align_corners) { - attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::align_corners; - } else if ((attrsV4.mode == ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx || - attrsV4.mode == ngraph::op::v4::Interpolate::InterpolateMode::linear) && + attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS; + } else if ((attrsV4.mode == ngraph::op::v4::Interpolate::InterpolateMode::LINEAR_ONNX || + attrsV4.mode == ngraph::op::v4::Interpolate::InterpolateMode::LINEAR) && std::all_of(attrsV4.pads_begin.begin(), attrsV4.pads_begin.end(), [](size_t i){return i == 0;}) && std::all_of(attrsV4.pads_end.begin(), attrsV4.pads_end.end(), [](size_t i){return i == 0;}) && !(input_shape_rank - 2 == 2 && attrsV0.axes == AxisSet{2, 3})) { - attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::half_pixel; + attrsV4.coordinate_transformation_mode = ngraph::opset4::Interpolate::CoordinateTransformMode::HALF_PIXEL; } auto interpolateV4 = std::make_shared(interpolationV0->input_value(0), interpolationV0->input_value(1), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/interpolate_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/interpolate_transformation.cpp index 0dfece76d576f5..d733c9283b6ea8 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/interpolate_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/interpolate_transformation.cpp @@ -428,8 +428,8 @@ const std::vector testValues { LayerTransformation::createParamsU8I8(), interpAttributes(), interp4Attributes( - ngraph::op::v4::Interpolate::InterpolateMode::nearest, - ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel, + ngraph::op::v4::Interpolate::InterpolateMode::NEAREST, + ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL, {0, 0, 0, 0}, {0, 0, 0, 0}), 4, @@ -453,8 +453,8 @@ const std::vector testValues { LayerTransformation::createParamsU8I8(), interpAttributes(), interp4Attributes( - ngraph::op::v4::Interpolate::InterpolateMode::nearest, - ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel, + ngraph::op::v4::Interpolate::InterpolateMode::NEAREST, + ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL, {0, 0, 0, 0}, {0, 0, 0, 0}), 4, @@ -478,8 +478,8 @@ const std::vector testValues { LayerTransformation::createParamsU8I8(), interpAttributes(), interp4Attributes( - ngraph::op::v4::Interpolate::InterpolateMode::nearest, - ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel, + ngraph::op::v4::Interpolate::InterpolateMode::NEAREST, + ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL, {0, 0, 0, 0}, {0, 0, 0, 0}), 4, @@ -503,8 +503,8 @@ const std::vector testValues { LayerTransformation::createParamsU8I8(), interpAttributes(), interp4Attributes( - ngraph::op::v4::Interpolate::InterpolateMode::nearest, - ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel, + ngraph::op::v4::Interpolate::InterpolateMode::NEAREST, + ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL, {0, 0, 0, 0}, {0, 0, 0, 0}), 4, @@ -528,8 +528,8 @@ const std::vector testValues { LayerTransformation::createParamsU8I8(), interpAttributes(), interp4Attributes( - ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx, - ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel, + ngraph::op::v4::Interpolate::InterpolateMode::LINEAR_ONNX, + ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL, {0, 0, 0, 0}, {0, 0, 0, 0}), 4, @@ -553,8 +553,8 @@ const std::vector testValues { LayerTransformation::createParamsU8I8(), interpAttributes(), interp4Attributes( - ngraph::op::v4::Interpolate::InterpolateMode::nearest, - ngraph::op::v4::Interpolate::CoordinateTransformMode::align_corners, + ngraph::op::v4::Interpolate::InterpolateMode::NEAREST, + ngraph::op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS, {0, 0, 0, 0}, {0, 0, 0, 0}), 4, @@ -578,8 +578,8 @@ const std::vector testValues { LayerTransformation::createParamsU8I8(), interpAttributes(), interp4Attributes( - ngraph::op::v4::Interpolate::InterpolateMode::nearest, - ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel, + ngraph::op::v4::Interpolate::InterpolateMode::NEAREST, + ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL, {0, 0, 0, 1}, {0, 0, 1, 0}), 4, diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_interpolate1_to_interpolate4_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_interpolate1_to_interpolate4_test.cpp index 12177f78cbcd4a..bc205748fd19f5 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/convert_interpolate1_to_interpolate4_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_interpolate1_to_interpolate4_test.cpp @@ -52,9 +52,9 @@ TEST(TransformationTests, ConvertInterpolate1ToInterpolate4) { auto default_scales_node = opset1::Constant::create(ngraph::element::f32, Shape{4}, {1.f, 1.f, 4.0f / 3.0f, 4.0f / 3.0f}); auto axes_node = opset1::Constant::create(ngraph::element::i64, Shape{4}, {0, 1, 2, 3}); - auto interpolate4_attr = opset4::Interpolate::InterpolateAttrs(opset4::Interpolate::InterpolateMode::nearest, - opset4::Interpolate::ShapeCalcMode::sizes, std::vector{0, 0, 0, 0}, std::vector{0, 0, 0, 0}, - opset4::Interpolate::CoordinateTransformMode::asymmetric, opset4::Interpolate::NearestMode::simple, + auto interpolate4_attr = opset4::Interpolate::InterpolateAttrs(opset4::Interpolate::InterpolateMode::NEAREST, + opset4::Interpolate::ShapeCalcMode::SIZES, std::vector{0, 0, 0, 0}, std::vector{0, 0, 0, 0}, + opset4::Interpolate::CoordinateTransformMode::ASYMMETRIC, opset4::Interpolate::NearestMode::SIMPLE, false, -0.75); auto interpolate4 = std::make_shared(data_node, out_shape_node, default_scales_node, axes_node, interpolate4_attr); @@ -97,9 +97,9 @@ TEST(TransformationTests, ConvertInterpolate1ToInterpolate4_1) { auto default_scales_node = opset1::Constant::create(ngraph::element::f32, Shape{2}, {4.0f / 3.0f, 4.0f / 3.0f}); auto axes_node = opset1::Constant::create(ngraph::element::i64, Shape{2}, {2, 3}); - auto interpolate4_attr = opset4::Interpolate::InterpolateAttrs(opset4::Interpolate::InterpolateMode::linear_onnx, - opset4::Interpolate::ShapeCalcMode::sizes, std::vector{0, 0, 0, 0}, std::vector{0, 0, 0, 0}, - opset4::Interpolate::CoordinateTransformMode::asymmetric, opset4::Interpolate::NearestMode::simple, + auto interpolate4_attr = opset4::Interpolate::InterpolateAttrs(opset4::Interpolate::InterpolateMode::LINEAR_ONNX, + opset4::Interpolate::ShapeCalcMode::SIZES, std::vector{0, 0, 0, 0}, std::vector{0, 0, 0, 0}, + opset4::Interpolate::CoordinateTransformMode::ASYMMETRIC, opset4::Interpolate::NearestMode::SIMPLE, true, -0.75); auto interpolate4 = std::make_shared(data_node, out_shape_node, default_scales_node, axes_node, interpolate4_attr); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp index 5d617ce9c90ea0..acea736e2cc159 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp @@ -21,38 +21,38 @@ const std::vector> inShapes = { }; const std::vector modesWithoutNearest = { - ngraph::op::v4::Interpolate::InterpolateMode::linear, - ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx, - ngraph::op::v4::Interpolate::InterpolateMode::cubic, + ngraph::op::v4::Interpolate::InterpolateMode::LINEAR, + ngraph::op::v4::Interpolate::InterpolateMode::LINEAR_ONNX, + ngraph::op::v4::Interpolate::InterpolateMode::CUBIC, }; const std::vector nearestMode = { - ngraph::op::v4::Interpolate::InterpolateMode::nearest, + ngraph::op::v4::Interpolate::InterpolateMode::NEAREST, }; const std::vector coordinateTransformModes = { - ngraph::op::v4::Interpolate::CoordinateTransformMode::tf_half_pixel_for_nn, - ngraph::op::v4::Interpolate::CoordinateTransformMode::pytorch_half_pixel, - ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel, - ngraph::op::v4::Interpolate::CoordinateTransformMode::asymmetric, - ngraph::op::v4::Interpolate::CoordinateTransformMode::align_corners, + ngraph::op::v4::Interpolate::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN, + ngraph::op::v4::Interpolate::CoordinateTransformMode::PYTORCH_HALF_PIXEL, + ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL, + ngraph::op::v4::Interpolate::CoordinateTransformMode::ASYMMETRIC, + ngraph::op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS, }; const std::vector shapeCalculationMode = { - ngraph::op::v4::Interpolate::ShapeCalcMode::sizes, - ngraph::op::v4::Interpolate::ShapeCalcMode::scales, + ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES, + ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES, }; const std::vector nearestModes = { - ngraph::op::v4::Interpolate::NearestMode::simple, - ngraph::op::v4::Interpolate::NearestMode::round_prefer_floor, - ngraph::op::v4::Interpolate::NearestMode::floor, - ngraph::op::v4::Interpolate::NearestMode::ceil, - ngraph::op::v4::Interpolate::NearestMode::round_prefer_ceil, + ngraph::op::v4::Interpolate::NearestMode::SIMPLE, + ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR, + ngraph::op::v4::Interpolate::NearestMode::FLOOR, + ngraph::op::v4::Interpolate::NearestMode::CEIL, + ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_CEIL, }; const std::vector defaultNearestMode = { - ngraph::op::v4::Interpolate::NearestMode::round_prefer_floor, + ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR, }; const std::vector> pads = { diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/concat_resize_concat.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/concat_resize_concat.cpp index 2dee7ff993717c..dd442cd9102d78 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/concat_resize_concat.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/concat_resize_concat.cpp @@ -57,10 +57,10 @@ class ConcatResizeConcatTest : public testing::WithParamInterface shape = {3, 3 }; std::vector scales = {1.5, 1.5 }; diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp index b3d599d9f91c28..7392cbdb53072a 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp @@ -144,28 +144,28 @@ const std::vector netPrecisions = { }; const std::vector coordinateTransformModes = { - ngraph::op::v4::Interpolate::CoordinateTransformMode::tf_half_pixel_for_nn, - ngraph::op::v4::Interpolate::CoordinateTransformMode::pytorch_half_pixel, - ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel, - ngraph::op::v4::Interpolate::CoordinateTransformMode::asymmetric, - ngraph::op::v4::Interpolate::CoordinateTransformMode::align_corners, + ngraph::op::v4::Interpolate::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN, + ngraph::op::v4::Interpolate::CoordinateTransformMode::PYTORCH_HALF_PIXEL, + ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL, + ngraph::op::v4::Interpolate::CoordinateTransformMode::ASYMMETRIC, + ngraph::op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS, }; const std::vector shapeCalculationMode = { - ngraph::op::v4::Interpolate::ShapeCalcMode::sizes, - ngraph::op::v4::Interpolate::ShapeCalcMode::scales, + ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES, + ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES, }; const std::vector nearestModes = { - ngraph::op::v4::Interpolate::NearestMode::simple, - ngraph::op::v4::Interpolate::NearestMode::round_prefer_floor, - ngraph::op::v4::Interpolate::NearestMode::floor, - ngraph::op::v4::Interpolate::NearestMode::ceil, - ngraph::op::v4::Interpolate::NearestMode::round_prefer_ceil, + ngraph::op::v4::Interpolate::NearestMode::SIMPLE, + ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR, + ngraph::op::v4::Interpolate::NearestMode::FLOOR, + ngraph::op::v4::Interpolate::NearestMode::CEIL, + ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_CEIL, }; const std::vector defNearestModes = { - ngraph::op::v4::Interpolate::NearestMode::round_prefer_floor, + ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR, }; const std::vector> pads = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp index c26f168d62848a..dc4a2c56f575e2 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp @@ -43,20 +43,20 @@ const std::vector coordina }; const std::vector shapeCalculationMode = { - ngraph::op::v4::Interpolate::ShapeCalcMode::sizes, - ngraph::op::v4::Interpolate::ShapeCalcMode::scales, + ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES, + ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES, }; const std::vector nearestModes = { - ngraph::op::v4::Interpolate::NearestMode::simple, - ngraph::op::v4::Interpolate::NearestMode::round_prefer_floor, - ngraph::op::v4::Interpolate::NearestMode::floor, - ngraph::op::v4::Interpolate::NearestMode::ceil, - ngraph::op::v4::Interpolate::NearestMode::round_prefer_ceil, + ngraph::op::v4::Interpolate::NearestMode::SIMPLE, + ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR, + ngraph::op::v4::Interpolate::NearestMode::FLOOR, + ngraph::op::v4::Interpolate::NearestMode::CEIL, + ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_CEIL, }; const std::vector defaultNearestMode = { - ngraph::op::v4::Interpolate::NearestMode::round_prefer_floor, + ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR, }; const std::vector> pads = { diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp index 31d17ca51ba607..23257e8acbaef0 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp @@ -126,8 +126,8 @@ const std::vector> defaultScales = { }; const std::vector shapeCalculationMode = { - ngraph::op::v4::Interpolate::ShapeCalcMode::sizes, - ngraph::op::v4::Interpolate::ShapeCalcMode::scales, + ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES, + ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES, }; const auto interpolateCasesNearestMode2x = ::testing::Combine( diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp index 6b3043a0063d6a..18af1da8868e15 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/utils/ngraph_helpers.cpp @@ -696,16 +696,16 @@ std::ostream& operator<<(std::ostream & os, ngraph::helpers::LogicalTypes type) std::ostream& operator<<(std::ostream & os, ngraph::op::v4::Interpolate::InterpolateMode type) { switch (type) { - case ngraph::op::v4::Interpolate::InterpolateMode::cubic: + case ngraph::op::v4::Interpolate::InterpolateMode::CUBIC: os << "cubic"; break; - case ngraph::op::v4::Interpolate::InterpolateMode::linear: + case ngraph::op::v4::Interpolate::InterpolateMode::LINEAR: os << "linear"; break; - case ngraph::op::v4::Interpolate::InterpolateMode::linear_onnx: + case ngraph::op::v4::Interpolate::InterpolateMode::LINEAR_ONNX: os << "linear_onnx"; break; - case ngraph::op::v4::Interpolate::InterpolateMode::nearest: + case ngraph::op::v4::Interpolate::InterpolateMode::NEAREST: os << "nearest"; break; default: @@ -716,19 +716,19 @@ std::ostream& operator<<(std::ostream & os, ngraph::op::v4::Interpolate::Interpo std::ostream& operator<<(std::ostream & os, ngraph::op::v4::Interpolate::CoordinateTransformMode type) { switch (type) { - case ngraph::op::v4::Interpolate::CoordinateTransformMode::align_corners: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS: os << "align_corners"; break; - case ngraph::op::v4::Interpolate::CoordinateTransformMode::asymmetric: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::ASYMMETRIC: os << "asymmetric"; break; - case ngraph::op::v4::Interpolate::CoordinateTransformMode::half_pixel: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL: os << "half_pixel"; break; - case ngraph::op::v4::Interpolate::CoordinateTransformMode::pytorch_half_pixel: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::PYTORCH_HALF_PIXEL: os << "pytorch_half_pixel"; break; - case ngraph::op::v4::Interpolate::CoordinateTransformMode::tf_half_pixel_for_nn: + case ngraph::op::v4::Interpolate::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN: os << "tf_half_pixel_for_nn"; break; default: @@ -739,19 +739,19 @@ std::ostream& operator<<(std::ostream & os, ngraph::op::v4::Interpolate::Coordin std::ostream& operator<<(std::ostream & os, ngraph::op::v4::Interpolate::NearestMode type) { switch (type) { - case ngraph::op::v4::Interpolate::NearestMode::ceil: + case ngraph::op::v4::Interpolate::NearestMode::CEIL: os << "ceil"; break; - case ngraph::op::v4::Interpolate::NearestMode::round_prefer_ceil: + case ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_CEIL: os << "round_prefer_ceil"; break; - case ngraph::op::v4::Interpolate::NearestMode::floor: + case ngraph::op::v4::Interpolate::NearestMode::FLOOR: os << "floor"; break; - case ngraph::op::v4::Interpolate::NearestMode::round_prefer_floor: + case ngraph::op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR: os << "round_prefer_floor"; break; - case ngraph::op::v4::Interpolate::NearestMode::simple: + case ngraph::op::v4::Interpolate::NearestMode::SIMPLE: os << "simple"; break; default: @@ -762,10 +762,10 @@ std::ostream& operator<<(std::ostream & os, ngraph::op::v4::Interpolate::Nearest std::ostream& operator<<(std::ostream & os, ngraph::op::v4::Interpolate::ShapeCalcMode type) { switch (type) { - case ngraph::op::v4::Interpolate::ShapeCalcMode::scales: + case ngraph::op::v4::Interpolate::ShapeCalcMode::SCALES: os << "scales"; break; - case ngraph::op::v4::Interpolate::ShapeCalcMode::sizes: + case ngraph::op::v4::Interpolate::ShapeCalcMode::SIZES: os << "sizes"; break; default: diff --git a/ngraph/core/include/ngraph/deprecated.hpp b/ngraph/core/include/ngraph/deprecated.hpp index c6ba7ac7adef54..07314dd6edaa24 100644 --- a/ngraph/core/include/ngraph/deprecated.hpp +++ b/ngraph/core/include/ngraph/deprecated.hpp @@ -16,12 +16,21 @@ #if defined(_WIN32) # define NGRAPH_DEPRECATED(msg) __declspec(deprecated(msg)) +// TODO: enable warning for Windows +# define NGRAPH_ENUM_DEPRECATED(val, msg) val #elif defined(__INTEL_COMPILER) -# define NGRAPH_DEPRECATED(msg) __attribute__((deprecated(msg))) +# define NGRAPH_DEPRECATED(msg) __attribute__((deprecated(msg))) +# define NGRAPH_ENUM_DEPRECATED(val, msg) val NGRAPH_DEPRECATED(msg) #elif defined(__GNUC__) # define NGRAPH_DEPRECATED(msg) __attribute__((deprecated((msg)))) +# if __GNUC__ < 6 && !defined(__clang__) +# define NGRAPH_ENUM_DEPRECATED(val, msg) val +# else +# define NGRAPH_ENUM_DEPRECATED(val, msg) val NGRAPH_DEPRECATED(msg) +# endif #else # define NGRAPH_DEPRECATED(msg) +# define NGRAPH_ENUM_DEPRECATED(val, msg) val #endif // Suppress warning "-Wdeprecated-declarations" / C4996 diff --git a/ngraph/core/include/ngraph/op/interpolate.hpp b/ngraph/core/include/ngraph/op/interpolate.hpp index e54acccdf51beb..7599608df9c93e 100644 --- a/ngraph/core/include/ngraph/op/interpolate.hpp +++ b/ngraph/core/include/ngraph/op/interpolate.hpp @@ -41,7 +41,18 @@ class NGRAPH_API Interpolate : public Op { public: NGRAPH_RTTI_DECLARATION; - enum class InterpolateMode { nearest, linear, cubic, area }; + NGRAPH_SUPPRESS_DEPRECATED_START + enum class InterpolateMode { + NGRAPH_ENUM_DEPRECATED(nearest, "Please use NEAREST instead"), + NGRAPH_ENUM_DEPRECATED(linear, "Please use LINEAR instead"), + NGRAPH_ENUM_DEPRECATED(cubic, "Please use CUBIC instead"), + NGRAPH_ENUM_DEPRECATED(area, "Please use AREA instead"), + NEAREST = nearest, + LINEAR = linear, + CUBIC = cubic, + AREA = area + }; + NGRAPH_SUPPRESS_DEPRECATED_END Interpolate() = default; /// \brief Constructs a Interpolate operation @@ -54,7 +65,7 @@ class NGRAPH_API Interpolate : public Op { void validate_and_infer_types() override; - virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; const InterpolateAttrs& get_attrs() const { return m_attrs; @@ -74,7 +85,14 @@ class NGRAPH_API Interpolate : public Op { /// /// sizes - output shape for interpolated axes is calculated using input `sizes` /// scales - output shape for interpolated axes is calculated using input `scales` - enum class ShapeCalcMode { sizes, scales }; + NGRAPH_SUPPRESS_DEPRECATED_START + enum class ShapeCalcMode { + NGRAPH_ENUM_DEPRECATED(sizes, "Please use SIZES instead"), + NGRAPH_ENUM_DEPRECATED(scales, "Please use SCALES instead"), + SIZES = sizes, + SCALES = scales + }; + NGRAPH_SUPPRESS_DEPRECATED_END /// \brief Interpolation mode /// @@ -82,29 +100,60 @@ class NGRAPH_API Interpolate : public Op { /// linear - linear interpolation as in TensorFlow /// linear_onnx - linear interpolation as in ONNX /// cubic - cubic interpolation - enum class InterpolateMode { nearest, linear, linear_onnx, cubic }; + NGRAPH_SUPPRESS_DEPRECATED_START + enum class InterpolateMode { + NGRAPH_ENUM_DEPRECATED(nearest, "Please use NEAREST instead"), + NGRAPH_ENUM_DEPRECATED(linear, "Please use LINEAR instead"), + NGRAPH_ENUM_DEPRECATED(linear_onnx, "Please use LINEAR_ONNX instead"), + NGRAPH_ENUM_DEPRECATED(cubic, "Please use CUBIC instead"), + NEAREST = nearest, + LINEAR = linear, + LINEAR_ONNX = linear_onnx, + CUBIC = cubic + }; + NGRAPH_SUPPRESS_DEPRECATED_END /// \brief Mode of the calculation of the source coordinate from resized one /// /// These modes are modes from ONNX runtime. + NGRAPH_SUPPRESS_DEPRECATED_START enum class CoordinateTransformMode { - half_pixel, - pytorch_half_pixel, - asymmetric, - tf_half_pixel_for_nn, - align_corners + NGRAPH_ENUM_DEPRECATED(half_pixel, "Please use HALF_PIXEL instead"), + NGRAPH_ENUM_DEPRECATED(pytorch_half_pixel, "Please use PYTORCH_HALF_PIXEL instead"), + NGRAPH_ENUM_DEPRECATED(asymmetric, "Please use ASYMMETRIC instead"), + NGRAPH_ENUM_DEPRECATED(tf_half_pixel_for_nn, "Please use TF_HALF_PIXEL_FOR_NN instead"), + NGRAPH_ENUM_DEPRECATED(align_corners, "Please use ALIGN_CORNERS instead"), + HALF_PIXEL = half_pixel, + PYTORCH_HALF_PIXEL = pytorch_half_pixel, + ASYMMETRIC = asymmetric, + TF_HALF_PIXEL_FOR_NN = tf_half_pixel_for_nn, + ALIGN_CORNERS = align_corners }; + NGRAPH_SUPPRESS_DEPRECATED_END /// \brief Round modes for the nearest interpolation. - enum class NearestMode { round_prefer_floor, round_prefer_ceil, floor, ceil, simple }; + NGRAPH_SUPPRESS_DEPRECATED_START + enum class NearestMode { + NGRAPH_ENUM_DEPRECATED(round_prefer_floor, "Please use ROUND_PREFER_FLOOR instead"), + NGRAPH_ENUM_DEPRECATED(round_prefer_ceil, "Please use ROUND_PREFER_CEIL instead"), + NGRAPH_ENUM_DEPRECATED(floor, "Please use FLOOR instead"), + NGRAPH_ENUM_DEPRECATED(ceil, "Please use CEIL instead"), + NGRAPH_ENUM_DEPRECATED(simple, "Please use SIMPLE instead"), + ROUND_PREFER_FLOOR = round_prefer_floor, + ROUND_PREFER_CEIL = round_prefer_ceil, + FLOOR = floor, + CEIL = ceil, + SIMPLE = simple + }; + NGRAPH_SUPPRESS_DEPRECATED_END struct InterpolateAttrs { // specifies type of interpolation // one of `nearest`, `linear`, `linear_onnx`, `cubic` Required. - InterpolateMode mode = InterpolateMode::nearest; + InterpolateMode mode = InterpolateMode::NEAREST; // specifies shape calculation mode // one of `sizes`, `scales` Required - ShapeCalcMode shape_calculation_mode = ShapeCalcMode::sizes; + ShapeCalcMode shape_calculation_mode = ShapeCalcMode::SIZES; // specify the number of pixels to add to the beginning of the image being // interpolated. This addition of pixels is done before interpolation // calculation. @@ -116,11 +165,11 @@ class NGRAPH_API Interpolate : public Op { // specifies how to transform the coordinate in the resized tensor to the // coordinate in the original tensor. one of `half_pixel`, `pytorch_half_pixel`, // `asymmetric`, `tf_half_pixel_for_nn`, `align_corners` - CoordinateTransformMode coordinate_transformation_mode = CoordinateTransformMode::half_pixel; + CoordinateTransformMode coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; // specifies round mode when `mode == nearest` and is used only when `mode == // nearest`. one of `round_prefer_floor`, `round_prefer_ceil`, `floor`, `ceil`, // `simple` - NearestMode nearest_mode = NearestMode::round_prefer_floor; + NearestMode nearest_mode = NearestMode::ROUND_PREFER_FLOOR; // a flag that specifies whether to perform anti-aliasing. default is `false` bool antialias = false; // specifies the parameter *a* for cubic interpolation (see, e.g. @@ -132,10 +181,10 @@ class NGRAPH_API Interpolate : public Op { InterpolateAttrs(InterpolateMode mode, ShapeCalcMode shape_calculation_mode, - std::vector pads_begin, - std::vector pads_end, - CoordinateTransformMode coordinate_transformation_mode = CoordinateTransformMode::half_pixel, - NearestMode nearest_mode = NearestMode::round_prefer_floor, + const std::vector& pads_begin, + const std::vector& pads_end, + CoordinateTransformMode coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL, + NearestMode nearest_mode = NearestMode::ROUND_PREFER_FLOOR, bool antialias = false, double cube_coeff = -0.75) : mode(mode), @@ -176,7 +225,7 @@ class NGRAPH_API Interpolate : public Op { void validate_and_infer_types() override; - virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; bool has_evaluate() const override; diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/interpolate.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/interpolate.hpp index d9e98f7ad3ae42..33a45e6c04aaa6 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/interpolate.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/interpolate.hpp @@ -27,7 +27,7 @@ using InterpolateMode = ngraph::op::v4::Interpolate::InterpolateMode; class GetNearestPixel final { public: /// \brief Constructs calculation of a nearest pixel in the default mode. - GetNearestPixel() : GetNearestPixel(Nearest_mode::round_prefer_floor) {} + GetNearestPixel() : GetNearestPixel(Nearest_mode::ROUND_PREFER_FLOOR) {} /// \brief Constructs calculation of nearest pixel for the specified mode. /// @@ -58,19 +58,19 @@ class GetNearestPixel final { /// \return The function to calculate the nearest pixel. Func get_func(Nearest_mode mode) { switch (mode) { - case Nearest_mode::round_prefer_ceil: + case Nearest_mode::ROUND_PREFER_CEIL: return [](float x_original, bool) { return static_cast(std::round(x_original)); }; - case Nearest_mode::floor: + case Nearest_mode::FLOOR: return [](float x_original, bool) { return static_cast(std::floor(x_original)); }; - case Nearest_mode::ceil: + case Nearest_mode::CEIL: return [](float x_original, bool) { return static_cast(std::ceil(x_original)); }; - case Nearest_mode::simple: + case Nearest_mode::SIMPLE: return [](float x_original, bool is_downsample) { if (is_downsample) { return static_cast(std::ceil(x_original)); @@ -93,7 +93,7 @@ class GetNearestPixel final { class GetOriginalCoordinate final { public: /// \brief Constructs calculation of a nearest pixel in the default mode. - GetOriginalCoordinate() : GetOriginalCoordinate(Transform_mode::half_pixel) {} + GetOriginalCoordinate() : GetOriginalCoordinate(Transform_mode::HALF_PIXEL) {} /// \brief Constructs calculation of the source coordinate. /// @@ -129,22 +129,22 @@ class GetOriginalCoordinate final { /// \return The function to calculate the source coordinate. Func get_func(Transform_mode mode) { switch (mode) { - case Transform_mode::pytorch_half_pixel: + case Transform_mode::PYTORCH_HALF_PIXEL: return [](float x_resized, float x_scale, float length_resized, float) { return length_resized > 1 ? (x_resized + 0.5f) / x_scale - 0.5f : 0.0f; }; break; - case Transform_mode::asymmetric: + case Transform_mode::ASYMMETRIC: return [](float x_resized, float x_scale, float, float) { return x_resized / x_scale; }; break; - case Transform_mode::tf_half_pixel_for_nn: + case Transform_mode::TF_HALF_PIXEL_FOR_NN: return [](float x_resized, float x_scale, float, float) { return (x_resized + 0.5f) / x_scale; }; break; - case Transform_mode::align_corners: + case Transform_mode::ALIGN_CORNERS: return [](float x_resized, float, float length_resized, float length_original) { return length_resized == 1 ? 0 : x_resized * (length_original - 1) / (length_resized - 1); }; @@ -290,16 +290,16 @@ class InterpolateEval final { helper = InterpolateEvalHelper{m_attrs, input_data_shape, axes, out_shape, scales}; switch (m_interp_mode) { - case InterpolateMode::nearest: + case InterpolateMode::NEAREST: nearest_func(input_data, out); break; - case InterpolateMode::linear: + case InterpolateMode::LINEAR: linear_func(input_data, out); break; - case InterpolateMode::linear_onnx: + case InterpolateMode::LINEAR_ONNX: linear_onnx_func(input_data, out); break; - case InterpolateMode::cubic: + case InterpolateMode::CUBIC: cubic_func(input_data, out); break; } diff --git a/ngraph/core/src/op/interpolate.cpp b/ngraph/core/src/op/interpolate.cpp index 63a337347b6879..42359cde32ca26 100644 --- a/ngraph/core/src/op/interpolate.cpp +++ b/ngraph/core/src/op/interpolate.cpp @@ -74,10 +74,10 @@ template <> EnumNames& EnumNames::get() { static auto enum_names = EnumNames("op::v0::Interpolate::InterpolateMode", - {{"nearest", op::v0::Interpolate::InterpolateMode::nearest}, - {"linear", op::v0::Interpolate::InterpolateMode::linear}, - {"cubic", op::v0::Interpolate::InterpolateMode::cubic}, - {"area", op::v0::Interpolate::InterpolateMode::area}}); + {{"nearest", op::v0::Interpolate::InterpolateMode::NEAREST}, + {"linear", op::v0::Interpolate::InterpolateMode::LINEAR}, + {"cubic", op::v0::Interpolate::InterpolateMode::CUBIC}, + {"area", op::v0::Interpolate::InterpolateMode::AREA}}); return enum_names; } @@ -255,7 +255,7 @@ void op::v4::Interpolate::validate_and_infer_types() { } } - if (m_attrs.shape_calculation_mode == ShapeCalcMode::scales) { + if (m_attrs.shape_calculation_mode == ShapeCalcMode::SCALES) { if (const auto& const_scales = get_constant_from_source(input_value(2))) { auto scales = const_scales->cast_vector(); infer_using_scales(output_shape, axes, scales, padded_input_shape); @@ -323,7 +323,7 @@ std::vector get_scales_vector(const HostTensorVector& args, std::vector scales; size_t num_of_axes = axes.size(); - if (attrs.shape_calculation_mode == ShapeCalcMode::scales) { + if (attrs.shape_calculation_mode == ShapeCalcMode::SCALES) { float* scales_ptr = args[scales_port]->get_data_ptr(); scales.insert(scales.end(), scales_ptr, scales_ptr + num_of_axes); } else { @@ -406,7 +406,7 @@ bool op::v4::Interpolate::evaluate_interpolate(const HostTensorVector& outputs, PartialShape output_shape{padded_input_shape}; - if (m_attrs.shape_calculation_mode == ShapeCalcMode::scales) { + if (m_attrs.shape_calculation_mode == ShapeCalcMode::SCALES) { infer_using_scales(output_shape, axes, scales, padded_input_shape); } else { auto sizes = get_target_shape_vector(inputs, num_of_axes); @@ -484,10 +484,10 @@ template <> NGRAPH_API EnumNames& EnumNames::get() { static auto enum_names = EnumNames( "op::v4::Interpolate::InterpolateMode", - {{"nearest", op::v4::Interpolate::InterpolateMode::nearest}, - {"linear", op::v4::Interpolate::InterpolateMode::linear}, - {"linear_onnx", op::v4::Interpolate::InterpolateMode::linear_onnx}, - {"cubic", op::v4::Interpolate::InterpolateMode::cubic}}); + {{"nearest", op::v4::Interpolate::InterpolateMode::NEAREST}, + {"linear", op::v4::Interpolate::InterpolateMode::LINEAR}, + {"linear_onnx", op::v4::Interpolate::InterpolateMode::LINEAR_ONNX}, + {"cubic", op::v4::Interpolate::InterpolateMode::CUBIC}}); return enum_names; } @@ -501,7 +501,7 @@ template <> NGRAPH_API EnumNames& EnumNames::get() { static auto enum_names = EnumNames( "op::v4::Interpolate::ShapeCalcMode", - {{"sizes", op::v4::Interpolate::ShapeCalcMode::sizes}, {"scales", op::v4::Interpolate::ShapeCalcMode::scales}}); + {{"sizes", op::v4::Interpolate::ShapeCalcMode::SIZES}, {"scales", op::v4::Interpolate::ShapeCalcMode::SCALES}}); return enum_names; } @@ -516,11 +516,11 @@ NGRAPH_API EnumNames& EnumNames::get() { static auto enum_names = EnumNames( "op::v4::Interpolate::CoordinateTransformMode", - {{"half_pixel", op::v4::Interpolate::CoordinateTransformMode::half_pixel}, - {"pytorch_half_pixel", op::v4::Interpolate::CoordinateTransformMode::pytorch_half_pixel}, - {"asymmetric", op::v4::Interpolate::CoordinateTransformMode::asymmetric}, - {"tf_half_pixel_for_nn", op::v4::Interpolate::CoordinateTransformMode::tf_half_pixel_for_nn}, - {"align_corners", op::v4::Interpolate::CoordinateTransformMode::align_corners}}); + {{"half_pixel", op::v4::Interpolate::CoordinateTransformMode::HALF_PIXEL}, + {"pytorch_half_pixel", op::v4::Interpolate::CoordinateTransformMode::PYTORCH_HALF_PIXEL}, + {"asymmetric", op::v4::Interpolate::CoordinateTransformMode::ASYMMETRIC}, + {"tf_half_pixel_for_nn", op::v4::Interpolate::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN}, + {"align_corners", op::v4::Interpolate::CoordinateTransformMode::ALIGN_CORNERS}}); return enum_names; } @@ -534,11 +534,11 @@ template <> NGRAPH_API EnumNames& EnumNames::get() { static auto enum_names = EnumNames( "op::v4::Interpolate::NearestMode", - {{"round_prefer_floor", op::v4::Interpolate::NearestMode::round_prefer_floor}, - {"round_prefer_ceil", op::v4::Interpolate::NearestMode::round_prefer_ceil}, - {"floor", op::v4::Interpolate::NearestMode::floor}, - {"ceil", op::v4::Interpolate::NearestMode::ceil}, - {"simple", op::v4::Interpolate::NearestMode::simple}}); + {{"round_prefer_floor", op::v4::Interpolate::NearestMode::ROUND_PREFER_FLOOR}, + {"round_prefer_ceil", op::v4::Interpolate::NearestMode::ROUND_PREFER_CEIL}, + {"floor", op::v4::Interpolate::NearestMode::FLOOR}, + {"ceil", op::v4::Interpolate::NearestMode::CEIL}, + {"simple", op::v4::Interpolate::NearestMode::SIMPLE}}); return enum_names; } diff --git a/ngraph/frontend/onnx/frontend/src/op/resize.cpp b/ngraph/frontend/onnx/frontend/src/op/resize.cpp index 30bce6245230f9..4f60a6f4eb5181 100644 --- a/ngraph/frontend/onnx/frontend/src/op/resize.cpp +++ b/ngraph/frontend/onnx/frontend/src/op/resize.cpp @@ -24,24 +24,24 @@ static const std::unordered_set supported_transforms = {"half_pixel "tf_half_pixel_for_nn"}; using InterpolateMode = ngraph::op::v4::Interpolate::InterpolateMode; -static const std::map interp_mode_map = {{"nearest", static_cast(InterpolateMode::nearest)}, - {"linear", static_cast(InterpolateMode::linear_onnx)}, - {"cubic", static_cast(InterpolateMode::cubic)}}; +static const std::map interp_mode_map = {{"nearest", static_cast(InterpolateMode::NEAREST)}, + {"linear", static_cast(InterpolateMode::LINEAR_ONNX)}, + {"cubic", static_cast(InterpolateMode::CUBIC)}}; using Transform_mode = ngraph::op::v4::Interpolate::CoordinateTransformMode; static const std::map transform_mode_map = { - {"half_pixel", static_cast(Transform_mode::half_pixel)}, - {"pytorch_half_pixel", static_cast(Transform_mode::pytorch_half_pixel)}, - {"align_corners", static_cast(Transform_mode::align_corners)}, - {"asymmetric", static_cast(Transform_mode::asymmetric)}, - {"tf_half_pixel_for_nn", static_cast(Transform_mode::tf_half_pixel_for_nn)}}; + {"half_pixel", static_cast(Transform_mode::HALF_PIXEL)}, + {"pytorch_half_pixel", static_cast(Transform_mode::PYTORCH_HALF_PIXEL)}, + {"align_corners", static_cast(Transform_mode::ALIGN_CORNERS)}, + {"asymmetric", static_cast(Transform_mode::ASYMMETRIC)}, + {"tf_half_pixel_for_nn", static_cast(Transform_mode::TF_HALF_PIXEL_FOR_NN)}}; using Nearest_mode = ngraph::op::v4::Interpolate::NearestMode; static const std::map nearest_mode_map = { - {"round_prefer_floor", static_cast(Nearest_mode::round_prefer_floor)}, - {"round_prefer_ceil", static_cast(Nearest_mode::round_prefer_ceil)}, - {"floor", static_cast(Nearest_mode::floor)}, - {"ceil", static_cast(Nearest_mode::ceil)}}; + {"round_prefer_floor", static_cast(Nearest_mode::ROUND_PREFER_FLOOR)}, + {"round_prefer_ceil", static_cast(Nearest_mode::ROUND_PREFER_CEIL)}, + {"floor", static_cast(Nearest_mode::FLOOR)}, + {"ceil", static_cast(Nearest_mode::CEIL)}}; static bool is_supported_str_value(const std::unordered_set& modes, const std::string& checked_mode) { return std::find(modes.begin(), modes.end(), checked_mode) != modes.end(); @@ -148,7 +148,7 @@ OutputVector resize(const onnx_import::Node& node) { if (inputs.size() == 4) // sizes input is provided { - attrs.shape_calculation_mode = default_opset::Interpolate::ShapeCalcMode::sizes; + attrs.shape_calculation_mode = default_opset::Interpolate::ShapeCalcMode::SIZES; const auto& sizes = inputs.at(3); const auto& sizes_shape = sizes.get_partial_shape(); @@ -161,7 +161,7 @@ OutputVector resize(const onnx_import::Node& node) { return {std::make_shared(data, sizes, scales, attrs)}; } - attrs.shape_calculation_mode = default_opset::Interpolate::ShapeCalcMode::scales; + attrs.shape_calculation_mode = default_opset::Interpolate::ShapeCalcMode::SCALES; const auto& scales = inputs.at(2); const auto& scales_shape = scales.get_partial_shape(); @@ -186,11 +186,11 @@ OutputVector resize(const onnx_import::Node& node) { auto attrs = get_resize_attrs(node); - 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; + 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; } CHECK_VALID_NODE(node, @@ -202,9 +202,6 @@ OutputVector resize(const onnx_import::Node& node) { } } // namespace set_1 - } // namespace op - } // namespace onnx_import - } // namespace ngraph diff --git a/ngraph/frontend/onnx/frontend/src/op/upsample.cpp b/ngraph/frontend/onnx/frontend/src/op/upsample.cpp index aeb1ddd06c5d98..6dc776b2222d74 100644 --- a/ngraph/frontend/onnx/frontend/src/op/upsample.cpp +++ b/ngraph/frontend/onnx/frontend/src/op/upsample.cpp @@ -37,19 +37,19 @@ void check_mode_support(const onnx_import::Node& node, const std::string& mode, } } -default_opset::Interpolate::InterpolateAttrs get_attributes(std::string mode) { +default_opset::Interpolate::InterpolateAttrs get_attributes(const std::string& mode) { using InterpolateMode = default_opset::Interpolate::InterpolateMode; using Transform_mode = default_opset::Interpolate::CoordinateTransformMode; using ShapeCalcMode = default_opset::Interpolate::ShapeCalcMode; const auto interpolate_mode = - (mode == "linear" || mode == "bilinear" ? InterpolateMode::linear_onnx : InterpolateMode::nearest); + (mode == "linear" || mode == "bilinear" ? InterpolateMode::LINEAR_ONNX : InterpolateMode::NEAREST); std::vector pad{0}; - auto attrs = default_opset::Interpolate::InterpolateAttrs(interpolate_mode, ShapeCalcMode::scales, pad, pad); + auto attrs = default_opset::Interpolate::InterpolateAttrs(interpolate_mode, ShapeCalcMode::SCALES, pad, pad); - if (attrs.mode == InterpolateMode::linear_onnx) - attrs.coordinate_transformation_mode = Transform_mode::asymmetric; + if (attrs.mode == InterpolateMode::LINEAR_ONNX) + attrs.coordinate_transformation_mode = Transform_mode::ASYMMETRIC; return attrs; } @@ -134,9 +134,6 @@ OutputVector upsample(const onnx_import::Node& node) { } } // namespace set_9 - } // namespace op - } // namespace onnx_import - } // namespace ngraph diff --git a/ngraph/frontend/paddlepaddle/src/op/interp.cpp b/ngraph/frontend/paddlepaddle/src/op/interp.cpp index 46d9f18f742be6..94e586ef0934c9 100644 --- a/ngraph/frontend/paddlepaddle/src/op/interp.cpp +++ b/ngraph/frontend/paddlepaddle/src/op/interp.cpp @@ -79,7 +79,7 @@ NamedOutputs interpolate(const NodeContext& node, const ngraph::opset6::Interpol Output target_spatial_shape; if (node.has_ng_input("OutSize")) { - attrs.shape_calculation_mode = ShapeCalcMode::sizes; + attrs.shape_calculation_mode = ShapeCalcMode::SIZES; auto hw_shape = node.get_ng_input("OutSize"); const auto shape_of_x = std::make_shared(x); auto shape_begin = opset6::Constant::create(element::i64, {1}, {0}); @@ -94,10 +94,10 @@ NamedOutputs interpolate(const NodeContext& node, const ngraph::opset6::Interpol 0); scales = calculate_scales_based_on_sizes(x, target_spatial_shape); } else if (out_w <= 0 || out_h <= 0) { - attrs.shape_calculation_mode = ShapeCalcMode::scales; + attrs.shape_calculation_mode = ShapeCalcMode::SCALES; target_spatial_shape = calculate_output_shape_based_on_scales(x, scale, scales); } else { - attrs.shape_calculation_mode = ShapeCalcMode::sizes; + attrs.shape_calculation_mode = ShapeCalcMode::SIZES; target_spatial_shape = extract_out_sizes(x, {out_h, out_w}); scales = calculate_scales_based_on_sizes(x, target_spatial_shape); } @@ -105,17 +105,17 @@ NamedOutputs interpolate(const NodeContext& node, const ngraph::opset6::Interpol bool align_corners = node.get_attribute("align_corners"); int32_t align_mode = node.get_attribute("align_mode"); - if (mode == InterpolateMode::nearest) { - attrs.coordinate_transformation_mode = CoordinateTransformMode::asymmetric; + if (mode == InterpolateMode::NEAREST) { + attrs.coordinate_transformation_mode = CoordinateTransformMode::ASYMMETRIC; } else if (!align_corners && align_mode == 1) { - attrs.coordinate_transformation_mode = CoordinateTransformMode::asymmetric; + attrs.coordinate_transformation_mode = CoordinateTransformMode::ASYMMETRIC; } else if (!align_corners && align_mode == 0) { - attrs.coordinate_transformation_mode = CoordinateTransformMode::half_pixel; + attrs.coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; } else if (align_corners) { - attrs.coordinate_transformation_mode = CoordinateTransformMode::align_corners; + attrs.coordinate_transformation_mode = CoordinateTransformMode::ALIGN_CORNERS; } - attrs.nearest_mode = Nearest_mode::simple; + attrs.nearest_mode = Nearest_mode::SIMPLE; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -126,16 +126,16 @@ NamedOutputs interpolate(const NodeContext& node, const ngraph::opset6::Interpol } NamedOutputs bilinear_interp_v2(const NodeContext& node) { - auto mode = ngraph::opset6::Interpolate::InterpolateMode::linear_onnx; + auto mode = ngraph::opset6::Interpolate::InterpolateMode::LINEAR_ONNX; return interpolate(node, mode); } NamedOutputs nearest_interp_v2(const NodeContext& node) { - auto mode = ngraph::opset6::Interpolate::InterpolateMode::nearest; + auto mode = ngraph::opset6::Interpolate::InterpolateMode::NEAREST; return interpolate(node, mode); } } // namespace op } // namespace pdpd } // namespace frontend -} // namespace ngraph \ No newline at end of file +} // namespace ngraph diff --git a/ngraph/test/op_eval/interpolate.cpp b/ngraph/test/op_eval/interpolate.cpp index ad77bee3699a98..7ddb2c3b64ef7f 100644 --- a/ngraph/test/op_eval/interpolate.cpp +++ b/ngraph/test/op_eval/interpolate.cpp @@ -41,45 +41,45 @@ TEST(op_eval, interpolate_v4_cubic) { ShapesAndAttrs{{3, 3}, Shape{1, 1, 3, 3}, {0.8f, 0.8f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::scales}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SCALES}, // resize_downsample_sizes_cubic: ShapesAndAttrs{{3, 3}, Shape{1, 1, 3, 3}, {0.75f, 0.75f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::sizes}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SIZES}, // resize_upsample_scales_cubic: ShapesAndAttrs{{8, 8}, Shape{1, 1, 8, 8}, {2.0f, 2.0f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::scales}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SCALES}, // resize_upsample_scales_cubic_asymmetric: ShapesAndAttrs{{8, 8}, Shape{1, 1, 8, 8}, {2.0f, 2.0f}, - CoordinateTransformMode::asymmetric, - ShapeCalcMode::scales}, + CoordinateTransformMode::ASYMMETRIC, + ShapeCalcMode::SCALES}, // resize_upsample_sizes_cubic: ShapesAndAttrs{{9, 10}, Shape{1, 1, 9, 10}, {2.25f, 2.5f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::sizes}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SIZES}, // resize_downsample_scales_cubic_align_corners: // (expected values from ONNX documentation are incorrect!) ShapesAndAttrs{{3, 3}, Shape{1, 1, 3, 3}, {0.8f, 0.8f}, - CoordinateTransformMode::align_corners, - ShapeCalcMode::scales}, + CoordinateTransformMode::ALIGN_CORNERS, + ShapeCalcMode::SCALES}, // resize_upsample_scales_cubic_align_corners: ShapesAndAttrs{{8, 8}, Shape{1, 1, 8, 8}, {2.0f, 2.0f}, - CoordinateTransformMode::align_corners, - ShapeCalcMode::scales}}; + CoordinateTransformMode::ALIGN_CORNERS, + ShapeCalcMode::SCALES}}; std::vector input_data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0}; @@ -140,10 +140,10 @@ TEST(op_eval, interpolate_v4_cubic) { auto axes = op::Constant::create(element::i64, Shape{2}, {2, 3}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::cubic; + attrs.mode = InterpolateMode::CUBIC; attrs.shape_calculation_mode = s.shape_calculation_mode; attrs.coordinate_transformation_mode = s.transform_mode; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -180,65 +180,65 @@ TEST(op_eval, interpolate_v4_nearest) { {1, 2}, Shape{1, 1, 1, 2}, {0.6f, 0.6f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::scales, - Nearest_mode::round_prefer_floor}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SCALES, + Nearest_mode::ROUND_PREFER_FLOOR}, // resize_downsample_sizes_nearest: ShapesAndAttrs{Shape{1, 1, 2, 4}, {1, 2}, Shape{1, 1, 1, 2}, {0.5f, 0.5f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::sizes, - Nearest_mode::round_prefer_floor}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SIZES, + Nearest_mode::ROUND_PREFER_FLOOR}, // resize_downsample_sizes_nearest_tf_half_pixel_for_nn: ShapesAndAttrs{Shape{1, 1, 4, 4}, {3, 2}, Shape{1, 1, 3, 2}, {0.75, 0.5}, - CoordinateTransformMode::tf_half_pixel_for_nn, - ShapeCalcMode::sizes, - Nearest_mode::round_prefer_floor}, + CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN, + ShapeCalcMode::SIZES, + Nearest_mode::ROUND_PREFER_FLOOR}, // resize_upsample_scales_nearest: ShapesAndAttrs{Shape{1, 1, 2, 2}, {4, 6}, Shape{1, 1, 4, 6}, {2.0f, 3.0f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::scales, - Nearest_mode::round_prefer_floor}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SCALES, + Nearest_mode::ROUND_PREFER_FLOOR}, // resize_upsample_sizes_nearest: ShapesAndAttrs{Shape{1, 1, 2, 2}, {7, 8}, Shape{1, 1, 7, 8}, {3.5f, 4.0f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::sizes, - Nearest_mode::round_prefer_floor}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SIZES, + Nearest_mode::ROUND_PREFER_FLOOR}, // resize_upsample_sizes_nearest_ceil_half_pixel: ShapesAndAttrs{Shape{1, 1, 4, 4}, {8, 8}, Shape{1, 1, 8, 8}, {2.0f, 2.0f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::sizes, - Nearest_mode::ceil}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SIZES, + Nearest_mode::CEIL}, // resize_upsample_sizes_nearest_floor_align_corners: ShapesAndAttrs{Shape{1, 1, 4, 4}, {8, 8}, Shape{1, 1, 8, 8}, {2.0f, 2.0f}, - CoordinateTransformMode::align_corners, - ShapeCalcMode::sizes, - Nearest_mode::floor}, + CoordinateTransformMode::ALIGN_CORNERS, + ShapeCalcMode::SIZES, + Nearest_mode::FLOOR}, // resize_upsample_sizes_nearest_round_prefer_ceil_asymmetric: ShapesAndAttrs{Shape{1, 1, 4, 4}, {8, 8}, Shape{1, 1, 8, 8}, {2.0f, 2.0f}, - CoordinateTransformMode::asymmetric, - ShapeCalcMode::sizes, - Nearest_mode::round_prefer_ceil}}; + CoordinateTransformMode::ASYMMETRIC, + ShapeCalcMode::SIZES, + Nearest_mode::ROUND_PREFER_CEIL}}; std::vector> input_data_list = { {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f}, @@ -282,7 +282,7 @@ TEST(op_eval, interpolate_v4_nearest) { auto axes = op::Constant::create(element::i64, Shape{2}, {2, 3}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::nearest; + attrs.mode = InterpolateMode::NEAREST; attrs.shape_calculation_mode = s.shape_calculation_mode; attrs.coordinate_transformation_mode = s.transform_mode; attrs.nearest_mode = s.nearest_mode; @@ -322,37 +322,37 @@ TEST(op_eval, interpolate_v4_linear_onnx) { {1, 2}, Shape{1, 1, 1, 2}, {0.6f, 0.6f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::scales}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SCALES}, // resize_downsample_sizes_linear_pytorch_half_pixel ShapesAndAttrs{Shape{1, 1, 4, 4}, {3, 1}, Shape{1, 1, 3, 1}, {0.75f, 0.25f}, - CoordinateTransformMode::pytorch_half_pixel, - ShapeCalcMode::sizes}, + CoordinateTransformMode::PYTORCH_HALF_PIXEL, + ShapeCalcMode::SIZES}, // resize_upsample_scales_linear ShapesAndAttrs{Shape{1, 1, 2, 2}, {4, 4}, Shape{1, 1, 4, 4}, {2.0f, 2.0f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::scales}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SCALES}, // resize_upsample_scales_linear_align_corners ShapesAndAttrs{Shape{1, 1, 2, 2}, {4, 4}, Shape{1, 1, 4, 4}, {2.0f, 2.0f}, - CoordinateTransformMode::align_corners, - ShapeCalcMode::scales}, + CoordinateTransformMode::ALIGN_CORNERS, + ShapeCalcMode::SCALES}, // resize_downsample_scales_linear_align_corners: // (expected values from ONNX documentation are not correct!) ShapesAndAttrs{Shape{1, 1, 2, 4}, {1, 2}, Shape{1, 1, 1, 2}, {0.6f, 0.6f}, - CoordinateTransformMode::align_corners, - ShapeCalcMode::scales}}; + CoordinateTransformMode::ALIGN_CORNERS, + ShapeCalcMode::SCALES}}; std::vector> input_data_list = { {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f}, @@ -391,10 +391,10 @@ TEST(op_eval, interpolate_v4_linear_onnx) { auto axes = op::Constant::create(element::i64, Shape{2}, {2, 3}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::linear_onnx; + attrs.mode = InterpolateMode::LINEAR_ONNX; attrs.shape_calculation_mode = s.shape_calculation_mode; attrs.coordinate_transformation_mode = s.transform_mode; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -431,36 +431,36 @@ TEST(op_eval, interpolate_v4_linear_onnx5d) { {2, 1, 2}, Shape{1, 1, 2, 1, 2}, {0.8f, 0.6f, 0.6f}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::scales}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SCALES}, // resize_downsample_scales_linear_align_corners {Shape{1, 1, 3, 2, 4}, {2, 1, 2}, Shape{1, 1, 2, 1, 2}, {0.8f, 0.6f, 0.6f}, - CoordinateTransformMode::align_corners, - ShapeCalcMode::scales}, + CoordinateTransformMode::ALIGN_CORNERS, + ShapeCalcMode::SCALES}, // resize_upsample_scales_linear {Shape{1, 1, 2, 2, 2}, {4, 4, 4}, Shape{1, 1, 4, 4, 4}, {2.0, 2.0, 2.0}, - CoordinateTransformMode::half_pixel, - ShapeCalcMode::scales}, + CoordinateTransformMode::HALF_PIXEL, + ShapeCalcMode::SCALES}, // resize_upsample_scales_linear_align_corners {Shape{1, 1, 2, 2, 2}, {4, 4, 4}, Shape{1, 1, 4, 4, 4}, {2.0, 2.0, 2.0}, - CoordinateTransformMode::align_corners, - ShapeCalcMode::scales}, + CoordinateTransformMode::ALIGN_CORNERS, + ShapeCalcMode::SCALES}, // resize_downsample_sizes_linear_pytorch_half_pixel {Shape{1, 1, 2, 4, 4}, {1, 3, 1}, Shape{1, 1, 1, 3, 1}, {0.5, 0.75, 0.25}, - CoordinateTransformMode::pytorch_half_pixel, - ShapeCalcMode::sizes}}; + CoordinateTransformMode::PYTORCH_HALF_PIXEL, + ShapeCalcMode::SIZES}}; std::vector> input_data_list = { // resize_downsample_scales_linear @@ -507,10 +507,10 @@ TEST(op_eval, interpolate_v4_linear_onnx5d) { auto axes = op::Constant::create(element::i64, Shape{3}, {2, 3, 4}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::linear_onnx; + attrs.mode = InterpolateMode::LINEAR_ONNX; attrs.shape_calculation_mode = s.shape_calculation_mode; attrs.coordinate_transformation_mode = s.transform_mode; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0, 0}; diff --git a/ngraph/test/type_prop/interpolate.cpp b/ngraph/test/type_prop/interpolate.cpp index 350ba8e4aa5509..70db74e2ff8662 100644 --- a/ngraph/test/type_prop/interpolate.cpp +++ b/ngraph/test/type_prop/interpolate.cpp @@ -21,10 +21,10 @@ TEST(type_prop, interpolate_v4) { auto axes = op::Constant::create(element::i64, Shape{2}, {2, 3}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::nearest; - attrs.shape_calculation_mode = ShapeCalcMode::scales; - attrs.coordinate_transformation_mode = CoordinateTransformMode::half_pixel; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.mode = InterpolateMode::NEAREST; + attrs.shape_calculation_mode = ShapeCalcMode::SCALES; + attrs.coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -43,10 +43,10 @@ TEST(type_prop, interpolate_v4_non_constant_axes_scales) { auto axes = std::make_shared(element::i32, PartialShape{2}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::nearest; - attrs.shape_calculation_mode = ShapeCalcMode::scales; - attrs.coordinate_transformation_mode = CoordinateTransformMode::half_pixel; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.mode = InterpolateMode::NEAREST; + attrs.shape_calculation_mode = ShapeCalcMode::SCALES; + attrs.coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -67,10 +67,10 @@ TEST(type_prop, interpolate_v4_non_constant_axes_sizes) { auto axes = std::make_shared(element::i32, PartialShape{2}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::nearest; - attrs.shape_calculation_mode = ShapeCalcMode::sizes; - attrs.coordinate_transformation_mode = CoordinateTransformMode::half_pixel; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.mode = InterpolateMode::NEAREST; + attrs.shape_calculation_mode = ShapeCalcMode::SIZES; + attrs.coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -92,10 +92,10 @@ TEST(type_prop, interpolate_v4_partial) { auto axes = op::Constant::create(element::i64, Shape{2}, {2, 3}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::nearest; - attrs.shape_calculation_mode = ShapeCalcMode::scales; - attrs.coordinate_transformation_mode = CoordinateTransformMode::half_pixel; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.mode = InterpolateMode::NEAREST; + attrs.shape_calculation_mode = ShapeCalcMode::SCALES; + attrs.coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -120,10 +120,10 @@ TEST(type_prop, interpolate_v4_partial_static_rank) { auto axes = op::Constant::create(element::i64, Shape{2}, {2, 3}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::nearest; - attrs.shape_calculation_mode = ShapeCalcMode::scales; - attrs.coordinate_transformation_mode = CoordinateTransformMode::half_pixel; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.mode = InterpolateMode::NEAREST; + attrs.shape_calculation_mode = ShapeCalcMode::SCALES; + attrs.coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -145,10 +145,10 @@ TEST(type_prop, interpolate_v4_partial_static_rank2) { auto axes = op::Constant::create(element::i64, Shape{2}, {2, 3}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::nearest; - attrs.shape_calculation_mode = ShapeCalcMode::scales; - attrs.coordinate_transformation_mode = CoordinateTransformMode::half_pixel; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.mode = InterpolateMode::NEAREST; + attrs.shape_calculation_mode = ShapeCalcMode::SCALES; + attrs.coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -170,10 +170,10 @@ TEST(type_prop, interpolate_v4_partial_static_rank3) { auto axes = op::Constant::create(element::i64, Shape{2}, {2, 3}); InterpolateAttrs attrs; - attrs.mode = InterpolateMode::nearest; - attrs.shape_calculation_mode = ShapeCalcMode::scales; - attrs.coordinate_transformation_mode = CoordinateTransformMode::half_pixel; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.mode = InterpolateMode::NEAREST; + attrs.shape_calculation_mode = ShapeCalcMode::SCALES; + attrs.coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0}; @@ -196,10 +196,10 @@ TEST(type_prop, interpolate_v4_interval_logic) { const auto out_shape = PartialShape{2, 2, Dimension(6, 400), Dimension(0, -1), Dimension(3, -1)}; InterpolateAttrs attrs; - attrs.mode = InterpolateMode::nearest; - attrs.shape_calculation_mode = ShapeCalcMode::scales; - attrs.coordinate_transformation_mode = CoordinateTransformMode::half_pixel; - attrs.nearest_mode = Nearest_mode::round_prefer_floor; + attrs.mode = InterpolateMode::NEAREST; + attrs.shape_calculation_mode = ShapeCalcMode::SCALES; + attrs.coordinate_transformation_mode = CoordinateTransformMode::HALF_PIXEL; + attrs.nearest_mode = Nearest_mode::ROUND_PREFER_FLOOR; attrs.antialias = false; attrs.pads_begin = {0, 0, 0, 0, 0}; attrs.pads_end = {0, 0, 0, 0, 0};