diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/inc/IWinmlExecutionProvider.h b/onnxruntime/core/providers/dml/DmlExecutionProvider/inc/IWinmlExecutionProvider.h index 88e3dd487d427..40958904f38b4 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/inc/IWinmlExecutionProvider.h +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/inc/IWinmlExecutionProvider.h @@ -65,10 +65,6 @@ namespace Windows::AI::MachineLearning::Adapter bool isBeforeOp, uint32_t resourceCount, IUnknown** resources) = 0; - - // 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. - virtual void Close() = 0; }; using MLOperatorTensorGetter = std::function, std::vector>>(uint32_t index)>; diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.cpp index 9c01df13741e1..109271c755487 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.cpp @@ -43,14 +43,6 @@ namespace Dml { using namespace onnxruntime::common; - ExecutionProvider::~ExecutionProvider() - { - if (m_impl) - { - m_impl->Close(); - } - } - static void CreateDmlKernelRegistry( _Out_ std::shared_ptr* registry, _Out_ std::shared_ptr* internalRegInfoMap) @@ -101,7 +93,7 @@ namespace Dml #endif } - void ExecutionProviderImpl::Close() + ExecutionProviderImpl::~ExecutionProviderImpl() { // Release the cached command list references before closing the context m_capturedGraphs.clear(); diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.h b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.h index c20969250fe84..8f4a101d14728 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.h +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/ExecutionProvider.h @@ -40,6 +40,8 @@ namespace Dml bool enableCpuSyncSpinning, bool disableMemoryArena); + virtual ~ExecutionProviderImpl(); + void ReleaseCompletedReferences(); public: // implements Dml::IExecutionProvider @@ -130,10 +132,6 @@ namespace Dml STDMETHOD_(D3D12_COMMAND_LIST_TYPE, GetCommandListTypeForQueue)() const override; STDMETHOD_(void, Flush)() const override; - // 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. @@ -253,7 +251,7 @@ namespace Dml class ExecutionProvider : public onnxruntime::IExecutionProvider { public: - virtual ~ExecutionProvider(); + virtual ~ExecutionProvider() = default; ExecutionProvider() = delete; explicit ExecutionProvider(