@@ -111,15 +111,17 @@ class Module final {
111
111
*
112
112
* @returns true if the program is loaded, false otherwise.
113
113
*/
114
- bool is_loaded () const ;
114
+ inline bool is_loaded () const {
115
+ return program_ != nullptr ;
116
+ }
115
117
116
118
/* *
117
119
* Get the program. The data loader used by the program is guaranteed to be
118
120
* valid for the lifetime of the program.
119
121
*
120
122
* @returns Shared pointer to the program or nullptr if it's not yet loaded.
121
123
*/
122
- std::shared_ptr<::executorch::runtime::Program> program () const {
124
+ inline std::shared_ptr<::executorch::runtime::Program> program () const {
123
125
return program_;
124
126
}
125
127
@@ -151,7 +153,9 @@ class Module final {
151
153
* @returns true if the method specified by method_name is loaded, false
152
154
* otherwise.
153
155
*/
154
- bool is_method_loaded (const std::string& method_name) const ;
156
+ inline bool is_method_loaded (const std::string& method_name) const {
157
+ return methods_.count (method_name);
158
+ }
155
159
156
160
/* *
157
161
* Get a method metadata struct by method name.
@@ -191,8 +195,8 @@ class Module final {
191
195
* @returns A Result object containing either a vector of output values
192
196
* from the method or an error to indicate failure.
193
197
*/
194
- ET_NODISCARD
195
- ::executorch::runtime::Result< std::vector<::executorch::runtime::EValue>>
198
+ ET_NODISCARD inline ::executorch::runtime::Result<
199
+ std::vector<::executorch::runtime::EValue>>
196
200
execute (
197
201
const std::string& method_name,
198
202
const ::executorch::runtime::EValue& input) {
@@ -209,8 +213,8 @@ class Module final {
209
213
* @returns A Result object containing either a vector of output values
210
214
* from the method or an error to indicate failure.
211
215
*/
212
- ET_NODISCARD
213
- ::executorch::runtime::Result< std::vector<::executorch::runtime::EValue>>
216
+ ET_NODISCARD inline ::executorch::runtime::Result<
217
+ std::vector<::executorch::runtime::EValue>>
214
218
execute (const std::string& method_name) {
215
219
return execute (method_name, std::vector<::executorch::runtime::EValue>{});
216
220
}
@@ -225,9 +229,9 @@ class Module final {
225
229
* @returns A Result object containing either the first output value from the
226
230
* method or an error to indicate failure.
227
231
*/
228
- ET_NODISCARD
229
- ::executorch::runtime::Result<::executorch::runtime:: EValue> get (
230
- const std::string& method_name,
232
+ ET_NODISCARD inline ::executorch::runtime::Result<
233
+ ::executorch::runtime::EValue>
234
+ get ( const std::string& method_name,
231
235
const std::vector<::executorch::runtime::EValue>& input) {
232
236
auto result = ET_UNWRAP (execute (method_name, input));
233
237
if (result.empty ()) {
@@ -246,9 +250,9 @@ class Module final {
246
250
* @returns A Result object containing either the first output value from the
247
251
* method or an error to indicate failure.
248
252
*/
249
- ET_NODISCARD
250
- ::executorch::runtime::Result<::executorch::runtime:: EValue> get (
251
- const std::string& method_name,
253
+ ET_NODISCARD inline ::executorch::runtime::Result<
254
+ ::executorch::runtime::EValue>
255
+ get ( const std::string& method_name,
252
256
const ::executorch::runtime::EValue& input) {
253
257
return get (method_name, std::vector<::executorch::runtime::EValue>{input});
254
258
}
@@ -262,9 +266,9 @@ class Module final {
262
266
* @returns A Result object containing either the first output value from the
263
267
* method or an error to indicate failure.
264
268
*/
265
- ET_NODISCARD
266
- ::executorch::runtime::Result<::executorch::runtime:: EValue> get (
267
- const std::string& method_name) {
269
+ ET_NODISCARD inline ::executorch::runtime::Result<
270
+ ::executorch::runtime::EValue>
271
+ get ( const std::string& method_name) {
268
272
return get (method_name, std::vector<::executorch::runtime::EValue>{});
269
273
}
270
274
@@ -277,8 +281,8 @@ class Module final {
277
281
* @returns A Result object containing either a vector of output values
278
282
* from the 'forward' method or an error to indicate failure.
279
283
*/
280
- ET_NODISCARD
281
- ::executorch::runtime::Result< std::vector<::executorch::runtime::EValue>>
284
+ ET_NODISCARD inline ::executorch::runtime::Result<
285
+ std::vector<::executorch::runtime::EValue>>
282
286
forward (const std::vector<::executorch::runtime::EValue>& input) {
283
287
return execute (" forward" , input);
284
288
}
@@ -292,8 +296,8 @@ class Module final {
292
296
* @returns A Result object containing either a vector of output values
293
297
* from the 'forward' method or an error to indicate failure.
294
298
*/
295
- ET_NODISCARD
296
- ::executorch::runtime::Result< std::vector<::executorch::runtime::EValue>>
299
+ ET_NODISCARD inline ::executorch::runtime::Result<
300
+ std::vector<::executorch::runtime::EValue>>
297
301
forward (const ::executorch::runtime::EValue& input) {
298
302
return forward (std::vector<::executorch::runtime::EValue>{input});
299
303
}
@@ -305,8 +309,8 @@ class Module final {
305
309
* @returns A Result object containing either a vector of output values
306
310
* from the 'forward' method or an error to indicate failure.
307
311
*/
308
- ET_NODISCARD
309
- ::executorch::runtime::Result< std::vector<::executorch::runtime::EValue>>
312
+ ET_NODISCARD inline ::executorch::runtime::Result<
313
+ std::vector<::executorch::runtime::EValue>>
310
314
forward () {
311
315
return forward (std::vector<::executorch::runtime::EValue>{});
312
316
}
@@ -319,7 +323,7 @@ class Module final {
319
323
* @returns A pointer to the EventTracer instance. Returns nullptr if no
320
324
* EventTracer is set.
321
325
*/
322
- ::executorch::runtime::EventTracer* event_tracer () const {
326
+ inline ::executorch::runtime::EventTracer* event_tracer () const {
323
327
return event_tracer_.get ();
324
328
}
325
329
0 commit comments