Guozhong/improve auto infer request line coverage (#15511)

* find test case for MultiDeviceInferRequest::SetBlob

* improve line coverage of infer_request

* add test cases for queryState and exception test case for perf count

* fix querystate running fail

* add test case to memory_states.cpp

* rename name of test case

* add memory_states.cpp to CMakeLists.txt

* Use _LogTag to judge whether MULTI

* clang-format intel_gna/memory_states.cpp

* Modify the position of the macro ENABLE_INTEL_CPU in the test case

---------

Co-authored-by: Chen Peter <peter.chen@intel.com>
This commit is contained in:
guozhong wang 2023-02-28 12:51:37 +08:00 committed by GitHub
parent 45dff75356
commit 913f616964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 140 additions and 81 deletions

View File

@ -91,12 +91,14 @@ void MultiDeviceInferRequest::SetBlob(const std::string& name, const InferenceEn
IInferRequestInternal::SetBlob(name, blob);
}
IE_SUPPRESS_DEPRECATED_START
void MultiDeviceInferRequest::SetBlob(const std::string& name, const Blob::Ptr& blob, const PreProcessInfo& info) {
if (_sharedRequest)
_sharedRequest->SetBlob(name, blob, info);
else
IInferRequestInternal::SetBlob(name, blob, info);
}
IE_SUPPRESS_DEPRECATED_END
InferenceEngine::Blob::Ptr MultiDeviceInferRequest::GetBlob(const std::string& name) {
if (_sharedRequest)
@ -124,8 +126,4 @@ std::vector<std::shared_ptr<InferenceEngine::IVariableStateInternal>> MultiDevic
IE_THROW(NotImplemented);
}
void MultiDeviceInferRequest::InferImpl() {
IE_THROW(NotImplemented);
}
} // namespace MultiDevicePlugin

View File

@ -38,8 +38,11 @@ public:
const InferenceEngine::SoIInferRequestInternal & request_to_share_blobs_with,
InferenceEngine::RemoteContext::Ptr ctx = nullptr);
std::map<std::string, InferenceEngine::InferenceEngineProfileInfo> GetPerformanceCounts() const override;
void InferImpl() override;
void SetBlob(const std::string& name, const InferenceEngine::Blob::Ptr& blob) override;
/**
* @deprecated This method will be removed in 2024.1 release
* @brief Sets blob with a pre-process information
*/
void SetBlob(const std::string& name,
const InferenceEngine::Blob::Ptr& blob,
const InferenceEngine::PreProcessInfo& info) override;

View File

@ -961,7 +961,9 @@ std::vector<DeviceInformation> MultiDeviceInferencePlugin::FilterDeviceByNetwork
});
// If CPU is in candidate list, load dynamic network to CPU first
if ((model->is_dynamic() || isStateful()) && cpuiter != metaDevices.end()) {
// For MULTI do not only load stateful network to CPU
// For AUTO CTPUT only load stateful network to CPU
if ((model->is_dynamic() || (isStateful() && _LogTag != "MULTI")) && cpuiter != metaDevices.end()) {
filterDevice.push_back(*cpuiter);
return filterDevice;
}

View File

@ -70,7 +70,7 @@ private:
std::vector<DeviceInformation> FilterDevice(const std::vector<DeviceInformation>& metaDevices,
const std::map<std::string, std::string>& config);
std::vector<DeviceInformation> FilterDeviceByNetwork(const std::vector<DeviceInformation>& metaDevices,
InferenceEngine::CNNNetwork network);
InferenceEngine::CNNNetwork network);
std::string GetLogTag() const noexcept;
static std::mutex _mtx;
static std::map<unsigned int, std::list<std::string>> _priorityMap;

View File

