File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -302,5 +302,15 @@ runtime::Error Module::set_output(
302
302
output_tensor.mutable_data_ptr (), output_tensor.nbytes (), output_index);
303
303
}
304
304
305
+ ET_NODISCARD inline runtime::Result<Method*> Module::get_method (
306
+ const std::string& method_name) {
307
+ ET_CHECK_OR_RETURN_ERROR (
308
+ methods_.count (method_name) > 0 ,
309
+ InvalidArgument,
310
+ " no such method in program: %s" ,
311
+ method_name.c_str ());
312
+ return methods_[method_name].method .get ();
313
+ }
314
+
305
315
} // namespace extension
306
316
} // namespace executorch
Original file line number Diff line number Diff line change @@ -493,6 +493,16 @@ class Module {
493
493
std::unique_ptr<NamedDataMap> data_map_;
494
494
495
495
protected:
496
+ /* *
497
+ * Get a method by method name.
498
+ *
499
+ * @param[in] method_name The name of the method to get.
500
+ *
501
+ * @returns A Result object containing either a pointer to the requested
502
+ * method or an error to indicate failure.
503
+ */
504
+ ET_NODISCARD inline runtime::Result<Method*> get_method (
505
+ const std::string& method_name);
496
506
std::unordered_map<std::string, MethodHolder> methods_;
497
507
498
508
friend class ExecuTorchJni ;
You can’t perform that action at this time.
0 commit comments