Added OnRunEnd and Sync method in ExecutionProvider (#10362)

Co-authored-by: Sumit Agarwal <sumitagarwal@microsoft.com>
This commit is contained in:
sumitsays 2022-01-25 13:00:44 -08:00 committed by GitHub
parent df16c605e8
commit e1012a8662
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View file

@ -97,6 +97,12 @@ namespace Dml
{
m_context->Close();
}
void ExecutionProviderImpl::WaitForOutstandingWork()
{
Flush();
m_context->GetCurrentCompletionEvent().WaitForSignal();
}
HRESULT __stdcall ExecutionProviderImpl::AllocatePooledResource(
size_t size,

View file

@ -130,6 +130,8 @@ namespace Dml
// Waits for flushed work, discards unflushed work, and discards associated references to
// prevent circular references. Must be the last call on the object before destruction.
void Close() override;
void WaitForOutstandingWork();
// Allocate a resource from pools. Releasing pooledResource returns it to the pool.
STDMETHOD(AllocatePooledResource)(
@ -249,6 +251,22 @@ namespace Dml
return m_impl->OnSessionInitializationEnd();
}
virtual onnxruntime::Status Sync() const final override
{
// Completely wait until the device has completed all preceding tasks.
// The application could have called SynchronizeBoundOutputs().
m_impl->WaitForOutstandingWork();
return Status::OK();
}
virtual onnxruntime::Status OnRunEnd(bool /*sync_stream*/) final override
{
// Flush any pending work to the GPU, but don't block for completion, permitting it
// to overlap other work.
m_impl->Flush();
return Status::OK();
}
void Flush()
{
return m_impl->Flush();