mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Fix profiling with C API (#710)
Currently, when using OrtEnableProfiling to enable profiling using the C API, the profile output file is created but is always empty. The reason is that InferenceSession::EndProfiling() needs to be called to write the profiling data to the output file. However there's currently no way to call this function via the C API. This adds a call to EndProfiling() to the descructor of the session if profiling is enabled in the session options.
This commit is contained in:
parent
c35d9797d7
commit
2674d9bd8a
1 changed files with 16 additions and 1 deletions
|
|
@ -191,7 +191,22 @@ InferenceSession::InferenceSession(const SessionOptions& session_options, loggin
|
|||
}
|
||||
}
|
||||
|
||||
InferenceSession::~InferenceSession() = default;
|
||||
InferenceSession::~InferenceSession() {
|
||||
if (session_options_.enable_profiling) {
|
||||
try {
|
||||
EndProfiling();
|
||||
} catch (std::exception& e) {
|
||||
// TODO: Currently we have no way to transport this error to the API user
|
||||
// Maybe this should be refactored, so that profiling must be explicitly
|
||||
// started and stopped via C-API functions.
|
||||
// And not like now a session option and therefore profiling must be started
|
||||
// and stopped implicitly.
|
||||
LOGS(*session_logger_, ERROR) << "Error during EndProfiling(): " << e.what();
|
||||
} catch (...) {
|
||||
LOGS(*session_logger_, ERROR) << "Unknown error during EndProfiling()";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
common::Status InferenceSession::RegisterExecutionProvider(std::unique_ptr<IExecutionProvider> p_exec_provider) {
|
||||
if (p_exec_provider == nullptr) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue