Skip to content

Commit 5a3ff8c

Browse files
Update on "[ExecuTorch][#10375] Add extension.BundledModule to Wrap extension.Module with Bundled Program Logic"
#10375 # Context This issue is a step of #9638. In #9638, we want to have `extension.Module` as the single source of implementation in `pybindings`, which means that `pybindings.PyModule` should use `extension.Module` rather than its own `pybindings.Module`. The issue is that `pybindings.PyModule` is dependent on the `method` getter from `pybindings.Module`, which `extension.Module` do not have. Since we don't want to expose `method` getter in `extension.Module`, we have to protect the getter, wrap the functions that is dependent on it and use the protected getter there, ultimately decouple `pybindings` from a `method` getter. # Proposal Now that we have a protected `method` getter, we can introduce a `extension.BundledModule`, a child class inheriting `extension.Module` which wraps up bundled program logic that is dependent on the `method` getter. Differential Revision: [D73564125](https://our.internmc.facebook.com/intern/diff/D73564125/) [ghstack-poisoned]
2 parents 395fea4 + 01ec43e commit 5a3ff8c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

extension/module/bundled_module.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
#define ET_BUNDLED_MODULE_NAMESPACE bundled_module
1717
#endif // USE_ATEN_LIB
1818

19-
using executorch::extension::ET_MODULE_NAMESPACE::Module;
20-
2119
namespace executorch {
2220
namespace extension {
2321
namespace ET_BUNDLED_MODULE_NAMESPACE {
2422

23+
using executorch::extension::ET_MODULE_NAMESPACE::Module;
24+
2525
/**
2626
* A facade class for loading bundled programs and executing methods within
2727
* them.

extension/module/module.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@
2424

2525
namespace executorch {
2626
namespace extension {
27-
namespace ET_MODULE_NAMESPACE {
2827

2928
using ET_RUNTIME_NAMESPACE::Method;
3029
using ET_RUNTIME_NAMESPACE::MethodMeta;
3130
using ET_RUNTIME_NAMESPACE::NamedDataMap;
3231
using ET_RUNTIME_NAMESPACE::Program;
3332

33+
class ExecuTorchJni;
34+
35+
namespace ET_MODULE_NAMESPACE {
36+
3437
/**
3538
* A facade class for loading programs and executing methods within them.
3639
*/
@@ -500,7 +503,7 @@ class Module {
500503
protected:
501504
std::unordered_map<std::string, MethodHolder> methods_;
502505

503-
friend class ExecuTorchJni;
506+
friend class executorch::extension::ExecuTorchJni;
504507
};
505508

506509
} // namespace ET_MODULE_NAMESPACE
@@ -518,6 +521,6 @@ using ::executorch::extension::ET_MODULE_NAMESPACE::Module;
518521
namespace executorch {
519522
namespace extension {
520523
// backward compatible namespace alias
521-
using namespace ::executorch::extension::ET_MODULE_NAMESPACE;
524+
using ::executorch::extension::ET_MODULE_NAMESPACE::Module;
522525
} // namespace extension
523526
} // namespace executorch

0 commit comments

Comments
 (0)