diff --git a/src/tests/functional/plugin/shared/src/base/import_export_base/import_export_base.cpp b/src/tests/functional/plugin/gna/Import_export_tests/base/import_export_base.cpp similarity index 98% rename from src/tests/functional/plugin/shared/src/base/import_export_base/import_export_base.cpp rename to src/tests/functional/plugin/gna/Import_export_tests/base/import_export_base.cpp index 1607d2cf3e1..3c371158ff0 100644 --- a/src/tests/functional/plugin/shared/src/base/import_export_base/import_export_base.cpp +++ b/src/tests/functional/plugin/gna/Import_export_tests/base/import_export_base.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "base/import_export_base/import_export_base.hpp" +#include "import_export_base.hpp" #include diff --git a/src/tests/functional/plugin/shared/include/base/import_export_base/import_export_base.hpp b/src/tests/functional/plugin/gna/Import_export_tests/base/import_export_base.hpp similarity index 100% rename from src/tests/functional/plugin/shared/include/base/import_export_base/import_export_base.hpp rename to src/tests/functional/plugin/gna/Import_export_tests/base/import_export_base.hpp diff --git a/src/tests/functional/plugin/gna/Import_export_tests/import_export_batch_size.cpp b/src/tests/functional/plugin/gna/Import_export_tests/import_export_batch_size.cpp index 2907da9338a..d916b55f0bc 100644 --- a/src/tests/functional/plugin/gna/Import_export_tests/import_export_batch_size.cpp +++ b/src/tests/functional/plugin/gna/Import_export_tests/import_export_batch_size.cpp @@ -13,7 +13,7 @@ #include #include "ngraph_functions/builders.hpp" -#include "base/import_export_base/import_export_base.hpp" +#include "base/import_export_base.hpp" namespace LayerTestDefinitions { diff --git a/src/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_export_multi_inputs.cpp b/src/tests/functional/plugin/gna/Import_export_tests/import_export_multi_inputs.cpp similarity index 98% rename from src/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_export_multi_inputs.cpp rename to src/tests/functional/plugin/gna/Import_export_tests/import_export_multi_inputs.cpp index bf465027f81..bfe4f6f269b 100644 --- a/src/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_export_multi_inputs.cpp +++ b/src/tests/functional/plugin/gna/Import_export_tests/import_export_multi_inputs.cpp @@ -10,7 +10,7 @@ #include #include "ngraph_functions/builders.hpp" -#include "base/import_export_base/import_export_base.hpp" +#include "base/import_export_base.hpp" namespace LayerTestsDefinitions { diff --git a/src/tests/functional/plugin/gna/Import_export_tests/import_reshape_permute_conv.cpp b/src/tests/functional/plugin/gna/Import_export_tests/import_reshape_permute_conv.cpp new file mode 100644 index 00000000000..d5a6e201bae --- /dev/null +++ b/src/tests/functional/plugin/gna/Import_export_tests/import_reshape_permute_conv.cpp @@ -0,0 +1,156 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "base/import_export_base.hpp" +#include "ngraph_functions/builders.hpp" + +namespace LayerTestsDefinitions { + +class ImportReshapePermuteConv : public FuncTestUtils::ImportNetworkTestBase { +protected: + void SetUp() override { + std::vector inputShape; + InferenceEngine::Precision netPrecision; + std::tie(inputShape, netPrecision, targetDevice, exportConfiguration, importConfiguration, applicationHeader) = this->GetParam(); + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + + auto params = ngraph::builder::makeParams(ngPrc, { inputShape }); + + std::vector outFormShapes1 = { 1, 1, 168, 2 }; + auto pattern1 = std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape{ 4 }, outFormShapes1); + auto reshape1 = std::make_shared(params[0], pattern1, false); + + auto permute1 = std::make_shared(reshape1, + ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{ 4 }, { 0, 3, 1, 2 })); + + auto conv1 = ngraph::builder::makeConvolution(permute1, ngPrc, { 1, 8 }, { 1, 1 }, { 0, 0 }, { 0, 0 }, { 1, 1 }, + ngraph::op::PadType::VALID, 12); + + auto permute2 = std::make_shared(conv1, + ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{ 4 }, { 0, 2, 3, 1 })); + + std::vector outFormShapes2 = { 1, 1932 }; + auto pattern2 = std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape{ 2 }, outFormShapes2); + auto reshape2 = std::make_shared(permute2, pattern2, false); + + ngraph::ResultVector results{ std::make_shared(reshape2) }; + function = std::make_shared(results, params, "ExportImportNetwork"); + }; +}; + +TEST_P(ImportReshapePermuteConv, CompareWithRefImpl) { + Run(); +}; + +} // namespace LayerTestsDefinitions + +using namespace LayerTestsDefinitions; + +namespace { + +class ImportExportGNAModelUnchanged : public ImportReshapePermuteConv { +private: + void exportImportNetwork() override { + { + std::ofstream out(fileName); + out.write(applicationHeader.c_str(), applicationHeader.size()); + executableNetwork.Export(out); + } + { + std::string appHeader(applicationHeader.size(), ' '); + std::fstream inputStream(fileName, std::ios_base::in | std::ios_base::binary); + if (inputStream.fail()) { + FAIL() << "Cannot open file to import model: " << fileName; + } + inputStream.read(&appHeader[0], applicationHeader.size()); + ASSERT_EQ(appHeader, applicationHeader); + executableNetwork = core->ImportNetwork(inputStream, targetDevice, configuration); + } + } + +protected: + void TearDown() override { + if (remove(fileName.c_str()) != 0) { + FAIL() << "Error: could not delete file " << fileName; + } + } + +private: + std::string fileName = "exported_model.blob"; +}; + +class ImportExportGNAModelChanged : public ImportExportGNAModelUnchanged {}; + +TEST_P(ImportExportGNAModelUnchanged, ReshapePermuteConv) { + TestRun(false); +}; + +TEST_P(ImportExportGNAModelChanged, ReshapePermuteConv) { + TestRun(true); +}; + +const std::vector> inputShapes = { + {1, 336} +}; + +const std::vector netPrecisions = { + InferenceEngine::Precision::FP32, + InferenceEngine::Precision::FP16 +}; + +const std::vector> exportConfigs = { + { + {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, + {"GNA_SCALE_FACTOR_0", "327.67"} + } +}; + +const std::vector> importConfigsChanged = { + { + {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, + {"GNA_SCALE_FACTOR_0", "32767"} + } +}; + +const std::vector> importConfigsUnchanged = { + { + {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, + {"GNA_SCALE_FACTOR_0", "327.67"} + }, + { + {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, + {"GNA_SCALE_FACTOR_0", "1"} + }, + { + {"GNA_DEVICE_MODE", "GNA_SW_EXACT"} + } +}; + +const std::vector appHeaders = { + "", + "APPLICATION_HEADER" +}; + +INSTANTIATE_TEST_SUITE_P(smoke_ImportNetworkGNA, ImportExportGNAModelUnchanged, + ::testing::Combine( + ::testing::ValuesIn(inputShapes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_GNA), + ::testing::ValuesIn(exportConfigs), + ::testing::ValuesIn(importConfigsUnchanged), + ::testing::ValuesIn(appHeaders)), + ImportExportGNAModelUnchanged::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_ImportNetworkGNA, ImportExportGNAModelChanged, + ::testing::Combine( + ::testing::ValuesIn(inputShapes), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_GNA), + ::testing::ValuesIn(exportConfigs), + ::testing::ValuesIn(importConfigsChanged), + ::testing::ValuesIn(appHeaders)), + ImportExportGNAModelChanged::getTestCaseName); + +} // namespace + diff --git a/src/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_reshape_permute_conv.cpp b/src/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_reshape_permute_conv.cpp deleted file mode 100644 index 9c1d515244d..00000000000 --- a/src/tests/functional/plugin/gna/shared_tests_instances/import_export_tests/import_reshape_permute_conv.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "import_export_tests/import_reshape_permute_conv.hpp" - -#include -#include - -using namespace LayerTestsDefinitions; - -namespace { - -class ImportExportGNAModelUnchanged : public ImportReshapePermuteConv { -private: - void exportImportNetwork() override { - { - std::ofstream out(fileName); - out.write(applicationHeader.c_str(), applicationHeader.size()); - executableNetwork.Export(out); - } - { - std::string appHeader(applicationHeader.size(), ' '); - std::fstream inputStream(fileName, std::ios_base::in | std::ios_base::binary); - if (inputStream.fail()) { - FAIL() << "Cannot open file to import model: " << fileName; - } - inputStream.read(&appHeader[0], applicationHeader.size()); - ASSERT_EQ(appHeader, applicationHeader); - executableNetwork = core->ImportNetwork(inputStream, targetDevice, configuration); - } - } - -protected: - void TearDown() override { - if (remove(fileName.c_str()) != 0) { - FAIL() << "Error: could not delete file " << fileName; - } - } - -private: - std::string fileName = "exported_model.blob"; -}; - -class ImportExportGNAModelChanged : public ImportExportGNAModelUnchanged {}; - -TEST_P(ImportExportGNAModelUnchanged, ReshapePermuteConv) { - TestRun(false); -}; - -TEST_P(ImportExportGNAModelChanged, ReshapePermuteConv) { - TestRun(true); -}; - -const std::vector> inputShapes = { - {1, 336} -}; - -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 -}; - -const std::vector> exportConfigs = { - { - {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, - {"GNA_SCALE_FACTOR_0", "327.67"} - } -}; - -const std::vector> importConfigsChanged = { - { - {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, - {"GNA_SCALE_FACTOR_0", "32767"} - } -}; - -const std::vector> importConfigsUnchanged = { - { - {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, - {"GNA_SCALE_FACTOR_0", "327.67"} - }, - { - {"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, - {"GNA_SCALE_FACTOR_0", "1"} - }, - { - {"GNA_DEVICE_MODE", "GNA_SW_EXACT"} - } -}; - -const std::vector appHeaders = { - "", - "APPLICATION_HEADER" -}; - -INSTANTIATE_TEST_SUITE_P(smoke_ImportNetworkGNA, ImportExportGNAModelUnchanged, - ::testing::Combine( - ::testing::ValuesIn(inputShapes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_GNA), - ::testing::ValuesIn(exportConfigs), - ::testing::ValuesIn(importConfigsUnchanged), - ::testing::ValuesIn(appHeaders)), - ImportExportGNAModelUnchanged::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_ImportNetworkGNA, ImportExportGNAModelChanged, - ::testing::Combine( - ::testing::ValuesIn(inputShapes), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_GNA), - ::testing::ValuesIn(exportConfigs), - ::testing::ValuesIn(importConfigsChanged), - ::testing::ValuesIn(appHeaders)), - ImportExportGNAModelChanged::getTestCaseName); - -} // namespace diff --git a/src/tests/functional/plugin/myriad/import_export/import_nonzero.cpp b/src/tests/functional/plugin/myriad/import_export/import_nonzero.cpp new file mode 100644 index 00000000000..14d3aace585 --- /dev/null +++ b/src/tests/functional/plugin/myriad/import_export/import_nonzero.cpp @@ -0,0 +1,116 @@ +// Copyright (C) 2018-2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph/opsets/opset5.hpp" +#include "shared_test_classes/base/layer_test_utils.hpp" + +namespace LayerTestsDefinitions { + +typedef std::tuple< + std::vector, // Input Shape + InferenceEngine::Precision, // Network Precision + std::string, // Target Device + std::string // Application Header +> exportImportNetworkParams; + +class ImportNonZero : public testing::WithParamInterface, + virtual public LayerTestsUtils::LayerTestsCommon { +protected: + void SetUp() override { + InferenceEngine::Precision netPrecision; + ngraph::Shape inputShape; + std::tie(inputShape, netPrecision, targetDevice, applicationHeader) = this->GetParam(); + const auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + + const auto parameter = std::make_shared(ngPrc, inputShape); + const auto nonZero = std::make_shared(parameter); + + function = std::make_shared(nonZero->outputs(), ngraph::ParameterVector{parameter}, "ExportImportNetwork"); + functionRefs = ngraph::clone_function(*function); + } + + void exportImportNetwork() { + std::stringstream strm; + strm.write(applicationHeader.c_str(), applicationHeader.size()); + executableNetwork.Export(strm); + + strm.seekg(0, strm.beg); + std::string appHeader(applicationHeader.size(), ' '); + strm.read(&appHeader[0], applicationHeader.size()); + ASSERT_EQ(appHeader, applicationHeader); + executableNetwork = core->ImportNetwork(strm, targetDevice, configuration); + } + + void Run() override { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + functionRefs = ngraph::clone_function(*function); + // load export configuration and save outputs + LoadNetwork(); + GenerateInputs(); + Infer(); + auto actualOutputs = GetOutputs(); + + auto referenceOutputs = CalculateRefs(); + Compare(referenceOutputs, actualOutputs); + + const auto compiledExecNetwork = executableNetwork; + exportImportNetwork(); + const auto importedExecNetwork = executableNetwork; + + GenerateInputs(); + Infer(); + + ASSERT_EQ(importedExecNetwork.GetInputsInfo().size(), compiledExecNetwork.GetInputsInfo().size()); + ASSERT_EQ(importedExecNetwork.GetOutputsInfo().size(), compiledExecNetwork.GetOutputsInfo().size()); + + for (const auto& next_input : importedExecNetwork.GetInputsInfo()) { + ASSERT_NO_THROW(compiledExecNetwork.GetInputsInfo()[next_input.first]); + Compare(next_input.second->getTensorDesc(), compiledExecNetwork.GetInputsInfo()[next_input.first]->getTensorDesc()); + } + for (const auto& next_output : importedExecNetwork.GetOutputsInfo()) { + ASSERT_NO_THROW(compiledExecNetwork.GetOutputsInfo()[next_output.first]); + } + auto importedOutputs = GetOutputs(); + + ASSERT_EQ(actualOutputs.size(), importedOutputs.size()); + + for (size_t i = 0; i < actualOutputs.size(); i++) { + Compare(actualOutputs[i]->getTensorDesc(), importedOutputs[i]->getTensorDesc()); + Compare(actualOutputs[i], importedOutputs[i]); + } + } + + + std::string applicationHeader; +}; + +TEST_P(ImportNonZero, CompareWithRefImpl) { + Run(); +}; + +} // namespace LayerTestsDefinitions + +using namespace LayerTestsDefinitions; + +namespace { + +const std::vector netPrecisions = { + InferenceEngine::Precision::FP32, +}; + +const std::vector appHeaders = { + "", + "APPLICATION_HEADER" +}; + +std::vector inputShape = ngraph::Shape{1000}; + +INSTANTIATE_TEST_SUITE_P(smoke_ImportNetworkCase, ImportNonZero, + ::testing::Combine( + ::testing::Values(inputShape), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(appHeaders))); + +} // namespace diff --git a/src/tests/functional/plugin/myriad/shared_tests_instances/import_export_tests/import_nonzero.cpp b/src/tests/functional/plugin/myriad/shared_tests_instances/import_export_tests/import_nonzero.cpp deleted file mode 100644 index 0a415c98a3a..00000000000 --- a/src/tests/functional/plugin/myriad/shared_tests_instances/import_export_tests/import_nonzero.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "import_export_tests/import_nonzero.hpp" -#include "vpu/private_plugin_config.hpp" - -using namespace LayerTestsDefinitions; - -namespace { - -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, -}; - -const std::vector> exportConfigs = { - {} -}; - -const std::vector> importConfigs = { - {} -}; - -const std::vector appHeaders = { - "", - "APPLICATION_HEADER" -}; - -std::vector inputShape = ngraph::Shape{1000}; - -INSTANTIATE_TEST_SUITE_P(smoke_ImportNetworkCase, ImportNonZero, - ::testing::Combine( - ::testing::Values(inputShape), - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), - ::testing::ValuesIn(exportConfigs), - ::testing::ValuesIn(importConfigs), - ::testing::ValuesIn(appHeaders)), - ImportNonZero::getTestCaseName); - -} // namespace diff --git a/src/tests/functional/plugin/shared/include/import_export_tests/import_nonzero.hpp b/src/tests/functional/plugin/shared/include/import_export_tests/import_nonzero.hpp deleted file mode 100644 index d40dcae248c..00000000000 --- a/src/tests/functional/plugin/shared/include/import_export_tests/import_nonzero.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "base/import_export_base/import_export_base.hpp" - -namespace LayerTestsDefinitions { - -class ImportNonZero : public FuncTestUtils::ImportNetworkTestBase { -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/import_export_tests/import_reshape_permute_conv.hpp b/src/tests/functional/plugin/shared/include/import_export_tests/import_reshape_permute_conv.hpp deleted file mode 100644 index d95efdaea02..00000000000 --- a/src/tests/functional/plugin/shared/include/import_export_tests/import_reshape_permute_conv.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "base/import_export_base/import_export_base.hpp" - -namespace LayerTestsDefinitions { - -class ImportReshapePermuteConv : public FuncTestUtils::ImportNetworkTestBase { -protected: - void SetUp() override; -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/src/import_export_tests/import_nonzero.cpp b/src/tests/functional/plugin/shared/src/import_export_tests/import_nonzero.cpp deleted file mode 100644 index d365d365c1f..00000000000 --- a/src/tests/functional/plugin/shared/src/import_export_tests/import_nonzero.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "import_export_tests/import_nonzero.hpp" - -#include "ngraph/opsets/opset5.hpp" - -namespace LayerTestsDefinitions { - -void ImportNonZero::SetUp() { - InferenceEngine::Precision netPrecision; - ngraph::Shape inputShape; - std::tie(inputShape, netPrecision, targetDevice, exportConfiguration, importConfiguration, applicationHeader) = this->GetParam(); - const auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - - const auto parameter = std::make_shared(ngPrc, inputShape); - const auto nonZero = std::make_shared(parameter); - - function = std::make_shared(nonZero->outputs(), ngraph::ParameterVector{parameter}, "ExportImportNetwork"); -} - -TEST_P(ImportNonZero, CompareWithRefImpl) { - Run(); -}; - -} // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/src/import_export_tests/import_reshape_permute_conv.cpp b/src/tests/functional/plugin/shared/src/import_export_tests/import_reshape_permute_conv.cpp deleted file mode 100644 index 6d6bbf223fa..00000000000 --- a/src/tests/functional/plugin/shared/src/import_export_tests/import_reshape_permute_conv.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "import_export_tests/import_reshape_permute_conv.hpp" - -#include "ngraph_functions/builders.hpp" - -namespace LayerTestsDefinitions { - -void ImportReshapePermuteConv::SetUp() { - std::vector inputShape; - InferenceEngine::Precision netPrecision; - std::tie(inputShape, netPrecision, targetDevice, exportConfiguration, importConfiguration, applicationHeader) = this->GetParam(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - - auto params = ngraph::builder::makeParams(ngPrc, { inputShape }); - - std::vector outFormShapes1 = { 1, 1, 168, 2 }; - auto pattern1 = std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape{ 4 }, outFormShapes1); - auto reshape1 = std::make_shared(params[0], pattern1, false); - - auto permute1 = std::make_shared(reshape1, - ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{ 4 }, { 0, 3, 1, 2 })); - - auto conv1 = ngraph::builder::makeConvolution(permute1, ngPrc, { 1, 8 }, { 1, 1 }, { 0, 0 }, { 0, 0 }, { 1, 1 }, - ngraph::op::PadType::VALID, 12); - - auto permute2 = std::make_shared(conv1, - ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{ 4 }, { 0, 2, 3, 1 })); - - std::vector outFormShapes2 = { 1, 1932 }; - auto pattern2 = std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape{ 2 }, outFormShapes2); - auto reshape2 = std::make_shared(permute2, pattern2, false); - - ngraph::ResultVector results{ std::make_shared(reshape2) }; - function = std::make_shared(results, params, "ExportImportNetwork"); -} - -TEST_P(ImportReshapePermuteConv, CompareWithRefImpl) { - Run(); -}; - -} // namespace LayerTestsDefinitions