[TESTS] Added Comparison and Logical single layer tests (#1242)
authorGorokhov Dmitriy <dmitry.gorokhov@intel.com>
Fri, 10 Jul 2020 10:56:22 +0000 (13:56 +0300)
committerGitHub <noreply@github.com>
Fri, 10 Jul 2020 10:56:22 +0000 (13:56 +0300)
15 files changed:
inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/comparison.cpp [new file with mode: 0644]
inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/logical.cpp [new file with mode: 0644]
inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/comparison.cpp [new file with mode: 0644]
inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/logical.cpp [new file with mode: 0644]
inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp
inference-engine/tests/functional/plugin/shared/include/single_layer_tests/comparison.hpp [new file with mode: 0644]
inference-engine/tests/functional/plugin/shared/include/single_layer_tests/logical.hpp [new file with mode: 0644]
inference-engine/tests/functional/plugin/shared/src/single_layer_tests/comparison.cpp [new file with mode: 0644]
inference-engine/tests/functional/plugin/shared/src/single_layer_tests/logical.cpp [new file with mode: 0644]
inference-engine/tests/ngraph_functions/include/ngraph_functions/builders.hpp
inference-engine/tests/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp
inference-engine/tests/ngraph_functions/src/comparison.cpp [new file with mode: 0644]
inference-engine/tests/ngraph_functions/src/constant.cpp
inference-engine/tests/ngraph_functions/src/logical.cpp [new file with mode: 0644]
inference-engine/tests/ngraph_functions/src/utils/ngraph_helpers.cpp

diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/comparison.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/comparison.cpp
new file mode 100644 (file)
index 0000000..e13b2ce
--- /dev/null
@@ -0,0 +1,58 @@
+// Copyright (C) 2020 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <vector>
+#include "single_layer_tests/comparison.hpp"
+#include "common_test_utils/test_constants.hpp"
+
+using namespace LayerTestsDefinitions;
+using namespace LayerTestsDefinitions::ComparisonParams;
+
+namespace {
+
+std::map<std::vector<size_t>, std::vector<std::vector<size_t >>> inputShapes = {
+        {{1}, {{1}, {17}, {1, 1}, {2, 18}, {1, 1, 2}, {2, 2, 3}, {1, 1, 2, 3}}},
+        {{5}, {{1}, {1, 1}, {2, 5}, {1, 1, 1}, {2, 2, 5}}},
+        {{2, 200}, {{1}, {200}, {1, 200}, {2, 200}, {2, 2, 200}}},
+        {{1, 3, 20}, {{20}, {2, 1, 1}}},
+        {{2, 17, 3, 4}, {{4}, {1, 3, 4}, {2, 1, 3, 4}}},
+        {{2, 1, 1, 3, 1}, {{1}, {1, 3, 4}, {2, 1, 3, 4}, {1, 1, 1, 1, 1}}},
+};
+
+std::vector<InferenceEngine::Precision> inputsPrecisions = {
+        InferenceEngine::Precision::FP32,
+};
+
+std::vector<ngraph::helpers::ComparisonTypes> comparisonOpTypes = {
+        ngraph::helpers::ComparisonTypes::EQUAL,
+        ngraph::helpers::ComparisonTypes::NOT_EQUAL,
+        ngraph::helpers::ComparisonTypes::GREATER,
+        ngraph::helpers::ComparisonTypes::GREATER_EQUAL,
+        ngraph::helpers::ComparisonTypes::LESS,
+        ngraph::helpers::ComparisonTypes::LESS_EQUAL,
+};
+
+std::vector<ngraph::helpers::InputLayerType> secondInputTypes = {
+        ngraph::helpers::InputLayerType::CONSTANT,
+        ngraph::helpers::InputLayerType::PARAMETER,
+};
+
+std::vector<InferenceEngine::Precision> netPrecisions = {
+        InferenceEngine::Precision::FP32,
+};
+
+std::map<std::string, std::string> additional_config = {};
+
+const auto ComparisonTestParams = ::testing::Combine(
+        ::testing::ValuesIn(ComparisonLayerTest::combineShapes(inputShapes)),
+        ::testing::ValuesIn(inputsPrecisions),
+        ::testing::ValuesIn(comparisonOpTypes),
+        ::testing::ValuesIn(secondInputTypes),
+        ::testing::ValuesIn(netPrecisions),
+        ::testing::Values(CommonTestUtils::DEVICE_CPU),
+        ::testing::Values(additional_config));
+
+INSTANTIATE_TEST_CASE_P(CompareWithRefs, ComparisonLayerTest, ComparisonTestParams, ComparisonLayerTest::getTestCaseName);
+
+}  // namespace
\ No newline at end of file
diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/logical.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/logical.cpp
new file mode 100644 (file)
index 0000000..75f8b70
--- /dev/null
@@ -0,0 +1,75 @@
+// Copyright (C) 2020 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <vector>
+#include "single_layer_tests/logical.hpp"
+#include "common_test_utils/test_constants.hpp"
+
+using namespace LayerTestsDefinitions;
+using namespace LayerTestsDefinitions::LogicalParams;
+
+namespace {
+
+std::map<std::vector<size_t>, std::vector<std::vector<size_t >>> inputShapes = {
+        {{1}, {{1}, {17}, {1, 1}, {2, 18}, {1, 1, 2}, {2, 2, 3}, {1, 1, 2, 3}}},
+        {{5}, {{1}, {1, 1}, {2, 5}, {1, 1, 1}, {2, 2, 5}}},
+        {{2, 200}, {{1}, {200}, {1, 200}, {2, 200}, {2, 2, 200}}},
+        {{1, 3, 20}, {{20}, {2, 1, 1}}},
+        {{2, 17, 3, 4}, {{4}, {1, 3, 4}, {2, 1, 3, 4}}},
+        {{2, 1, 1, 3, 1}, {{1}, {1, 3, 4}, {2, 1, 3, 4}, {1, 1, 1, 1, 1}}},
+};
+
+std::map<std::vector<size_t>, std::vector<std::vector<size_t >>> inputShapesNot = {
+        {{1}, {}},
+        {{5}, {}},
+        {{2, 200}, {}},
+        {{1, 3, 20}, {}},
+        {{2, 17, 3, 4}, {}},
+        {{2, 1, 1, 3, 1}, {}},
+};
+
+std::vector<InferenceEngine::Precision> inputsPrecisions = {
+        InferenceEngine::Precision::BOOL,
+};
+
+std::vector<ngraph::helpers::LogicalTypes> logicalOpTypes = {
+        ngraph::helpers::LogicalTypes::LOGICAL_AND,
+        ngraph::helpers::LogicalTypes::LOGICAL_OR,
+        ngraph::helpers::LogicalTypes::LOGICAL_XOR,
+};
+
+std::vector<ngraph::helpers::InputLayerType> secondInputTypes = {
+        ngraph::helpers::InputLayerType::CONSTANT,
+        ngraph::helpers::InputLayerType::PARAMETER,
+};
+
+std::vector<InferenceEngine::Precision> netPrecisions = {
+        InferenceEngine::Precision::FP32,
+};
+
+std::map<std::string, std::string> additional_config = {};
+
+const auto LogicalTestParams = ::testing::Combine(
+        ::testing::ValuesIn(LogicalLayerTest::combineShapes(inputShapes)),
+        ::testing::ValuesIn(inputsPrecisions),
+        ::testing::ValuesIn(logicalOpTypes),
+        ::testing::ValuesIn(secondInputTypes),
+        ::testing::ValuesIn(netPrecisions),
+        ::testing::Values(CommonTestUtils::DEVICE_CPU),
+        ::testing::Values(additional_config));
+
+const auto LogicalTestParamsNot = ::testing::Combine(
+        ::testing::ValuesIn(LogicalLayerTest::combineShapes(inputShapesNot)),
+        ::testing::ValuesIn(inputsPrecisions),
+        ::testing::Values(ngraph::helpers::LogicalTypes::LOGICAL_NOT),
+        ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT),
+        ::testing::ValuesIn(netPrecisions),
+        ::testing::Values(CommonTestUtils::DEVICE_CPU),
+        ::testing::Values(additional_config));
+
+INSTANTIATE_TEST_CASE_P(CompareWithRefs, LogicalLayerTest, LogicalTestParams, LogicalLayerTest::getTestCaseName);
+
+INSTANTIATE_TEST_CASE_P(CompareWithRefsNot, LogicalLayerTest, LogicalTestParamsNot, LogicalLayerTest::getTestCaseName);
+
+}  // namespace
\ No newline at end of file
diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/comparison.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/comparison.cpp
new file mode 100644 (file)
index 0000000..396a0e5
--- /dev/null
@@ -0,0 +1,58 @@
+// Copyright (C) 2020 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <vector>
+#include "single_layer_tests/comparison.hpp"
+#include "common_test_utils/test_constants.hpp"
+
+using namespace LayerTestsDefinitions;
+using namespace LayerTestsDefinitions::ComparisonParams;
+
+namespace {
+
+std::map<std::vector<size_t>, std::vector<std::vector<size_t >>> inputShapes = {
+        {{1}, {{1}, {17}, {1, 1}, {2, 18}, {1, 1, 2}, {2, 2, 3}, {1, 1, 2, 3}}},
+        {{5}, {{1}, {1, 1}, {2, 5}, {1, 1, 1}, {2, 2, 5}}},
+        {{2, 200}, {{1}, {200}, {1, 200}, {2, 200}, {2, 2, 200}}},
+        {{1, 3, 20}, {{20}, {2, 1, 1}}},
+        {{2, 17, 3, 4}, {{4}, {1, 3, 4}, {2, 1, 3, 4}}},
+        {{2, 1, 1, 3, 1}, {{1}, {1, 3, 4}, {2, 1, 3, 4}, {1, 1, 1, 1, 1}}},
+};
+
+std::vector<InferenceEngine::Precision> inputsPrecisions = {
+        InferenceEngine::Precision::FP32,
+};
+
+std::vector<ngraph::helpers::ComparisonTypes> comparisonOpTypes = {
+        ngraph::helpers::ComparisonTypes::EQUAL,
+        ngraph::helpers::ComparisonTypes::NOT_EQUAL,
+        ngraph::helpers::ComparisonTypes::GREATER,
+        ngraph::helpers::ComparisonTypes::GREATER_EQUAL,
+        ngraph::helpers::ComparisonTypes::LESS,
+        ngraph::helpers::ComparisonTypes::LESS_EQUAL,
+};
+
+std::vector<ngraph::helpers::InputLayerType> secondInputTypes = {
+        ngraph::helpers::InputLayerType::CONSTANT,
+        ngraph::helpers::InputLayerType::PARAMETER,
+};
+
+std::vector<InferenceEngine::Precision> netPrecisions = {
+        InferenceEngine::Precision::FP32,
+};
+
+std::map<std::string, std::string> additional_config = {};
+
+const auto ComparisonTestParams = ::testing::Combine(
+        ::testing::ValuesIn(ComparisonLayerTest::combineShapes(inputShapes)),
+        ::testing::ValuesIn(inputsPrecisions),
+        ::testing::ValuesIn(comparisonOpTypes),
+        ::testing::ValuesIn(secondInputTypes),
+        ::testing::ValuesIn(netPrecisions),
+        ::testing::Values(CommonTestUtils::DEVICE_GPU),
+        ::testing::Values(additional_config));
+
+INSTANTIATE_TEST_CASE_P(CompareWithRefs, ComparisonLayerTest, ComparisonTestParams, ComparisonLayerTest::getTestCaseName);
+
+}  // namespace
\ No newline at end of file
diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/logical.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/logical.cpp
new file mode 100644 (file)
index 0000000..75f8b70
--- /dev/null
@@ -0,0 +1,75 @@
+// Copyright (C) 2020 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <vector>
+#include "single_layer_tests/logical.hpp"
+#include "common_test_utils/test_constants.hpp"
+
+using namespace LayerTestsDefinitions;
+using namespace LayerTestsDefinitions::LogicalParams;
+
+namespace {
+
+std::map<std::vector<size_t>, std::vector<std::vector<size_t >>> inputShapes = {
+        {{1}, {{1}, {17}, {1, 1}, {2, 18}, {1, 1, 2}, {2, 2, 3}, {1, 1, 2, 3}}},
+        {{5}, {{1}, {1, 1}, {2, 5}, {1, 1, 1}, {2, 2, 5}}},
+        {{2, 200}, {{1}, {200}, {1, 200}, {2, 200}, {2, 2, 200}}},
+        {{1, 3, 20}, {{20}, {2, 1, 1}}},
+        {{2, 17, 3, 4}, {{4}, {1, 3, 4}, {2, 1, 3, 4}}},
+        {{2, 1, 1, 3, 1}, {{1}, {1, 3, 4}, {2, 1, 3, 4}, {1, 1, 1, 1, 1}}},
+};
+
+std::map<std::vector<size_t>, std::vector<std::vector<size_t >>> inputShapesNot = {
+        {{1}, {}},
+        {{5}, {}},
+        {{2, 200}, {}},
+        {{1, 3, 20}, {}},
+        {{2, 17, 3, 4}, {}},
+        {{2, 1, 1, 3, 1}, {}},
+};
+
+std::vector<InferenceEngine::Precision> inputsPrecisions = {
+        InferenceEngine::Precision::BOOL,
+};
+
+std::vector<ngraph::helpers::LogicalTypes> logicalOpTypes = {
+        ngraph::helpers::LogicalTypes::LOGICAL_AND,
+        ngraph::helpers::LogicalTypes::LOGICAL_OR,
+        ngraph::helpers::LogicalTypes::LOGICAL_XOR,
+};
+
+std::vector<ngraph::helpers::InputLayerType> secondInputTypes = {
+        ngraph::helpers::InputLayerType::CONSTANT,
+        ngraph::helpers::InputLayerType::PARAMETER,
+};
+
+std::vector<InferenceEngine::Precision> netPrecisions = {
+        InferenceEngine::Precision::FP32,
+};
+
+std::map<std::string, std::string> additional_config = {};
+
+const auto LogicalTestParams = ::testing::Combine(
+        ::testing::ValuesIn(LogicalLayerTest::combineShapes(inputShapes)),
+        ::testing::ValuesIn(inputsPrecisions),
+        ::testing::ValuesIn(logicalOpTypes),
+        ::testing::ValuesIn(secondInputTypes),
+        ::testing::ValuesIn(netPrecisions),
+        ::testing::Values(CommonTestUtils::DEVICE_CPU),
+        ::testing::Values(additional_config));
+
+const auto LogicalTestParamsNot = ::testing::Combine(
+        ::testing::ValuesIn(LogicalLayerTest::combineShapes(inputShapesNot)),
+        ::testing::ValuesIn(inputsPrecisions),
+        ::testing::Values(ngraph::helpers::LogicalTypes::LOGICAL_NOT),
+        ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT),
+        ::testing::ValuesIn(netPrecisions),
+        ::testing::Values(CommonTestUtils::DEVICE_CPU),
+        ::testing::Values(additional_config));
+
+INSTANTIATE_TEST_CASE_P(CompareWithRefs, LogicalLayerTest, LogicalTestParams, LogicalLayerTest::getTestCaseName);
+
+INSTANTIATE_TEST_CASE_P(CompareWithRefsNot, LogicalLayerTest, LogicalTestParamsNot, LogicalLayerTest::getTestCaseName);
+
+}  // namespace
\ No newline at end of file
index a212cc89bd21902d001cfb902603ba641497b899..c5a7b20aa676337bd9b1b1bb28682079cfb8d78b 100644 (file)
@@ -16,5 +16,7 @@ std::vector<std::string> disabledTestPatterns() {
             ".*BehaviorTests\\.pluginDoesNotChangeOriginalNetwork.*",
             //TODO: Issue: 34349
             R"(.*(IEClassLoadNetwork).*(QueryNetworkMULTIWithHETERONoThrow_V10|QueryNetworkHETEROWithMULTINoThrow_V10).*)",
+            //TODO: Issue: 34748
+            R"(.*(ComparisonLayerTest).*)",
     };
 }
