Skip to content

Commit 0644627

Browse files
Update on "[ExecuTorch] Separate extension.Module Namespaces from Aten and non-Aten"
# Context Separate `extension.Module` Namespaces to be `executorch::extension::module` and `executorch::extension::module::aten`, otherwise if a package relies on both aten and non-aten of the same implementation and the namespace is the same, there will be duplicate symbol issue like: ``` ld.lld: error: duplicate symbol: vtable for executorch::extension::Module >>> defined at {redacted}/executorch/extension/module/__module__/__stripped__/module.cpp.pic.stripped.o:(vtable for executorch::extension::Module) >>> defined at {redacted}/executorch/extension/module/__module_aten__/__stripped__/module.cpp.pic.stripped.o: ``` # Proposal Doing something similar to what we already did for `bundled_program` in #10307 Since `extension.Module` is a public API, we introduce a namespace alias, so that existing use cases won't get affected. Since namespace alias doesn't create additional symbols, there won't be duplicate symbol issue. Differential Revision: [D73903870](https://our.internmc.facebook.com/intern/diff/D73903870/) [ghstack-poisoned]
1 parent 89c020d commit 0644627

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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
*/
@@ -510,7 +513,7 @@ class Module {
510513
const std::string& method_name);
511514
std::unordered_map<std::string, MethodHolder> methods_;
512515

513-
friend class ExecuTorchJni;
516+
friend class executorch::extension::ExecuTorchJni;
514517
};
515518

516519
} // namespace ET_MODULE_NAMESPACE
@@ -528,6 +531,6 @@ using ::executorch::extension::ET_MODULE_NAMESPACE::Module;
528531
namespace executorch {
529532
namespace extension {
530533
// backward compatible namespace alias
531-
using namespace ::executorch::extension::ET_MODULE_NAMESPACE;
534+
using ::executorch::extension::ET_MODULE_NAMESPACE::Module;
532535
} // namespace extension
533536
} // namespace executorch

0 commit comments

Comments
 (0)