mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
Spawn child process to run DeviceLostRecovery scenario test (#2530)
* Spawn child process to run DeviceLostRecovery scenario test
This commit is contained in:
parent
c615002f5d
commit
3afb7a89fe
1 changed files with 45 additions and 33 deletions
|
|
@ -66,6 +66,7 @@ protected:
|
|||
GPUTEST
|
||||
}
|
||||
};
|
||||
using ScenarioCppWinrtGpuTestDeathTest = ScenarioCppWinrtGpuTest;
|
||||
|
||||
class ScenarioCppWinrtGpuSkipEdgeCoreTest : public ScenarioCppWinrtTest
|
||||
{
|
||||
|
|
@ -1442,44 +1443,55 @@ TEST_F(ScenarioCppWinrtTest, EncryptedStream)
|
|||
EXPECT_NO_THROW(session = LearningModelSession(model));
|
||||
}
|
||||
|
||||
TEST_F(ScenarioCppWinrtGpuTest, DeviceLostRecovery)
|
||||
void DeviceLostRecoveryHelper()
|
||||
{
|
||||
// load a model
|
||||
std::wstring filePath = FileHelpers::GetModulePath() + L"model.onnx";
|
||||
LearningModel model = LearningModel::LoadFromFilePath(filePath);
|
||||
// create a session on the DirectX device
|
||||
LearningModelSession session(model, LearningModelDevice(LearningModelDeviceKind::DirectX));
|
||||
// create a binding set
|
||||
LearningModelBinding binding(session);
|
||||
// bind the inputs
|
||||
BindFeatures(binding, model.InputFeatures());
|
||||
// load a model
|
||||
std::wstring filePath = FileHelpers::GetModulePath() + L"model.onnx";
|
||||
LearningModel model = LearningModel::LoadFromFilePath(filePath);
|
||||
// create a session on the DirectX device
|
||||
LearningModelSession session(model, LearningModelDevice(LearningModelDeviceKind::DirectX));
|
||||
// create a binding set
|
||||
LearningModelBinding binding(session);
|
||||
// bind the inputs
|
||||
BindFeatures(binding, model.InputFeatures());
|
||||
|
||||
// force device lost here
|
||||
{
|
||||
winrt::com_ptr<ID3D12Device5> d3d12Device;
|
||||
D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_0, __uuidof(ID3D12Device5), d3d12Device.put_void());
|
||||
d3d12Device->RemoveDevice();
|
||||
}
|
||||
// force device lost here
|
||||
{
|
||||
winrt::com_ptr<ID3D12Device5> d3d12Device;
|
||||
D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_0, __uuidof(ID3D12Device5), d3d12Device.put_void());
|
||||
d3d12Device->RemoveDevice();
|
||||
}
|
||||
|
||||
// evaluate should fail
|
||||
try
|
||||
{
|
||||
session.Evaluate(binding, L"");
|
||||
FAIL() << "Evaluate should fail after removing the device";
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
// evaluate should fail
|
||||
try
|
||||
{
|
||||
session.Evaluate(binding, L"");
|
||||
FAIL() << "Evaluate should fail after removing the device";
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
// remove all references to the device by reseting the session and binding.
|
||||
session = nullptr;
|
||||
binding = nullptr;
|
||||
// remove all references to the device by reseting the session and binding.
|
||||
session = nullptr;
|
||||
binding = nullptr;
|
||||
|
||||
// create new session and binding and try again!
|
||||
EXPECT_NO_THROW(session = LearningModelSession(model, LearningModelDevice(LearningModelDeviceKind::DirectX)));
|
||||
EXPECT_NO_THROW(binding = LearningModelBinding(session));
|
||||
BindFeatures(binding, model.InputFeatures());
|
||||
EXPECT_NO_THROW(session.Evaluate(binding, L""));
|
||||
// create new session and binding and try again!
|
||||
session = LearningModelSession(model, LearningModelDevice(LearningModelDeviceKind::DirectX));
|
||||
binding = LearningModelBinding(session);
|
||||
BindFeatures(binding, model.InputFeatures());
|
||||
session.Evaluate(binding, L"");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
TEST_F(ScenarioCppWinrtGpuTestDeathTest, DeviceLostRecovery) {
|
||||
|
||||
::testing::FLAGS_gtest_death_test_style = "threadsafe";
|
||||
EXPECT_EXIT(
|
||||
DeviceLostRecoveryHelper(),
|
||||
::testing::ExitedWithCode(0),
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
TEST_F(ScenarioCppWinrtGpuSkipEdgeCoreTest, D2DInterop)
|
||||
|
|
|
|||
Loading…
Reference in a new issue