\ No newline at end of file
diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/comparison.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/comparison.hpp
new file mode 100644 (file)
index 0000000..30dcc08
--- /dev/null
@@ -0,0 +1,40 @@
+// Copyright (C) 2020 Intel Corporation
+//
+// SPDX-License-Identifier: Apache-2.0
+
+#include <gtest/gtest.h>
+
+#include <map>
+#include <functional_test_utils/layer_test_utils.hpp>
+
+#include "common_test_utils/common_layers_params.hpp"
+#include "common_test_utils/common_utils.hpp"
+#include "common_test_utils/test_common.hpp"
+#include "common_test_utils/test_constants.hpp"
+#include "ie_core.hpp"
+
+namespace LayerTestsDefinitions {
+namespace ComparisonParams {
+using InputShapesTuple = std::pair<std::vector<size_t>, std::vector<size_t>>;
+} // ComparisonParams
+
+typedef std::tuple<
+    ComparisonParams::InputShapesTuple, // Input shapes tuple
+    InferenceEngine::Precision,         // Inputs precision
+    ngraph::helpers::ComparisonTypes,   // Comparison op type
+    ngraph::helpers::InputLayerType,    // Second input type
+    InferenceEngine::Precision,         // Net precision
+    std::string,                        // Device name
+    std::map<std::string, std::string>  // Additional network configuration
+> ComparisonTestParams;
+
+class ComparisonLayerTest : public testing::WithParamInterface<ComparisonTestParams>,
+    public LayerTestsUtils::LayerTestsCommon {
+protected:
+    void SetUp() override;
+
+public:
+    static std::string getTestCaseName(testing::TestParamInfo<ComparisonTestParams> obj);
+    static std::vector<ComparisonParams::InputShapesTuple> combineShapes(const std::map<std::vector<size_t>, std::vector<std::vector<size_t >>>& inputShapes);
+};
+} // namespace LayerTestsDefinitions
diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/logical.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/logical.hpp
new file mode 100644 (file)
index 0000000..26549de
--- /dev/null
@@ -0,0 +1,40 @@
+// Copyright (C) 2020 Intel Corporation
+//
+// SPDX-License-Identifier: Apache-2.0
+
+#include <gtest/gtest.h>
+
+#include <map>
+#include <functional_test_utils/layer_test_utils.hpp>
+
+#include "common_test_utils/common_layers_params.hpp"
+#include "common_test_utils/common_utils.hpp"
+#include "common_test_utils/test_common.hpp"
+#include "common_test_utils/test_constants.hpp"
+#include "ie_core.hpp"
+
+namespace LayerTestsDefinitions {
+namespace LogicalParams {
+using InputShapesTuple = std::pair<std::vector<size_t>, std::vector<size_t>>;
+} // LogicalParams
+
+typedef std::tuple<
+    LogicalParams::InputShapesTuple,    // Input shapes tuple
+    InferenceEngine::Precision,         // Inputs precision
+    ngraph::helpers::LogicalTypes,      // Logical op type
+    ngraph::helpers::InputLayerType,    // Second input type
+    InferenceEngine::Precision,         // Net precision
+    std::string,                        // Device name
+    std::map<std::string, std::string>  // Additional network configuration
+> LogicalTestParams;
+
+class LogicalLayerTest : public testing::WithParamInterface<LogicalTestParams>,
+    public LayerTestsUtils::LayerTestsCommon {
+protected:
+    void SetUp() override;
+
+public:
+    static std::string getTestCaseName(testing::TestParamInfo<LogicalTestParams> obj);
+    static std::vector<LogicalParams::InputShapesTuple> combineShapes(const std::map<std::vector<size_t>, std::vector<std::vector<size_t >>>& inputShapes);
+};
+} // namespace LayerTestsDefinitions
diff --git a/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/comparison.cpp b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/comparison.cpp
new file mode 100644 (file)
index 0000000..6d3c70d
--- /dev/null
@@ -0,0 +1,79 @@
+// Copyright (C) 2020 Intel Corporation
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gtest/gtest.h>
+
+#include <map>
+
+#include "functional_test_utils/layer_test_utils.hpp"
+#include "ngraph_functions/builders.hpp"
+#include "ngraph_functions/utils/ngraph_helpers.hpp"
+
+#include "single_layer_tests/comparison.hpp"
+
+using namespace LayerTestsDefinitions::ComparisonParams;
+
+namespace LayerTestsDefinitions {
+std::string ComparisonLayerTest::getTestCaseName(testing::TestParamInfo<ComparisonTestParams> obj) {
+    InputShapesTuple inputShapes;
+    InferenceEngine::Precision inputsPrecision;
+    ngraph::helpers::ComparisonTypes comparisonOpType;
+    ngraph::helpers::InputLayerType secondInputType;
+    InferenceEngine::Precision netPrecision;
+    std::string targetName;
+    std::map<std::string, std::string> additional_config;
+    std::tie(inputShapes, inputsPrecision, comparisonOpType, secondInputType, netPrecision, targetName, additional_config) = obj.param;
+    std::ostringstream results;
+
+    results << "IS0=" << CommonTestUtils::vec2str(inputShapes.first) << "_";
+    results << "IS1=" << CommonTestUtils::vec2str(inputShapes.second) << "_";
+    results << "inputsPRC=" << inputsPrecision.name() << "_";
+    results << "comparisonOpType=" << comparisonOpType << "_";
+    results << "secondInputType=" << secondInputType << "_";
+    results << "netPRC=" << netPrecision.name() << "_";
+    results << "targetDevice=" << targetName;
+    return results.str();
+}
+
+std::vector<InputShapesTuple> ComparisonLayerTest::combineShapes(const std::map<std::vector<size_t>, std::vector<std::vector<size_t >>>& inputShapes) {
+    std::vector<InputShapesTuple> resVec;
+    for (auto& inputShape : inputShapes) {
+        for (auto& item : inputShape.second) {
+            resVec.push_back({inputShape.first, item});
+        }
+    }
+    return resVec;
+}
+
+
+void ComparisonLayerTest::SetUp() {
+    InputShapesTuple inputShapes;
+    InferenceEngine::Precision inputsPrecision;
+    ngraph::helpers::ComparisonTypes comparisonOpType;
+    ngraph::helpers::InputLayerType secondInputType;
+    InferenceEngine::Precision netPrecision;
+    std::string targetName;
+    std::map<std::string, std::string> additional_config;
+    std::tie(inputShapes, inputsPrecision, comparisonOpType, secondInputType, netPrecision, targetDevice, additional_config) = this->GetParam();
+
+    auto ngInputsPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputsPrecision);
+    configuration.insert(additional_config.begin(), additional_config.end());
+
+    auto inputs = ngraph::builder::makeParams(ngInputsPrc, {inputShapes.first});
+
+    auto secondInput = ngraph::builder::makeInputLayer(ngInputsPrc, secondInputType, inputShapes.second);
+    if (secondInputType == ngraph::helpers::InputLayerType::PARAMETER) {
+        inputs.push_back(std::dynamic_pointer_cast<ngraph::opset3::Parameter>(secondInput));
+    }
+
+    auto comparisonNode = ngraph::builder::makeComparison(inputs[0], secondInput, comparisonOpType);
+    function = std::make_shared<ngraph::Function>(comparisonNode, inputs, "Comparison");
+}
+
+
+TEST_P(ComparisonLayerTest, ComparisonTests) {
+    Run();
+}
+} // namespace LayerTestsDefinitions
\ No newline at end of file
diff --git a/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/logical.cpp b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/logical.cpp
new file mode 100644 (file)
index 0000000..80ff08c
--- /dev/null
@@ -0,0 +1,88 @@
+// Copyright (C) 2020 Intel Corporation
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <gtest/gtest.h>
+
+#include <map>
+
+#include "functional_test_utils/layer_test_utils.hpp"
+#include "ngraph_functions/builders.hpp"
+#include "ngraph_functions/utils/ngraph_helpers.hpp"
+
+#include "single_layer_tests/logical.hpp"
+
+using namespace LayerTestsDefinitions::LogicalParams;
+
+namespace LayerTestsDefinitions {
+std::string LogicalLayerTest::getTestCaseName(testing::TestParamInfo<LogicalTestParams> obj) {
+    InputShapesTuple inputShapes;
+    InferenceEngine::Precision inputsPrecision;
+    ngraph::helpers::LogicalTypes comparisonOpType;
+    ngraph::helpers::InputLayerType secondInputType;
+    InferenceEngine::Precision netPrecision;
+    std::string targetName;
+    std::map<std::string, std::string> additional_config;
+    std::tie(inputShapes, inputsPrecision, comparisonOpType, secondInputType, netPrecision, targetName, additional_config) = obj.param;
+    std::ostringstream results;
+
+    results << "IS0=" << CommonTestUtils::vec2str(inputShapes.first) << "_";
+    results << "IS1=" << CommonTestUtils::vec2str(inputShapes.second) << "_";
+    results << "inputsPRC=" << inputsPrecision.name() << "_";
+    results << "comparisonOpType=" << comparisonOpType << "_";
+    results << "secondInputType=" << secondInputType << "_";
+    results << "netPRC=" << netPrecision.name() << "_";
+    results << "targetDevice=" << targetName;
+    return results.str();
+}
+
+std::vector<InputShapesTuple> LogicalLayerTest::combineShapes(const std::map<std::vector<size_t>, std::vector<std::vector<size_t >>>& inputShapes) {
+    std::vector<InputShapesTuple> resVec;
+    for (auto& inputShape : inputShapes) {
+        for (auto& item : inputShape.second) {
+            resVec.push_back({inputShape.first, item});
+        }
+
+        if (inputShape.second.empty()) {
+            resVec.push_back({inputShape.first, {}});
+        }
+    }
+    return resVec;
+}
+
+
+void LogicalLayerTest::SetUp() {
+    InputShapesTuple inputShapes;
+    InferenceEngine::Precision inputsPrecision;
+    ngraph::helpers::LogicalTypes logicalOpType;
+    ngraph::helpers::InputLayerType secondInputType;
+    InferenceEngine::Precision netPrecision;
+    std::string targetName;
+    std::map<std::string, std::string> additional_config;
+    std::tie(inputShapes, inputsPrecision, logicalOpType, secondInputType, netPrecision, targetDevice, additional_config) = this->GetParam();
+
+    auto ngInputsPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputsPrecision);
+    configuration.insert(additional_config.begin(), additional_config.end());
+
+    auto inputs = ngraph::builder::makeParams(ngInputsPrc, {inputShapes.first});
+
+    std::shared_ptr<ngraph::Node> logicalNode;
+    if (logicalOpType != ngraph::helpers::LogicalTypes::LOGICAL_NOT) {
+        auto secondInput = ngraph::builder::makeInputLayer(ngInputsPrc, secondInputType, inputShapes.second);
+        if (secondInputType == ngraph::helpers::InputLayerType::PARAMETER) {
+            inputs.push_back(std::dynamic_pointer_cast<ngraph::opset3::Parameter>(secondInput));
+        }
+        logicalNode = ngraph::builder::makeLogical(inputs[0], secondInput, logicalOpType);
+    } else {
+        logicalNode = ngraph::builder::makeLogical(inputs[0], ngraph::Output<ngraph::Node>(), logicalOpType);
+    }
+
+    function = std::make_shared<ngraph::Function>(logicalNode, inputs, "Logical");
+}
+
+
+TEST_P(LogicalLayerTest, LogicalTests) {
+    Run();
+}
+} // namespace LayerTestsDefinitions
\ No newline at end of file
index 438c68bee37b25582595861dcd0a3697a12b229a..7ffe2cc94fa807f913c8fe1d0b9bcccb14252213 100644 (file)
@@ -290,5 +290,13 @@ std::shared_ptr<ngraph::Node> makeScatterNDUpdate(const ngraph::Output<Node> &in
                                                   const std::vector<size_t>& indices,
                                                   const ngraph::Output<Node> &update);
 
