-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add getter/setter of C# OrtEnv log level #13402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| * | ||
| * \since Version 1.13. | ||
| */ | ||
| ORT_API2_STATUS(UpdateEnvWithCustomLogLevel, OrtLoggingLevel log_severity_level, _In_ const OrtEnv* ort_env); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't really have OrtEnv passed as const when you've an API to update it :-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing out! That has been fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add C++ API so users do not have to go to C back and forth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++ API has been added in latest commit as well. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One important thing to mention is thread-safety. Typically, we do not update the environment after the creation and any thread or even multiple sessions can use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One important thing to mention is thread-safety. Typically, we do not update the environment after the creation and any thread or even multiple sessions can use it.
Really appreciate the context you shared. The reason adding this env_update feature is this feature exists in Pybind but missing in c# binding, and we would like to unify the user experience and provide the ability to adjust default logger
This feature reuses the existing design in Pybind:set_default_logger_severity. Do you have any suggestions in order to improve this design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. One thing to note, we usually pass the object ptr as a first argument, as you can see in other examples. Please, adjust.
| public IntPtr ReleaseKernelInfo; | ||
|
|
||
| public IntPtr GetTrainingApi; | ||
| public IntPtr SessionOptionsAppendExecutionProvider_CANN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these CANN related declarations expected to be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public LogLevel GetLogLevel() | ||
| { | ||
| return currentLogLevel; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is really needed, it should be a property. And you can then combine set/get #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sharing! This has been improved in the latest commit and verified in test case.
yuslepukhin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
| API_IMPL_BEGIN | ||
| LoggingManager* default_logging_manager = ort_env->GetLoggingManager(); | ||
| int severity_level = static_cast<int>(log_severity_level); | ||
| default_logging_manager->SetDefaultLoggerSeverity(static_cast<logging::Severity>(severity_level)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yuslepukhin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
### Description * Add getter/setter to access and update C# OrtEnv log level * Add C API about updating ort env with custom log level to support the setter above (Following [pybind implementation](https://github.com/microsoft/onnxruntime/blob/952c99304a764328070ac6c07f510deec06dedf4/onnxruntime/python/onnxruntime_pybind_state.cc#L923-L924)) * Add test case to verify getter & setter ### Motivation and Context * For C++/Python, the log level can be adjusted via OrtEnv, and this feature is missing in C# binding
Description
Motivation and Context