@ -10,44 +10,37 @@
using namespace BehaviorTestsDefinitions;
namespace {
InferenceEngine::CNNNetwork getNetwork() {
ngraph::Shape shape = {1, 200};
ngraph::element::Type type = ngraph::element::f32;
auto input = std::make_shared<ngraph::op::v0::Parameter>(type, shape);
auto mem_i1 = std::make_shared<ngraph::op::v0::Constant>(type, shape, 0);
auto mem_r1 = std::make_shared<ngraph::op::v3::ReadValue>(mem_i1, "r_1-3");
auto mul1 = std::make_shared<ngraph::op::v1::Multiply>(mem_r1, input);
auto mem_i2 = std::make_shared<ngraph::op::v0::Constant>(type, shape, 0);
auto mem_r2 = std::make_shared<ngraph::op::v3::ReadValue>(mem_i2, "c_1-3");
auto mul2 = std::make_shared<ngraph::op::v1::Multiply>(mem_r2, mul1);
auto mem_w2 = std::make_shared<ngraph::op::v3::Assign>(mul2, "c_1-3");
auto mem_w1 = std::make_shared<ngraph::op::v3::Assign>(mul2, "r_1-3");
auto sigm = std::make_shared<ngraph::op::Sigmoid>(mul2);
sigm->set_friendly_name("sigmod_state");
mem_r1->set_friendly_name("Memory_1");
mem_w1->add_control_dependency(mem_r1);
sigm->add_control_dependency(mem_w1);
mem_r2->set_friendly_name("Memory_2");
mem_w2->add_control_dependency(mem_r2);
sigm->add_control_dependency(mem_w2);
auto function = std::make_shared<ngraph::Function>(ngraph::NodeVector{sigm}, ngraph::ParameterVector{input}, "addOutput");
return InferenceEngine::CNNNetwork{function};
}
std::vector<memoryStateParams> memoryStateTestCases = {
memoryStateParams(getNetwork(), {"c_1-3", "r_1-3"}, CommonTestUtils::DEVICE_CPU, {}),
memoryStateParams(getNetwork(), {"c_1-3", "r_1-3"}, CommonTestUtils::DEVICE_AUTO,
{{MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_CPU}}),
memoryStateParams(getNetwork(), {"c_1-3", "r_1-3"}, CommonTestUtils::DEVICE_HETERO,
{{MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_CPU}})
};
memoryStateParams(InferRequestVariableStateTest::getNetwork(), {"c_1-3", "r_1-3"}, CommonTestUtils::DEVICE_CPU, {}),
memoryStateParams(InferRequestVariableStateTest::getNetwork(),
{"c_1-3", "r_1-3"},
CommonTestUtils::DEVICE_HETERO,
{{MULTI_CONFIG_KEY(DEVICE_PRIORITIES), CommonTestUtils::DEVICE_CPU}})};
INSTANTIATE_TEST_SUITE_P(smoke_VariableStateBasic, InferRequestVariableStateTest,
std::vector<memoryStateParams> memoryStateAutoTestCases = {
memoryStateParams(InferRequestVariableStateTest::getNetwork(),
{"c_1-3", "r_1-3"},
CommonTestUtils::DEVICE_AUTO,
{{MULTI_CONFIG_KEY(DEVICE_PRIORITIES), CommonTestUtils::DEVICE_CPU}})};
std::vector<memoryStateParams> memoryStateMultiTestCases = {
memoryStateParams(InferRequestVariableStateTest::getNetwork(),
{"c_1-3", "r_1-3"},
CommonTestUtils::DEVICE_MULTI,
{{MULTI_CONFIG_KEY(DEVICE_PRIORITIES), CommonTestUtils::DEVICE_CPU}})};
INSTANTIATE_TEST_SUITE_P(smoke_VariableStateBasic,
InferRequestVariableStateTest,
::testing::ValuesIn(memoryStateTestCases),
InferRequestVariableStateTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests,
InferRequestVariableStateTest,
::testing::ValuesIn(memoryStateAutoTestCases),
InferRequestVariableStateTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests,
InferRequestVariableStateTest,
::testing::ValuesIn(memoryStateMultiTestCases),
InferRequestVariableStateTest::getTestCaseName);
} // namespace

View File

