Skip to content

Commit 52411d8

Browse files
dbortfacebook-github-bot
authored andcommitted
Migrate backends/apple to the new namespace
Summary: Move the Apple backends out of the `torch::` namespace, and update to avoid using the `torch::` or `exec_aten::` namespaces. Differential Revision: D63908530
1 parent d34cc4e commit 52411d8

39 files changed

+160
-160
lines changed

backends/apple/coreml/runtime/delegate/coreml_backend_delegate.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#endif
2626

2727
namespace {
28-
using namespace torch::executor;
28+
using namespace executorch::runtime;
2929
using namespace executorchcoreml;
3030

3131
std::optional<MultiArray::DataType> get_data_type(ScalarType scalar_type) {
@@ -133,8 +133,8 @@ ModelLoggingOptions get_logging_options(BackendExecutionContext& context) {
133133

134134
} //namespace
135135

136-
namespace torch {
137-
namespace executor {
136+
namespace executorch {
137+
namespace backends {
138138

139139
using namespace executorchcoreml;
140140

@@ -235,5 +235,5 @@ ModelLoggingOptions get_logging_options(BackendExecutionContext& context) {
235235
static auto success_with_compiler = register_backend(backend);
236236
}
237237

238-
} // namespace executor
239-
} // namespace torch
238+
} // namespace backends
239+
} // namespace executorch

backends/apple/coreml/runtime/include/coreml_backend/delegate.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace executorchcoreml {
1717
class BackendDelegate;
1818
}
1919

20-
namespace torch {
21-
namespace executor {
20+
namespace executorch {
21+
namespace backends {
2222

2323
class CoreMLBackendDelegate final : public ::executorch::runtime::BackendInterface {
2424
public:
@@ -65,5 +65,5 @@ class CoreMLBackendDelegate final : public ::executorch::runtime::BackendInterfa
6565
private:
6666
std::shared_ptr<executorchcoreml::BackendDelegate> impl_;
6767
};
68-
} // namespace executor
69-
} // namespace torch
68+
} // namespace backends
69+
} // namespace executorch

backends/apple/coreml/runtime/sdk/model_event_logger_impl.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
namespace {
1919

20-
using namespace torch::executor;
20+
using namespace executorch::runtime;
2121

2222
uint64_t time_units_to_nano_seconds(uint64_t time_units) {
2323
static mach_timebase_info_data_t info;
@@ -109,7 +109,7 @@ bool is_packed(NSArray<NSNumber *> *shape, NSArray<NSNumber *> *strides) {
109109
[op_path_to_value_map enumerateKeysAndObjectsUsingBlock:^(ETCoreMLModelStructurePath *path,
110110
MLMultiArray *intermediate_value,
111111
BOOL * _Nonnull __unused stop) {
112-
using namespace torch::executor;
112+
using namespace executorch::runtime;
113113

114114
@autoreleasepool {
115115
NSString *debug_symbol = op_path_to_debug_symbol_name_map[path];

backends/apple/coreml/runtime/test/BackendDelegateTests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ + (nullable NSURL *)bundledResourceWithName:(NSString *)name extension:(NSString
6060
}
6161

6262
+ (void)setUp {
63-
torch::executor::runtime_init();
63+
executorch::runtime::runtime_init();
6464
}
6565

6666
- (void)setUp {

backends/apple/coreml/runtime/test/CoreMLBackendDelegateTests.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
static constexpr size_t kRuntimeMemorySize = 50 * 1024U * 1024U; // 50 MB
1919

20-
using namespace torch::executor;
21-
using torch::executor::testing::TensorFactory;
20+
using namespace executorch::runtime;
21+
using executorch::runtime::testing::TensorFactory;
2222

2323
namespace {
2424
// TODO: Move the following methods to a utility class, so that it can be shared with `executor_runner.main.mm`
@@ -107,8 +107,8 @@
107107
}
108108
Buffer buffer(tensor_meta->nbytes(), 0);
109109
auto sizes = tensor_meta->sizes();
110-
exec_aten::TensorImpl tensor_impl(tensor_meta->scalar_type(), std::size(sizes), const_cast<int *>(sizes.data()), buffer.data());
111-
exec_aten::Tensor tensor(&tensor_impl);
110+
executorch::aten::TensorImpl tensor_impl(tensor_meta->scalar_type(), std::size(sizes), const_cast<int *>(sizes.data()), buffer.data());
111+
executorch::aten::Tensor tensor(&tensor_impl);
112112
EValue input_value(std::move(tensor));
113113
Error err = method.set_input(input_value, i);
114114
if (err != Error::Ok) {
@@ -129,7 +129,7 @@ @interface CoreMLBackendDelegateTests : XCTestCase
129129
@implementation CoreMLBackendDelegateTests
130130

131131
+ (void)setUp {
132-
torch::executor::runtime_init();
132+
executorch::runtime::runtime_init();
133133
}
134134

135135
+ (nullable NSURL *)bundledResourceWithName:(NSString *)name extension:(NSString *)extension {

backends/apple/coreml/runtime/test/ETCoreMLAssetManagerTests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ @interface ETCoreMLAssetManagerTests : XCTestCase
2323
@implementation ETCoreMLAssetManagerTests
2424

2525
+ (void)setUp {
26-
torch::executor::runtime_init();
26+
executorch::runtime::runtime_init();
2727
}
2828

2929
- (void)setUp {

backends/apple/coreml/runtime/test/ETCoreMLModelDebuggerTests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ @interface ETCoreMLModelDebuggerTests : XCTestCase
7070
@implementation ETCoreMLModelDebuggerTests
7171

7272
+ (void)setUp {
73-
torch::executor::runtime_init();
73+
executorch::runtime::runtime_init();
7474
}
7575

7676
+ (nullable NSURL *)bundledResourceWithName:(NSString *)name extension:(NSString *)extension {

backends/apple/coreml/runtime/test/ETCoreMLModelManagerTests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ + (nullable NSURL *)bundledResourceWithName:(NSString *)name extension:(NSString
3232
}
3333

3434
- (void)setUp {
35-
torch::executor::runtime_init();
35+
executorch::runtime::runtime_init();
3636
@autoreleasepool {
3737
NSError *localError = nil;
3838
self.fileManager = [[NSFileManager alloc] init];

backends/apple/coreml/runtime/test/ETCoreMLModelProfilerTests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ @interface ETCoreMLModelProfilerTests : XCTestCase
5959
@implementation ETCoreMLModelProfilerTests
6060

6161
+ (void)setUp {
62-
torch::executor::runtime_init();
62+
executorch::runtime::runtime_init();
6363
}
6464

6565
+ (nullable NSURL *)bundledResourceWithName:(NSString *)name extension:(NSString *)extension {

backends/apple/mps/runtime/MPSBackend.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include <string>
1717
#include <iostream>
1818

19-
namespace torch {
20-
namespace executor {
19+
namespace executorch {
20+
namespace backends {
2121

2222
class MPSBackend final : public ::executorch::runtime::BackendInterface {
2323
public:
@@ -81,7 +81,7 @@ Error execute(
8181
output_pointers.push_back(&args[i]->toTensor());
8282
}
8383
} else if (args[i]->isTensorList()) {
84-
const exec_aten::ArrayRef<exec_aten::Tensor>& tensorList = args[i]->toTensorList();
84+
const executorch::aten::ArrayRef<executorch::aten::Tensor>& tensorList = args[i]->toTensorList();
8585
for (auto& tensor_ : tensorList) {
8686
if (input_pointers.size() < executor->getNumInputs()) {
8787
input_pointers.push_back(&tensor_);
@@ -122,5 +122,5 @@ void destroy(DelegateHandle* handle) const override {
122122
static auto success_with_compiler = register_backend(backend);
123123
} // namespace
124124

125-
} // namespace executor
126-
} // namespace torch
125+
} // namespace backends
126+
} // namespace executorch

backends/apple/mps/runtime/MPSCompiler.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <memory>
1515
#include <vector>
1616

17-
namespace torch {
18-
namespace executor {
17+
namespace executorch {
18+
namespace backends {
1919
namespace mps {
2020
namespace delegate {
2121

@@ -34,5 +34,5 @@ class MPSCompiler {
3434

3535
} // namespace delegate
3636
} // namespace mps
37-
} // namespace executor
38-
} // namespace torch
37+
} // namespace backends
38+
} // namespace executorch

backends/apple/mps/runtime/MPSCompiler.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
#define MPS_UNUSED(x) ( (void)(x) )
2525

26-
namespace torch {
27-
namespace executor {
26+
namespace executorch {
27+
namespace backends {
2828
namespace mps {
2929
namespace delegate {
3030

@@ -66,5 +66,5 @@
6666

6767
} // namespace delegate
6868
} // namespace mps
69-
} // namespace executor
70-
} // namespace torch
69+
} // namespace backends
70+
} // namespace executorch

backends/apple/mps/runtime/MPSDelegateHeader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
#include <executorch/runtime/core/result.h>
99

10-
namespace torch {
11-
namespace executor {
10+
namespace executorch {
11+
namespace backends {
1212
namespace mps {
1313
namespace delegate {
1414

@@ -109,5 +109,5 @@ struct MPSDelegateHeader {
109109

110110
} // namespace delegate
111111
} // namespace mps
112-
} // namespace executor
113-
} // namespace torch
112+
} // namespace backends
113+
} // namespace executorch

backends/apple/mps/runtime/MPSDelegateHeader.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <executorch/runtime/core/error.h>
1111
#include <executorch/runtime/core/result.h>
1212

13-
namespace torch {
14-
namespace executor {
13+
namespace executorch {
14+
namespace backends {
1515
namespace mps {
1616
namespace delegate {
1717

@@ -49,5 +49,5 @@ uint64_t getUInt64LE(const uint8_t* data) {
4949

5050
} // namespace delegate
5151
} // namespace mps
52-
} // namespace executor
53-
} // namespace torch
52+
} // namespace backends
53+
} // namespace executorch

backends/apple/mps/runtime/MPSDevice.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
#define MB(x) (x * 1048576UL)
2222

23-
namespace torch {
24-
namespace executor {
23+
namespace executorch {
24+
namespace backends {
2525
namespace mps {
2626
namespace delegate {
2727

@@ -88,5 +88,5 @@ bool is_macos_13_or_newer(
8888

8989
} // namespace delegate
9090
} // namespace mps
91-
} // namespace executor
92-
} // namespace torch
91+
} // namespace backends
92+
} // namespace executorch

backends/apple/mps/runtime/MPSDevice.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include <memory>
99
#include <mutex>
1010

11-
namespace torch {
12-
namespace executor {
11+
namespace executorch {
12+
namespace backends {
1313
namespace mps {
1414
namespace delegate {
1515

@@ -152,5 +152,5 @@ bool is_macos_13_or_newer(MacOSVersion version) {
152152

153153
} // namespace delegate
154154
} // namespace mps
155-
} // namespace executor
156-
} // namespace torch
155+
} // namespace backends
156+
} // namespace executorch

backends/apple/mps/runtime/MPSExecutor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include <memory>
1717
#include <vector>
1818

19-
namespace torch {
20-
namespace executor {
19+
namespace executorch {
20+
namespace backends {
2121
namespace mps {
2222
namespace delegate {
2323

@@ -87,6 +87,6 @@ class MPSExecutor {
8787

8888
} // namespace delegate
8989
} // namespace mps
90-
} // namespace executor
91-
} // namespace torch
90+
} // namespace backends
91+
} // namespace executorch
9292
// clang-format on

backends/apple/mps/runtime/MPSExecutor.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ @interface MPSGraphExecutable()
1717
@end
1818

1919

20-
namespace torch {
21-
namespace executor {
20+
namespace executorch {
21+
namespace backends {
2222
namespace mps {
2323
namespace delegate {
2424

@@ -239,5 +239,5 @@ @interface MPSGraphExecutable()
239239

240240
} // namespace delegate
241241
} // namespace mps
242-
} // namespace executor
243-
} // namespace torch
242+
} // namespace backends
243+
} // namespace executorch

backends/apple/mps/runtime/MPSGraphBuilder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#include <unordered_map>
2525
#include <vector>
2626

27-
namespace torch {
28-
namespace executor {
27+
namespace executorch {
28+
namespace backends {
2929
namespace mps {
3030
namespace delegate {
3131

@@ -197,5 +197,5 @@ class MPSGraphBuilder {
197197

198198
} // namespace delegate
199199
} // namespace mps
200-
} // namespace executor
201-
} // namespace torch
200+
} // namespace backends
201+
} // namespace executorch

backends/apple/mps/runtime/MPSGraphBuilder.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include <executorch/backends/apple/mps/runtime/MPSDevice.h>
88
#include <executorch/backends/apple/mps/runtime/MPSDelegateHeader.h>
99

10-
namespace torch {
11-
namespace executor {
10+
namespace executorch {
11+
namespace backends {
1212
namespace mps {
1313
namespace delegate {
1414

@@ -186,5 +186,5 @@
186186

187187
} // namespace delegate
188188
} // namespace mps
189-
} // namespace executor
190-
} // namespace torch
189+
} // namespace backends
190+
} // namespace executorch

backends/apple/mps/runtime/MPSStream.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#include <unordered_map>
1919

20-
namespace torch {
21-
namespace executor {
20+
namespace executorch {
21+
namespace backends {
2222
namespace mps {
2323
namespace delegate {
2424

@@ -135,5 +135,5 @@ class MPSStreamImpl {
135135

136136
} // namespace delegate
137137
} // namespace mps
138-
} // namespace executor
139-
} // namespace torch
138+
} // namespace backends
139+
} // namespace executorch

backends/apple/mps/runtime/MPSStream.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ @interface MPSGraphExecutionDescriptor ()
1111
@property (readwrite, atomic) BOOL enableCommitAndContinue;
1212
@end
1313

14-
namespace torch {
15-
namespace executor {
14+
namespace executorch {
15+
namespace backends {
1616
namespace mps {
1717
namespace delegate {
1818

@@ -258,5 +258,5 @@ @interface MPSGraphExecutionDescriptor ()
258258

259259
} // namespace delegate
260260
} // namespace mps
261-
} // namespace executor
262-
} // namespace torch
261+
} // namespace backends
262+
} // namespace executorch

0 commit comments

Comments
 (0)