Skip to content

Commit 8b17e81

Browse files
solve duplicate dependency issues to unblock pybinding backend migration (#11594)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #11566 by @Gasoonjia ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/14/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/14/head Merge bot PR base: https://github.com/pytorch/executorch/tree/main Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/14/orig @diff-train-skip-merge Co-authored-by: gasoonjia <[email protected]>
1 parent 920ec2b commit 8b17e81

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

extension/module/bundled_module.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ std::unique_ptr<BufferDataLoader> program_data_loader(
2727
}
2828
} // namespace
2929

30+
namespace ET_BUNDLED_MODULE_NAMESPACE {
31+
3032
BundledModule::BundledModule(
3133
const void* bundled_program_ptr,
3234
std::unique_ptr<runtime::MemoryAllocator> memory_allocator,
@@ -107,6 +109,6 @@ runtime::Error BundledModule::verify_method_outputs(
107109
return executorch::BUNDLED_PROGRAM_NAMESPACE::verify_method_outputs(
108110
*method, bundled_program_ptr_, testset_idx, rtol, atol);
109111
}
110-
112+
} // namespace ET_BUNDLED_MODULE_NAMESPACE
111113
} // namespace extension
112114
} // namespace executorch

extension/module/bundled_module.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,19 @@
1010

1111
#include <executorch/extension/module/module.h>
1212

13+
#ifdef USE_ATEN_LIB
14+
#define ET_BUNDLED_MODULE_NAMESPACE bundled_module::aten
15+
#else // !USE_ATEN_LIB
16+
#define ET_BUNDLED_MODULE_NAMESPACE bundled_module
17+
#endif // USE_ATEN_LIB
18+
1319
namespace executorch {
1420
namespace extension {
1521

22+
using ET_MODULE_NAMESPACE::Module;
23+
24+
namespace ET_BUNDLED_MODULE_NAMESPACE {
25+
1626
/**
1727
* A facade class for loading bundled programs and executing methods within
1828
* them.
@@ -119,5 +129,6 @@ class BundledModule : public Module {
119129
bool is_loaded_from_file_ = false;
120130
};
121131

132+
} // namespace ET_BUNDLED_MODULE_NAMESPACE
122133
} // namespace extension
123134
} // namespace executorch

extension/module/module.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
namespace executorch {
3838
namespace extension {
39+
namespace ET_MODULE_NAMESPACE {
3940

4041
using ET_RUNTIME_NAMESPACE::MethodMeta;
4142
using ET_RUNTIME_NAMESPACE::Program;
@@ -308,5 +309,6 @@ runtime::Error Module::set_output(
308309
output_tensor.mutable_data_ptr(), output_tensor.nbytes(), output_index);
309310
}
310311

312+
} // namespace ET_MODULE_NAMESPACE
311313
} // namespace extension
312314
} // namespace executorch

extension/module/module.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
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 {
2127

@@ -24,6 +30,9 @@ using ET_RUNTIME_NAMESPACE::MethodMeta;
2430
using ET_RUNTIME_NAMESPACE::NamedDataMap;
2531
using ET_RUNTIME_NAMESPACE::Program;
2632

33+
class ExecuTorchJni;
34+
35+
namespace ET_MODULE_NAMESPACE {
2736
/**
2837
* A facade class for loading programs and executing methods within them.
2938
*/
@@ -493,16 +502,24 @@ class Module {
493502
protected:
494503
std::unordered_map<std::string, MethodHolder> methods_;
495504

496-
friend class ExecuTorchJni;
505+
friend class executorch::extension::ExecuTorchJni;
497506
};
498507

508+
} // namespace ET_MODULE_NAMESPACE
499509
} // namespace extension
500510
} // namespace executorch
501511

502512
namespace torch {
503513
namespace executor {
504514
// TODO(T197294990): Remove these deprecated aliases once all users have moved
505515
// to the new `::executorch` namespaces.
506-
using ::executorch::extension::Module;
516+
using ::executorch::extension::ET_MODULE_NAMESPACE::Module;
507517
} // namespace executor
508518
} // namespace torch
519+
520+
namespace executorch {
521+
namespace extension {
522+
// backward compatible namespace alias
523+
using ::executorch::extension::ET_MODULE_NAMESPACE::Module;
524+
} // namespace extension
525+
} // namespace executorch

extension/module/test/bundled_module_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <executorch/extension/module/bundled_module.h>
1010
#include <gtest/gtest.h>
1111

12-
using namespace ::executorch::extension;
12+
using namespace ::executorch::extension::ET_BUNDLED_MODULE_NAMESPACE;
1313
using namespace ::executorch::runtime;
1414

1515
class BundledModuleTest : public ::testing::Test {

0 commit comments

Comments
 (0)