Skip to content

Commit 1062e8d

Browse files
[ExecuTorch] Separate extension.Module Namespaces from Aten and non-Aten
Pull Request resolved: #10576 # 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. ghstack-source-id: 281124468 @exported-using-ghexport Differential Revision: [D73903870](https://our.internmc.facebook.com/intern/diff/D73903870/)
1 parent c5dd476 commit 1062e8d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

extension/module/module.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@
1616

1717
#include <executorch/runtime/executor/program.h>
1818

19+
#ifdef USE_ATEN_LIB
20+
#define ET_MODULE_NAMESPACE module::aten
21+
#else // !USE_ATEN_LIB
22+
#define ET_MODULE_NAMESPACE module
23+
#endif // USE_ATEN_LIB
24+
1925
namespace executorch {
2026
namespace extension {
27+
namespace ET_MODULE_NAMESPACE {
2128

2229
using ET_RUNTIME_NAMESPACE::Method;
2330
using ET_RUNTIME_NAMESPACE::MethodMeta;
@@ -506,13 +513,21 @@ class Module {
506513
friend class ExecuTorchJni;
507514
};
508515

516+
} // namespace ET_MODULE_NAMESPACE
509517
} // namespace extension
510518
} // namespace executorch
511519

512520
namespace torch {
513521
namespace executor {
514522
// TODO(T197294990): Remove these deprecated aliases once all users have moved
515523
// to the new `::executorch` namespaces.
516-
using ::executorch::extension::Module;
524+
using ::executorch::extension::ET_MODULE_NAMESPACE::Module;
517525
} // namespace executor
518526
} // namespace torch
527+
528+
namespace executorch {
529+
namespace extension {
530+
// backward compatible namespace alias
531+
using namespace ::executorch::extension::ET_MODULE_NAMESPACE;
532+
} // namespace extension
533+
} // namespace executorch

0 commit comments

Comments
 (0)