+std::shared_ptr<ngraph::Node> makeComparison(const ngraph::Output<Node> &in0,
+                                             const ngraph::Output<Node> &in1,
+                                             ngraph::helpers::ComparisonTypes comparisonType);
+
+std::shared_ptr<ngraph::Node> makeLogical(const ngraph::Output<Node> &in0,
+                                          const ngraph::Output<Node> &in1,
+                                          ngraph::helpers::LogicalTypes logicalType);
+
 }  // namespace builder
 }  // namespace ngraph
index afbd5d7464300ef9f7debfcaa2988e88e273b561..898259e89dbc40ca9b49c35397ad601e7c7c8070 100644 (file)
@@ -115,6 +115,22 @@ enum EltwiseTypes {
     SUBTRACT
 };
 
+enum ComparisonTypes {
+    EQUAL,
+    NOT_EQUAL,
+    LESS,
+    LESS_EQUAL,
+    GREATER,
+    GREATER_EQUAL
+};
+
+enum LogicalTypes {
+    LOGICAL_AND,
+    LOGICAL_OR,
+    LOGICAL_XOR,
+    LOGICAL_NOT
+};
+
 enum SqueezeOpType {
     SQUEEZE,
     UNSQUEEZE
@@ -204,5 +220,9 @@ std::ostream& operator<<(std::ostream & os, ngraph::helpers::SqueezeOpType type)
 
 std::ostream& operator<<(std::ostream& os, ngraph::helpers::InputLayerType type);
 
+std::ostream& operator<<(std::ostream & os, ngraph::helpers::ComparisonTypes type);
+
+std::ostream& operator<<(std::ostream & os, ngraph::helpers::LogicalTypes type);
+
 }  // namespace helpers
 }  // namespace ngraph
