@@ -110,46 +110,6 @@ class PyTorchBackendInterface {
110
110
virtual void destroy (ET_UNUSED DelegateHandle* handle) const {}
111
111
};
112
112
113
- struct Backend {
114
- const char * name_;
115
- PyTorchBackendInterface* interface_ptr_;
116
- };
117
-
118
- // The max number of backends that can be registered in
119
- // an app. It's hard coded to 16 because it's not estimated
120
- // to have more than 16 backends in a system. Each table
121
- // element has two pointers, represented by Backend struct.
122
- // The memory overhead for this table is minimum (only a few bytes).
123
- constexpr size_t kRegistrationTableMaxSize = 16 ;
124
-
125
- class BackendRegistry {
126
- public:
127
- BackendRegistry () : registrationTableSize_(0 ) {}
128
-
129
- /* *
130
- * Registers the Backend object (i.e. string name and PyTorchBackendInterface
131
- * pair) so that it could be called via the name during the runtime.
132
- * @param[in] backend Backend object of the user-defined backend delegate.
133
- * @retval Error code representing whether registration was successful.
134
- */
135
- ET_NODISCARD Error register_backend (const Backend& backend);
136
-
137
- /* *
138
- * Returns the corresponding object pointer for a given string name.
139
- * The mapping is populated using register_backend method.
140
- *
141
- * @param[in] name Name of the user-defined backend delegate.
142
- * @retval Pointer to the appropriate object that implements
143
- * PyTorchBackendInterface. Nullptr if it can't find anything
144
- * with the given name.
145
- */
146
- PyTorchBackendInterface* get_backend_class (const char * name);
147
-
148
- private:
149
- Backend backend_table_[kRegistrationTableMaxSize ];
150
- size_t registrationTableSize_;
151
- };
152
-
153
113
/* *
154
114
* Returns the corresponding object pointer for a given string name.
155
115
* The mapping is populated using register_backend method.
@@ -161,6 +121,16 @@ class BackendRegistry {
161
121
*/
162
122
PyTorchBackendInterface* get_backend_class (const char * name);
163
123
124
+ /* *
125
+ * A named instance of a backend.
126
+ */
127
+ struct Backend {
128
+ // / The name of the backend. Must match the string used in the PTE file.
129
+ const char * name;
130
+ // / The instance of the backend to use when loading and executing programs.
131
+ PyTorchBackendInterface* backend;
132
+ };
133
+
164
134
/* *
165
135
* Registers the Backend object (i.e. string name and PyTorchBackendInterface
166
136
* pair) so that it could be called via the name during the runtime.
@@ -178,11 +148,9 @@ namespace executor {
178
148
// TODO(T197294990): Remove these deprecated aliases once all users have moved
179
149
// to the new `::executorch` namespaces.
180
150
using ::executorch::runtime::Backend;
181
- using ::executorch::runtime::BackendRegistry;
182
151
using ::executorch::runtime::CompileSpec;
183
152
using ::executorch::runtime::DelegateHandle;
184
153
using ::executorch::runtime::get_backend_class;
185
- // using ::executorch::runtime::kRegistrationTableMaxSize;
186
154
using ::executorch::runtime::PyTorchBackendInterface;
187
155
using ::executorch::runtime::register_backend;
188
156
using ::executorch::runtime::SizedBuffer;
0 commit comments