@ -12,39 +12,10 @@
using namespace BehaviorTestsDefinitions;
namespace {
InferenceEngine::CNNNetwork getNetwork() {
ngraph::Shape shape = {1, 200};
ngraph::element::Type type = ngraph::element::f32;
auto input = std::make_shared<ngraph::op::v0::Parameter>(type, shape);
auto mem_i1 = std::make_shared<ngraph::op::v0::Constant>(type, shape, 0);
auto mem_r1 = std::make_shared<ngraph::op::v3::ReadValue>(mem_i1, "r_1-3");
auto mul1 = std::make_shared<ngraph::op::v1::Multiply>(mem_r1, input);
auto mem_i2 = std::make_shared<ngraph::op::v0::Constant>(type, shape, 0);
auto mem_r2 = std::make_shared<ngraph::op::v3::ReadValue>(mem_i2, "c_1-3");
auto mul2 = std::make_shared<ngraph::op::v1::Multiply>(mem_r2, mul1);
auto mem_w2 = std::make_shared<ngraph::op::v3::Assign>(mul2, "c_1-3");
auto mem_w1 = std::make_shared<ngraph::op::v3::Assign>(mul2, "r_1-3");
auto sigm = std::make_shared<ngraph::op::Sigmoid>(mul2);
sigm->set_friendly_name("sigmod_state");
mem_r1->set_friendly_name("Memory_1");
mem_w1->add_control_dependency(mem_r1);
sigm->add_control_dependency(mem_w1);
mem_r2->set_friendly_name("Memory_2");
mem_w2->add_control_dependency(mem_r2);
sigm->add_control_dependency(mem_w2);
auto function =
std::make_shared<ngraph::Function>(ngraph::NodeVector{sigm}, ngraph::ParameterVector{input}, "addOutput");
return InferenceEngine::CNNNetwork{function};
}
std::vector<memoryStateParams> memoryStateTestCases = {
memoryStateParams(getNetwork(), {"c_1-3", "r_1-3"}, CommonTestUtils::DEVICE_GNA, {})};
std::vector<memoryStateParams> memoryStateTestCases = {memoryStateParams(InferRequestVariableStateTest::getNetwork(),
{"c_1-3", "r_1-3"},
CommonTestUtils::DEVICE_GNA,
{})};
INSTANTIATE_TEST_SUITE_P(smoke_VariableStateBasic,
InferRequestVariableStateTest,

View File

@ -45,7 +45,9 @@ if (ENABLE_INTEL_CPU)
set_source_files_properties(
"${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/behavior/ov_plugin/life_time.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/behavior/ov_infer_request/perf_counters.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/multi/gpu_remote_blob_tests.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/behavior/infer_request/memory_states.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/behavior/ov_executable_network/exec_net_base.cpp"
PROPERTIES COMPILE_DEFINITIONS ENABLE_INTEL_CPU=1)
endif()

View File

@ -0,0 +1,27 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <common_test_utils/test_constants.hpp>
#include "behavior/infer_request/memory_states.hpp"
#include "functional_test_utils/plugin_cache.hpp"
#include "ngraph_functions/builders.hpp"
using namespace BehaviorTestsDefinitions;
namespace {
std::vector<memoryStateParams> memoryStateTestCases = {
#ifdef ENABLE_INTEL_CPU
memoryStateParams(InferRequestVariableStateTest::getNetwork(),
{"c_1-3", "r_1-3"},
CommonTestUtils::DEVICE_MULTI,
{{MULTI_CONFIG_KEY(DEVICE_PRIORITIES),
CommonTestUtils::DEVICE_GPU + std::string(",") + CommonTestUtils::DEVICE_CPU}})
#endif
};
INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests,
InferRequestQueryStateExceptionTest,
::testing::ValuesIn(memoryStateTestCases),
InferRequestQueryStateExceptionTest::getTestCaseName);
} // namespace

View File

@ -34,12 +34,14 @@ auto configs = []() {
};
auto Multiconfigs = []() {
return std::vector<ov::AnyMap>{{ov::device::priorities(CommonTestUtils::DEVICE_GPU)},
return std::vector<ov::AnyMap>{
{ov::device::priorities(CommonTestUtils::DEVICE_GPU)},
#ifdef ENABLE_INTEL_CPU
{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU),
ov::intel_auto::device_bind_buffer(false)},
{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU),
ov::intel_auto::device_bind_buffer(true)}
{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU), ov::enable_profiling(true)},
{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU),
ov::intel_auto::device_bind_buffer(false)},
{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU),
ov::intel_auto::device_bind_buffer(true)}
#endif
};
};
@ -85,4 +87,19 @@ INSTANTIATE_TEST_SUITE_P(smoke_AutoBatch_BehaviorTests, OVInferRequestPerfCounte
::testing::Values(CommonTestUtils::DEVICE_BATCH),
::testing::ValuesIn(AutoBatchConfigs())),
OVInferRequestPerfCountersTest::getTestCaseName);
auto MulticonfigsTest = []() {
return std::vector<ov::AnyMap>{
#ifdef ENABLE_INTEL_CPU
{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU),
ov::device::priorities(CommonTestUtils::DEVICE_CPU, CommonTestUtils::DEVICE_GPU)}
#endif
};
};
INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests,
OVInferRequestPerfCountersExceptionTest,
::testing::Combine(::testing::Values(CommonTestUtils::DEVICE_MULTI),
::testing::ValuesIn(MulticonfigsTest())),
OVInferRequestPerfCountersExceptionTest::getTestCaseName);
} // namespace

