Skip to content

Commit ac2039d

Browse files
committed
Update on "[5.1/ N] set_option/get_option API with {backend_name, backend options} only"
This PR only expose the set_option/get_option API via the pair {backend_name, backend_options}, without necessarily backend options map. The backend options map and it's corresponding API will be exposed to another PR Reference PR in #11758 which exposes the set_option/get_option with backendoptions map too Differential Revision: [D77190316](https://our.internmc.facebook.com/intern/diff/D77190316/) [ghstack-poisoned]
2 parents 432bd26 + 2ca6c33 commit ac2039d

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

runtime/backend/interface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class BackendInterface {
111111
* @retval Error::Ok if successful.
112112
*/
113113
ET_NODISCARD virtual Error set_option(
114-
BackendOptionContext& context,
114+
__ET_UNUSED BackendOptionContext& context,
115115
const executorch::runtime::Span<BackendOption>& backend_options) {
116116
return Error::Ok;
117117
};
@@ -127,7 +127,7 @@ class BackendInterface {
127127
* @retval Error::Ok if successful.
128128
*/
129129
ET_NODISCARD virtual Error get_option(
130-
BackendOptionContext& context,
130+
__ET_UNUSED BackendOptionContext& context,
131131
executorch::runtime::Span<BackendOption>& backend_options) {
132132
return Error::Ok;
133133
};

runtime/backend/options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using OptionValue =
2929
struct BackendOption {
3030
// key is the name of the backend option, like num_threads, enable_profiling,
3131
// etc
32-
char key[kMaxOptionKeyLength];
32+
char key[kMaxOptionKeyLength]{};
3333
// value is the value of the backend option, like 4, true, etc
3434
OptionValue value;
3535
};
@@ -129,7 +129,7 @@ class BackendOptions {
129129
Error set_option(const char (&key)[N], const char* value) noexcept {
130130
static_assert(N <= kMaxOptionKeyLength, "Option key is too long");
131131
// Create a fixed-size array and copy the string
132-
std::array<char, kMaxOptionValueLength> arr;
132+
std::array<char, kMaxOptionValueLength> arr{};
133133
strncpy(arr.data(), value, kMaxOptionValueLength - 1);
134134
arr[kMaxOptionValueLength - 1] = '\0'; // Ensure null termination
135135
return set_option_impl(key, arr);

runtime/backend/test/backend_interface_update_test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ class MockBackend : public BackendInterface {
4040
}
4141

4242
Result<DelegateHandle*> init(
43-
BackendInitContext& context,
44-
FreeableBuffer* processed,
45-
ArrayRef<CompileSpec> compile_specs) const override {
43+
__ET_UNUSED BackendInitContext& context,
44+
__ET_UNUSED FreeableBuffer* processed,
45+
__ET_UNUSED ArrayRef<CompileSpec> compile_specs) const override {
4646
init_called = true;
4747
return nullptr;
4848
}
4949

5050
Error execute(
51-
BackendExecutionContext& context,
52-
DelegateHandle* handle,
53-
EValue** args) const override {
51+
__ET_UNUSED BackendExecutionContext& context,
52+
__ET_UNUSED DelegateHandle* handle,
53+
__ET_UNUSED EValue** args) const override {
5454
execute_count++;
5555
return Error::Ok;
5656
}
5757

5858
Error set_option(
59-
BackendOptionContext& context,
59+
__ET_UNUSED BackendOptionContext& context,
6060
const executorch::runtime::Span<BackendOption>& backend_options)
6161
override {
6262
set_option_count++;

0 commit comments

Comments
 (0)