From 90177f5275b0df014ea19518b4ca735965cbab36 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Tue, 29 Jun 2021 23:29:21 +0300 Subject: [PATCH 01/11] Added convert tests --- docs/template_plugin/src/template_plugin.cpp | 2 - .../tests/functional/op_reference/convert.cpp | 296 ++++++++++++++++++ .../base/layer_test_utils.hpp | 2 +- 3 files changed, 297 insertions(+), 3 deletions(-) create mode 100644 docs/template_plugin/tests/functional/op_reference/convert.cpp diff --git a/docs/template_plugin/src/template_plugin.cpp b/docs/template_plugin/src/template_plugin.cpp index a0f7a30ee171cf..1e9cd774018686 100644 --- a/docs/template_plugin/src/template_plugin.cpp +++ b/docs/template_plugin/src/template_plugin.cpp @@ -66,8 +66,6 @@ std::shared_ptr TransformNetwork(const std::shared_ptr(); - // Template plugin handles only FP32 networks - passManager.register_pass(precisions_array {{ngraph::element::f16, ngraph::element::f32}}); // Example: register plugin specific transformation passManager.register_pass(); passManager.register_pass(); diff --git a/docs/template_plugin/tests/functional/op_reference/convert.cpp b/docs/template_plugin/tests/functional/op_reference/convert.cpp new file mode 100644 index 00000000000000..e78b59bda095b5 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/convert.cpp @@ -0,0 +1,296 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include +#include +#include +#include + +#include "transformations/utils/utils.hpp" +// #include "ngraph/runtime/reference/convert.hpp" +// #include "ngraph/runtime/tensor.hpp" +// #include "runtime/backend.hpp" +// #include "util/all_close.hpp" +// #include "util/all_close_f.hpp" +// #include "util/engine/test_engines.hpp" +// #include "util/ndarray.hpp" +// #include "util/test_case.hpp" +// #include "util/test_control.hpp" +// #include "util/test_tools.hpp" + +using namespace ngraph; +using namespace InferenceEngine; + +template +InferenceEngine::Blob::Ptr create_blob(const ngraph::element::Type& element_type, std::vector values, size_t size = 0) { + size_t real_size = size ? size : values.size() * sizeof(T) / element_type.size(); + auto blob = make_blob_with_precision( + InferenceEngine::TensorDesc(InferenceEngine::details::convertPrecision(element_type), {real_size}, InferenceEngine::Layout::C)); + blob->allocate(); + MemoryBlob::Ptr minput = as(blob); + IE_ASSERT(minput); + auto minputHolder = minput->wmap(); + + std::memcpy(minputHolder.as(), values.data(), sizeof(T) * values.size()); + + return blob; +} + +struct ConvertParams { + template + ConvertParams(const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, const std::vector iValues, + const std::vector oValues, size_t iSize = 0, size_t oSize = 0) { + pshape = shape; + inType = iType; + outType = oType; + + inputData = create_blob(iType, iValues, iSize); + refData = create_blob(oType, oValues, oSize); + } + ngraph::PartialShape pshape; + ngraph::element::Type inType; + ngraph::element::Type outType; + InferenceEngine::Blob::Ptr inputData; + InferenceEngine::Blob::Ptr refData; +}; + +class CommonReferenceTest { +public: + CommonReferenceTest(): targetDevice("TEMPLATE") { + core = PluginCache::get().ie(targetDevice); + } + + void Exec() { + LoadNetwork(); + FillInputs(); + Infer(); + Compare(); + } + + void LoadNetwork() { + InferenceEngine::CNNNetwork cnnNetwork(function); + auto inputInfo = cnnNetwork.getInputsInfo(); + auto outputInfo = cnnNetwork.getOutputsInfo(); + for (const auto& param : function->get_parameters()) { + inputInfo[param->get_friendly_name()]->setPrecision(InferenceEngine::details::convertPrecision(param->get_element_type())); + } + for (const auto& result : function->get_results()) { + outputInfo[ngraph::op::util::create_ie_output_name(result->input_value(0))]->setPrecision( + InferenceEngine::details::convertPrecision(result->get_element_type())); + } + executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice); + } + + void FillInputs() { + const auto& inputInfo = executableNetwork.GetInputsInfo(); + const auto& params = function->get_parameters(); + ASSERT_EQ(params.size(), inputData.size()); + ASSERT_EQ(inputInfo.size(), inputData.size()); + + for (size_t i = 0; i < params.size(); i++) { + const auto& param = params[i]; + const auto infoIt = inputInfo.find(param->get_friendly_name()); + GTEST_ASSERT_NE(infoIt, inputInfo.cend()); + + const auto& info = infoIt->second; + auto blob = make_blob_with_precision(info->getTensorDesc()); + blob->allocate(); + + ASSERT_EQ(blob->byteSize(), inputData[i]->byteSize()); + + MemoryBlob::Ptr mInputData = as(inputData[i]); + ASSERT_NE(mInputData, nullptr); + auto minputDataHolder = mInputData->rmap(); + + MemoryBlob::Ptr mBlob = as(blob); + ASSERT_NE(mBlob, nullptr); + auto mBlobHolder = mBlob->wmap(); + + std::memcpy(mBlobHolder.as(), minputDataHolder.as(), inputData[i]->byteSize()); + inputData[i] = blob; + } + } + + void Infer() { + inferRequest = executableNetwork.CreateInferRequest(); + + const auto& inputsInfo = executableNetwork.GetInputsInfo(); + const auto& functionParams = function->get_parameters(); + for (int i = 0; i < functionParams.size(); ++i) { + const auto& param = functionParams[i]; + const auto infoIt = inputsInfo.find(param->get_friendly_name()); + GTEST_ASSERT_NE(infoIt, inputsInfo.cend()); + + const auto& info = infoIt->second; + auto blob = inputData[i]; + + inferRequest.SetBlob(info->name(), blob); + } + inferRequest.Infer(); + } + + void Compare() { + ASSERT_EQ(executableNetwork.GetOutputsInfo().size(), refOutData.size()); + std::vector outputs; + for (const auto& result : function->get_results()) { + auto name = ngraph::op::util::create_ie_output_name(result->input_value(0)); + outputs.emplace_back(inferRequest.GetBlob(name)); + } + + ASSERT_EQ(refOutData.size(), outputs.size()); + for (size_t i = 0; i < refOutData.size(); i++) { + CompareBlobs(refOutData[i], outputs[i]); + } + } + +protected: + const std::string targetDevice; + std::shared_ptr core; + std::shared_ptr function; + + InferenceEngine::ExecutableNetwork executableNetwork; + InferenceEngine::InferRequest inferRequest; + std::vector inputData; + std::vector refOutData; + float threshold = 1e-2f; + +private: + void CompareBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob) { + ASSERT_TRUE(refBlob != nullptr); + ASSERT_TRUE(outBlob != nullptr); + ASSERT_EQ(refBlob->getTensorDesc().getPrecision(), outBlob->getTensorDesc().getPrecision()); + ASSERT_EQ(refBlob->byteSize(), outBlob->byteSize()); + + auto mRef = as(refBlob); + IE_ASSERT(mRef); + const auto refLockMemory = mRef->rmap(); + const auto refBuffer = refLockMemory.as(); + + auto mOut = as(outBlob); + IE_ASSERT(mOut); + const auto outLockMemory = mOut->rmap(); + const auto outBuffer = outLockMemory.as(); + + const auto& precision = refBlob->getTensorDesc().getPrecision(); + switch (precision) { + case InferenceEngine::Precision::FP32: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I32: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I64: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I8: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::U16: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I16: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::BOOL: + case InferenceEngine::Precision::U8: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::U64: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::BF16: + LayerTestsUtils::LayerTestsCommon::Compare( + reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::FP16: + LayerTestsUtils::LayerTestsCommon::Compare( + reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I4: + case InferenceEngine::Precision::U4: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size() / 2, threshold); + break; + default: + FAIL() << "Comparator for " << precision << " precision isn't supported"; + } + } +}; + +class ReferenceConvertLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params.pshape, params.inType, params.outType); + inputData = {params.inputData}; + refOutData = {params.refData}; + } + +private: + static std::shared_ptr CreateFunction(const PartialShape& input_shape, const element::Type& input_type, + const element::Type& expected_output_type) { + const auto in = std::make_shared(input_type, input_shape); + const auto convert = std::make_shared(in, expected_output_type); + return std::make_shared(NodeVector {convert}, ParameterVector {in}); + } +}; + +TEST_P(ReferenceConvertLayerTest, CompareWithHardcodedRefs) { + Exec(); +} + +INSTANTIATE_TEST_SUITE_P( + smoke_Convert_With_Hardcided_Refs, ReferenceConvertLayerTest, + ::testing::Values( + // destination boolean + ConvertParams(ngraph::PartialShape {2, 3}, ngraph::element::u8, ngraph::element::boolean, + std::vector {0, 12, 23, 0, std::numeric_limits::lowest(), std::numeric_limits::max()}, + std::vector {0, 1, 1, 0, 0, 1}), + ConvertParams(ngraph::PartialShape {2, 3}, ngraph::element::i32, ngraph::element::boolean, + std::vector {0, -12, 23, 0, std::numeric_limits::lowest(), std::numeric_limits::max()}, + std::vector {0, 1, 1, 0, 1, 1}), + ConvertParams(ngraph::PartialShape {3, 3}, ngraph::element::f32, ngraph::element::boolean, + std::vector {0.f, 1.5745f, 0.12352f, 0.f, std::numeric_limits::lowest(), std::numeric_limits::max(), + std::numeric_limits::min(), std::numeric_limits::infinity(), -std::numeric_limits::infinity()}, + std::vector {0, 1, 1, 0, 1, 1, 1, 1, 1}), + + // destination i4 + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u1, ngraph::element::i4, std::vector {0xA0}, std::vector {0x10, 0x10}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i4, std::vector {0x12, 0x03}, std::vector {0x12, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i4, std::vector {1, 2, 0, 3}, std::vector {0x12, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i4, std::vector {0xFE, 0x03}, std::vector {0xFE, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i4, std::vector {-1, -2, 2, 3}, std::vector {0xFE, 0x23}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i4, std::vector {-1, -2, 0, 3}, + std::vector {0xFE, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i4, std::vector {-1, -2, 0, 3}, + std::vector {0xFE, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i4, std::vector {-1, -2, 2, 3}, std::vector {0xFE, 0x23}, + 4, 4))); diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp index 9d13251574331f..72172e6992482a 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/layer_test_utils.hpp @@ -101,7 +101,7 @@ class LayerTestsCommon : public CommonTestUtils::TestsCommon { double diff = static_cast(absoluteDifference) / max; if (max == 0 || (diff > static_cast(threshold)) || std::isnan(static_cast(res)) || std::isnan(static_cast(ref))) { - IE_THROW() << "Relative comparison of values expected: " << ref << " and actual: " << res + IE_THROW() << "Relative comparison of values expected: " << std::to_string(ref) << " and actual: " << std::to_string(res) << " at index " << i << " with threshold " << threshold << " failed"; } From f89c1273c93eef1cc2cef8a8bb384c166cc8f59d Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 30 Jun 2021 08:41:02 +0300 Subject: [PATCH 02/11] Moved convert tests to template plugin --- .../op_reference/base_reference_test.cpp | 173 ++ .../op_reference/base_reference_test.hpp | 53 + .../tests/functional/op_reference/convert.cpp | 542 +++--- .../single_layer_tests/convert.cpp | 15 +- ngraph/test/CMakeLists.txt | 1 - ngraph/test/backend/convert.in.cpp | 1547 ----------------- ngraph/test/runtime/ie/unit_test.manifest | 84 - 7 files changed, 579 insertions(+), 1836 deletions(-) create mode 100644 docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp create mode 100644 docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp delete mode 100644 ngraph/test/backend/convert.in.cpp diff --git a/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp new file mode 100644 index 00000000000000..ef0205b08facbd --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp @@ -0,0 +1,173 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include "base_reference_test.hpp" + +#include + +#include "transformations/utils/utils.hpp" + +using namespace InferenceEngine; + +CommonReferenceTest::CommonReferenceTest(): targetDevice("TEMPLATE") { + core = PluginCache::get().ie(targetDevice); +} + +void CommonReferenceTest::Exec() { + LoadNetwork(); + FillInputs(); + Infer(); + Compare(); +} + +void CommonReferenceTest::LoadNetwork() { + InferenceEngine::CNNNetwork cnnNetwork(function); + auto inputInfo = cnnNetwork.getInputsInfo(); + auto outputInfo = cnnNetwork.getOutputsInfo(); + for (const auto& param : function->get_parameters()) { + inputInfo[param->get_friendly_name()]->setPrecision(InferenceEngine::details::convertPrecision(param->get_element_type())); + } + for (const auto& result : function->get_results()) { + outputInfo[ngraph::op::util::create_ie_output_name(result->input_value(0))]->setPrecision( + InferenceEngine::details::convertPrecision(result->get_element_type())); + } + executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice); +} + +void CommonReferenceTest::FillInputs() { + const auto& inputInfo = executableNetwork.GetInputsInfo(); + const auto& params = function->get_parameters(); + ASSERT_EQ(params.size(), inputData.size()); + ASSERT_EQ(inputInfo.size(), inputData.size()); + + for (size_t i = 0; i < params.size(); i++) { + const auto& param = params[i]; + const auto infoIt = inputInfo.find(param->get_friendly_name()); + GTEST_ASSERT_NE(infoIt, inputInfo.cend()); + + const auto& info = infoIt->second; + auto blob = make_blob_with_precision(info->getTensorDesc()); + blob->allocate(); + + ASSERT_EQ(blob->byteSize(), inputData[i]->byteSize()); + + MemoryBlob::Ptr mInputData = as(inputData[i]); + ASSERT_NE(mInputData, nullptr); + auto minputDataHolder = mInputData->rmap(); + + MemoryBlob::Ptr mBlob = as(blob); + ASSERT_NE(mBlob, nullptr); + auto mBlobHolder = mBlob->wmap(); + + std::memcpy(mBlobHolder.as(), minputDataHolder.as(), inputData[i]->byteSize()); + inputData[i] = blob; + } +} + +void CommonReferenceTest::Infer() { + inferRequest = executableNetwork.CreateInferRequest(); + + const auto& inputsInfo = executableNetwork.GetInputsInfo(); + const auto& functionParams = function->get_parameters(); + for (int i = 0; i < functionParams.size(); ++i) { + const auto& param = functionParams[i]; + const auto infoIt = inputsInfo.find(param->get_friendly_name()); + GTEST_ASSERT_NE(infoIt, inputsInfo.cend()); + + const auto& info = infoIt->second; + auto blob = inputData[i]; + + inferRequest.SetBlob(info->name(), blob); + } + inferRequest.Infer(); +} + +void CommonReferenceTest::Compare() { + ASSERT_EQ(executableNetwork.GetOutputsInfo().size(), refOutData.size()); + std::vector outputs; + for (const auto& result : function->get_results()) { + auto name = ngraph::op::util::create_ie_output_name(result->input_value(0)); + outputs.emplace_back(inferRequest.GetBlob(name)); + } + + ASSERT_EQ(refOutData.size(), outputs.size()); + for (size_t i = 0; i < refOutData.size(); i++) { + CompareBlobs(refOutData[i], outputs[i]); + } +} +void CommonReferenceTest::CompareBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob) { + ASSERT_TRUE(refBlob != nullptr); + ASSERT_TRUE(outBlob != nullptr); + ASSERT_EQ(refBlob->getTensorDesc().getPrecision(), outBlob->getTensorDesc().getPrecision()); + ASSERT_EQ(refBlob->byteSize(), outBlob->byteSize()); + + auto mRef = as(refBlob); + IE_ASSERT(mRef); + const auto refLockMemory = mRef->rmap(); + const auto refBuffer = refLockMemory.as(); + + auto mOut = as(outBlob); + IE_ASSERT(mOut); + const auto outLockMemory = mOut->rmap(); + const auto outBuffer = outLockMemory.as(); + + const auto& precision = refBlob->getTensorDesc().getPrecision(); + switch (precision) { + case InferenceEngine::Precision::BF16: + LayerTestsUtils::LayerTestsCommon::Compare( + reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::FP16: + LayerTestsUtils::LayerTestsCommon::Compare( + reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::FP32: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I8: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I16: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I32: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I64: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::BOOL: + case InferenceEngine::Precision::U8: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size(), threshold); + break; + case InferenceEngine::Precision::U16: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::U32: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::U64: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), + reinterpret_cast(outBuffer), refBlob->size(), threshold); + break; + case InferenceEngine::Precision::I4: + case InferenceEngine::Precision::U4: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size() / 2, threshold); + break; + case InferenceEngine::Precision::BIN: + LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), + refBlob->size() / 8, threshold); + break; + default: + FAIL() << "Comparator for " << precision << " precision isn't supported"; + } +} diff --git a/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp b/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp new file mode 100644 index 00000000000000..ce3b33d5d7a2f3 --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include + +class CommonReferenceTest { +public: + CommonReferenceTest(); + + void Exec(); + + void LoadNetwork(); + + void FillInputs(); + + void Infer(); + + void Compare(); + +private: + void CompareBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob); + +protected: + const std::string targetDevice; + std::shared_ptr core; + std::shared_ptr function; + + InferenceEngine::ExecutableNetwork executableNetwork; + InferenceEngine::InferRequest inferRequest; + std::vector inputData; + std::vector refOutData; + float threshold = 1e-2f; +}; + +template +InferenceEngine::Blob::Ptr CreateBlob(const ngraph::element::Type& element_type, std::vector values, size_t size = 0) { + size_t real_size = size ? size : values.size() * sizeof(T) / element_type.size(); + auto blob = make_blob_with_precision( + InferenceEngine::TensorDesc(InferenceEngine::details::convertPrecision(element_type), {real_size}, InferenceEngine::Layout::C)); + blob->allocate(); + InferenceEngine::MemoryBlob::Ptr minput = InferenceEngine::as(blob); + IE_ASSERT(minput); + auto minputHolder = minput->wmap(); + + std::memcpy(minputHolder.as(), values.data(), sizeof(T) * values.size()); + + return blob; +} + diff --git a/docs/template_plugin/tests/functional/op_reference/convert.cpp b/docs/template_plugin/tests/functional/op_reference/convert.cpp index e78b59bda095b5..78ef5d0b3950f8 100644 --- a/docs/template_plugin/tests/functional/op_reference/convert.cpp +++ b/docs/template_plugin/tests/functional/op_reference/convert.cpp @@ -10,36 +10,11 @@ #include #include -#include "transformations/utils/utils.hpp" -// #include "ngraph/runtime/reference/convert.hpp" -// #include "ngraph/runtime/tensor.hpp" -// #include "runtime/backend.hpp" -// #include "util/all_close.hpp" -// #include "util/all_close_f.hpp" -// #include "util/engine/test_engines.hpp" -// #include "util/ndarray.hpp" -// #include "util/test_case.hpp" -// #include "util/test_control.hpp" -// #include "util/test_tools.hpp" +#include "base_reference_test.hpp" using namespace ngraph; using namespace InferenceEngine; -template -InferenceEngine::Blob::Ptr create_blob(const ngraph::element::Type& element_type, std::vector values, size_t size = 0) { - size_t real_size = size ? size : values.size() * sizeof(T) / element_type.size(); - auto blob = make_blob_with_precision( - InferenceEngine::TensorDesc(InferenceEngine::details::convertPrecision(element_type), {real_size}, InferenceEngine::Layout::C)); - blob->allocate(); - MemoryBlob::Ptr minput = as(blob); - IE_ASSERT(minput); - auto minputHolder = minput->wmap(); - - std::memcpy(minputHolder.as(), values.data(), sizeof(T) * values.size()); - - return blob; -} - struct ConvertParams { template ConvertParams(const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, const std::vector iValues, @@ -48,8 +23,8 @@ struct ConvertParams { inType = iType; outType = oType; - inputData = create_blob(iType, iValues, iSize); - refData = create_blob(oType, oValues, oSize); + inputData = CreateBlob(iType, iValues, iSize); + refData = CreateBlob(oType, oValues, oSize); } ngraph::PartialShape pshape; ngraph::element::Type inType; @@ -58,177 +33,6 @@ struct ConvertParams { InferenceEngine::Blob::Ptr refData; }; -class CommonReferenceTest { -public: - CommonReferenceTest(): targetDevice("TEMPLATE") { - core = PluginCache::get().ie(targetDevice); - } - - void Exec() { - LoadNetwork(); - FillInputs(); - Infer(); - Compare(); - } - - void LoadNetwork() { - InferenceEngine::CNNNetwork cnnNetwork(function); - auto inputInfo = cnnNetwork.getInputsInfo(); - auto outputInfo = cnnNetwork.getOutputsInfo(); - for (const auto& param : function->get_parameters()) { - inputInfo[param->get_friendly_name()]->setPrecision(InferenceEngine::details::convertPrecision(param->get_element_type())); - } - for (const auto& result : function->get_results()) { - outputInfo[ngraph::op::util::create_ie_output_name(result->input_value(0))]->setPrecision( - InferenceEngine::details::convertPrecision(result->get_element_type())); - } - executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice); - } - - void FillInputs() { - const auto& inputInfo = executableNetwork.GetInputsInfo(); - const auto& params = function->get_parameters(); - ASSERT_EQ(params.size(), inputData.size()); - ASSERT_EQ(inputInfo.size(), inputData.size()); - - for (size_t i = 0; i < params.size(); i++) { - const auto& param = params[i]; - const auto infoIt = inputInfo.find(param->get_friendly_name()); - GTEST_ASSERT_NE(infoIt, inputInfo.cend()); - - const auto& info = infoIt->second; - auto blob = make_blob_with_precision(info->getTensorDesc()); - blob->allocate(); - - ASSERT_EQ(blob->byteSize(), inputData[i]->byteSize()); - - MemoryBlob::Ptr mInputData = as(inputData[i]); - ASSERT_NE(mInputData, nullptr); - auto minputDataHolder = mInputData->rmap(); - - MemoryBlob::Ptr mBlob = as(blob); - ASSERT_NE(mBlob, nullptr); - auto mBlobHolder = mBlob->wmap(); - - std::memcpy(mBlobHolder.as(), minputDataHolder.as(), inputData[i]->byteSize()); - inputData[i] = blob; - } - } - - void Infer() { - inferRequest = executableNetwork.CreateInferRequest(); - - const auto& inputsInfo = executableNetwork.GetInputsInfo(); - const auto& functionParams = function->get_parameters(); - for (int i = 0; i < functionParams.size(); ++i) { - const auto& param = functionParams[i]; - const auto infoIt = inputsInfo.find(param->get_friendly_name()); - GTEST_ASSERT_NE(infoIt, inputsInfo.cend()); - - const auto& info = infoIt->second; - auto blob = inputData[i]; - - inferRequest.SetBlob(info->name(), blob); - } - inferRequest.Infer(); - } - - void Compare() { - ASSERT_EQ(executableNetwork.GetOutputsInfo().size(), refOutData.size()); - std::vector outputs; - for (const auto& result : function->get_results()) { - auto name = ngraph::op::util::create_ie_output_name(result->input_value(0)); - outputs.emplace_back(inferRequest.GetBlob(name)); - } - - ASSERT_EQ(refOutData.size(), outputs.size()); - for (size_t i = 0; i < refOutData.size(); i++) { - CompareBlobs(refOutData[i], outputs[i]); - } - } - -protected: - const std::string targetDevice; - std::shared_ptr core; - std::shared_ptr function; - - InferenceEngine::ExecutableNetwork executableNetwork; - InferenceEngine::InferRequest inferRequest; - std::vector inputData; - std::vector refOutData; - float threshold = 1e-2f; - -private: - void CompareBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob) { - ASSERT_TRUE(refBlob != nullptr); - ASSERT_TRUE(outBlob != nullptr); - ASSERT_EQ(refBlob->getTensorDesc().getPrecision(), outBlob->getTensorDesc().getPrecision()); - ASSERT_EQ(refBlob->byteSize(), outBlob->byteSize()); - - auto mRef = as(refBlob); - IE_ASSERT(mRef); - const auto refLockMemory = mRef->rmap(); - const auto refBuffer = refLockMemory.as(); - - auto mOut = as(outBlob); - IE_ASSERT(mOut); - const auto outLockMemory = mOut->rmap(); - const auto outBuffer = outLockMemory.as(); - - const auto& precision = refBlob->getTensorDesc().getPrecision(); - switch (precision) { - case InferenceEngine::Precision::FP32: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), - refBlob->size(), threshold); - break; - case InferenceEngine::Precision::I32: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), - reinterpret_cast(outBuffer), refBlob->size(), threshold); - break; - case InferenceEngine::Precision::I64: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), - reinterpret_cast(outBuffer), refBlob->size(), threshold); - break; - case InferenceEngine::Precision::I8: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), - refBlob->size(), threshold); - break; - case InferenceEngine::Precision::U16: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), - reinterpret_cast(outBuffer), refBlob->size(), threshold); - break; - case InferenceEngine::Precision::I16: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), - reinterpret_cast(outBuffer), refBlob->size(), threshold); - break; - case InferenceEngine::Precision::BOOL: - case InferenceEngine::Precision::U8: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), - reinterpret_cast(outBuffer), refBlob->size(), threshold); - break; - case InferenceEngine::Precision::U64: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), - reinterpret_cast(outBuffer), refBlob->size(), threshold); - break; - case InferenceEngine::Precision::BF16: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), refBlob->size(), threshold); - break; - case InferenceEngine::Precision::FP16: - LayerTestsUtils::LayerTestsCommon::Compare( - reinterpret_cast(refBuffer), reinterpret_cast(outBuffer), refBlob->size(), threshold); - break; - case InferenceEngine::Precision::I4: - case InferenceEngine::Precision::U4: - LayerTestsUtils::LayerTestsCommon::Compare(reinterpret_cast(refBuffer), - reinterpret_cast(outBuffer), refBlob->size() / 2, threshold); - break; - default: - FAIL() << "Comparator for " << precision << " precision isn't supported"; - } - } -}; - class ReferenceConvertLayerTest : public testing::TestWithParam, public CommonReferenceTest { public: void SetUp() override { @@ -266,6 +70,54 @@ INSTANTIATE_TEST_SUITE_P( std::numeric_limits::min(), std::numeric_limits::infinity(), -std::numeric_limits::infinity()}, std::vector {0, 1, 1, 0, 1, 1, 1, 1, 1}), + // destination bf16 + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::f32, ngraph::element::bf16, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + ConvertParams(ngraph::PartialShape {11}, ngraph::element::u8, ngraph::element::bf16, + std::vector {0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}, + std::vector {0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}), + + // destination f16 + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::f32, ngraph::element::f16, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + ConvertParams(ngraph::PartialShape {11}, ngraph::element::u8, ngraph::element::f16, std::vector {0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}, + std::vector {0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}), + + // destination f32 + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u1, ngraph::element::f32, std::vector {0xA0}, + std::vector {1.0f, 0.0f, 1.0f, 0.0f}, 4), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u4, ngraph::element::f32, std::vector {0xFB, 0x0A}, + std::vector {15.0f, 11.0f, 0.0f, 10.0f}, 4), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u8, ngraph::element::f32, std::vector {255, 128, 32, 0}, + std::vector {255.0f, 128.0f, 32.0f, 0.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u16, ngraph::element::f32, std::vector {64000, 32000, 128, 0}, + std::vector {64000.0f, 32000.0f, 128.0f, 0.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u32, ngraph::element::f32, std::vector {4000000, 2000000, 128, 0}, + std::vector {4000000.0f, 2000000.0f, 128.0f, 0.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::u64, ngraph::element::f32, std::vector {4000000, 2000000, 128, 0}, + std::vector {4000000.0f, 2000000.0f, 128.0f, 0.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i4, ngraph::element::f32, std::vector {0xFE, 0xF2}, + std::vector {-1.0f, -2.0f, -1.0f, 2.0f}, 4), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i8, ngraph::element::f32, std::vector {-127, -0, 0, 127}, + std::vector {-127.0f, -0.0f, 0.0f, 127.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i16, ngraph::element::f32, std::vector {-32000, -0, 0, 32000}, + std::vector {-32000.0f, -0.0f, 0.0f, 32000.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i32, ngraph::element::f32, std::vector {-64000, -0, 0, 64000}, + std::vector {-64000.0f, -0.0f, 0.0f, 64000.0f}), + ConvertParams(ngraph::PartialShape {2, 2}, ngraph::element::i64, ngraph::element::f32, std::vector {-64000, -0, 0, 64000}, + std::vector {-64000.0f, -0.0f, 0.0f, 64000.0f}), + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::bf16, ngraph::element::f32, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::f16, ngraph::element::f32, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + ConvertParams(ngraph::PartialShape {1, 1, 3, 5}, ngraph::element::f32, ngraph::element::f32, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}, + std::vector {0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}), + // destination i4 ConvertParams(ngraph::PartialShape {4}, ngraph::element::u1, ngraph::element::i4, std::vector {0xA0}, std::vector {0x10, 0x10}, 4, 4), ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i4, std::vector {0x12, 0x03}, std::vector {0x12, 0x03}, @@ -293,4 +145,294 @@ INSTANTIATE_TEST_SUITE_P( ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i4, std::vector {-1, -2, 0, 3}, std::vector {0xFE, 0x03}, 4, 4), ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i4, std::vector {-1, -2, 2, 3}, std::vector {0xFE, 0x23}, - 4, 4))); + 4, 4), + // destination i8 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::i8, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i8, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i8, std::vector {1, 2, 0, 3}, std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i8, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i8, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i8, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i8, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + // destination i16 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::i16, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i16, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i16, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i16, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i16, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i16, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + // destination i32 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::i32, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i32, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i32, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i32, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i32, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i32, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + // destination i64 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::i64, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::i64, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::i64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::i64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::i64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::i64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::i64, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::i64, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::i64, std::vector {-1, -2, 0, 3}, + std::vector {-1, -2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::i64, std::vector {-1, -2, 2, 3}, + std::vector {-1, -2, 2, 3}), + + // destination u1 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u1, std::vector {0xA0}, std::vector {0xA0}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u4, ngraph::element::u1, std::vector {0x10, 0x01, 0x00, 0x00}, + std::vector {0x90}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u8, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u16, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u32, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u64, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i4, ngraph::element::u1, std::vector {0x10, 0x01, 0x00, 0x00}, + std::vector {0x90}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i8, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i16, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i32, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::i64, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::f16, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::bf16, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + ConvertParams(ngraph::PartialShape {8}, ngraph::element::f32, ngraph::element::u1, std::vector {1, 0, 1, 0, 0, 0, 0, 1}, + std::vector {0xA1}, 8, 8), + + // destination u4 + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u1, ngraph::element::u4, std::vector {0xA0}, std::vector {0x10, 0x10}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u4, std::vector {0x12, 0x03}, std::vector {0x12, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u4, std::vector {1, 2, 0, 3}, std::vector {0x12, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u4, std::vector {1, 2, 0, 3}, + std::vector {0x12, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u4, std::vector {0xFE, 0x03}, std::vector {0xFE, 0x03}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u4, std::vector {-1, -2, 2, 3}, std::vector {0xFE, 0x23}, + 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u4, std::vector {-1, -2, 2, 3}, + std::vector {0xFE, 0x23}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u4, std::vector {-1, -2, 0, 3}, + std::vector {0xFE, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u4, std::vector {-1, -2, 0, 3}, + std::vector {0xFE, 0x03}, 4, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u4, std::vector {-1, -2, 2, 3}, std::vector {0xFE, 0x23}, + 4, 4), + + // destination u8 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u8, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u8, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u8, std::vector {1, 2, 0, 3}, std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u8, std::vector {0x21, 0x43}, std::vector {2, 1, 4, 3}, + 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u8, std::vector {1, 2, 2, 3}, std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u8, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u8, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u8, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u8, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u8, std::vector {1, 2, 2, 3}, std::vector {1, 2, 2, 3}), + + // destination u16 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u16, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u16, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u16, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u16, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u16, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + + // destination u32 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u32, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u32, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u32, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u32, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u32, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + + // destination u64 + ConvertParams(ngraph::PartialShape {8}, ngraph::element::u1, ngraph::element::u64, std::vector {0x81}, + std::vector {1, 0, 0, 0, 0, 0, 0, 1}, 8), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u4, ngraph::element::u64, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u8, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u16, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u32, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::u64, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i4, ngraph::element::u64, std::vector {0x21, 0x43}, + std::vector {2, 1, 4, 3}, 4), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i8, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i16, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i32, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::i64, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f16, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u64, std::vector {1, 2, 0, 3}, + std::vector {1, 2, 0, 3}), + ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u64, std::vector {1, 2, 2, 3}, + std::vector {1, 2, 2, 3}))); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp index 70ed6c6512fc41..a7835740f165b2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp @@ -14,13 +14,20 @@ namespace { const std::vector> inShape = {{1, 2, 3, 4}}; const std::vector precisions = { - Precision::U8, + // Precision::I4, Precision::I8, - Precision::U16, Precision::I16, Precision::I32, - Precision::U64, Precision::I64, + // Precision::BIN, + // Precision::BOOL, + // Precision::U4, + Precision::U8, + Precision::U16, + // Precision::U32, + Precision::U64, + Precision::BF16, + Precision::FP16, Precision::FP32 }; @@ -34,4 +41,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvertLayerTest, ConvertLayerTest, ::testing::Values(CommonTestUtils::DEVICE_CPU)), ConvertLayerTest::getTestCaseName); -} // namespace \ No newline at end of file +} // namespace diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 548d76f345816a..fcaffcf073a9da 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -367,7 +367,6 @@ set(MULTI_TEST_SRC backend/comparison.in.cpp backend/concat.in.cpp backend/constant.in.cpp - backend/convert.in.cpp backend/convert_like.in.cpp backend/convolution_backprop.in.cpp backend/convolution.in.cpp diff --git a/ngraph/test/backend/convert.in.cpp b/ngraph/test/backend/convert.in.cpp deleted file mode 100644 index 20cb1d16953d20..00000000000000 --- a/ngraph/test/backend/convert.in.cpp +++ /dev/null @@ -1,1547 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/runtime/reference/convert.hpp" -#include "ngraph/runtime/tensor.hpp" -#include "runtime/backend.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.hpp" -#include "util/engine/test_engines.hpp" -#include "util/ndarray.hpp" -#include "util/test_case.hpp" -#include "util/test_control.hpp" -#include "util/test_tools.hpp" - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; - -using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); -namespace -{ - std::shared_ptr CreateFunction(const Shape& input_shape, - const element::Type& input_type, - const element::Type& expected_output_type) - { - const auto in = make_shared(input_type, input_shape); - const auto convert = make_shared(in, expected_output_type); - return make_shared(NodeVector{convert}, ParameterVector{in}); - } - - template - void ConvertTest(const std::vector& input, - const Shape& input_shape, - const ngraph::element::Type& input_type, - const std::vector& expected_output, - const ngraph::element::Type& expected_output_type) - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto test_case = test::TestCase(f); - test_case.add_input(input); - test_case.add_expected_output(expected_output); - - test_case.run(); - } - - // TestCase doesn't support LP types - template - void LPConvertTest(const std::vector& input, - const Shape& input_shape, - const ngraph::element::Type& input_type, - const std::vector& expected_output, - const ngraph::element::Type& expected_output_type) - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} // namespace - -// destination: boolean -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_boolean) -{ - const uint8_t lowest = std::numeric_limits::lowest(); - const uint8_t max = std::numeric_limits::max(); - - const std::vector input{0, 12, 23, 0, lowest, max}; - const Shape input_shape{2, 3}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 1, 1, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::boolean; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_boolean) -{ - const int32_t lowest = std::numeric_limits::lowest(); - const int32_t max = std::numeric_limits::max(); - - const std::vector input{0, -12, 23, 0, lowest, max}; - const Shape input_shape{2, 3}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{0, 1, 1, 0, 1, 1}; - const element::Type expected_output_type = ngraph::element::boolean; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_boolean) -{ - const float lowest = std::numeric_limits::lowest(); - const float max = std::numeric_limits::max(); - const float min = std::numeric_limits::min(); - const float pos_inf = std::numeric_limits::infinity(); - const float neg_inf = -std::numeric_limits::infinity(); - - const std::vector input{0.f, 1.5745f, 0.12352f, 0.f, lowest, max, min, pos_inf, neg_inf}; - const Shape input_shape{3, 3}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{0, 1, 1, 0, 1, 1, 1, 1, 1}; - const element::Type expected_output_type = ngraph::element::boolean; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: bf16 -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_bf16) -{ - const std::vector input{ - 0.5f, 1.5f, 0.5f, 2.5f, 1.5f, 0.5f, 3.5f, 2.5f, 0.5f, 0.5f, 2.5f, 0.5f, 0.5f, 0.5f, 1.5f}; - const Shape input_shape{1, 1, 3, 5}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output(std::begin(input), std::end(input)); - const element::Type expected_output_type = ngraph::element::bf16; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: f16 -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_f16) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const element::Type expected_output_type = ngraph::element::f16; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: f32 -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_f32) -{ - const std::vector input{0xFE, 0xF2}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1.0f, -2.0f, -1.0f, 2.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(float)); - EXPECT_TRUE(test::all_close_f(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i8_to_f32) -{ - const std::vector input{-127, -0, 0, 127}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i8; - - const std::vector expected_output{-127.0f, -0.0f, 0.0f, 127.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i16_to_f32) -{ - const std::vector input{-32000, -0, 0, 32000}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i16; - - const std::vector expected_output{-32000.0f, -0.0f, 0.0f, 32000.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_f32) -{ - const std::vector input{-64000, -0, 0, 64000}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{-64000.0f, -0.0f, 0.0f, 64000.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i64_to_f32) -{ - const std::vector input{-64000, -0, 0, 64000}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::i64; - - const std::vector expected_output{-64000.0f, -0.0f, 0.0f, 64000.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_f32) -{ - const std::vector input{0xA0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1.0f, 0.0f, 1.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(float)); - EXPECT_TRUE(test::all_close_f(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_f32) -{ - const std::vector input{0xFB, 0x0A}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{15.0f, 11.0f, 0.0f, 10.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(float)); - EXPECT_TRUE(test::all_close_f(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_f32) -{ - const std::vector input{255, 128, 32, 0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{255.0f, 128.0f, 32.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u16_to_f32) -{ - const std::vector input{64000, 32000, 128, 0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u16; - - const std::vector expected_output{64000.0f, 32000.0f, 128.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u32_to_f32) -{ - const std::vector input{4000000, 2000000, 128, 0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u32; - - const std::vector expected_output{4000000.0f, 2000000.0f, 128.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u64_to_f32) -{ - const std::vector input{4000000, 2000000, 128, 0}; - const Shape input_shape{2, 2}; - const element::Type input_type = ngraph::element::u64; - - const std::vector expected_output{4000000.0f, 2000000.0f, 128.0f, 0.0f}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_bf16_to_f32) -{ - const std::vector input{ - 0.5, 1.5, 0.5, 2.5, 1.5, 0.5, 3.5, 2.5, 0.5, 0.5, 2.5, 0.5, 0.5, 0.5, 1.5}; - const Shape input_shape{1, 1, 3, 5}; - const element::Type input_type = ngraph::element::bf16; - - const std::vector expected_output(std::begin(input), std::end(input)); - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f16_to_f32) -{ - const std::vector input{-20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5}; - const Shape input_shape{3, 3}; - const element::Type input_type = ngraph::element::f16; - - const std::vector expected_output{-20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_f32) -{ - const std::vector input{-20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5}; - const Shape input_shape{3, 3}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{-20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5}; - const element::Type expected_output_type = ngraph::element::f32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i4 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i4) -{ - const std::vector input{0xA0}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{0x10, 0x10}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i4) -{ - const std::vector input{0x12, 0x03}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i4) -{ - const std::vector input{1, 2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u16_to_i4) -{ - const std::vector input{1, 2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u16; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u32_to_i4) -{ - const std::vector input{1, 2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u32; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u64_to_i4) -{ - const std::vector input{1, 2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u64; - - const std::vector expected_output{0x12, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i8_to_i4) -{ - const std::vector input{-1, -2, 2, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i8; - - const std::vector expected_output{0xFE, 0x23}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i16_to_i4) -{ - const std::vector input{-1, -2, 2, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i16; - - const std::vector expected_output{0xFE, 0x23}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_i4) -{ - const std::vector input{-1, -2, 2, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{0xFE, 0x23}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i64_to_i4) -{ - const std::vector input{-1, -2, 2, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i64; - - const std::vector expected_output{0xFE, 0x23}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f16_to_i4) -{ - const std::vector input{-1, -2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::f16; - - const std::vector expected_output{0xFE, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_bf16_to_i4) -{ - const std::vector input{-1, -2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::bf16; - - const std::vector expected_output{0xFE, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_i4) -{ - const std::vector input{-1, -2, 0, 3}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{0xFE, 0x03}; - const element::Type expected_output_type = ngraph::element::i4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i8 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i8) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::i8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i8) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::i8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_i8) -{ - const std::vector input{0xFE, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1, -2, 4, 3}; - const element::Type expected_output_type = ngraph::element::i8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i8) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 128}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::i8; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i16 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i16) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::i16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i16) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::i16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_i16) -{ - const std::vector input{0xFE, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1, -2, 4, 3}; - const element::Type expected_output_type = ngraph::element::i16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i16) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const element::Type expected_output_type = ngraph::element::i16; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i32 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i32) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::i32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i32) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::i32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_i32) -{ - const std::vector input{0xFE, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1, -2, 4, 3}; - const element::Type expected_output_type = ngraph::element::i32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i32) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const element::Type expected_output_type = ngraph::element::i32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: i64 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_i64) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::i64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_i64) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::i64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_i64) -{ - const std::vector input{0xFE, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{-1, -2, 4, 3}; - const element::Type expected_output_type = ngraph::element::i64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(int64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_i64) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 130, 142}; - const element::Type expected_output_type = ngraph::element::i64; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u1 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u1) -{ - const std::vector input{0xF0}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{0xF0}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u1) -{ - const std::vector input{0x10, 0x01, 0x00, 0x00}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{0x90}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u16_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u16; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u32_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u32; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u64_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u64; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u1) -{ - const std::vector input{0x10, 0x01, 0x00, 0x00}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{0x90}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i8_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::i8; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i16_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::i16; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i64_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::i64; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f16_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::f16; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_bf16_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::bf16; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_u1) -{ - const std::vector input{1, 0, 1, 0, 0, 0, 0, 1}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{0xA1}; - const element::Type expected_output_type = ngraph::element::u1; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u4 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u4) -{ - const std::vector input{0xF0}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{0x11, 0x11}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u4) -{ - const std::vector input{0x22, 0x33}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{0x22, 0x33}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u16_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u16; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u32_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u32; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u64_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u64; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u4) -{ - const std::vector input{0x22, 0x33}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{0x22, 0x33}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i8_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i8; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i16_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i16; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i32_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i32; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i64_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i64; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f16_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::f16; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_bf16_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::bf16; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_f32_to_u4) -{ - const std::vector input{7, 0, 1, 15}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::f32; - - const std::vector expected_output{0x70, 0x1F}; - const element::Type expected_output_type = ngraph::element::u4; - - LPConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u8 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u8) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::u8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u8) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::u8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u8) -{ - const std::vector input{0x12, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{1, 2, 4, 3}; - const element::Type expected_output_type = ngraph::element::u8; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint8_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u8) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::u8; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u16 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u16) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::u16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u16) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::u16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u16) -{ - const std::vector input{0x12, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{1, 2, 4, 3}; - const element::Type expected_output_type = ngraph::element::u16; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint16_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u16) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::u16; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u32 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u32) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::u32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u32) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::u32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u32) -{ - const std::vector input{0x12, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{1, 2, 4, 3}; - const element::Type expected_output_type = ngraph::element::u32; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint32_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u32) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::u32; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// destination: u64 -NGRAPH_TEST(${BACKEND_NAME}, convert_u1_to_u64) -{ - const std::vector input{0x81}; - const Shape input_shape{8}; - const element::Type input_type = ngraph::element::u1; - - const std::vector expected_output{1, 0, 0, 0, 0, 0, 0, 1}; - const element::Type expected_output_type = ngraph::element::u64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u4_to_u64) -{ - const std::vector input{0x21, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::u4; - - const std::vector expected_output{2, 1, 4, 3}; - const element::Type expected_output_type = ngraph::element::u64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_i4_to_u64) -{ - const std::vector input{0x12, 0x43}; - const Shape input_shape{4}; - const element::Type input_type = ngraph::element::i4; - - const std::vector expected_output{1, 2, 4, 3}; - const element::Type expected_output_type = ngraph::element::u64; - - { - const auto f = CreateFunction(input_shape, input_type, expected_output_type); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - auto input_tesnor = backend->create_tensor(input_type, input_shape); - copy_data(input_tesnor, input); - auto output = backend->create_tensor(expected_output_type, input_shape); - auto handle = backend->compile(f); - handle->call_with_validate({output}, {input_tesnor}); - - std::vector result(expected_output.size()); - output->read(result.data(), result.size() * sizeof(uint64_t)); - EXPECT_TRUE(test::all_close(expected_output, result)); - } -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_u8_to_u64) -{ - const std::vector input{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const Shape input_shape{11}; - const element::Type input_type = ngraph::element::u8; - - const std::vector expected_output{0, 10, 15, 20, 43, 56, 78, 99, 102, 110, 127}; - const element::Type expected_output_type = ngraph::element::u64; - - ConvertTest(input, input_shape, input_type, expected_output, expected_output_type); -} - -// jit tests -NGRAPH_TEST(${BACKEND_NAME}, convert_float32_int8) -{ - std::vector f32vec = {-100.5, -20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5, 100.5}; - std::vector result(f32vec.size()); - std::vector i8vec(std::begin(f32vec), std::end(f32vec)); - runtime::reference::convert(f32vec.data(), result.data(), f32vec.size()); - EXPECT_EQ(result, i8vec); -} - -NGRAPH_TEST(${BACKEND_NAME}, convert_fp16_int8) -{ - std::vector f32vec = {-100.5, -20.5, -15, -10.5, -0.5, 0, 0.5, 10.5, 15, 20.5, 100.5}; - std::vector f16vec(std::begin(f32vec), std::end(f32vec)); - std::vector i8vec(std::begin(f16vec), std::end(f16vec)); - std::vector result(i8vec.size()); - runtime::reference::convert(f16vec.data(), result.data(), f16vec.size()); - EXPECT_EQ(result, i8vec); -} diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 75d42a3a568cf0..bf92db7af61d3f 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -942,90 +942,6 @@ roll_3d_input roll_3d_input_negative_shift roll_negative_axes -# convert operation -IE_CPU.convert_u8_to_boolean -IE_CPU.convert_i32_to_boolean -IE_CPU.convert_f32_to_boolean -IE_CPU.convert_u8_to_f16 -IE_CPU.convert_u8_to_i16 -IE_CPU.convert_u8_to_i64 -IE_CPU.convert_u8_to_u16 -IE_CPU.convert_u8_to_u32 -IE_CPU.convert_u8_to_u64 -IE_CPU.convert_f16_to_f32 -IE_CPU.convert_u32_to_f32 -IE_CPU.convert_i4_to_f32 -IE_CPU.convert_u1_to_f32 -IE_CPU.convert_u4_to_f32 - -IE_CPU.convert_u1_to_u1 -IE_CPU.convert_u4_to_u1 -IE_CPU.convert_u8_to_u1 -IE_CPU.convert_u16_to_u1 -IE_CPU.convert_u32_to_u1 -IE_CPU.convert_u64_to_u1 -IE_CPU.convert_i4_to_u1 -IE_CPU.convert_i8_to_u1 -IE_CPU.convert_i16_to_u1 -IE_CPU.convert_i32_to_u1 -IE_CPU.convert_i64_to_u1 -IE_CPU.convert_f16_to_u1 -IE_CPU.convert_bf16_to_u1 -IE_CPU.convert_f32_to_u1 - -IE_CPU.convert_u1_to_i4 -IE_CPU.convert_u4_to_i4 -IE_CPU.convert_u8_to_i4 -IE_CPU.convert_u16_to_i4 -IE_CPU.convert_u32_to_i4 -IE_CPU.convert_u64_to_i4 -IE_CPU.convert_i8_to_i4 -IE_CPU.convert_i16_to_i4 -IE_CPU.convert_i32_to_i4 -IE_CPU.convert_i64_to_i4 -IE_CPU.convert_f16_to_i4 -IE_CPU.convert_bf16_to_i4 -IE_CPU.convert_f32_to_i4 - -IE_CPU.convert_u1_to_u4 -IE_CPU.convert_u4_to_u4 -IE_CPU.convert_u8_to_u4 -IE_CPU.convert_u16_to_u4 -IE_CPU.convert_u32_to_u4 -IE_CPU.convert_u64_to_u4 -IE_CPU.convert_i4_to_u4 -IE_CPU.convert_i8_to_u4 -IE_CPU.convert_i16_to_u4 -IE_CPU.convert_i32_to_u4 -IE_CPU.convert_i64_to_u4 -IE_CPU.convert_f16_to_u4 -IE_CPU.convert_bf16_to_u4 -IE_CPU.convert_f32_to_u4 - -IE_CPU.convert_u1_to_i8 -IE_CPU.convert_u4_to_i8 -IE_CPU.convert_i4_to_i8 -IE_CPU.convert_u1_to_i16 -IE_CPU.convert_u4_to_i16 -IE_CPU.convert_i4_to_i16 -IE_CPU.convert_u1_to_i32 -IE_CPU.convert_u4_to_i32 -IE_CPU.convert_i4_to_i32 -IE_CPU.convert_u1_to_i64 -IE_CPU.convert_u4_to_i64 -IE_CPU.convert_i4_to_i64 -IE_CPU.convert_u1_to_u8 -IE_CPU.convert_u4_to_u8 -IE_CPU.convert_i4_to_u8 -IE_CPU.convert_u1_to_u16 -IE_CPU.convert_u4_to_u16 -IE_CPU.convert_i4_to_u16 -IE_CPU.convert_u1_to_u32 -IE_CPU.convert_u4_to_u32 -IE_CPU.convert_i4_to_u32 -IE_CPU.convert_u1_to_u64 -IE_CPU.convert_u4_to_u64 -IE_CPU.convert_i4_to_u64 #------------------------------------------------------------------------------- # # Inference Engine CPU plugin excludes From 55ed4dae4ebf93c0405d3db1a5cf4ec7c116f89b Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 30 Jun 2021 09:47:49 +0300 Subject: [PATCH 03/11] Fixed build --- .../tests/functional/op_reference/base_reference_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp index ef0205b08facbd..731fe59471ef97 100644 --- a/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp +++ b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp @@ -69,7 +69,7 @@ void CommonReferenceTest::Infer() { const auto& inputsInfo = executableNetwork.GetInputsInfo(); const auto& functionParams = function->get_parameters(); - for (int i = 0; i < functionParams.size(); ++i) { + for (size_t i = 0; i < functionParams.size(); ++i) { const auto& param = functionParams[i]; const auto infoIt = inputsInfo.find(param->get_friendly_name()); GTEST_ASSERT_NE(infoIt, inputsInfo.cend()); From 5be48ff2d83b4ecf143e46201c036e1e35390042 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 30 Jun 2021 10:35:50 +0300 Subject: [PATCH 04/11] Fixed comments --- .../functional/op_reference/base_reference_test.cpp | 8 ++++---- .../functional/op_reference/base_reference_test.hpp | 8 ++++---- .../tests/functional/op_reference/convert.cpp | 12 +++--------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp index 731fe59471ef97..51af4d2ea1a221 100644 --- a/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp +++ b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp @@ -17,7 +17,7 @@ void CommonReferenceTest::Exec() { LoadNetwork(); FillInputs(); Infer(); - Compare(); + Validate(); } void CommonReferenceTest::LoadNetwork() { @@ -82,7 +82,7 @@ void CommonReferenceTest::Infer() { inferRequest.Infer(); } -void CommonReferenceTest::Compare() { +void CommonReferenceTest::Validate() { ASSERT_EQ(executableNetwork.GetOutputsInfo().size(), refOutData.size()); std::vector outputs; for (const auto& result : function->get_results()) { @@ -92,10 +92,10 @@ void CommonReferenceTest::Compare() { ASSERT_EQ(refOutData.size(), outputs.size()); for (size_t i = 0; i < refOutData.size(); i++) { - CompareBlobs(refOutData[i], outputs[i]); + ValidateBlobs(refOutData[i], outputs[i]); } } -void CommonReferenceTest::CompareBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob) { +void CommonReferenceTest::ValidateBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob) { ASSERT_TRUE(refBlob != nullptr); ASSERT_TRUE(outBlob != nullptr); ASSERT_EQ(refBlob->getTensorDesc().getPrecision(), outBlob->getTensorDesc().getPrecision()); diff --git a/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp b/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp index ce3b33d5d7a2f3..6e3fd942a9e722 100644 --- a/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp +++ b/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp @@ -19,10 +19,10 @@ class CommonReferenceTest { void Infer(); - void Compare(); + void Validate(); private: - void CompareBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob); + void ValidateBlobs(const InferenceEngine::Blob::Ptr& refBlob, const InferenceEngine::Blob::Ptr& outBlob); protected: const std::string targetDevice; @@ -37,7 +37,7 @@ class CommonReferenceTest { }; template -InferenceEngine::Blob::Ptr CreateBlob(const ngraph::element::Type& element_type, std::vector values, size_t size = 0) { +InferenceEngine::Blob::Ptr CreateBlob(const ngraph::element::Type& element_type, const std::vector& values, size_t size = 0) { size_t real_size = size ? size : values.size() * sizeof(T) / element_type.size(); auto blob = make_blob_with_precision( InferenceEngine::TensorDesc(InferenceEngine::details::convertPrecision(element_type), {real_size}, InferenceEngine::Layout::C)); @@ -46,7 +46,7 @@ InferenceEngine::Blob::Ptr CreateBlob(const ngraph::element::Type& element_type, IE_ASSERT(minput); auto minputHolder = minput->wmap(); - std::memcpy(minputHolder.as(), values.data(), sizeof(T) * values.size()); + std::memcpy(minputHolder.as(), values.data(), std::min(real_size * element_type.size(), sizeof(T) * values.size())); return blob; } diff --git a/docs/template_plugin/tests/functional/op_reference/convert.cpp b/docs/template_plugin/tests/functional/op_reference/convert.cpp index 78ef5d0b3950f8..5d7b8f089566dd 100644 --- a/docs/template_plugin/tests/functional/op_reference/convert.cpp +++ b/docs/template_plugin/tests/functional/op_reference/convert.cpp @@ -17,15 +17,9 @@ using namespace InferenceEngine; struct ConvertParams { template - ConvertParams(const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, const std::vector iValues, - const std::vector oValues, size_t iSize = 0, size_t oSize = 0) { - pshape = shape; - inType = iType; - outType = oType; - - inputData = CreateBlob(iType, iValues, iSize); - refData = CreateBlob(oType, oValues, oSize); - } + ConvertParams(const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, const std::vector& iValues, + const std::vector& oValues, size_t iSize = 0, size_t oSize = 0) + : pshape(shape), inType(iType), outType(oType), inputData(CreateBlob(iType, iValues, iSize)), refData(CreateBlob(oType, oValues, oSize)) {} ngraph::PartialShape pshape; ngraph::element::Type inType; ngraph::element::Type outType; From 405c169406d3ac0c06b912a4aadbcac2db9c3aa0 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 30 Jun 2021 11:06:13 +0300 Subject: [PATCH 05/11] Fixed templateFuncTests --- docs/template_plugin/src/template_plugin.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/template_plugin/src/template_plugin.cpp b/docs/template_plugin/src/template_plugin.cpp index 1e9cd774018686..c92918983cdcfe 100644 --- a/docs/template_plugin/src/template_plugin.cpp +++ b/docs/template_plugin/src/template_plugin.cpp @@ -66,6 +66,17 @@ std::shared_ptr TransformNetwork(const std::shared_ptr(); + // GAPI supports only FP32 networks for pre-processing + bool needF16toF32 = false; + for (const auto& param : function->get_parameters()) { + if (param->get_element_type() == ngraph::element::f16 && + inputInfoMap.at(param->get_friendly_name())->getTensorDesc().getPrecision() != InferenceEngine::Precision::FP16) { + needF16toF32 = true; + break; + } + } + if (needF16toF32) + passManager.register_pass(precisions_array {{ngraph::element::f16, ngraph::element::f32}}); // Example: register plugin specific transformation passManager.register_pass(); passManager.register_pass(); From c1743c50af7e1b8cab21127869b0baf4393358f3 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Thu, 1 Jul 2021 13:16:18 +0300 Subject: [PATCH 06/11] Fixed review comments --- .../tests/functional/op_reference/convert.cpp | 13 +++++++++++-- .../functional_test_utils/src/plugin_cache.cpp | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/template_plugin/tests/functional/op_reference/convert.cpp b/docs/template_plugin/tests/functional/op_reference/convert.cpp index 5d7b8f089566dd..fb32fda4cbbfd8 100644 --- a/docs/template_plugin/tests/functional/op_reference/convert.cpp +++ b/docs/template_plugin/tests/functional/op_reference/convert.cpp @@ -35,6 +35,14 @@ class ReferenceConvertLayerTest : public testing::TestWithParam, inputData = {params.inputData}; refOutData = {params.refData}; } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "shape=" << param.pshape << "_"; + result << "iType=" << param.inType << "_"; + result << "oType=" << param.outType; + return result.str(); + } private: static std::shared_ptr CreateFunction(const PartialShape& input_shape, const element::Type& input_type, @@ -50,7 +58,7 @@ TEST_P(ReferenceConvertLayerTest, CompareWithHardcodedRefs) { } INSTANTIATE_TEST_SUITE_P( - smoke_Convert_With_Hardcided_Refs, ReferenceConvertLayerTest, + smoke_Convert_With_Hardcoded_Refs, ReferenceConvertLayerTest, ::testing::Values( // destination boolean ConvertParams(ngraph::PartialShape {2, 3}, ngraph::element::u8, ngraph::element::boolean, @@ -429,4 +437,5 @@ INSTANTIATE_TEST_SUITE_P( ConvertParams(ngraph::PartialShape {4}, ngraph::element::bf16, ngraph::element::u64, std::vector {1, 2, 0, 3}, std::vector {1, 2, 0, 3}), ConvertParams(ngraph::PartialShape {4}, ngraph::element::f32, ngraph::element::u64, std::vector {1, 2, 2, 3}, - std::vector {1, 2, 2, 3}))); + std::vector {1, 2, 2, 3})), + ReferenceConvertLayerTest::getTestCaseName); diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp b/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp index 95b8e29eff417d..a5fbffc731c810 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp @@ -61,11 +61,13 @@ std::shared_ptr PluginCache::ie(const std::string &device std::exit(EXIT_FAILURE); } +#ifndef NDEBUG std::cout << "Available devices for " << deviceToCheck << ":" << std::endl; for (const auto &device : availableDevices) { std::cout << " " << device << std::endl; } +#endif } } return ie_core; From b5807ec61897eef636dd692d24cf40207d0b209b Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 7 Jul 2021 15:41:29 +0300 Subject: [PATCH 07/11] Added dynamic registration of template plugin --- .ci/azure/linux.yml | 1 - cmake/features.cmake | 2 -- docs/template_plugin/src/CMakeLists.txt | 6 ++---- .../functional_test_utils/src/plugin_cache.cpp | 8 ++++++++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index 146775f6189f02..f9fcee6a66eb77 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -103,7 +103,6 @@ jobs: cmakeArgs: > -GNinja -DVERBOSE_BUILD=ON - -DENABLE_TEMPLATE_PLUGIN=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE=/usr/bin/python3.6 diff --git a/cmake/features.cmake b/cmake/features.cmake index 6042d9d2238881..1f0c198913cc23 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -24,8 +24,6 @@ Supported values:\ ie_option (ENABLE_PROFILING_FIRST_INFERENCE "Build with ITT tracing of first inference time." ON) -ie_option(ENABLE_TEMPLATE_PLUGIN "Register template plugin into plugins.xml" OFF) - ie_option_enum(SELECTIVE_BUILD "Enable OpenVINO conditional compilation or statistics collection. \ In case SELECTIVE_BUILD is enabled, the SELECTIVE_BUILD_STAT variable should contain the path to the collected InelSEAPI statistics. \ Usage: -DSELECTIVE_BUILD=ON -DSELECTIVE_BUILD_STAT=/path/*.csv" OFF diff --git a/docs/template_plugin/src/CMakeLists.txt b/docs/template_plugin/src/CMakeLists.txt index e91b6f215860a4..a6411523780629 100644 --- a/docs/template_plugin/src/CMakeLists.txt +++ b/docs/template_plugin/src/CMakeLists.txt @@ -36,10 +36,8 @@ target_link_libraries(${TARGET_NAME} PRIVATE set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO}) # ATTENTION: uncomment to register a plugin in the plugins.xml file -if(ENABLE_TEMPLATE_PLUGIN) - ie_register_plugins(MAIN_TARGET ${TARGET_NAME} - POSSIBLE_PLUGINS ${TARGET_NAME}) -endif() +# ie_register_plugins(MAIN_TARGET ${TARGET_NAME} +# POSSIBLE_PLUGINS ${TARGET_NAME}) # [cmake:plugin] # ATTENTION: uncomment to install component diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp b/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp index a5fbffc731c810..48d67e2d2d3260 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp @@ -49,6 +49,14 @@ std::shared_ptr PluginCache::ie(const std::string &device } assert(0 != ie_core.use_count()); + // register template plugin if it is needed + const auto& availableDevices = ie_core->GetAvailableDevices(); + if (std::find(availableDevices.begin(), availableDevices.end(), "TEMPLATE") == availableDevices.end()) { + std::string pluginName = "templatePlugin"; + pluginName += IE_BUILD_POSTFIX; + ie_core->RegisterPlugin(pluginName, "TEMPLATE"); + } + if (!deviceToCheck.empty()) { std::vector metrics = ie_core->GetMetric(deviceToCheck, METRIC_KEY(SUPPORTED_METRICS)); From e8cac0b5a74c2d47e47a625b14e5472b95d987f0 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 7 Jul 2021 18:28:15 +0300 Subject: [PATCH 08/11] Fixed functional tests --- .../behavior/core_integration.cpp | 10 +- .../include/behavior/core_integration.hpp | 182 +++++++++--------- 2 files changed, 100 insertions(+), 92 deletions(-) diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp index 2c067aaf7b68ab..60ffbf048934e6 100644 --- a/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp +++ b/docs/template_plugin/tests/functional/shared_tests_instances/behavior/core_integration.cpp @@ -73,7 +73,7 @@ using IEClassSetConfigTestHETERO = IEClassNetworkTest; TEST_F(IEClassSetConfigTestHETERO, smoke_SetConfigNoThrow) { { - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(ie.SetConfig({{HETERO_CONFIG_KEY(DUMP_GRAPH_DOT), CONFIG_VALUE(YES)}}, "HETERO")); @@ -84,7 +84,7 @@ TEST_F(IEClassSetConfigTestHETERO, smoke_SetConfigNoThrow) { } { - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(ie.SetConfig({{HETERO_CONFIG_KEY(DUMP_GRAPH_DOT), CONFIG_VALUE(NO)}}, "HETERO")); @@ -95,7 +95,7 @@ TEST_F(IEClassSetConfigTestHETERO, smoke_SetConfigNoThrow) { } { - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(ie.GetMetric("HETERO", METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -118,7 +118,7 @@ INSTANTIATE_TEST_SUITE_P( using IEClassGetConfigTestTEMPLATE = IEClassNetworkTest; TEST_F(IEClassGetConfigTestTEMPLATE, smoke_GetConfigNoThrow) { - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; std::string deviceName = CommonTestUtils::DEVICE_TEMPLATE; @@ -209,4 +209,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE)); #endif // ENABLE_MKL_DNN -} // namespace \ No newline at end of file +} // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp index adcd0e525b43bf..1064edaa570865 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/core_integration.hpp @@ -62,6 +62,14 @@ namespace BehaviorTestsDefinitions { } +inline Core createCoreWithTemplate() { + Core ie; + std::string pluginName = "templatePlugin"; + pluginName += IE_BUILD_POSTFIX; + ie.RegisterPlugin(pluginName, "TEMPLATE"); + return ie; +} + class IEClassBasicTestP : public ::testing::Test, public WithParamInterface > { protected: std::string deviceName; @@ -211,20 +219,20 @@ TEST(IEClassBasicTest, smoke_createDefault) { TEST_P(IEClassBasicTestP, registerExistingPluginThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.RegisterPlugin(pluginName, deviceName), Exception); } TEST_P(IEClassBasicTestP, registerNewPluginNoThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.RegisterPlugin(pluginName, "NEW_DEVICE_NAME")); ASSERT_NO_THROW(ie.GetMetric("NEW_DEVICE_NAME", METRIC_KEY(SUPPORTED_CONFIG_KEYS))); } TEST(IEClassBasicTest, smoke_registerExistingPluginFileThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.RegisterPlugins("nonExistPlugins.xml"), Exception); } @@ -277,7 +285,7 @@ TEST_P(IEClassBasicTestP, smoke_registerPluginsXMLUnicodePath) { GTEST_COUT << "Test " << testIndex << std::endl; - Core ie; + Core ie = createCoreWithTemplate(); GTEST_COUT << "Core created " << testIndex << std::endl; ASSERT_NO_THROW(ie.RegisterPlugins(::FileUtils::wStringtoMBCSstringChar(pluginsXmlW))); CommonTestUtils::removeFile(pluginsXmlW); @@ -310,19 +318,19 @@ TEST_P(IEClassBasicTestP, smoke_registerPluginsXMLUnicodePath) { TEST_P(IEClassBasicTestP, getVersionsByExactDeviceNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.GetVersions(deviceName + ".0")); } TEST_P(IEClassBasicTestP, getVersionsByDeviceClassNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.GetVersions(deviceName)); } TEST_P(IEClassBasicTestP, getVersionsNonEmpty) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_EQ(2, ie.GetVersions(CommonTestUtils::DEVICE_HETERO + std::string(":") + deviceName).size()); } @@ -332,7 +340,7 @@ TEST_P(IEClassBasicTestP, getVersionsNonEmpty) { TEST_P(IEClassBasicTestP, unregisterExistingPluginNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); // device instance is not created yet ASSERT_THROW(ie.UnregisterPlugin(deviceName), Exception); @@ -344,7 +352,7 @@ TEST_P(IEClassBasicTestP, unregisterExistingPluginNoThrow) { TEST_P(IEClassBasicTestP, accessToUnregisteredPluginThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.UnregisterPlugin(deviceName), Exception); ASSERT_NO_THROW(ie.GetVersions(deviceName)); ASSERT_NO_THROW(ie.UnregisterPlugin(deviceName)); @@ -355,7 +363,7 @@ TEST_P(IEClassBasicTestP, accessToUnregisteredPluginThrows) { TEST(IEClassBasicTest, smoke_unregisterNonExistingPluginThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.UnregisterPlugin("unkown_device"), Exception); } @@ -365,45 +373,45 @@ TEST(IEClassBasicTest, smoke_unregisterNonExistingPluginThrows) { TEST_P(IEClassBasicTestP, SetConfigAllThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{"unsupported_key", "4"}})); ASSERT_ANY_THROW(ie.GetVersions(deviceName)); } TEST_P(IEClassBasicTestP, SetConfigForUnRegisteredDeviceThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.SetConfig({{"unsupported_key", "4"}}, "unregistered_device"), Exception); } TEST_P(IEClassBasicTestP, SetConfigNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{KEY_PERF_COUNT, YES}}, deviceName)); } TEST_P(IEClassBasicTestP, SetConfigAllNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{KEY_PERF_COUNT, YES}})); ASSERT_NO_THROW(ie.GetVersions(deviceName)); } TEST(IEClassBasicTest, smoke_SetConfigHeteroThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{KEY_PERF_COUNT, YES}}, CommonTestUtils::DEVICE_HETERO)); } TEST_P(IEClassBasicTestP, SetConfigHeteroTargetFallbackThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.SetConfig({{"TARGET_FALLBACK", deviceName}}, CommonTestUtils::DEVICE_HETERO)); } TEST(IEClassBasicTest, smoke_SetConfigHeteroNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); bool value = false; ASSERT_NO_THROW(ie.SetConfig({{HETERO_CONFIG_KEY(DUMP_GRAPH_DOT), YES}}, CommonTestUtils::DEVICE_HETERO)); @@ -421,7 +429,7 @@ TEST(IEClassBasicTest, smoke_SetConfigHeteroNoThrow) { TEST_P(IEClassBasicTestP, ImportNetworkThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); if (deviceName == CommonTestUtils::DEVICE_CPU || deviceName == CommonTestUtils::DEVICE_GPU) { @@ -440,20 +448,20 @@ TEST_P(IEClassBasicTestP, ImportNetworkThrows) { TEST(IEClassBasicTest, smoke_ImportNetworkHeteroThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.ImportNetwork("model", CommonTestUtils::DEVICE_HETERO), NetworkNotRead); } TEST(IEClassBasicTest, smoke_ImportNetworkMultiThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - InferenceEngine::Core ie; + InferenceEngine::Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.ImportNetwork("model", CommonTestUtils::DEVICE_MULTI), NetworkNotRead); } TEST_P(IEClassBasicTestP, ImportNetworkWithNullContextThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); RemoteContext::Ptr context = nullptr; std::istringstream stream("None"); ASSERT_THROW(ie.ImportNetwork(stream, context, {}), Exception); @@ -465,19 +473,19 @@ TEST_P(IEClassBasicTestP, ImportNetworkWithNullContextThrows) { TEST_P(IEClassNetworkTestP, LoadNetworkActualNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.LoadNetwork(actualNetwork, deviceName)); } TEST_P(IEClassNetworkTestP, LoadNetworkActualHeteroDeviceNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.LoadNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO + std::string(":") + deviceName)); } TEST_P(IEClassNetworkTestP, LoadNetworkActualHeteroDevice2NoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.LoadNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO, {{"TARGET_FALLBACK", deviceName}})); } @@ -487,7 +495,7 @@ TEST_P(IEClassNetworkTestP, LoadNetworkActualHeteroDevice2NoThrow) { TEST_P(IEClassImportExportTestP, smoke_ImportNetworkThrowsIfNoDeviceName) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); std::stringstream strm; ExecutableNetwork executableNetwork; ASSERT_NO_THROW(executableNetwork = ie.LoadNetwork(actualNetwork, deviceName)); @@ -500,7 +508,7 @@ TEST_P(IEClassImportExportTestP, smoke_ImportNetworkThrowsIfNoDeviceName) { TEST_P(IEClassImportExportTestP, smoke_ImportNetworkNoThrowWithDeviceName) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); std::stringstream strm; ExecutableNetwork executableNetwork; ASSERT_NO_THROW(executableNetwork = ie.LoadNetwork(actualNetwork, deviceName)); @@ -511,7 +519,7 @@ TEST_P(IEClassImportExportTestP, smoke_ImportNetworkNoThrowWithDeviceName) { TEST_P(IEClassImportExportTestP, smoke_ExportUsingFileNameImportFromStreamNoThrowWithDeviceName) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ExecutableNetwork executableNetwork; std::string fileName{"ExportedNetwork"}; { @@ -534,13 +542,13 @@ TEST_P(IEClassImportExportTestP, smoke_ExportUsingFileNameImportFromStreamNoThro TEST_P(IEClassNetworkTestP, QueryNetworkActualThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_NO_THROW(ie.QueryNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO + std::string(":") + deviceName)); } TEST_P(IEClassNetworkTestP, QueryNetworkActualNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); try { ie.QueryNetwork(actualNetwork, deviceName); @@ -552,7 +560,7 @@ TEST_P(IEClassNetworkTestP, QueryNetworkActualNoThrow) { TEST_P(IEClassNetworkTestP, QueryNetworkWithKSO) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); try { auto rres = ie.QueryNetwork(ksoNetwork, deviceName); @@ -571,7 +579,7 @@ TEST_P(IEClassNetworkTestP, QueryNetworkWithKSO) { TEST_P(IEClassNetworkTestP, SetAffinityWithConstantBranches) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); try { std::shared_ptr func; @@ -623,7 +631,7 @@ TEST_P(IEClassNetworkTestP, SetAffinityWithConstantBranches) { TEST_P(IEClassNetworkTestP, SetAffinityWithKSO) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); try { auto rres = ie.QueryNetwork(ksoNetwork, deviceName); @@ -647,7 +655,7 @@ TEST_P(IEClassNetworkTestP, SetAffinityWithKSO) { TEST_P(IEClassNetworkTestP, QueryNetworkHeteroActualNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); QueryNetworkResult res; ASSERT_NO_THROW(res = ie.QueryNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO, {{"TARGET_FALLBACK", deviceName}})); ASSERT_LT(0, res.supportedLayersMap.size()); @@ -655,13 +663,13 @@ TEST_P(IEClassNetworkTestP, QueryNetworkHeteroActualNoThrow) { TEST_P(IEClassNetworkTestP, QueryNetworkMultiThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); ASSERT_THROW(ie.QueryNetwork(actualNetwork, CommonTestUtils::DEVICE_MULTI), Exception); } TEST(IEClassBasicTest, smoke_GetMetricSupportedMetricsHeteroNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; std::string deviceName = CommonTestUtils::DEVICE_HETERO; @@ -678,7 +686,7 @@ TEST(IEClassBasicTest, smoke_GetMetricSupportedMetricsHeteroNoThrow) { TEST(IEClassBasicTest, smoke_GetMetricSupportedConfigKeysHeteroNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; std::string deviceName = CommonTestUtils::DEVICE_HETERO; @@ -695,7 +703,7 @@ TEST(IEClassBasicTest, smoke_GetMetricSupportedConfigKeysHeteroNoThrow) { TEST(IEClassBasicTest, smoke_GetMetricSupportedConfigKeysHeteroThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); // TODO: check std::string targetDevice = CommonTestUtils::DEVICE_HETERO + std::string(":") + CommonTestUtils::DEVICE_CPU; ASSERT_THROW(ie.GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS)), Exception); @@ -703,7 +711,7 @@ TEST(IEClassBasicTest, smoke_GetMetricSupportedConfigKeysHeteroThrows) { TEST_P(IEClassGetMetricTest_SUPPORTED_METRICS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_METRICS))); @@ -719,7 +727,7 @@ TEST_P(IEClassGetMetricTest_SUPPORTED_METRICS, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -735,7 +743,7 @@ TEST_P(IEClassGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_AVAILABLE_DEVICES, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES))); @@ -751,7 +759,7 @@ TEST_P(IEClassGetMetricTest_AVAILABLE_DEVICES, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_FULL_DEVICE_NAME, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(FULL_DEVICE_NAME))); @@ -763,7 +771,7 @@ TEST_P(IEClassGetMetricTest_FULL_DEVICE_NAME, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_OPTIMIZATION_CAPABILITIES, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(OPTIMIZATION_CAPABILITIES))); @@ -779,7 +787,7 @@ TEST_P(IEClassGetMetricTest_OPTIMIZATION_CAPABILITIES, GetMetricAndPrintNoThrow) TEST_P(IEClassGetMetricTest_DEVICE_GOPS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(DEVICE_GOPS))); @@ -795,7 +803,7 @@ TEST_P(IEClassGetMetricTest_DEVICE_GOPS, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_DEVICE_TYPE, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(DEVICE_TYPE))); @@ -808,7 +816,7 @@ TEST_P(IEClassGetMetricTest_DEVICE_TYPE, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_NUMBER_OF_WAITING_INFER_REQUESTS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED() - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(NUMBER_OF_WAITING_INFER_REQUESTS))); @@ -821,7 +829,7 @@ TEST_P(IEClassGetMetricTest_NUMBER_OF_WAITING_INFER_REQUESTS, GetMetricAndPrintN TEST_P(IEClassGetMetricTest_NUMBER_OF_EXEC_INFER_REQUESTS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(NUMBER_OF_EXEC_INFER_REQUESTS))); @@ -834,7 +842,7 @@ TEST_P(IEClassGetMetricTest_NUMBER_OF_EXEC_INFER_REQUESTS, GetMetricAndPrintNoTh TEST_P(IEClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(RANGE_FOR_ASYNC_INFER_REQUESTS))); @@ -857,7 +865,7 @@ TEST_P(IEClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, GetMetricAndPrintNoT TEST_P(IEClassGetMetricTest_RANGE_FOR_STREAMS, GetMetricAndPrintNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(RANGE_FOR_STREAMS))); @@ -877,7 +885,7 @@ TEST_P(IEClassGetMetricTest_RANGE_FOR_STREAMS, GetMetricAndPrintNoThrow) { TEST_P(IEClassGetMetricTest_ThrowUnsupported, GetMetricThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_THROW(p = ie.GetMetric(deviceName, "unsupported_metric"), Exception); @@ -885,7 +893,7 @@ TEST_P(IEClassGetMetricTest_ThrowUnsupported, GetMetricThrow) { TEST_P(IEClassGetConfigTest, GetConfigNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -900,7 +908,7 @@ TEST_P(IEClassGetConfigTest, GetConfigNoThrow) { TEST_P(IEClassGetConfigTest, GetConfigHeteroNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -913,7 +921,7 @@ TEST_P(IEClassGetConfigTest, GetConfigHeteroNoThrow) { TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigHeteroThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_THROW(p = ie.GetConfig(CommonTestUtils::DEVICE_HETERO, "unsupported_config"), Exception); @@ -921,7 +929,7 @@ TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigHeteroThrow) { TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigHeteroWithDeviceThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_THROW(p = ie.GetConfig(CommonTestUtils::DEVICE_HETERO + std::string(":") + deviceName, HETERO_CONFIG_KEY(DUMP_GRAPH_DOT)), @@ -930,7 +938,7 @@ TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigHeteroWithDeviceThrow) { TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_THROW(p = ie.GetConfig(deviceName, "unsupported_config"), Exception); @@ -938,7 +946,7 @@ TEST_P(IEClassGetConfigTest_ThrowUnsupported, GetConfigThrow) { TEST_P(IEClassGetAvailableDevices, GetAvailableDevicesNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); std::vector devices; ASSERT_NO_THROW(devices = ie.GetAvailableDevices()); @@ -962,7 +970,7 @@ TEST_P(IEClassGetAvailableDevices, GetAvailableDevicesNoThrow) { // TEST_P(IEClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -981,7 +989,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoT TEST_P(IEClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1000,7 +1008,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow TEST_P(IEClassExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1015,7 +1023,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) { TEST_P(IEClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1030,7 +1038,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, G TEST_P(IEClassExecutableNetworkGetMetricTest_ThrowsUnsupported, GetMetricThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1040,7 +1048,7 @@ TEST_P(IEClassExecutableNetworkGetMetricTest_ThrowsUnsupported, GetMetricThrow) TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1057,7 +1065,7 @@ TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigNoThrow) { TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1067,7 +1075,7 @@ TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigThrows) { TEST_P(IEClassExecutableNetworkSetConfigTest, SetConfigThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1077,7 +1085,7 @@ TEST_P(IEClassExecutableNetworkSetConfigTest, SetConfigThrows) { TEST_P(IEClassExecutableNetworkSupportedConfigTest, SupportedConfigWorks) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1090,7 +1098,7 @@ TEST_P(IEClassExecutableNetworkSupportedConfigTest, SupportedConfigWorks) { TEST_P(IEClassExecutableNetworkUnsupportedConfigTest, UnsupportedConfigThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); ExecutableNetwork exeNetwork = ie.LoadNetwork(simpleNetwork, deviceName); @@ -1099,7 +1107,7 @@ TEST_P(IEClassExecutableNetworkUnsupportedConfigTest, UnsupportedConfigThrows) { TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigNoEmptyNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ASSERT_NO_THROW(p = ie.GetMetric(deviceName, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); @@ -1122,7 +1130,7 @@ TEST_P(IEClassExecutableNetworkGetConfigTest, GetConfigNoEmptyNoThrow) { TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter pHetero, pDevice; ExecutableNetwork heteroExeNetwork = ie.LoadNetwork(actualNetwork, heteroDeviceName); @@ -1156,7 +1164,7 @@ TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMet TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter pHetero, pDevice; ExecutableNetwork heteroExeNetwork = ie.LoadNetwork(actualNetwork, heteroDeviceName); @@ -1196,7 +1204,7 @@ TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricN TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; ExecutableNetwork exeNetwork = ie.LoadNetwork(actualNetwork, heteroDeviceName); @@ -1209,7 +1217,7 @@ TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThro TEST_P(IEClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK, GetMetricNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); Parameter p; setHeteroNetworkAffinity(deviceName); @@ -1237,7 +1245,7 @@ bool supportsDeviceID(Core &ie, const std::string &deviceName) { TEST_P(IEClassQueryNetworkTest, QueryNetworkHETEROWithDeviceIDNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { auto deviceIDs = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES)).as>(); @@ -1252,7 +1260,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkHETEROWithDeviceIDNoThrow) { TEST_P(IEClassQueryNetworkTest, QueryNetworkWithDeviceID) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { try { @@ -1268,7 +1276,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkWithDeviceID) { TEST_P(IEClassQueryNetworkTest, QueryNetworkWithBigDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.QueryNetwork(actualNetwork, deviceName + ".110"), Exception); @@ -1279,7 +1287,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkWithBigDeviceIDThrows) { TEST_P(IEClassQueryNetworkTest, QueryNetworkWithInvalidDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.QueryNetwork(actualNetwork, deviceName + ".l0"), Exception); @@ -1290,7 +1298,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkWithInvalidDeviceIDThrows) { TEST_P(IEClassQueryNetworkTest, QueryNetworkHETEROWithBigDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.QueryNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO, @@ -1305,7 +1313,7 @@ TEST_P(IEClassQueryNetworkTest, QueryNetworkHETEROWithBigDeviceIDThrows) { // TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROWithDeviceIDNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { auto deviceIDs = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES)).as>(); @@ -1320,7 +1328,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROWithDeviceIDNoThrow) { TEST_P(IEClassLoadNetworkTest, LoadNetworkWithDeviceIDNoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { auto deviceIDs = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES)).as>(); @@ -1334,7 +1342,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkWithDeviceIDNoThrow) { TEST_P(IEClassLoadNetworkTest, LoadNetworkWithBigDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.LoadNetwork(actualNetwork, deviceName + ".10"), Exception); @@ -1345,7 +1353,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkWithBigDeviceIDThrows) { TEST_P(IEClassLoadNetworkTest, LoadNetworkWithInvalidDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.LoadNetwork(actualNetwork, deviceName + ".l0"), Exception); @@ -1356,7 +1364,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkWithInvalidDeviceIDThrows) { TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROWithBigDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.LoadNetwork(actualNetwork, "HETERO", @@ -1368,7 +1376,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROWithBigDeviceIDThrows) { TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROAndDeviceIDThrows) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName)) { ASSERT_THROW(ie.LoadNetwork(actualNetwork, CommonTestUtils::DEVICE_HETERO, @@ -1385,7 +1393,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROAndDeviceIDThrows) { TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROwithMULTINoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) { std::string devices; auto availableDevices = ie.GetMetric(deviceName, METRIC_KEY(AVAILABLE_DEVICES)).as>(); @@ -1406,7 +1414,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkHETEROwithMULTINoThrow) { TEST_P(IEClassLoadNetworkTest, LoadNetworkMULTIwithHETERONoThrow) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) { std::string devices; @@ -1431,7 +1439,7 @@ TEST_P(IEClassLoadNetworkTest, LoadNetworkMULTIwithHETERONoThrow) { TEST_P(IEClassLoadNetworkTest, QueryNetworkHETEROWithMULTINoThrow_V10) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) { std::string devices; @@ -1466,7 +1474,7 @@ TEST_P(IEClassLoadNetworkTest, QueryNetworkHETEROWithMULTINoThrow_V10) { TEST_P(IEClassLoadNetworkTest, QueryNetworkMULTIWithHETERONoThrow_V10) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); if (supportsDeviceID(ie, deviceName) && supportsAvaliableDevices(ie, deviceName)) { std::string devices; @@ -1500,7 +1508,7 @@ TEST_P(IEClassLoadNetworkTest, QueryNetworkMULTIWithHETERONoThrow_V10) { TEST_P(IEClassLoadNetworkAfterCoreRecreateTest, LoadAfterRecreateCoresAndPlugins) { SKIP_IF_CURRENT_TEST_IS_DISABLED(); - Core ie; + Core ie = createCoreWithTemplate(); { auto versions = ie.GetVersions(std::string(CommonTestUtils::DEVICE_MULTI) + ":" + deviceName + "," + CommonTestUtils::DEVICE_CPU); ASSERT_EQ(3, versions.size()); @@ -1510,7 +1518,7 @@ TEST_P(IEClassLoadNetworkAfterCoreRecreateTest, LoadAfterRecreateCoresAndPlugins config.insert({"CPU_THREADS_NUM", "3"}); } ASSERT_NO_THROW({ - Core ie; + Core ie = createCoreWithTemplate(); std::string name = actualNetwork.getInputsInfo().begin()->first; actualNetwork.getInputsInfo().at(name)->setPrecision(Precision::U8); auto executableNetwork = ie.LoadNetwork(actualNetwork, deviceName, config); From f1b2983bfa847605c5c6887b8726d58bcd7d22aa Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Thu, 8 Jul 2021 06:47:14 +0300 Subject: [PATCH 09/11] Fixed behavior tests --- .../plugin/shared/src/behavior/cpp_holders.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/inference-engine/tests/functional/plugin/shared/src/behavior/cpp_holders.cpp b/inference-engine/tests/functional/plugin/shared/src/behavior/cpp_holders.cpp index f253ee322bf990..49d955c25f6d1b 100644 --- a/inference-engine/tests/functional/plugin/shared/src/behavior/cpp_holders.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/behavior/cpp_holders.cpp @@ -8,6 +8,13 @@ #include "behavior/cpp_holders.hpp" namespace BehaviorTestsDefinitions { + inline InferenceEngine::Core createCoreWithTemplate() { + InferenceEngine::Core ie; + std::string pluginName = "templatePlugin"; + pluginName += IE_BUILD_POSTFIX; + ie.RegisterPlugin(pluginName, "TEMPLATE"); + return ie; + } std::string HoldersTest::getTestCaseName(testing::TestParamInfo obj) { std::string targetDevice; std::vector order; @@ -47,7 +54,7 @@ namespace BehaviorTestsDefinitions { void release_order_test(std::vector order, const std::string &deviceName, std::shared_ptr function) { InferenceEngine::CNNNetwork cnnNet(function); - InferenceEngine::Core core; + InferenceEngine::Core core = createCoreWithTemplate(); auto exe_net = core.LoadNetwork(cnnNet, deviceName); auto request = exe_net.CreateInferRequest(); std::vector states = {}; @@ -60,7 +67,7 @@ namespace BehaviorTestsDefinitions { auto release = [&](int i) { switch (i) { case 0: - core = InferenceEngine::Core{}; + core = createCoreWithTemplate(); break; case 1: exe_net = {}; @@ -84,7 +91,7 @@ namespace BehaviorTestsDefinitions { std::vector order, const std::string &deviceName, std::shared_ptr function) { InferenceEngine::CNNNetwork cnnNet(function); - InferenceEngine::Core core; + InferenceEngine::Core core = createCoreWithTemplate(); std::stringstream stream; { auto exe_net = core.LoadNetwork(cnnNet, deviceName); @@ -142,7 +149,7 @@ namespace BehaviorTestsDefinitions { TEST_P(HoldersTestOnImportedNetwork, CreateRequestWithCoreRemoved) { InferenceEngine::CNNNetwork cnnNet(function); - InferenceEngine::Core core; + InferenceEngine::Core core = createCoreWithTemplate(); std::stringstream stream; { auto exe_net = core.LoadNetwork(cnnNet, targetDevice); From 6c8e41675c79c2e27a87782b08c82301896d8ed2 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Thu, 8 Jul 2021 06:54:04 +0300 Subject: [PATCH 10/11] Added ticket --- .../cpu/shared_tests_instances/single_layer_tests/convert.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp index a7835740f165b2..e7ac96b6540990 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/convert.cpp @@ -14,16 +14,19 @@ namespace { const std::vector> inShape = {{1, 2, 3, 4}}; const std::vector precisions = { + // Ticket: 59594 // Precision::I4, Precision::I8, Precision::I16, Precision::I32, Precision::I64, + // Ticket: 59594 // Precision::BIN, // Precision::BOOL, // Precision::U4, Precision::U8, Precision::U16, + // Ticket: 59594 // Precision::U32, Precision::U64, Precision::BF16, From ec0dd8eab78431ae4e4ec2d65d859a3fbdbd09c6 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Mon, 12 Jul 2021 07:17:38 +0300 Subject: [PATCH 11/11] Try to avoid fails --- .../ie_test_utils/functional_test_utils/src/plugin_cache.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp b/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp index 48d67e2d2d3260..95c7e18a18115c 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/src/plugin_cache.cpp @@ -50,12 +50,11 @@ std::shared_ptr PluginCache::ie(const std::string &device assert(0 != ie_core.use_count()); // register template plugin if it is needed - const auto& availableDevices = ie_core->GetAvailableDevices(); - if (std::find(availableDevices.begin(), availableDevices.end(), "TEMPLATE") == availableDevices.end()) { + try { std::string pluginName = "templatePlugin"; pluginName += IE_BUILD_POSTFIX; ie_core->RegisterPlugin(pluginName, "TEMPLATE"); - } + } catch (...) {} if (!deviceToCheck.empty()) { std::vector metrics = ie_core->GetMetric(deviceToCheck, METRIC_KEY(SUPPORTED_METRICS));