From 03e451647e20ddcb5a5557435a9715618d890045 Mon Sep 17 00:00:00 2001 From: Dave Bort Date: Mon, 7 Oct 2024 17:02:16 -0700 Subject: [PATCH] Migrate backends/arm to the new namespace (#5904) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/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 --- backends/arm/runtime/ArmBackendEthosU.cpp | 41 ++++++++++++++++------- backends/arm/runtime/VelaBinStream.cpp | 13 +++++-- backends/arm/runtime/VelaBinStream.h | 8 +++++ 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/backends/arm/runtime/ArmBackendEthosU.cpp b/backends/arm/runtime/ArmBackendEthosU.cpp index ec918433b0..b0452fb9e7 100644 --- a/backends/arm/runtime/ArmBackendEthosU.cpp +++ b/backends/arm/runtime/ArmBackendEthosU.cpp @@ -15,17 +15,31 @@ #include -#include "executorch/backends/arm/runtime/VelaBinStream.h" -#include "executorch/runtime/backend/interface.h" -#include "executorch/runtime/core/error.h" -#include "executorch/runtime/core/evalue.h" -#include "executorch/runtime/core/exec_aten/util/dim_order_util.h" -#include "executorch/runtime/core/exec_aten/util/scalar_type_util.h" +#include +#include +#include +#include +#include +#include using namespace std; -namespace torch { -namespace executor { +using executorch::aten::ScalarType; +using executorch::runtime::ArrayRef; +using executorch::runtime::Backend; +using executorch::runtime::BackendExecutionContext; +using executorch::runtime::BackendInitContext; +using executorch::runtime::CompileSpec; +using executorch::runtime::DelegateHandle; +using executorch::runtime::Error; +using executorch::runtime::EValue; +using executorch::runtime::FreeableBuffer; +using executorch::runtime::MemoryAllocator; +using executorch::runtime::Result; + +namespace executorch { +namespace backends { +namespace arm { typedef struct { FreeableBuffer* processed; @@ -142,10 +156,10 @@ class ArmBackend final : public ::executorch::runtime::BackendInterface { Error, "Input %d expected Integer (4 byte) or Char (1 byte) integer inputs, got ScalarType id %s", i, - toString(tensor_in.scalar_type())); + executorch::runtime::toString(tensor_in.scalar_type())); return Error::InvalidProgram; } - supported = is_contiguous_dim_order( + supported = executorch::runtime::is_contiguous_dim_order( tensor_in.dim_order().data(), tensor_in.dim()); if (!supported) { ET_LOG( @@ -268,7 +282,7 @@ class ArmBackend final : public ::executorch::runtime::BackendInterface { private: Error check_requires_permute( int index, - const exec_aten::Tensor tensor, + const executorch::aten::Tensor tensor, VelaIO* io, bool permuted_io_flag, bool* is_permuted) const { @@ -343,5 +357,6 @@ Backend backend_id{"ArmBackend", &backend}; static auto registered = register_backend(backend_id); } // namespace -} // namespace executor -} // namespace torch +} // namespace arm +} // namespace backends +} // namespace executorch diff --git a/backends/arm/runtime/VelaBinStream.cpp b/backends/arm/runtime/VelaBinStream.cpp index e2badbbd9f..a26fe9f23e 100644 --- a/backends/arm/runtime/VelaBinStream.cpp +++ b/backends/arm/runtime/VelaBinStream.cpp @@ -10,10 +10,15 @@ * as that function emits this format and the two need to align. */ +#include + #include -#include "executorch/backends/arm/runtime/VelaBinStream.h" -#include "executorch/runtime/core/error.h" +#include + +namespace executorch { +namespace backends { +namespace arm { // get next mul of 16 ptr, return n if already aligned static uintptr_t next_mul_16(uintptr_t n) { @@ -91,3 +96,7 @@ bool vela_bin_read(const char* data, VelaHandles* handles, int size) { // We've fallen off the end without finding vela_end_stream return false; } + +} // namespace arm +} // namespace backends +} // namespace executorch diff --git a/backends/arm/runtime/VelaBinStream.h b/backends/arm/runtime/VelaBinStream.h index e946078f5a..04b8b2ada0 100644 --- a/backends/arm/runtime/VelaBinStream.h +++ b/backends/arm/runtime/VelaBinStream.h @@ -18,6 +18,10 @@ #include #include +namespace executorch { +namespace backends { +namespace arm { + // Standard block name size const uint32_t kVelaBlockNameLength = 16; @@ -67,3 +71,7 @@ bool vela_bin_read(const char* data, VelaHandles* handles, int size); * on the Ethos-U. */ bool vela_bin_validate(const char* data, int size); + +} // namespace arm +} // namespace backends +} // namespace executorch