View File

@ -28,5 +28,8 @@ protected:
public:
void SetUp() override;
static std::string getTestCaseName(const testing::TestParamInfo<memoryStateParams> &obj);
static InferenceEngine::CNNNetwork getNetwork();
};
using InferRequestQueryStateExceptionTest = InferRequestVariableStateTest;
} // namespace BehaviorTestsDefinitions

View File

@ -14,6 +14,7 @@ struct OVInferRequestPerfCountersTest : public virtual OVInferRequestTests {
void SetUp() override;
ov::InferRequest req;
};
using OVInferRequestPerfCountersExceptionTest = OVInferRequestPerfCountersTest;
} // namespace behavior
} // namespace test
} // namespace ov

View File

@ -31,6 +31,36 @@ void InferRequestVariableStateTest::SetUp() {
IEInferRequestTestBase::SetUp();
}
InferenceEngine::CNNNetwork InferRequestVariableStateTest::getNetwork() {
ngraph::Shape shape = {1, 200};
ngraph::element::Type type = ngraph::element::f32;
auto input = std::make_shared<ngraph::op::v0::Parameter>(type, shape);
auto mem_i1 = std::make_shared<ngraph::op::v0::Constant>(type, shape, 0);
auto mem_r1 = std::make_shared<ngraph::op::v3::ReadValue>(mem_i1, "r_1-3");
auto mul1 = std::make_shared<ngraph::op::v1::Multiply>(mem_r1, input);
auto mem_i2 = std::make_shared<ngraph::op::v0::Constant>(type, shape, 0);
auto mem_r2 = std::make_shared<ngraph::op::v3::ReadValue>(mem_i2, "c_1-3");
auto mul2 = std::make_shared<ngraph::op::v1::Multiply>(mem_r2, mul1);
auto mem_w2 = std::make_shared<ngraph::op::v3::Assign>(mul2, "c_1-3");
auto mem_w1 = std::make_shared<ngraph::op::v3::Assign>(mul2, "r_1-3");
auto sigm = std::make_shared<ngraph::op::Sigmoid>(mul2);
sigm->set_friendly_name("sigmod_state");
mem_r1->set_friendly_name("Memory_1");
mem_w1->add_control_dependency(mem_r1);
sigm->add_control_dependency(mem_w1);
mem_r2->set_friendly_name("Memory_2");
mem_w2->add_control_dependency(mem_r2);
sigm->add_control_dependency(mem_w2);
auto function =
std::make_shared<ngraph::Function>(ngraph::NodeVector{sigm}, ngraph::ParameterVector{input}, "addOutput");
return InferenceEngine::CNNNetwork{function};
}
InferenceEngine::ExecutableNetwork InferRequestVariableStateTest::PrepareNetwork() {
net.addOutput("Memory_1");
net.addOutput("Memory_2");
@ -249,4 +279,11 @@ TEST_P(InferRequestVariableStateTest, inferreq_smoke_VariableState_2infers) {
}
}
}
TEST_P(InferRequestQueryStateExceptionTest, inferreq_smoke_QueryState_ExceptionTest) {
auto executableNet = PrepareNetwork();
auto inferReq = executableNet.CreateInferRequest();
EXPECT_ANY_THROW(inferReq.QueryState());
}
} // namespace BehaviorTestsDefinitions

View File

@ -33,6 +33,11 @@ TEST_P(OVInferRequestPerfCountersTest, NotEmptyAfterSyncInfer) {
OV_ASSERT_NO_THROW(perf = req.get_profiling_info());
ASSERT_FALSE(perf.empty());
}
TEST_P(OVInferRequestPerfCountersExceptionTest, perfCountWereNotEnabledExceptionTest) {
EXPECT_ANY_THROW(req.get_profiling_info());
}
} // namespace behavior
} // namespace test
} // namespace ov