From affa0b839d5039af42869ded7caff6669e0d1bfd Mon Sep 17 00:00:00 2001 From: eshoguli Date: Wed, 25 Oct 2023 16:04:00 +0100 Subject: [PATCH] refactoring: InputLayerType::NONE was removed --- .../single_layer_tests/classes/eltwise.cpp | 94 +++++++++---------- .../instances/common/eltwise.cpp | 4 +- .../ov_helpers/ov_models/src/input_layer.cpp | 4 - .../include/common_test_utils/test_enums.hpp | 1 - .../common_test_utils/src/test_enums.cpp | 3 - 5 files changed, 48 insertions(+), 58 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp index f7cfb151a86e14..92e7ff007d5275 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/eltwise.cpp @@ -158,58 +158,56 @@ void EltwiseLayerCPUTest::SetUp() { } ov::ParameterVector parameters{std::make_shared(netType, inputDynamicShapes.front())}; std::shared_ptr secondaryInput; - switch (secondaryInputType) { - case ngraph::helpers::InputLayerType::PARAMETER: { - auto param = std::make_shared(netType, inputDynamicShapes.back()); - secondaryInput = param; - parameters.push_back(param); - break; - } - case ngraph::helpers::InputLayerType::CONSTANT: { - auto pShape = inputDynamicShapes.back(); - ngraph::Shape shape; - if (pShape.is_static()) { - shape = pShape.get_shape(); - } else { - ASSERT_TRUE(pShape.rank().is_static()); - shape = std::vector(pShape.rank().get_length(), 1); - for (size_t i = 0; i < pShape.size(); ++i) { - if (pShape[i].is_static()) { - shape[i] = pShape[i].get_length(); + if (eltwiseType != ngraph::helpers::EltwiseTypes::BITWISE_NOT) { + switch (secondaryInputType) { + case ngraph::helpers::InputLayerType::PARAMETER: { + auto param = std::make_shared(netType, inputDynamicShapes.back()); + secondaryInput = param; + parameters.push_back(param); + break; + } + case ngraph::helpers::InputLayerType::CONSTANT: { + auto pShape = inputDynamicShapes.back(); + ngraph::Shape shape; + if (pShape.is_static()) { + shape = pShape.get_shape(); + } else { + ASSERT_TRUE(pShape.rank().is_static()); + shape = std::vector(pShape.rank().get_length(), 1); + for (size_t i = 0; i < pShape.size(); ++i) { + if (pShape[i].is_static()) { + shape[i] = pShape[i].get_length(); + } } } - } - auto data_tensor = generate_eltwise_input(netType, shape); - if ((netType == ElementType::i8) || (netType == ElementType::u8)) { - auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); - secondaryInput = ngraph::builder::makeConstant(netType, shape, data); - } else if ((netType == ElementType::i16) || (netType == ElementType::u16)) { - auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); - secondaryInput = ngraph::builder::makeConstant(netType, shape, data); - } else if ((netType == ElementType::i32) || (netType == ElementType::u32)) { - auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); - secondaryInput = ngraph::builder::makeConstant(netType, shape, data); - } else if (netType == ElementType::f16) { - auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); - secondaryInput = ngraph::builder::makeConstant(netType, shape, data); - } else { - auto data_ptr = reinterpret_cast(data_tensor.data()); - std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); - secondaryInput = ngraph::builder::makeConstant(netType, shape, data); + auto data_tensor = generate_eltwise_input(netType, shape); + if ((netType == ElementType::i8) || (netType == ElementType::u8)) { + auto data_ptr = reinterpret_cast(data_tensor.data()); + std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + secondaryInput = ngraph::builder::makeConstant(netType, shape, data); + } else if ((netType == ElementType::i16) || (netType == ElementType::u16)) { + auto data_ptr = reinterpret_cast(data_tensor.data()); + std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + secondaryInput = ngraph::builder::makeConstant(netType, shape, data); + } else if ((netType == ElementType::i32) || (netType == ElementType::u32)) { + auto data_ptr = reinterpret_cast(data_tensor.data()); + std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + secondaryInput = ngraph::builder::makeConstant(netType, shape, data); + } else if (netType == ElementType::f16) { + auto data_ptr = reinterpret_cast(data_tensor.data()); + std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + secondaryInput = ngraph::builder::makeConstant(netType, shape, data); + } else { + auto data_ptr = reinterpret_cast(data_tensor.data()); + std::vector data(data_ptr, data_ptr + ngraph::shape_size(shape)); + secondaryInput = ngraph::builder::makeConstant(netType, shape, data); + } + break; + } + default: { + FAIL() << "Unsupported InputLayerType"; } - break; - } - case ngraph::helpers::InputLayerType::NONE: { - // the second input is absent - break; - } - default: { - FAIL() << "Unsupported InputLayerType"; } } auto eltwise = ngraph::builder::makeEltwise(parameters[0], secondaryInput, eltwiseType); diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp index a152027d1d376b..7bc76746861444 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp @@ -278,7 +278,7 @@ const auto params_4D_bitwise_NOT = ::testing::Combine( ::testing::Combine( ::testing::Values(bitwise_in_shapes_4D), ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), - ::testing::ValuesIn({ ngraph::helpers::InputLayerType::NONE }), + ::testing::ValuesIn({ ngraph::helpers::InputLayerType::CONSTANT }), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), ::testing::ValuesIn({ ov::element::Type_t::i8, ov::element::Type_t::u8, ov::element::Type_t::i32 }), ::testing::Values(ov::element::Type_t::undefined), @@ -295,7 +295,7 @@ const auto params_4D_bitwise_NOT_i16 = ::testing::Combine( ::testing::Combine( ::testing::Values(bitwise_in_shapes_4D), ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), - ::testing::ValuesIn({ ngraph::helpers::InputLayerType::NONE }), + ::testing::ValuesIn({ ngraph::helpers::InputLayerType::CONSTANT }), ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), ::testing::ValuesIn({ ov::element::Type_t::i16, ov::element::Type_t::u16 }), ::testing::Values(ov::element::Type_t::undefined), diff --git a/src/tests/ov_helpers/ov_models/src/input_layer.cpp b/src/tests/ov_helpers/ov_models/src/input_layer.cpp index 5256ab8935ed5b..8b87774e5630dc 100644 --- a/src/tests/ov_helpers/ov_models/src/input_layer.cpp +++ b/src/tests/ov_helpers/ov_models/src/input_layer.cpp @@ -24,10 +24,6 @@ std::shared_ptr makeInputLayer(const element::Type& type, input = std::make_shared(type, ov::Shape(shape)); break; } - case ov::test::utils::InputLayerType::NONE: { - // input is not used - break; - } default: throw std::runtime_error("Unsupported inputType"); } diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/test_enums.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/test_enums.hpp index 19594dc71403ba..5c93d211cac30b 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/test_enums.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/test_enums.hpp @@ -71,7 +71,6 @@ enum SqueezeOpType { enum class InputLayerType { CONSTANT, PARAMETER, - NONE, }; enum LogicalTypes { diff --git a/src/tests/test_utils/common_test_utils/src/test_enums.cpp b/src/tests/test_utils/common_test_utils/src/test_enums.cpp index 5ee68272780b21..e67122d9b8af4f 100644 --- a/src/tests/test_utils/common_test_utils/src/test_enums.cpp +++ b/src/tests/test_utils/common_test_utils/src/test_enums.cpp @@ -110,9 +110,6 @@ std::ostream& operator<<(std::ostream& os, ov::test::utils::InputLayerType type) case ov::test::utils::InputLayerType::PARAMETER: os << "PARAMETER"; break; - case ov::test::utils::InputLayerType::NONE: - os << "NONE"; - break; default: throw std::runtime_error("NOT_SUPPORTED_INPUT_LAYER_TYPE"); }