diff --git a/inference-engine/tests/ngraph_functions/src/comparison.cpp b/inference-engine/tests/ngraph_functions/src/comparison.cpp
new file mode 100644 (file)
index 0000000..25497b8
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <memory>
+#include <ngraph/opsets/opset3.hpp>
+#include "ngraph_functions/utils/ngraph_helpers.hpp"
+
+namespace ngraph {
+namespace builder {
+
+std::shared_ptr<ngraph::Node> makeComparison(const ngraph::Output<Node> &in0,
+                                             const ngraph::Output<Node> &in1,
+                                             ngraph::helpers::ComparisonTypes comparisonType) {
+    switch (comparisonType) {
+        case ngraph::helpers::ComparisonTypes::EQUAL:
+            return std::make_shared<ngraph::opset3::Equal>(in0, in1);
+        case ngraph::helpers::ComparisonTypes::NOT_EQUAL:
+            return std::make_shared<ngraph::opset3::NotEqual>(in0, in1);
+        case ngraph::helpers::ComparisonTypes::GREATER:
+            return std::make_shared<ngraph::opset3::Greater>(in0, in1);
+        case ngraph::helpers::ComparisonTypes::GREATER_EQUAL:
+            return std::make_shared<ngraph::opset3::GreaterEqual>(in0, in1);
+        case ngraph::helpers::ComparisonTypes::LESS:
+            return std::make_shared<ngraph::opset3::Less>(in0, in1);
+        case ngraph::helpers::ComparisonTypes::LESS_EQUAL:
+            return std::make_shared<ngraph::opset3::LessEqual>(in0, in1);
+        default: {
+            throw std::runtime_error("Incorrect type of Comparison operation");
+        }
+    }
+}
+
+}  // namespace builder
+}  // namespace ngraph
\ No newline at end of file
index 5600015b67ff7631daeb143ab163a7f6ed43ce97..a9c266c624985311d93ae8f1e2cd7a67f37cefd9 100644 (file)
@@ -46,6 +46,7 @@ std::shared_ptr<Node> makeConstant(const element::Type &type, const std::vector<
         makeNode(ngraph::element::Type_t::u16);
         makeNode(ngraph::element::Type_t::u32);
         makeNode(ngraph::element::Type_t::u64);
+        makeNode(ngraph::element::Type_t::boolean);
 #undef makeNode
         default:
             throw std::runtime_error("Unhandled precision");
diff --git a/inference-engine/tests/ngraph_functions/src/logical.cpp b/inference-engine/tests/ngraph_functions/src/logical.cpp
new file mode 100644 (file)
index 0000000..95c47f0
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include <memory>
+#include <ngraph/opsets/opset3.hpp>
+#include "ngraph_functions/utils/ngraph_helpers.hpp"
+
+namespace ngraph {
+namespace builder {
+
+std::shared_ptr<ngraph::Node> makeLogical(const ngraph::Output<Node> &in0,
+                                          const ngraph::Output<Node> &in1,
+                                          ngraph::helpers::LogicalTypes logicalType) {
+    switch (logicalType) {
+        case ngraph::helpers::LogicalTypes::LOGICAL_AND:
+            return std::make_shared<ngraph::opset3::LogicalAnd>(in0, in1);
+        case ngraph::helpers::LogicalTypes::LOGICAL_OR:
+            return std::make_shared<ngraph::opset3::LogicalOr>(in0, in1);
+        case ngraph::helpers::LogicalTypes::LOGICAL_NOT:
+            return std::make_shared<ngraph::opset3::LogicalNot>(in0);
+        case ngraph::helpers::LogicalTypes::LOGICAL_XOR:
+            return std::make_shared<ngraph::opset3::LogicalXor>(in0, in1);
+        default: {
+            throw std::runtime_error("Incorrect type of Logical operation");
+        }
+    }
+}
+
+}  // namespace builder
+}  // namespace ngraph
\ No newline at end of file
index f79c75c494faa3dc9b2e45e638de82636a47e6a8..3304316f269c2b660843c6b8ccc96f1fbe310581 100644 (file)
@@ -560,5 +560,51 @@ std::ostream& operator<<(std::ostream& os, ngraph::helpers::InputLayerType type)
     return os;
 }
 
