[AUTO] Fix segment fault appeared in the compiled model.get_property() of AUTO (#20777)
* disable CPU_HELP context if it released. * Enable test case. * Updated. * Updated. * Updated.
This commit is contained in:
1 parent
afc599563e
commit
859319e2a5
3 files changed
+131
-2
No files matched your search
@@ -264,8 +264,9 @@ ov::Any AutoCompiledModel::get_property(const std::string& name) const {
|
||||
return m_scheduler->m_compile_context[ACTUALDEVICE].
|
||||
m_compiled_model->get_property(name).as<bool>();
|
||||
} else {
|
||||
OPENVINO_ASSERT(m_scheduler->m_compile_context[CPU].m_is_already == true);
|
||||
std::lock_guard<std::mutex> lock(m_context->m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_context->m_mutex);
|
||||
OPENVINO_ASSERT(m_scheduler->m_compile_context[CPU].m_is_already == true &&
|
||||
m_scheduler->m_compile_context[CPU].m_compiled_model._ptr);
|
||||
return m_scheduler->m_compile_context[CPU].
|
||||
m_compiled_model->get_property(name).as<bool>();
|
||||
}
|
||||
|
||||
@@ -231,6 +231,7 @@ void AutoSchedule::init() {
|
||||
m_worker_requests["CPU_HELP"].clear();
|
||||
m_compile_context[CPU].m_compiled_model._ptr.reset();
|
||||
m_compile_context[CPU].m_compiled_model._so.reset();
|
||||
m_compile_context[CPU].m_is_already = false;
|
||||
LOG_INFO_TAG("helper released!!");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,124 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
using PropertyConfigParams = std::tuple<bool, // if CPU device sleep
|
||||
bool // if actual device sleep
|
||||
>;
|
||||
class AutoCompiledModelGetPropertyWithReleaseHelper : public tests::AutoTest,
|
||||
public ::testing::TestWithParam<PropertyConfigParams> {
|
||||
public:
|
||||
static std::string getTestCaseName(testing::TestParamInfo<PropertyConfigParams> obj) {
|
||||
bool cpuSleep;
|
||||
bool actSleep;
|
||||
std::tie(cpuSleep, actSleep) = obj.param;
|
||||
std::ostringstream result;
|
||||
if (cpuSleep) {
|
||||
result << "cpuHelper_sleep_Yes_";
|
||||
} else {
|
||||
result << "cpuHelper_sleep_No_";
|
||||
}
|
||||
|
||||
if (actSleep) {
|
||||
result << "actDevice_sleep_Yes_";
|
||||
} else {
|
||||
result << "actDevice_sleep_No_";
|
||||
}
|
||||
|
||||
return result.str();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(AutoCompiledModelGetPropertyWithReleaseHelper, getPropertyTestAfterReleaseResourceNoThrow) {
|
||||
// get Parameter
|
||||
bool cpuSleep;
|
||||
bool actSleep;
|
||||
std::tie(cpuSleep, actSleep) = this->GetParam();
|
||||
// test auto plugin
|
||||
plugin->set_device_name("AUTO");
|
||||
const std::string strDevices = ov::test::utils::DEVICE_GPU + std::string(",") + ov::test::utils::DEVICE_CPU;
|
||||
std::string modelNameCpu = "Text model name for CPU";
|
||||
std::string modelNameActual = "Text model name for actual device";
|
||||
|
||||
ON_CALL(*mockIExeNet.get(), get_property(StrEq(ov::model_name.name())))
|
||||
.WillByDefault(Return(ov::Any(modelNameCpu)));
|
||||
ON_CALL(*mockIExeNetActual.get(), get_property(StrEq(ov::model_name.name())))
|
||||
.WillByDefault(Return(ov::Any(modelNameActual)));
|
||||
|
||||
ON_CALL(*mockIExeNetActual.get(), get_property(StrEq(ov::loaded_from_cache.name())))
|
||||
.WillByDefault(Return(ov::Any(false)));
|
||||
ON_CALL(*mockIExeNet.get(), get_property(StrEq(ov::loaded_from_cache.name())))
|
||||
.WillByDefault(Return(ov::Any(false)));
|
||||
|
||||
if (actSleep) {
|
||||
ON_CALL(*core,
|
||||
compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),
|
||||
::testing::Matcher<const std::string&>(StrEq(ov::test::utils::DEVICE_GPU)),
|
||||
_))
|
||||
.WillByDefault(InvokeWithoutArgs([this]() {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||||
return mockExeNetworkActual;
|
||||
}));
|
||||
} else {
|
||||
ON_CALL(*core,
|
||||
compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),
|
||||
::testing::Matcher<const std::string&>(StrEq(ov::test::utils::DEVICE_GPU)),
|
||||
_))
|
||||
.WillByDefault(InvokeWithoutArgs([this]() {
|
||||
return mockExeNetworkActual;
|
||||
}));
|
||||
}
|
||||
if (cpuSleep) {
|
||||
ON_CALL(*core,
|
||||
compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),
|
||||
::testing::Matcher<const std::string&>(StrEq(ov::test::utils::DEVICE_CPU)),
|
||||
_))
|
||||
.WillByDefault(InvokeWithoutArgs([this]() {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||||
return mockExeNetwork;
|
||||
}));
|
||||
} else {
|
||||
ON_CALL(*core,
|
||||
compile_model(::testing::Matcher<const std::shared_ptr<const ov::Model>&>(_),
|
||||
::testing::Matcher<const std::string&>(StrEq(ov::test::utils::DEVICE_CPU)),
|
||||
_))
|
||||
.WillByDefault(InvokeWithoutArgs([this]() {
|
||||
return mockExeNetwork;
|
||||
}));
|
||||
}
|
||||
metaDevices = {{ov::test::utils::DEVICE_CPU, {}, -1}, {ov::test::utils::DEVICE_GPU, {}, -1}};
|
||||
DeviceInformation devInfo;
|
||||
ON_CALL(*plugin, parse_meta_devices(_, _)).WillByDefault(Return(metaDevices));
|
||||
ON_CALL(*plugin, get_valid_device)
|
||||
.WillByDefault([](const std::vector<DeviceInformation>& metaDevices, const std::string& netPrecision) {
|
||||
std::list<DeviceInformation> devices(metaDevices.begin(), metaDevices.end());
|
||||
return devices;
|
||||
});
|
||||
ON_CALL(*plugin, select_device(Property(&std::vector<DeviceInformation>::size, Eq(2)), _, _))
|
||||
.WillByDefault(Return(metaDevices[1]));
|
||||
ON_CALL(*plugin, select_device(Property(&std::vector<DeviceInformation>::size, Eq(1)), _, _))
|
||||
.WillByDefault(Return(metaDevices[0]));
|
||||
config.insert(ov::device::priorities(ov::test::utils::DEVICE_CPU + std::string(",") + ov::test::utils::DEVICE_GPU));
|
||||
std::shared_ptr<ov::ICompiledModel> exeNetwork;
|
||||
std::string result;
|
||||
ASSERT_NO_THROW(exeNetwork = plugin->compile_model(model, config));
|
||||
if (actSleep) {
|
||||
if (!cpuSleep) {
|
||||
ASSERT_NO_THROW(result = exeNetwork->get_property(ov::model_name.name()).as<std::string>());
|
||||
EXPECT_EQ(result, modelNameCpu);
|
||||
}
|
||||
} else {
|
||||
ASSERT_NO_THROW(result = exeNetwork->get_property(ov::model_name.name()).as<std::string>());
|
||||
}
|
||||
|
||||
auto supported_config_keys =
|
||||
exeNetwork->get_property(ov::supported_properties.name()).as<std::vector<ov::PropertyName>>();
|
||||
for (const auto& cfg : supported_config_keys) {
|
||||
if (cfg == ov::model_name)
|
||||
continue;
|
||||
ASSERT_NO_THROW(exeNetwork->get_property(cfg).as<std::string>());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(AutoReleaseHelperTest, releaseResource) {
|
||||
// get Parameter
|
||||
bool cpuSuccess;
|
||||
@@ -128,3 +246,12 @@ INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests,
|
||||
AutoReleaseHelperTest,
|
||||
::testing::ValuesIn(testConfigs),
|
||||
AutoReleaseHelperTest::getTestCaseName);
|
||||
|
||||
const std::vector<ConfigParams> testReleaseConfigs = {ConfigParams{false, true},
|
||||
ConfigParams{false, false},
|
||||
ConfigParams{true, false}};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests,
|
||||
AutoCompiledModelGetPropertyWithReleaseHelper,
|
||||
::testing::ValuesIn(testReleaseConfigs),
|
||||
AutoCompiledModelGetPropertyWithReleaseHelper::getTestCaseName);
|
||||
Reference in new issue
Block a user