Skip to content

Commit b9e9479

Browse files
dbortfacebook-github-bot
authored andcommitted
Migrate backends/vulkan to the new namespace (#5876)
Summary: Pull Request resolved: #5876 Move the vulkan backend out of the `torch::` namespace, and update to avoid using the `torch::` or `exec_aten::` namespaces. Reviewed By: jorgep31415 Differential Revision: D63903939 fbshipit-source-id: 42ff0ba2b560eb3e2bee02c014e39f44d7b0ec94
1 parent be4b7f4 commit b9e9479

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

backends/vulkan/runtime/VulkanBackend.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,23 @@
3030
#include <type_traits>
3131
#include <vector>
3232

33-
namespace torch {
34-
namespace executor {
33+
namespace executorch {
34+
namespace backends {
3535
namespace vulkan {
3636
namespace {
3737

38+
using executorch::runtime::ArrayRef;
39+
using executorch::runtime::Backend;
40+
using executorch::runtime::BackendExecutionContext;
41+
using executorch::runtime::BackendInitContext;
42+
using executorch::runtime::CompileSpec;
43+
using executorch::runtime::DelegateHandle;
44+
using executorch::runtime::Error;
45+
using executorch::runtime::EValue;
46+
using executorch::runtime::FreeableBuffer;
47+
using executorch::runtime::kTensorDimensionLimit;
48+
using executorch::runtime::Result;
49+
3850
using namespace vkcompute;
3951

4052
// Flatbuffer types
@@ -357,7 +369,7 @@ class GraphBuilder {
357369
bool maybe_resize_input(
358370
ComputeGraph* graph,
359371
const size_t input_i,
360-
exec_aten::Tensor& et_tensor) {
372+
executorch::aten::Tensor& et_tensor) {
361373
ValueRef in_tensor_ref = graph->inputs()[input_i].value;
362374
vTensorPtr in_tensor = graph->get_tensor(in_tensor_ref);
363375

@@ -392,17 +404,18 @@ bool maybe_resize_input(
392404
void maybe_resize_output(
393405
ComputeGraph* graph,
394406
const size_t output_i,
395-
exec_aten::Tensor& et_tensor) {
407+
executorch::aten::Tensor& et_tensor) {
396408
ValueRef out_tensor_ref = graph->outputs()[output_i].value;
397409
vTensorPtr out_tensor = graph->get_tensor(out_tensor_ref);
398410

399-
exec_aten::SizesType new_output_size[kTensorDimensionLimit];
411+
executorch::aten::SizesType new_output_size[kTensorDimensionLimit];
400412
size_t ndim = out_tensor->sizes().size();
401413
for (int i = 0; i < ndim; ++i) {
402414
new_output_size[i] = out_tensor->sizes()[i];
403415
}
404416

405-
exec_aten::ArrayRef<exec_aten::SizesType> output_size{new_output_size, ndim};
417+
executorch::aten::ArrayRef<executorch::aten::SizesType> output_size{
418+
new_output_size, ndim};
406419
Error err = resize_tensor(et_tensor, output_size);
407420

408421
ET_CHECK_MSG(err == Error::Ok, "Failed to resize output tensor.");
@@ -555,5 +568,5 @@ static auto success_with_compiler = register_backend(backend);
555568

556569
} // namespace
557570
} // namespace vulkan
558-
} // namespace executor
559-
} // namespace torch
571+
} // namespace backends
572+
} // namespace executorch

backends/vulkan/runtime/VulkanDelegateHeader.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515

1616
#pragma clang diagnostic ignored "-Wdeprecated"
1717

18-
namespace torch {
19-
namespace executor {
18+
namespace executorch {
19+
namespace backends {
2020
namespace vulkan {
2121

22+
using executorch::runtime::Error;
23+
using executorch::runtime::Result;
24+
2225
namespace {
2326

2427
struct ByteSlice {
@@ -101,5 +104,5 @@ Result<VulkanDelegateHeader> VulkanDelegateHeader::parse(const void* data) {
101104
}
102105

103106
} // namespace vulkan
104-
} // namespace executor
105-
} // namespace torch
107+
} // namespace backends
108+
} // namespace executorch

backends/vulkan/runtime/VulkanDelegateHeader.h

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

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

13-
namespace torch {
14-
namespace executor {
13+
namespace executorch {
14+
namespace backends {
1515
namespace vulkan {
1616

1717
// Byte decoding utilities
@@ -22,7 +22,8 @@ uint32_t getUInt16LE(const uint8_t* data);
2222
struct VulkanDelegateHeader {
2323
bool is_valid() const;
2424

25-
static Result<VulkanDelegateHeader> parse(const void* data);
25+
static executorch::runtime::Result<VulkanDelegateHeader> parse(
26+
const void* data);
2627

2728
uint32_t header_size;
2829
uint32_t flatbuffer_offset;
@@ -32,5 +33,5 @@ struct VulkanDelegateHeader {
3233
};
3334

3435
} // namespace vulkan
35-
} // namespace executor
36-
} // namespace torch
36+
} // namespace backends
37+
} // namespace executorch

backends/vulkan/test/utils/test_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void record_matmul_texture3d(
358358
_(uint8_t, Byte) \
359359
_(int8_t, Char) \
360360
_(int32_t, Int) \
361-
_(exec_aten::Half, Half) \
361+
_(executorch::aten::Half, Half) \
362362
_(float, Float) \
363363
_(int8_t, QInt8)
364364

backends/vulkan/test/vulkan_compute_api_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ TEST_F(VulkanComputeAPITest, test_buffer_float16) {
601601
if (!context()->adapter_ptr()->has_full_float16_buffers_support()) {
602602
GTEST_SKIP();
603603
}
604-
test_storage_buffer_type<exec_aten::Half, vkapi::kHalf>(16);
604+
test_storage_buffer_type<executorch::aten::Half, vkapi::kHalf>(16);
605605
}
606606

607607
TEST_F(VulkanComputeAPITest, test_buffer_int8) {
@@ -683,7 +683,7 @@ TEST_F(VulkanComputeAPITest, buffer_tensor_sanity_check) {
683683
run_buffer_tensor_sanity_check<float>(a);
684684
break;
685685
case vkapi::kHalf:
686-
run_buffer_tensor_sanity_check<exec_aten::Half>(a);
686+
run_buffer_tensor_sanity_check<executorch::aten::Half>(a);
687687
break;
688688
case vkapi::kChar:
689689
run_buffer_tensor_sanity_check<int8_t>(a);
@@ -2528,7 +2528,7 @@ TEST(VulkanToFromGPUShaderTest, round_trip_tests) {
25282528

25292529
for (auto& sizes : to_test) {
25302530
RUN_TESTS(float, vkapi::kFloat)
2531-
RUN_TESTS(exec_aten::Half, vkapi::kHalf)
2531+
RUN_TESTS(executorch::aten::Half, vkapi::kHalf)
25322532
}
25332533

25342534
for (auto& sizes : to_test_int8) {

0 commit comments

Comments
 (0)