From 6379ee0ab21af3c4ef97d2e546ed7fb4925e5f6f Mon Sep 17 00:00:00 2001 From: eshoguli Date: Mon, 23 Oct 2023 01:47:54 +0100 Subject: [PATCH] test --- .../functional/single_layer_tests/bitwise.cpp | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 src/plugins/intel_cpu/tests/functional/single_layer_tests/bitwise.cpp diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/bitwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/bitwise.cpp new file mode 100644 index 00000000000000..505990f24aff9f --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/bitwise.cpp @@ -0,0 +1,153 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +//#include +#include "ov_models/builders.hpp" +#include "test_utils/cpu_test_utils.hpp" + +using namespace InferenceEngine; +using namespace CPUTestUtils; +using namespace ngraph::helpers; + +namespace CPULayerTestsDefinitions { + +typedef std::tuple< + std::pair, std::vector>, // Input shapes tuple + ngraph::helpers::LogicalTypes, // Logical op type + ngraph::helpers::InputLayerType, // Second input type + InferenceEngine::Precision, // Net precision + InferenceEngine::Precision, // Input precision + InferenceEngine::Precision, // Output precision + InferenceEngine::Layout, // Input layout + InferenceEngine::Layout, // Output layout + std::string, // Device name + std::map // Additional network configuration +> BitwiseTestParams; + +typedef std::tuple< + BitwiseTestParams, + CPUSpecificParams> +BitwiseLayerCPUTestParamSet; + +class BitwiseLayerCPUTest : public testing::WithParamInterface, + virtual public LayerTestsUtils::LayerTestsCommon, public CPUTestsBase { +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + BitwiseTestParams basicParamsSet; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, cpuParams) = obj.param; + + std::ostringstream result; + //result << LayerTestsDefinitions::BitwiseLayerTest::getTestCaseName(testing::TestParamInfo( + // basicParamsSet, 0)); + + result << CPUTestsBase::getTestCaseName(cpuParams); + + return result.str(); + } + +protected: + void SetUp() override { + BitwiseTestParams basicParamsSet; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, cpuParams) = this->GetParam(); + + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + + std::pair, std::vector> inputShapes; + ngraph::helpers::LogicalTypes logicalOpType; + ngraph::helpers::InputLayerType secondInputType; + InferenceEngine::Precision netPrecision; + std::string targetName; + std::map additional_config; + std::tie(inputShapes, logicalOpType, secondInputType, netPrecision, inPrc, outPrc, + inLayout, outLayout, targetDevice, additional_config) = basicParamsSet; + + selectedType = getPrimitiveType() + "_" + inPrc.name(); + + auto ngInputsPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(Precision::BOOL); // Because ngraph supports only boolean input for logical ops + configuration.insert(additional_config.begin(), additional_config.end()); + + ov::ParameterVector inputs{std::make_shared(ngInputsPrc, ov::Shape(inputShapes.first))}; + std::shared_ptr 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(secondInput)); + } + logicalNode = ngraph::builder::makeLogical(inputs[0], secondInput, logicalOpType); + } else { + logicalNode = ngraph::builder::makeLogical(inputs[0], ngraph::Output(), logicalOpType); + } + + logicalNode->get_rt_info() = getCPUInfo(); + + function = std::make_shared(logicalNode, inputs, "Logical"); + } +}; + +TEST_P(BitwiseLayerCPUTest, CompareWithRefs) { + Run(); + CheckPluginRelatedResults(executableNetwork, "Eltwise"); +} + +namespace { + +//std::map, std::vector>> 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>> inputShapesNot = { +// {{1}, {}}, +// {{5}, {}}, +// {{2, 200}, {}}, +// {{1, 3, 20}, {}}, +// {{2, 17, 3, 4}, {}}, +// {{2, 1, 1, 3, 1}, {}}, +//}; + +std::vector, std::vector>> inputShapes = {}; + +std::vector inputsPrecisions = { + InferenceEngine::Precision::BOOL, +}; + +std::vector logicalOpTypes = { + ngraph::helpers::LogicalTypes::LOGICAL_AND, + ngraph::helpers::LogicalTypes::LOGICAL_OR, + ngraph::helpers::LogicalTypes::LOGICAL_XOR, +}; + +std::vector secondInputTypes = { + ngraph::helpers::InputLayerType::CONSTANT, + ngraph::helpers::InputLayerType::PARAMETER, +}; + +std::map additional_config; + +std::vector inpOutPrc = {Precision::FP32}; + +const auto bitwiseTestParams = ::testing::Combine( + ::testing::Combine( + ::testing::ValuesIn(inputShapes), + ::testing::ValuesIn(logicalOpTypes), + ::testing::ValuesIn(secondInputTypes), + ::testing::Values(Precision::BF16), + ::testing::ValuesIn(inpOutPrc), + ::testing::ValuesIn(inpOutPrc), + ::testing::Values(Layout::ANY), + ::testing::Values(Layout::ANY), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::Values(additional_config)), + ::testing::Values(emptyCPUSpec)); + +INSTANTIATE_TEST_SUITE_P(smoke_Bitwise_Eltwise_CPU, BitwiseLayerCPUTest, bitwiseTestParams, BitwiseLayerCPUTest::getTestCaseName); + +} // namespace +} // namespace CPULayerTestsDefinitions