Open Hopobcn opened 4 days ago
Is this something that needs to be a long-term part of the Execution Provider API, or something that you can temporarily add locally for this sort of testing?
For the use case i'm presenting I agree that this could be implemented as an optional behavior tied to whether profiling/tracing is enabled. However, I believe that providing such a notification (e.g., OnSessionEnd) would serve a broader purpose beyond just my immediate use case. It would give Execution Providers a chance to perform optional cleanup or synchronization tasks when the session is being destroyed, which can be valuable in other scenarios as well.
In my case, this mechanism would allow the Execution Provider to finalize its profiling traces properly, ensuring they include all relevant events (such as memory deallocation) that occur during the destruction of InferenceSession. Without this notification, some important cleanup or finalization steps might be performed outside of the tracing scope giving a sensation of leaking resources.
By making OnSessionEnd part of the API but keeping its implementation optional, Execution Providers that do not need this feature could simply rely on the default no-op implementation. This would ensure backward compatibility while allowing providers that need it to implement this functionality.
Describe the feature request
I am implementing profiling for a new Execution Provider, this new provider traces contain information about the memory allocations/deallocaitons performed in the accelerator (among other events). Problem is, due current destruction ordering in
InferenceSession::~InferenceSession()
the tracing session may be ended before 1) sessionstate is wiped and 2) execution providers are destroyed. This proposal would address (2).Currently, Execution Providers have no opportunity to get notified that the session will finish to perform cleanup before profiling session finishes.
Would it be acceptable to add
to
IExecutionProvider
and refactor
~InferenceSession()
destructor accordingly?I can contribute with the change if necessary.
Describe scenario use case
Improve information contained in traces by informing ExecutionProviders that the session will end, letting them perform optional cleanups before the tracing session ends.