-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add a generic collection of session configurations to the SessionOptions #4718
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
|
|
||
| typedef enum OrtSessionConfigKey { | ||
| ORT_SESSION_CONFIG_MAXIMUM, // Always leave this as the last value | ||
| } OrtSessionConfigKey; |
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.
Since I don't have any EP setting to add here anymore, so I will leave this as a stub
Maybe we want to add a header file for this enum with clear naming convention and string format for each config
#WontFix
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.
Should we call this OrtSessionOptionKey? Adding a new vocab might confuse folks. #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.
Could go either way on this.
We have SessionOptions and we're adding essentially a collection of key:value pairs to that (so a collection within a collection).
We somewhat hide the session options in parts of the API (e.g. it's SetSessionLogId not SetSessionOptionX although the parameter is a SessionOptions instance) but make it obvious in others (CloneSessionOptions).
Due to that, OrtSessionOptionKey could potentially be confused as something to set any 'key' in SessionOptions.
Possibly the clearest is OrtSessionOptionsConfigKey.
In reply to: 466683249 [](ancestors = 466683249)
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.
|
|
||
| typedef enum OrtSessionConfigKey { | ||
| ORT_SESSION_CONFIG_MAXIMUM, // Always leave this as the last value | ||
| } OrtSessionConfigKey; |
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.
Should we call this OrtSessionOptionKey? Adding a new vocab might confuse folks. #Resolved
| * \param config_key An enum as the key of the configuration | ||
| * \param config_value A null terminated string representation of the config value | ||
| */ | ||
| ORT_API2_STATUS(SetSessionConfiguration, _Inout_ OrtSessionOptions* options, |
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.
Should we call this AddSessionOption()? With the enum change from OrtSessionConfigKey -> OrtSessionOptionKey, this would be clearer. And config_value can be option_value. #Resolved
| * \param config_value A null terminated string representation of the config value | ||
| */ | ||
| ORT_API2_STATUS(SetSessionConfiguration, _Inout_ OrtSessionOptions* options, | ||
| _In_ OrtSessionConfigKey config_key, _In_ const char* config_value); |
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.
Should we allow users to set existing session options as well using this method? #WontFix
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.
We'd have to implement logic to handle converting the string to the correct type including error checking for all options. I think it would also be confusing to have two different ways to set one value in SessionOptions in the API.
In reply to: 466694258 [](ancestors = 466694258)
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 wanted to convert logid (which is a good candidate to use the map<enum, string>) into the the map, but it is used in too many places
In reply to: 466726344 [](ancestors = 466726344,466694258)
|
C# SessionOptions class needs update as does python API #Resolved |
|
This will be updated once the c/cxx api is settled In reply to: 670235316 [](ancestors = 670235316) |
|
|
||
| // Key for disable MatMul PrePacking, | ||
| // if the config value is set to "1" then the prepacking is disabled, otherwise prepacking is enabled | ||
| constexpr const char* kDisablePrePacking = "Math.MatMul.DisablePrePacking"; |
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.
This is probably not the best place for these keys, any suggestion?
#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.
I'd be tempted to have them under include/onnxruntime/core/common.
We should have some naming guidelines. I'd prefer an 'area' first - like 'op' for operators. Having Math and MatMul seems unnecessary (also I didn't think pre-packing would be limited to a specific operator, and that we would enable it more globally as that's what happens in SessionState currently).
In reply to: 469027840 [](ancestors = 469027840)
| #endif | ||
|
|
||
| #pragma region Session_Options_Configs | ||
|
|
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.
Keep these config definitions here for now.
When we have more configs defined, we can move them into a separated head file
#Closed
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.
nit: Would prefer a separate header file now. We can put the strings in an appropriate namespace like onnxruntime::config_keys, and it won't break user's builds later when we move it. #Resolved
| inline std::string ToWideString(const std::string& s) { return s; } | ||
| #endif | ||
|
|
||
| // Naming Convention for a Session Options Config Key |
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.
How will the C API users discover these keys? This is a C++ file and won't be shipped as part of our packages. I suggest either (1) creating a separate file called session_options_config_keys.h and including it from the top level c_api.h or (2) adding the keys directly in c_api.h. I prefer 1 as it's a bit cleaner. #Resolved
|
|
||
| // Key for disable PrePacking, | ||
| // If the config value is set to "1" then the prepacking is disabled, otherwise prepacking is enabled (default value) | ||
| #define ORT_SESSION_OPTIONS_CONFIG_DISABLEPREPACKING "session_state.disable_prepacking" No newline at end of file |
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.
Since this is pure c api, changed to use macro instead of const char*
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.
Didn't follow this. What was wrong with const char*?
skottmckay
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 generic configurations for session options
Motivation and Context
Right now in order to change some setting within an inference sessions, we will need to either
This proposal is to add a single function OrtApis::SetSessionConfiguration to add different configurations for the inference session