Skip to content

Commit cf56ba7

Browse files
pytorchbotdbort
andauthored
MIgrate some random files away from the torch:: namespace (#5866)
MIgrate some random files away from the torch:: namespace (#5836) Summary: Pull Request resolved: #5836 A couple tests and helpers that my previous passes didn't catch. After this, the only remaining `//executorch/...` code under the `torch::` namespace is under `backends/...` and `kernels/...` (and in some other places that define kernels). Reviewed By: cccclai Differential Revision: D63797660 fbshipit-source-id: f4075d670c6b7f083c8c3ab1e9c465da32e8b3ac (cherry picked from commit 3a25651) Co-authored-by: Dave Bort <[email protected]>
1 parent 594ab5e commit cf56ba7

File tree

5 files changed

+44
-32
lines changed

5 files changed

+44
-32
lines changed

exir/backend/test/demos/rpc/ExecutorBackend.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,30 @@
2121
#include <executorch/runtime/executor/method.h>
2222
#include <executorch/runtime/executor/program.h>
2323

24-
namespace torch {
25-
namespace executor {
24+
using ::executorch::aten::Tensor;
25+
using ::executorch::extension::BufferDataLoader;
26+
using ::executorch::runtime::ArrayRef;
27+
using ::executorch::runtime::Backend;
28+
using ::executorch::runtime::BackendExecutionContext;
29+
using ::executorch::runtime::BackendInitContext;
30+
using ::executorch::runtime::CompileSpec;
31+
using ::executorch::runtime::DelegateHandle;
32+
using ::executorch::runtime::Error;
33+
using ::executorch::runtime::EValue;
34+
using ::executorch::runtime::FreeableBuffer;
35+
using ::executorch::runtime::HierarchicalAllocator;
36+
using ::executorch::runtime::MemoryAllocator;
37+
using ::executorch::runtime::MemoryManager;
38+
using ::executorch::runtime::Method;
39+
using ::executorch::runtime::MethodMeta;
40+
using ::executorch::runtime::Program;
41+
using ::executorch::runtime::Result;
42+
using ::executorch::runtime::Span;
43+
using ::executorch::runtime::Tag;
44+
using ::executorch::runtime::internal::copy_tensor_data;
45+
46+
namespace example {
47+
2648
/**
2749
* ExecutorBackend is a backend to execute an executorch program via delegate.
2850
* In preprocess, the preprocesed bytes (delegate blob) is an executorch
@@ -51,8 +73,8 @@ class ExecutorBackend final : public ::executorch::runtime::BackendInterface {
5173
// will return the data directly without copying it.
5274
MemoryAllocator* runtime_allocator = context.get_runtime_allocator();
5375
auto loader = ET_ALLOCATE_INSTANCE_OR_RETURN_ERROR(
54-
runtime_allocator, util::BufferDataLoader);
55-
new (loader) util::BufferDataLoader(processed->data(), processed->size());
76+
runtime_allocator, BufferDataLoader);
77+
new (loader) BufferDataLoader(processed->data(), processed->size());
5678
// Can't free `processed` because the program will point into that memory.
5779

5880
// Try loading the program.
@@ -150,7 +172,7 @@ class ExecutorBackend final : public ::executorch::runtime::BackendInterface {
150172
if (output.tag == Tag::Tensor) {
151173
Tensor t_src = output.toTensor();
152174
Tensor t_dst = args[num_inputs + i]->toTensor();
153-
status = internal::copy_tensor_data(t_dst, t_src);
175+
status = copy_tensor_data(t_dst, t_src);
154176
}
155177
}
156178

@@ -165,12 +187,11 @@ class ExecutorBackend final : public ::executorch::runtime::BackendInterface {
165187
}
166188
};
167189

168-
Error registerExecutorBackend() {
190+
Error register_executor_backend() {
169191
static auto cls = ExecutorBackend();
170192
static Backend backend{"ExecutorBackend", &cls};
171193
static auto success_with_compiler = register_backend(backend);
172194
return success_with_compiler;
173195
}
174196

175-
} // namespace executor
176-
} // namespace torch
197+
} // namespace example

exir/backend/test/demos/rpc/ExecutorBackend.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
#include <executorch/runtime/core/error.h>
1212

13-
namespace torch {
14-
namespace executor {
13+
namespace example {
1514

16-
Error registerExecutorBackend();
15+
::executorch::runtime::Error register_executor_backend();
1716

18-
} // namespace executor
19-
} // namespace torch
17+
} // namespace example

exir/backend/test/demos/rpc/ExecutorBackendRegister.cpp

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

13-
namespace torch {
14-
namespace executor {
13+
namespace example {
1514
namespace {
16-
static Error register_success = registerExecutorBackend();
15+
static ::executorch::runtime::Error register_success =
16+
register_executor_backend();
1717
} // namespace
18-
} // namespace executor
19-
} // namespace torch
18+
} // namespace example

runtime/core/test/evalue_test.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
using namespace ::testing;
1818

19-
namespace torch {
20-
namespace executor {
21-
2219
using exec_aten::ScalarType;
2320
using executorch::runtime::BoxedEvalueList;
2421
using executorch::runtime::EValue;
@@ -30,7 +27,7 @@ class EValueTest : public ::testing::Test {
3027
void SetUp() override {
3128
// Since these tests cause ET_LOG to be called, the PAL must be initialized
3229
// first.
33-
runtime_init();
30+
executorch::runtime::runtime_init();
3431
}
3532
};
3633

@@ -276,6 +273,3 @@ TEST_F(EValueTest, ConstructFromNullPtrAborts) {
276273

277274
ET_EXPECT_DEATH({ EValue evalue(null_ptr); }, "");
278275
}
279-
280-
} // namespace executor
281-
} // namespace torch

test/utils/alignment.h

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

1313
#include <gmock/gmock.h> // For MATCHER_P
1414

15-
namespace torch {
16-
namespace executor {
15+
namespace executorch {
16+
namespace runtime {
1717
namespace testing {
1818

1919
/**
@@ -28,7 +28,7 @@ inline bool is_aligned(const void* ptr, size_t alignment) {
2828
* Lets gtest users write `EXPECT_THAT(ptr, IsAlignedTo(alignment))` or
2929
* `EXPECT_THAT(ptr, Not(IsAlignedTo(alignment)))`.
3030
*
31-
* See also `EXPECT_POINTER_IS_ALIGNED_TO()`.
31+
* See also `EXPECT_ALIGNED()`.
3232
*/
3333
MATCHER_P(IsAlignedTo, other, "") {
3434
return is_aligned(arg, other);
@@ -39,10 +39,10 @@ MATCHER_P(IsAlignedTo, other, "") {
3939
*/
4040

4141
#define EXPECT_ALIGNED(ptr, alignment) \
42-
EXPECT_THAT((ptr), torch::executor::testing::IsAlignedTo((alignment)))
42+
EXPECT_THAT((ptr), executorch::runtime::testing::IsAlignedTo((alignment)))
4343
#define ASSERT_ALIGNED(ptr, alignment) \
44-
ASSERT_THAT((ptr), torch::executor::testing::IsAlignedTo((alignment)))
44+
ASSERT_THAT((ptr), executorch::runtime::testing::IsAlignedTo((alignment)))
4545

4646
} // namespace testing
47-
} // namespace executor
48-
} // namespace torch
47+
} // namespace runtime
48+
} // namespace executorch

0 commit comments

Comments
 (0)