Skip to content

Commit 48d08da

Browse files
pytorchbotdbort
andauthored
Migrate backends/arm to the new namespace (#5974)
Migrate backends/arm to the new namespace (#5904) Summary: Pull Request resolved: #5904 Move the Arm backend out of the `torch::` namespace, and update to avoid using the `torch::` or `exec_aten::` namespaces. Also, move the VelaBinStream code into a namespace to avoid declaring symbols in the global namespace. Reviewed By: mergennachin Differential Revision: D63923290 fbshipit-source-id: a98e4c1ede8072a9fd96fb7fc2e2fcc4e82bc28a (cherry picked from commit 03e4516) Co-authored-by: Dave Bort <[email protected]>
1 parent 7b93aa2 commit 48d08da

File tree

3 files changed

+55
-13
lines changed

3 files changed

+55
-13
lines changed

backends/arm/runtime/ArmBackendEthosU.cpp

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,31 @@
1515

1616
#include <ethosu_driver.h>
1717

18-
#include "executorch/backends/arm/runtime/VelaBinStream.h"
19-
#include "executorch/runtime/backend/interface.h"
20-
#include "executorch/runtime/core/error.h"
21-
#include "executorch/runtime/core/evalue.h"
22-
#include "executorch/runtime/core/exec_aten/util/scalar_type_util.h"
18+
#include <executorch/backends/arm/runtime/VelaBinStream.h>
19+
#include <executorch/runtime/backend/interface.h>
20+
#include <executorch/runtime/core/error.h>
21+
#include <executorch/runtime/core/evalue.h>
22+
#include <executorch/runtime/core/exec_aten/util/dim_order_util.h>
23+
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
2324

2425
using namespace std;
2526

26-
namespace torch {
27-
namespace executor {
27+
using executorch::aten::ScalarType;
28+
using executorch::runtime::ArrayRef;
29+
using executorch::runtime::Backend;
30+
using executorch::runtime::BackendExecutionContext;
31+
using executorch::runtime::BackendInitContext;
32+
using executorch::runtime::CompileSpec;
33+
using executorch::runtime::DelegateHandle;
34+
using executorch::runtime::Error;
35+
using executorch::runtime::EValue;
36+
using executorch::runtime::FreeableBuffer;
37+
using executorch::runtime::MemoryAllocator;
38+
using executorch::runtime::Result;
39+
40+
namespace executorch {
41+
namespace backends {
42+
namespace arm {
2843

2944
typedef struct {
3045
FreeableBuffer* processed;
@@ -141,7 +156,16 @@ class ArmBackend final : public ::executorch::runtime::BackendInterface {
141156
Error,
142157
"Input %d expected Integer (4 byte) or Char (1 byte) integer inputs, got ScalarType id %s",
143158
i,
144-
toString(tensor_in.scalar_type()));
159+
executorch::runtime::toString(tensor_in.scalar_type()));
160+
return Error::InvalidProgram;
161+
}
162+
supported = executorch::runtime::is_contiguous_dim_order(
163+
tensor_in.dim_order().data(), tensor_in.dim());
164+
if (!supported) {
165+
ET_LOG(
166+
Error,
167+
"Input %d expected contiguous dim_order, but got non-contiguous dim_order",
168+
i);
145169
return Error::InvalidProgram;
146170
}
147171

@@ -258,7 +282,7 @@ class ArmBackend final : public ::executorch::runtime::BackendInterface {
258282
private:
259283
Error check_requires_permute(
260284
int index,
261-
const exec_aten::Tensor tensor,
285+
const executorch::aten::Tensor tensor,
262286
VelaIO* io,
263287
bool permuted_io_flag,
264288
bool* is_permuted) const {
@@ -333,5 +357,6 @@ Backend backend_id{"ArmBackend", &backend};
333357
static auto registered = register_backend(backend_id);
334358
} // namespace
335359

336-
} // namespace executor
337-
} // namespace torch
360+
} // namespace arm
361+
} // namespace backends
362+
} // namespace executorch

backends/arm/runtime/VelaBinStream.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010
* as that function emits this format and the two need to align.
1111
*/
1212

13+
#include <executorch/backends/arm/runtime/VelaBinStream.h>
14+
1315
#include <cstring>
1416

15-
#include "executorch/backends/arm/runtime/VelaBinStream.h"
16-
#include "executorch/runtime/core/error.h"
17+
#include <executorch/runtime/core/error.h>
18+
19+
namespace executorch {
20+
namespace backends {
21+
namespace arm {
1722

1823
// get next mul of 16 ptr, return n if already aligned
1924
static uintptr_t next_mul_16(uintptr_t n) {
@@ -91,3 +96,7 @@ bool vela_bin_read(const char* data, VelaHandles* handles, int size) {
9196
// We've fallen off the end without finding vela_end_stream
9297
return false;
9398
}
99+
100+
} // namespace arm
101+
} // namespace backends
102+
} // namespace executorch

backends/arm/runtime/VelaBinStream.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include <cstddef>
1919
#include <cstdint>
2020

21+
namespace executorch {
22+
namespace backends {
23+
namespace arm {
24+
2125
// Standard block name size
2226
const uint32_t kVelaBlockNameLength = 16;
2327

@@ -67,3 +71,7 @@ bool vela_bin_read(const char* data, VelaHandles* handles, int size);
6771
* on the Ethos-U.
6872
*/
6973
bool vela_bin_validate(const char* data, int size);
74+
75+
} // namespace arm
76+
} // namespace backends
77+
} // namespace executorch

0 commit comments

Comments
 (0)