From 42bcf6b5af9a0c3c1620932d2f45498b13c4fe44 Mon Sep 17 00:00:00 2001 From: Nikita Semaev Date: Fri, 28 May 2021 20:00:51 +0300 Subject: [PATCH 01/16] Hiding the problem, Validate() changes 'function' --- .../shared_test_classes/src/base/layer_test_utils.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp b/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp index cc3927b25c53b3..0435fbe24ed882 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp @@ -45,21 +45,22 @@ void LayerTestsCommon::Run() { s.updateOPsStats(function, PassRate::Statuses::CRASHED); } + auto function_ = function; try { LoadNetwork(); GenerateInputs(); Infer(); Validate(); - s.updateOPsStats(function, PassRate::Statuses::PASSED); + s.updateOPsStats(function_, PassRate::Statuses::PASSED); } catch (const std::runtime_error &re) { - s.updateOPsStats(function, PassRate::Statuses::FAILED); + s.updateOPsStats(function_, PassRate::Statuses::FAILED); GTEST_FATAL_FAILURE_(re.what()); } catch (const std::exception &ex) { - s.updateOPsStats(function, PassRate::Statuses::FAILED); + s.updateOPsStats(function_, PassRate::Statuses::FAILED); GTEST_FATAL_FAILURE_(ex.what()); } catch (...) { - s.updateOPsStats(function, PassRate::Statuses::FAILED); + s.updateOPsStats(function_, PassRate::Statuses::FAILED); GTEST_FATAL_FAILURE_("Unknown failure occurred."); } } From 03aa9f5c0bddf6d01637a1d6b43f8d402b5cea3d Mon Sep 17 00:00:00 2001 From: nsemaev Date: Mon, 23 Aug 2021 13:56:45 +0300 Subject: [PATCH 02/16] Template plugin tests --- .../functional/op_reference/notequal.cpp | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 docs/template_plugin/tests/functional/op_reference/notequal.cpp diff --git a/docs/template_plugin/tests/functional/op_reference/notequal.cpp b/docs/template_plugin/tests/functional/op_reference/notequal.cpp new file mode 100644 index 00000000000000..5540ead6ce996a --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/notequal.cpp @@ -0,0 +1,78 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include +#include +#include + +#include "comparison.hpp" + +using namespace ngraph; +using namespace InferenceEngine; +using ComparisonTypes = ngraph::helpers::ComparisonTypes; + +namespace reference_tests { + namespace ComparisonOpsRefTestDefinitions { + namespace { + TEST_P(ReferenceComparisonLayerTest, GreaterCompareWithHardcodedRefs) { + Exec(); + } + + template + std::vector generateComparisonParams(const element::Type& type) { + using T = typename element_type_traits::value_type; + std::vector compParams { + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 2}, type, std::vector {1, 0, 10, 999}}) + .input2({{2, 2}, type, std::vector {1, 0, 10, 999}}) + .expected({{2, 2}, element::boolean, std::vector {0, 0, 0, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 3}, type, std::vector {0, 15, 45, 10, 5, 10}}) + .input2({{2, 3}, type, std::vector {1, 15, -45, 10, 50, 10}}) + .expected({{2, 3}, element::boolean, std::vector {1, 0, 1, 0, 1, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{1}, type, std::vector {23}}) + .input2({{1}, type, std::vector {23}}) + .expected({{1}, element::boolean, std::vector {0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{1}, type, std::vector {20}}) + .input2({{1}, type, std::vector {10}}) + .expected({{1}, element::boolean, std::vector {1}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 4}, type, std::vector {0, 12, 23, 0, 1, 5, 12, 8}}) + .input2({{2, 4}, type, std::vector {0, 12, 23, 0, 10, 5, 11, 8}}) + .expected({{2, 4}, element::boolean, std::vector {0, 0, 0, 0, 1, 0, 1, 0}}); + return compParams; + } + + std::vector generateComparisonCombinedParams() { + const std::vector> compTypeParams { + generateComparisonParams(element::f32), + generateComparisonParams(element::f16), + generateComparisonParams(element::i32), + generateComparisonParams(element::i64), + generateComparisonParams(element::u32), + generateComparisonParams(element::u64), + generateComparisonParams(element::boolean)}; + std::vector combinedParams; + + for (const auto& params : compTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; + } + + } // namespace + INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()), + ReferenceComparisonLayerTest::getTestCaseName); + } // namespace ComparisonOpsRefTestDefinitions +} // namespace reference_tests \ No newline at end of file From c5386b90908b0777acfad87e954e50738d09b95b Mon Sep 17 00:00:00 2001 From: nsemaev Date: Tue, 24 Aug 2021 18:12:59 +0300 Subject: [PATCH 03/16] Undo the changes that are not necessary --- .../shared_test_classes/src/base/layer_test_utils.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp b/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp index c78019da583e54..056826aff86a5f 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp @@ -45,22 +45,21 @@ void LayerTestsCommon::Run() { s.updateOPsStats(function, PassRate::Statuses::CRASHED); } - auto function_ = function; try { LoadNetwork(); GenerateInputs(); Infer(); Validate(); - s.updateOPsStats(function_, PassRate::Statuses::PASSED); + s.updateOPsStats(function, PassRate::Statuses::PASSED); } catch (const std::runtime_error &re) { - s.updateOPsStats(function_, PassRate::Statuses::FAILED); + s.updateOPsStats(function, PassRate::Statuses::FAILED); GTEST_FATAL_FAILURE_(re.what()); } catch (const std::exception &ex) { - s.updateOPsStats(function_, PassRate::Statuses::FAILED); + s.updateOPsStats(function, PassRate::Statuses::FAILED); GTEST_FATAL_FAILURE_(ex.what()); } catch (...) { - s.updateOPsStats(function_, PassRate::Statuses::FAILED); + s.updateOPsStats(function, PassRate::Statuses::FAILED); GTEST_FATAL_FAILURE_("Unknown failure occurred."); } } From 150fac10efc62ce6d589b8372efe74430136cf9a Mon Sep 17 00:00:00 2001 From: nsemaev Date: Wed, 25 Aug 2021 03:39:47 +0300 Subject: [PATCH 04/16] Align code style --- .../functional/op_reference/notequal.cpp | 110 +++++++++--------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/docs/template_plugin/tests/functional/op_reference/notequal.cpp b/docs/template_plugin/tests/functional/op_reference/notequal.cpp index 5540ead6ce996a..5756c9d13b6358 100644 --- a/docs/template_plugin/tests/functional/op_reference/notequal.cpp +++ b/docs/template_plugin/tests/functional/op_reference/notequal.cpp @@ -16,63 +16,63 @@ using namespace InferenceEngine; using ComparisonTypes = ngraph::helpers::ComparisonTypes; namespace reference_tests { - namespace ComparisonOpsRefTestDefinitions { - namespace { - TEST_P(ReferenceComparisonLayerTest, GreaterCompareWithHardcodedRefs) { - Exec(); - } +namespace ComparisonOpsRefTestDefinitions { +namespace { + TEST_P(ReferenceComparisonLayerTest, GreaterCompareWithHardcodedRefs) { + Exec(); + } - template - std::vector generateComparisonParams(const element::Type& type) { - using T = typename element_type_traits::value_type; - std::vector compParams { - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 2}, type, std::vector {1, 0, 10, 999}}) - .input2({{2, 2}, type, std::vector {1, 0, 10, 999}}) - .expected({{2, 2}, element::boolean, std::vector {0, 0, 0, 0}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 3}, type, std::vector {0, 15, 45, 10, 5, 10}}) - .input2({{2, 3}, type, std::vector {1, 15, -45, 10, 50, 10}}) - .expected({{2, 3}, element::boolean, std::vector {1, 0, 1, 0, 1, 0}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{1}, type, std::vector {23}}) - .input2({{1}, type, std::vector {23}}) - .expected({{1}, element::boolean, std::vector {0}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{1}, type, std::vector {20}}) - .input2({{1}, type, std::vector {10}}) - .expected({{1}, element::boolean, std::vector {1}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 4}, type, std::vector {0, 12, 23, 0, 1, 5, 12, 8}}) - .input2({{2, 4}, type, std::vector {0, 12, 23, 0, 10, 5, 11, 8}}) - .expected({{2, 4}, element::boolean, std::vector {0, 0, 0, 0, 1, 0, 1, 0}}); - return compParams; - } + template + std::vector generateComparisonParams(const element::Type& type) { + using T = typename element_type_traits::value_type; + std::vector compParams { + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 2}, type, std::vector {1, 0, 10, 999}}) + .input2({{2, 2}, type, std::vector {1, 0, 10, 999}}) + .expected({{2, 2}, element::boolean, std::vector {0, 0, 0, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 3}, type, std::vector {0, 15, 45, 10, 5, 10}}) + .input2({{2, 3}, type, std::vector {1, 15, -45, 10, 50, 10}}) + .expected({{2, 3}, element::boolean, std::vector {1, 0, 1, 0, 1, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{1}, type, std::vector {23}}) + .input2({{1}, type, std::vector {23}}) + .expected({{1}, element::boolean, std::vector {0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{1}, type, std::vector {20}}) + .input2({{1}, type, std::vector {10}}) + .expected({{1}, element::boolean, std::vector {1}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 4}, type, std::vector {0, 12, 23, 0, 1, 5, 12, 8}}) + .input2({{2, 4}, type, std::vector {0, 12, 23, 0, 10, 5, 11, 8}}) + .expected({{2, 4}, element::boolean, std::vector {0, 0, 0, 0, 1, 0, 1, 0}}); + return compParams; + } - std::vector generateComparisonCombinedParams() { - const std::vector> compTypeParams { - generateComparisonParams(element::f32), - generateComparisonParams(element::f16), - generateComparisonParams(element::i32), - generateComparisonParams(element::i64), - generateComparisonParams(element::u32), - generateComparisonParams(element::u64), - generateComparisonParams(element::boolean)}; - std::vector combinedParams; + std::vector generateComparisonCombinedParams() { + const std::vector> compTypeParams { + generateComparisonParams(element::f32), + generateComparisonParams(element::f16), + generateComparisonParams(element::i32), + generateComparisonParams(element::i64), + generateComparisonParams(element::u32), + generateComparisonParams(element::u64), + generateComparisonParams(element::boolean)}; + std::vector combinedParams; - for (const auto& params : compTypeParams) { - combinedParams.insert(combinedParams.end(), params.begin(), params.end()); - } - return combinedParams; - } + for (const auto& params : compTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; + } - } // namespace - INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()), - ReferenceComparisonLayerTest::getTestCaseName); - } // namespace ComparisonOpsRefTestDefinitions +} // namespace +INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()), + ReferenceComparisonLayerTest::getTestCaseName); +} // namespace ComparisonOpsRefTestDefinitions } // namespace reference_tests \ No newline at end of file From a4e3309c0d4c62720566b39cd81439d78de1d4f2 Mon Sep 17 00:00:00 2001 From: nsemaev Date: Wed, 25 Aug 2021 03:41:56 +0300 Subject: [PATCH 05/16] Added \n at end of file --- docs/template_plugin/tests/functional/op_reference/notequal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/template_plugin/tests/functional/op_reference/notequal.cpp b/docs/template_plugin/tests/functional/op_reference/notequal.cpp index 5756c9d13b6358..20c023bd37a071 100644 --- a/docs/template_plugin/tests/functional/op_reference/notequal.cpp +++ b/docs/template_plugin/tests/functional/op_reference/notequal.cpp @@ -75,4 +75,4 @@ namespace { INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()), ReferenceComparisonLayerTest::getTestCaseName); } // namespace ComparisonOpsRefTestDefinitions -} // namespace reference_tests \ No newline at end of file +} // namespace reference_tests From dcd09701efb9b1e77d08ccf83ae24c44e9443a0c Mon Sep 17 00:00:00 2001 From: nsemaev Date: Fri, 27 Aug 2021 13:15:15 +0300 Subject: [PATCH 06/16] Removing an unused implementation --- .../include/ngraph/runtime/reference/not_equal.hpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/not_equal.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/not_equal.hpp index 7b10df0e22d197..fcc3206c2921f2 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/not_equal.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/not_equal.hpp @@ -18,17 +18,6 @@ namespace ngraph { namespace runtime { namespace reference { -template -void not_equal(const T* arg0, - const T* arg1, - char* out, - size_t count) // TODO: using char for bool, is this right? -{ - for (size_t i = 0; i < count; i++) { - out[i] = arg0[i] != arg1[i]; - } -} - template void not_equal(const T* arg0, const T* arg1, From cc48e904ec563431427f629f498a18e0e778efa9 Mon Sep 17 00:00:00 2001 From: nsemaev Date: Tue, 31 Aug 2021 12:56:01 +0300 Subject: [PATCH 07/16] New version with Code Style checking --- .../functional/op_reference/notequal.cpp | 154 +++++++++++------- 1 file changed, 99 insertions(+), 55 deletions(-) diff --git a/docs/template_plugin/tests/functional/op_reference/notequal.cpp b/docs/template_plugin/tests/functional/op_reference/notequal.cpp index 20c023bd37a071..6d4c2c2f6e7689 100644 --- a/docs/template_plugin/tests/functional/op_reference/notequal.cpp +++ b/docs/template_plugin/tests/functional/op_reference/notequal.cpp @@ -15,64 +15,108 @@ using namespace ngraph; using namespace InferenceEngine; using ComparisonTypes = ngraph::helpers::ComparisonTypes; + namespace reference_tests { -namespace ComparisonOpsRefTestDefinitions { -namespace { - TEST_P(ReferenceComparisonLayerTest, GreaterCompareWithHardcodedRefs) { - Exec(); - } + namespace ComparisonOpsRefTestDefinitions { + namespace { + + template + std::vector generateComparisonParams(const element::Type& type) { + using T = typename element_type_traits::value_type; + std::vector compParams { + // 1D // 2D // 3D // 4D + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 2}, type, std::vector {1, 0, 10, 999}}) + .input2({{2, 2}, type, std::vector {1, 0, 10, 999}}) + .expected({{2, 2}, element::boolean, std::vector {1, 1, 1, 1}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 3}, type, std::vector {0, 15, 45, 10, 5, 10}}) + .input2({{2, 3}, type, std::vector {1, 15, -45, 10, 50, 10}}) + .expected({{2, 3}, element::boolean, std::vector {1, 0, 1, 0, 1, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{1}, type, std::vector {20}}) + .input2({{1}, type, std::vector {10}}) + .expected({{1}, element::boolean, std::vector {1}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 4}, type, std::vector {0, 12, 23, 0, 1, 5, 12, 8}}) + .input2({{2, 4}, type, std::vector {0, 12, 23, 0, 10, 5, 11, 8}}) + .expected({{2, 4}, element::boolean, std::vector {0, 0, 0, 0, 1, 0, 1, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{3, 1, 2}, type, std::vector {2, 1, 4, 1, 3, 1}}) + .input2({{1, 2, 1}, type, std::vector {1, 1}}) + .expected({{3, 2, 2}, element::boolean, std::vector {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 1, 2, 1}, type, std::vector {2, 1, 4, 1}}) + .input2({{1, 2, 1}, type, std::vector {1, 1}}) + .expected({{2, 1, 2, 1}, element::boolean, std::vector {0, 1, 0, 1}})}; + return compParams; + } + + std::vector generateComparisonCombinedParams() { + const std::vector> compTypeParams { + generateComparisonParams(element::f32), + generateComparisonParams(element::f16), + generateComparisonParams(element::i32), + generateComparisonParams(element::u32), + generateComparisonParams(element::boolean)}; + std::vector combinedParams; + + for (const auto& params : compTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; + } + + INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()), + ReferenceComparisonLayerTest::getTestCaseName); - template - std::vector generateComparisonParams(const element::Type& type) { - using T = typename element_type_traits::value_type; - std::vector compParams { - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 2}, type, std::vector {1, 0, 10, 999}}) - .input2({{2, 2}, type, std::vector {1, 0, 10, 999}}) - .expected({{2, 2}, element::boolean, std::vector {0, 0, 0, 0}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 3}, type, std::vector {0, 15, 45, 10, 5, 10}}) - .input2({{2, 3}, type, std::vector {1, 15, -45, 10, 50, 10}}) - .expected({{2, 3}, element::boolean, std::vector {1, 0, 1, 0, 1, 0}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{1}, type, std::vector {23}}) - .input2({{1}, type, std::vector {23}}) - .expected({{1}, element::boolean, std::vector {0}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{1}, type, std::vector {20}}) - .input2({{1}, type, std::vector {10}}) - .expected({{1}, element::boolean, std::vector {1}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 4}, type, std::vector {0, 12, 23, 0, 1, 5, 12, 8}}) - .input2({{2, 4}, type, std::vector {0, 12, 23, 0, 10, 5, 11, 8}}) - .expected({{2, 4}, element::boolean, std::vector {0, 0, 0, 0, 1, 0, 1, 0}}); - return compParams; - } + template + std::vector generateNumericParams(const element::Type& type) { + using T = typename element_type_traits::value_type; + std::vector compParams { + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{4}, type, std::vector {-2.5f, 25.5f, 2.25f, NAN}}) + .input2({{4}, type, std::vector {10.0f, 5.0f, 2.25f, 10.0f}}) + .expected({{4}, element::boolean, std::vector {0, 0, 1, 0, }}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 3}, type, std::vector {0.0f, NAN, NAN, 1.0f, 21.0f, -INFINITY}}) + .input2({{2, 3}, type, std::vector {1.0f, NAN, 23.0f, 1.0f, 19.0f, 21.0f}}) + .expected({{2, 3}, element::boolean, std::vector {0, 0, 0, 1, 0, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{1}, type, std::vector {INFINITY}}) + .input2({{1}, type, std::vector {INFINITY}}) + .expected({{1}, element::boolean, std::vector {1}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{5}, type, std::vector {-2.5f, 25.5f, 2.25f, INFINITY, 6.0f}}) + .input2({{5}, type, std::vector {10.0f, 5.0f, 2.25f, 10.0f, -INFINITY}}) + .expected({{5}, element::boolean, std::vector {0, 0, 1, 0, 0}})}; + return compParams; + } - std::vector generateComparisonCombinedParams() { - const std::vector> compTypeParams { - generateComparisonParams(element::f32), - generateComparisonParams(element::f16), - generateComparisonParams(element::i32), - generateComparisonParams(element::i64), - generateComparisonParams(element::u32), - generateComparisonParams(element::u64), - generateComparisonParams(element::boolean)}; - std::vector combinedParams; + std::vector generateNumericCombinedParams() { + const std::vector> compTypeParams { + generateNumericParams(element::f16), + generateNumericParams(element::f32)}; + std::vector combinedParams; - for (const auto& params : compTypeParams) { - combinedParams.insert(combinedParams.end(), params.begin(), params.end()); - } - return combinedParams; - } + for (const auto& params : compTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; + } -} // namespace -INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()), - ReferenceComparisonLayerTest::getTestCaseName); -} // namespace ComparisonOpsRefTestDefinitions + INSTANTIATE_TEST_SUITE_P(smoke_Numeric_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateNumericCombinedParams()), + ReferenceComparisonLayerTest::getTestCaseName); + } // namespace + } // namespace ComparisonOpsRefTestDefinitions } // namespace reference_tests From f1636b654e04428e1191161b7f5150d163d1400d Mon Sep 17 00:00:00 2001 From: nsemaev Date: Tue, 31 Aug 2021 16:49:11 +0300 Subject: [PATCH 08/16] Cleaning backend tests --- ngraph/test/CMakeLists.txt | 1 - ngraph/test/backend/comparison.in.cpp | 47 --------------------------- ngraph/test/backend/zero_sized.in.cpp | 4 --- 3 files changed, 52 deletions(-) delete mode 100644 ngraph/test/backend/comparison.in.cpp diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index ec621a10509430..0236fddcd10a95 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -420,7 +420,6 @@ set(MULTI_TEST_SRC backend/bucketize.in.cpp backend/builder_reduce_ops_opset1.in.cpp backend/ceiling.in.cpp - backend/comparison.in.cpp backend/concat.in.cpp backend/constant.in.cpp backend/convolution_backprop.in.cpp diff --git a/ngraph/test/backend/comparison.in.cpp b/ngraph/test/backend/comparison.in.cpp deleted file mode 100644 index dbe1247b89668c..00000000000000 --- a/ngraph/test/backend/comparison.in.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include -#include -#include - -#include "gtest/gtest.h" -#include "ngraph/log.hpp" -#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/ndarray.hpp" -#include "util/random.hpp" -#include "util/test_control.hpp" -#include "util/test_tools.hpp" - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; - -NGRAPH_TEST(${BACKEND_NAME}, notequal) { - Shape shape{2, 2, 2}; - auto A = make_shared(element::f32, shape); - auto B = make_shared(element::f32, shape); - auto f = make_shared(make_shared(A, B), ParameterVector{A, B}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - copy_data(a, vector{1, 8, -8, 17, -0.5, 0, 1, 1}); - auto b = backend->create_tensor(element::f32, shape); - copy_data(b, vector{1, 8, 4, 8, 0, 0, 1, 1.5}); - auto result = backend->create_tensor(element::boolean, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a, b}); - EXPECT_EQ((vector{0, 0, 1, 1, 1, 0, 0, 1}), read_vector(result)); -} diff --git a/ngraph/test/backend/zero_sized.in.cpp b/ngraph/test/backend/zero_sized.in.cpp index 29846308d63c1b..ba8bdf53dbf57b 100644 --- a/ngraph/test/backend/zero_sized.in.cpp +++ b/ngraph/test/backend/zero_sized.in.cpp @@ -227,10 +227,6 @@ NGRAPH_TEST(${BACKEND_NAME}, zero_sized_multiply) { make_binary_empty_test("${BACKEND_NAME}"); } -NGRAPH_TEST(${BACKEND_NAME}, zero_sized_not_equal) { - make_binary_empty_test("${BACKEND_NAME}", true); -} - NGRAPH_TEST(${BACKEND_NAME}, zero_sized_power) { make_binary_empty_test("${BACKEND_NAME}"); } From 185ae1d0eb4be8fe99d7046c0000990772675486 Mon Sep 17 00:00:00 2001 From: Nikita Semaev Date: Fri, 3 Sep 2021 12:18:05 +0300 Subject: [PATCH 09/16] Reworked the tests the right way --- .../functional/op_reference/not_equal.cpp | 123 ++++++++++++++++++ .../functional/op_reference/notequal.cpp | 122 ----------------- 2 files changed, 123 insertions(+), 122 deletions(-) create mode 100644 docs/template_plugin/tests/functional/op_reference/not_equal.cpp delete mode 100644 docs/template_plugin/tests/functional/op_reference/notequal.cpp diff --git a/docs/template_plugin/tests/functional/op_reference/not_equal.cpp b/docs/template_plugin/tests/functional/op_reference/not_equal.cpp new file mode 100644 index 00000000000000..e0292ecc67a4be --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/not_equal.cpp @@ -0,0 +1,123 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include +#include +#include + +#include "comparison.hpp" + +using namespace ngraph; +using namespace InferenceEngine; +using ComparisonTypes = ngraph::helpers::ComparisonTypes; + + +namespace reference_tests { +namespace ComparisonOpsRefTestDefinitions { +namespace { + +template +std::vector generateComparisonParams(const element::Type& type) { + using T = typename element_type_traits::value_type; + std::vector compParams { + // 1D // 2D // 3D // 4D + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 2}, type, std::vector {1, 0, 10, 255}}) + .input2({{2, 2}, type, std::vector {1, 0, 10, 255}}) + .expected({{2, 2}, element::boolean, std::vector {0, 0, 0, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 3}, type, std::vector {0, 15, 45, 10, 5, 10}}) + .input2({{2, 3}, type, std::vector {1, 15, 5, 10, 50, 10}}) + .expected({{2, 3}, element::boolean, std::vector {1, 0, 1, 0, 1, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{1}, type, std::vector {20}}) + .input2({{1}, type, std::vector {10}}) + .expected({{1}, element::boolean, std::vector {1}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 4}, type, std::vector {0, 12, 23, 0, 1, 5, 12, 8}}) + .input2({{2, 4}, type, std::vector {0, 12, 23, 0, 10, 5, 11, 8}}) + .expected({{2, 4}, element::boolean, std::vector {0, 0, 0, 0, 1, 0, 1, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{3, 1, 2}, type, std::vector {2, 7, 4, 7, 3, 7}}) + .input2({{1, 2, 1}, type, std::vector {7, 7}}) + .expected({{3, 2, 2}, element::boolean, std::vector {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 1, 2, 1}, type, std::vector {1, 2, 1, 4}}) + .input2({{1, 2, 1}, type, std::vector {1, 1}}) + .expected({{2, 1, 2, 1}, element::boolean, std::vector {0, 1, 0, 1}})}; + return compParams; +} + +std::vector generateComparisonCombinedParams() { + const std::vector> compTypeParams { + generateComparisonParams(element::f32), + generateComparisonParams(element::f16), + generateComparisonParams(element::i32), + generateComparisonParams(element::u32), + generateComparisonParams(element::boolean)}; + std::vector combinedParams; + + for (const auto& params : compTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, + ::testing::ValuesIn(generateComparisonCombinedParams()), + ReferenceComparisonLayerTest::getTestCaseName); + +template +std::vector generateNumericParams(const element::Type& type) { + using T = typename element_type_traits::value_type; + std::vector compParams { + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{4}, type, std::vector {-2.5f, 25.5f, 2.25f, NAN}}) + .input2({{4}, type, std::vector {10.0f, 5.0f, 2.25f, 10.0f}}) + .expected({{4}, element::boolean, std::vector {1, 1, 0, 1}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{2, 3}, type, std::vector {0.0f, NAN, NAN, 1.0f, 21.0f, -INFINITY}}) + .input2({{2, 3}, type, std::vector {1.0f, NAN, 23.0f, 1.0f, 19.0f, 21.0f}}) + .expected({{2, 3}, element::boolean, std::vector {1, 1, 1, 0, 1, 1}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{1}, type, std::vector {INFINITY}}) + .input2({{1}, type, std::vector {INFINITY}}) + .expected({{1}, element::boolean, std::vector {0}}), + Builder {} + .compType(ComparisonTypes::NOT_EQUAL) + .input1({{5}, type, std::vector {-2.5f, 25.5f, 2.25f, INFINITY, 6.0f}}) + .input2({{5}, type, std::vector {10.0f, 5.0f, 2.25f, 10.0f, -INFINITY}}) + .expected({{5}, element::boolean, std::vector {1, 1, 0, 1, 1}})}; + return compParams; +} + +std::vector generateNumericCombinedParams() { + const std::vector> compTypeParams { + generateNumericParams(element::f16), + generateNumericParams(element::f32)}; + std::vector combinedParams; + + for (const auto& params : compTypeParams) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + } + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_Numeric_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateNumericCombinedParams()), + ReferenceComparisonLayerTest::getTestCaseName); +} // namespace +} // namespace ComparisonOpsRefTestDefinitions +} // namespace reference_tests diff --git a/docs/template_plugin/tests/functional/op_reference/notequal.cpp b/docs/template_plugin/tests/functional/op_reference/notequal.cpp deleted file mode 100644 index 6d4c2c2f6e7689..00000000000000 --- a/docs/template_plugin/tests/functional/op_reference/notequal.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include -#include -#include -#include - -#include "comparison.hpp" - -using namespace ngraph; -using namespace InferenceEngine; -using ComparisonTypes = ngraph::helpers::ComparisonTypes; - - -namespace reference_tests { - namespace ComparisonOpsRefTestDefinitions { - namespace { - - template - std::vector generateComparisonParams(const element::Type& type) { - using T = typename element_type_traits::value_type; - std::vector compParams { - // 1D // 2D // 3D // 4D - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 2}, type, std::vector {1, 0, 10, 999}}) - .input2({{2, 2}, type, std::vector {1, 0, 10, 999}}) - .expected({{2, 2}, element::boolean, std::vector {1, 1, 1, 1}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 3}, type, std::vector {0, 15, 45, 10, 5, 10}}) - .input2({{2, 3}, type, std::vector {1, 15, -45, 10, 50, 10}}) - .expected({{2, 3}, element::boolean, std::vector {1, 0, 1, 0, 1, 0}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{1}, type, std::vector {20}}) - .input2({{1}, type, std::vector {10}}) - .expected({{1}, element::boolean, std::vector {1}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 4}, type, std::vector {0, 12, 23, 0, 1, 5, 12, 8}}) - .input2({{2, 4}, type, std::vector {0, 12, 23, 0, 10, 5, 11, 8}}) - .expected({{2, 4}, element::boolean, std::vector {0, 0, 0, 0, 1, 0, 1, 0}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{3, 1, 2}, type, std::vector {2, 1, 4, 1, 3, 1}}) - .input2({{1, 2, 1}, type, std::vector {1, 1}}) - .expected({{3, 2, 2}, element::boolean, std::vector {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 1, 2, 1}, type, std::vector {2, 1, 4, 1}}) - .input2({{1, 2, 1}, type, std::vector {1, 1}}) - .expected({{2, 1, 2, 1}, element::boolean, std::vector {0, 1, 0, 1}})}; - return compParams; - } - - std::vector generateComparisonCombinedParams() { - const std::vector> compTypeParams { - generateComparisonParams(element::f32), - generateComparisonParams(element::f16), - generateComparisonParams(element::i32), - generateComparisonParams(element::u32), - generateComparisonParams(element::boolean)}; - std::vector combinedParams; - - for (const auto& params : compTypeParams) { - combinedParams.insert(combinedParams.end(), params.begin(), params.end()); - } - return combinedParams; - } - - INSTANTIATE_TEST_SUITE_P(smoke_Comparison_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateComparisonCombinedParams()), - ReferenceComparisonLayerTest::getTestCaseName); - - template - std::vector generateNumericParams(const element::Type& type) { - using T = typename element_type_traits::value_type; - std::vector compParams { - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{4}, type, std::vector {-2.5f, 25.5f, 2.25f, NAN}}) - .input2({{4}, type, std::vector {10.0f, 5.0f, 2.25f, 10.0f}}) - .expected({{4}, element::boolean, std::vector {0, 0, 1, 0, }}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{2, 3}, type, std::vector {0.0f, NAN, NAN, 1.0f, 21.0f, -INFINITY}}) - .input2({{2, 3}, type, std::vector {1.0f, NAN, 23.0f, 1.0f, 19.0f, 21.0f}}) - .expected({{2, 3}, element::boolean, std::vector {0, 0, 0, 1, 0, 0}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{1}, type, std::vector {INFINITY}}) - .input2({{1}, type, std::vector {INFINITY}}) - .expected({{1}, element::boolean, std::vector {1}}), - Builder {} - .compType(ComparisonTypes::NOT_EQUAL) - .input1({{5}, type, std::vector {-2.5f, 25.5f, 2.25f, INFINITY, 6.0f}}) - .input2({{5}, type, std::vector {10.0f, 5.0f, 2.25f, 10.0f, -INFINITY}}) - .expected({{5}, element::boolean, std::vector {0, 0, 1, 0, 0}})}; - return compParams; - } - - std::vector generateNumericCombinedParams() { - const std::vector> compTypeParams { - generateNumericParams(element::f16), - generateNumericParams(element::f32)}; - std::vector combinedParams; - - for (const auto& params : compTypeParams) { - combinedParams.insert(combinedParams.end(), params.begin(), params.end()); - } - return combinedParams; - } - - INSTANTIATE_TEST_SUITE_P(smoke_Numeric_With_Hardcoded_Refs, ReferenceComparisonLayerTest, ::testing::ValuesIn(generateNumericCombinedParams()), - ReferenceComparisonLayerTest::getTestCaseName); - } // namespace - } // namespace ComparisonOpsRefTestDefinitions -} // namespace reference_tests From 90285b9f17206a8b26e8db6d96ed7b163bcf2815 Mon Sep 17 00:00:00 2001 From: Nikita Semaev Date: Fri, 3 Sep 2021 13:17:20 +0300 Subject: [PATCH 10/16] Removed visit_attributes() --- ngraph/core/include/ngraph/op/not_equal.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ngraph/core/include/ngraph/op/not_equal.hpp b/ngraph/core/include/ngraph/op/not_equal.hpp index a2d37109abcd91..db40f07d0541b6 100644 --- a/ngraph/core/include/ngraph/op/not_equal.hpp +++ b/ngraph/core/include/ngraph/op/not_equal.hpp @@ -25,10 +25,8 @@ class NGRAPH_API NotEqual : public util::BinaryElementwiseComparison { const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec(AutoBroadcastType::NUMPY)); virtual 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; - bool visit_attributes(AttributeVisitor& visitor) override; }; } // namespace v1 } // namespace op From daa56ffa59003f42ad292548ac3704abea6eea97 Mon Sep 17 00:00:00 2001 From: Nikita Semaev Date: Fri, 3 Sep 2021 13:19:58 +0300 Subject: [PATCH 11/16] Removed visit_attributes() in source file --- ngraph/core/src/op/not_equal.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ngraph/core/src/op/not_equal.cpp b/ngraph/core/src/op/not_equal.cpp index 56f969b214cdeb..0ad95af500686d 100644 --- a/ngraph/core/src/op/not_equal.cpp +++ b/ngraph/core/src/op/not_equal.cpp @@ -84,9 +84,3 @@ bool op::v1::NotEqual::has_evaluate() const { } return false; } - -bool op::v1::NotEqual::visit_attributes(AttributeVisitor& visitor) { - NGRAPH_OP_SCOPE(v1_NotEqual_visit_attributes); - BinaryElementwiseComparison::visit_attributes(visitor); - return true; -} From 112d0eba3dded89f6dc7be8b4f1a06bf5970deca Mon Sep 17 00:00:00 2001 From: Nikita Semaev Date: Fri, 3 Sep 2021 13:23:35 +0300 Subject: [PATCH 12/16] Added NGRAPH_CHECK macros to evaluate() --- ngraph/core/src/op/not_equal.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ngraph/core/src/op/not_equal.cpp b/ngraph/core/src/op/not_equal.cpp index 0ad95af500686d..ccdbb36e4daf8d 100644 --- a/ngraph/core/src/op/not_equal.cpp +++ b/ngraph/core/src/op/not_equal.cpp @@ -7,6 +7,7 @@ #include "itt.hpp" #include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/not_equal.hpp" +#include "ngraph/validation_util.hpp" using namespace std; using namespace ngraph; @@ -65,6 +66,7 @@ shared_ptr op::v1::NotEqual::clone_with_new_inputs(const OutputVector& new bool op::v1::NotEqual::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { NGRAPH_OP_SCOPE(v1_NotEqual_evaluate); + NGRAPH_CHECK(validate_host_tensor_vector(outputs, 1) && validate_host_tensor_vector(inputs, 2)); return not_equalop::evaluate_not_equal(inputs[0], inputs[1], outputs[0], get_autob()); } From 73a70ed8c12882b45b694af4927398dee69d60b4 Mon Sep 17 00:00:00 2001 From: Nikita Semaev Date: Fri, 3 Sep 2021 13:26:28 +0300 Subject: [PATCH 13/16] Removed zero_sized_not_equal mention from unit_test.manifest --- ngraph/test/runtime/ie/unit_test.manifest | 1 - 1 file changed, 1 deletion(-) diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index c32732c3c2639c..88172bc3933ab8 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -288,7 +288,6 @@ zero_sized_lesseq zero_sized_maximum zero_sized_minimum zero_sized_multiply -zero_sized_not_equal zero_sized_power zero_sized_subtract sum_trivial From 5b7478056f4d9dd667ecd3d73053b8d2fb1f68bf Mon Sep 17 00:00:00 2001 From: Nikita Semaev Date: Fri, 3 Sep 2021 13:30:20 +0300 Subject: [PATCH 14/16] Added function name to the constants.py --- .../functional_test_utils/layer_tests_summary/utils/constants.py | 1 + 1 file changed, 1 insertion(+) diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index d40dc40480c2e3..9bc91017959cb1 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -78,6 +78,7 @@ 'NonMaxSuppression-5', 'NonZero-3', 'NormalizeL2-1', + 'NotEqual-1' 'PriorBox-1', 'PriorBoxClustered-1', 'Proposal-1', From 3f169c7c49c1c4b00e62a29d8639659af11680ed Mon Sep 17 00:00:00 2001 From: Nikita Semaev Date: Fri, 3 Sep 2021 13:38:18 +0300 Subject: [PATCH 15/16] Revert "Added function name to the constants.py" This reverts commit 5b7478056f4d9dd667ecd3d73053b8d2fb1f68bf. --- .../functional_test_utils/layer_tests_summary/utils/constants.py | 1 - 1 file changed, 1 deletion(-) diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 9bc91017959cb1..d40dc40480c2e3 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -78,7 +78,6 @@ 'NonMaxSuppression-5', 'NonZero-3', 'NormalizeL2-1', - 'NotEqual-1' 'PriorBox-1', 'PriorBoxClustered-1', 'Proposal-1', From cbd82480de195638903b97f35495f81691da3955 Mon Sep 17 00:00:00 2001 From: Nikita Semaev Date: Wed, 8 Sep 2021 02:30:36 +0300 Subject: [PATCH 16/16] Return visit_attributes() for op::v1::NotEqual due to NotEqual being moved to another location --- ngraph/core/src/op/not_equal.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ngraph/core/src/op/not_equal.cpp b/ngraph/core/src/op/not_equal.cpp index 19c5d89049dcef..cebed042fedf0c 100644 --- a/ngraph/core/src/op/not_equal.cpp +++ b/ngraph/core/src/op/not_equal.cpp @@ -86,3 +86,9 @@ bool op::v1::NotEqual::has_evaluate() const { } return false; } + +bool op::v1::NotEqual::visit_attributes(AttributeVisitor& visitor) { + NGRAPH_OP_SCOPE(v1_NotEqual_visit_attributes); + BinaryElementwiseComparison::visit_attributes(visitor); + return true; +}