-
Notifications
You must be signed in to change notification settings - Fork 603
[1/N] Add BackendOptions class #11389
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
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/11389
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 8c35e52 with merge base 222d9e3 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) ghstack-source-id: 288273758 Pull Request resolved: #11389
This pull request was exported from Phabricator. Differential Revision: D75993712 |
This PR needs a
|
Previous comment in the old PR: #11288 From @JacobSzwejbka :
|
From @mergennachin:
|
My response:
|
I think what @mergennachin suggested makes sense. If user code is setting backend specific option they already have to know what backend they are talking about, unless some options are backend agnostic. Other piece of the puzzle is how the user will update this. And from #10216 it seems that we will pipe |
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D75993712 |
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D75993712 |
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) [ghstack-poisoned]
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D75993712 |
New comments are addressed, let me know your thoughts |
* @return Error::Ok on success, Error::InvalidArgument if storage is full | ||
*/ | ||
template <size_t N> | ||
Error set_option(const char (&key)[N], bool value) noexcept { |
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.
Do we need N? It will just create N different methods for many possible lengths. My suggestion is to remove N as template param and expect callsites to be something like
char my_option_name[kMaxOptionKeyLength] = "use_gpu";
...set_option(my_option_name, True)
// Create a fixed-size array and copy the string | ||
std::array<char, kMaxOptionValueLength> arr; | ||
strncpy(arr.data(), value, kMaxOptionValueLength - 1); | ||
arr[kMaxOptionValueLength - 1] = '\0'; // Ensure null termination |
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.
Using the suggestion I mentioned above will also not require you to do this. ALthough its not a bit deal
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.
Looks good. I still think we should not need N or KeyLen template params. So I would suggest to fix that.
I remove the template N, given that it might generate too many code and causing too much size regression. However the cost is that the key length check is runtime instead of compile time, which I think maybe fine |
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D75993712 |
There shouldnt be any key lengths check really though? Your fn would be |
runtime/backend/options.h
Outdated
* @return Error::Ok on success, Error::InvalidArgument if storage is full | ||
*/ | ||
Error set_option(const char* key, bool value) noexcept { | ||
ET_CHECK_MSG( |
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.
See my comment. I didt mean this
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D75993712 |
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712) [ghstack-poisoned]
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712) [ghstack-poisoned]
Discuss offline with @kimishpatel and experiement with |
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D75993712 |
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712) [ghstack-poisoned]
Introduce backend option as discussed in #10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/) Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D75993712 |
aebf93d
into
gh/cccclai/21/base
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #11389 by @cccclai ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/cccclai/21/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/cccclai/21/head Merge bot PR base: https://github.com/pytorch/executorch/tree/main Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/cccclai/21/orig @diff-train-skip-merge Co-authored-by: Chen Lai <[email protected]>
Pull Request resolved: pytorch/executorch#11389 Introduce backend option as discussed in pytorch/executorch#10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. ghstack-source-id: 290059228 Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/)
Pull Request resolved: pytorch/executorch#11389 Introduce backend option as discussed in pytorch/executorch#10216 Step 1: Introducd Backend Option class In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int. ghstack-source-id: 290059228 Differential Revision: [D75993712](https://our.internmc.facebook.com/intern/diff/D75993712/)
Stack from ghstack (oldest at bottom):
Introduce backend option as discussed in #10216
Step 1: Introducd Backend Option class
In later stage, it will be plugged in with the rest of the stack. BackendOptions is pretty much a list of BackendOption, and backend option is a key value pair. The key is a string, and the value can be 3 different types, including bool, string and int.
Differential Revision: D75993712
Differential Revision: D75993712