Skip to content

Commit ab2cc0c

Browse files
committed
Update on "Support Span to construct from a single element similar to ArrayRef"
Copy the constructor from ArrayRef here https://github.com/pytorch/executorch/blob/5365c5559accc7a0d522eacdfb7385ce8914ef53/runtime/core/array_ref.h#L78-L81 so it's easier to use exported-using-ghexport Differential Revision: [D76825662](https://our.internmc.facebook.com/intern/diff/D76825662/) Differential Revision: [D76825662](https://our.internmc.facebook.com/intern/diff/D76825662) [ghstack-poisoned]
2 parents 739a353 + 0f81024 commit ab2cc0c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

runtime/backend/backend_options.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#pragma once
1010
#include <executorch/runtime/core/error.h>
11+
#include <executorch/runtime/core/span.h>
1112
#include <cstddef>
1213
#include <cstring>
1314
#include <variant>
@@ -71,6 +72,15 @@ class BackendOptions {
7172
return Error::NotFound;
7273
}
7374

75+
executorch::runtime::Span<BackendOption> view() const {
76+
return executorch::runtime::Span<BackendOption>(options_, size_);
77+
}
78+
79+
// Non-const version that allows modification of the underlying data
80+
executorch::runtime::Span<BackendOption> view() {
81+
return executorch::runtime::Span<BackendOption>(options_, size_);
82+
}
83+
7484
private:
7585
BackendOption options_[MaxCapacity]{}; // Storage for backend options
7686
size_t size_; // Current number of options

0 commit comments

Comments
 (0)