Conversation
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.
a883739 to
3280697
Compare
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 7 pipeline(s). |
|
Is it better to add an end profiling function in the C API? |
|
@snnn There is also no way to call I also think this implicit EndProfiling covers the vast majority of use-cases. And allowing explicit control of the profiling state would necessitate larger changes in the C API (removing the profiling option and introducing new functions). So all in all I think this is fine as is. |
|
Destructor shouldn't do any file io, including closing file. |
|
|
Because destructor can't report error. |
|
True, but in this case an error is unlikely and logging would suffice IMO. It would be good to catch exceptions in the desrtuctor though. I'll update the pull request. |
|
Alright, I catch the (unlikely) exception now and log it. I also added a TODO that this is not optimal and maybe the C API should be refactored, so that profiling can be started and stopped explicitly. But this pull request takes profiling via the C API from completetly broken to working as expected in most cases. |
RyanUnderhill
left a comment
There was a problem hiding this comment.
Yeah, I think this is a good compromise for now.
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.