+std::ostream& operator<<(std::ostream & os, ngraph::helpers::ComparisonTypes type) {
+    switch (type) {
+        case ngraph::helpers::ComparisonTypes::EQUAL:
+            os << "Equal";
+            break;
+        case ngraph::helpers::ComparisonTypes::NOT_EQUAL:
+            os << "NotEqual";
+            break;
+        case ngraph::helpers::ComparisonTypes::GREATER:
+            os << "Greater";
+            break;
+        case ngraph::helpers::ComparisonTypes::GREATER_EQUAL:
+            os << "GreaterEqual";
+            break;
+        case ngraph::helpers::ComparisonTypes::LESS:
+            os << "Less";
+            break;
+        case ngraph::helpers::ComparisonTypes::LESS_EQUAL:
+            os << "LessEqual";
+            break;
+        default:
+            throw std::runtime_error("NOT_SUPPORTED_OP_TYPE");
+    }
+    return os;
+}
+
+std::ostream& operator<<(std::ostream & os, ngraph::helpers::LogicalTypes type) {
+    switch (type) {
+        case ngraph::helpers::LogicalTypes::LOGICAL_AND:
+            os << "LogicalAnd";
+            break;
+        case ngraph::helpers::LogicalTypes::LOGICAL_OR:
+            os << "LogicalOr";
+            break;
+        case ngraph::helpers::LogicalTypes::LOGICAL_NOT:
+            os << "LogicalNot";
+            break;
+        case ngraph::helpers::LogicalTypes::LOGICAL_XOR:
+            os << "LogicalXor";
+            break;
+        default:
+            throw std::runtime_error("NOT_SUPPORTED_OP_TYPE");
+    }
+    return os;
+}
+
 }  // namespace helpers
 }  // namespace ngraph