Skip to content

Commit 0648a8a

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix various using namespace issues in executorch (#5464)
Summary: Pull Request resolved: #5464 Summary #buildsonlynotests - No runtime effects! - If you approve of this diff, please use the "Accept & Ship" button ig-no-test - Doesn't require Instagram testing. Reviewed By: palmje Differential Revision: D62953540 fbshipit-source-id: 2ca3cd05710e8c7c7ef33c4fef7a9005ed0c617c
1 parent 26c736e commit 0648a8a

File tree

3 files changed

+87
-75
lines changed

3 files changed

+87
-75
lines changed

backends/vulkan/test/utils/test_utils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <cassert>
1616
#include <random>
1717

18+
using namespace vkcompute;
19+
1820
//
1921
// Operator Recording Functions
2022
//

backends/vulkan/test/utils/test_utils.h

Lines changed: 84 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,39 @@
1616
#include <executorch/backends/vulkan/runtime/graph/ops/utils/ShaderNameUtils.h>
1717
#include <executorch/backends/vulkan/runtime/graph/ops/utils/StagingUtils.h>
1818

19-
using namespace vkcompute;
20-
2119
#define CREATE_FLOAT_TEXTURE(sizes, allocate_memory) \
22-
api::vTensor( \
23-
api::context(), \
20+
vkcompute::api::vTensor( \
21+
vkcompute::api::context(), \
2422
sizes, \
2523
vkapi::kFloat, \
2624
utils::StorageType::TEXTURE_3D, \
2725
utils::GPUMemoryLayout::TENSOR_CHANNELS_PACKED, \
2826
allocate_memory);
2927

3028
#define CREATE_FLOAT_BUFFER(sizes, allocate_memory) \
31-
api::vTensor( \
32-
api::context(), \
29+
vkcompute::api::vTensor( \
30+
vkcompute::api::context(), \
3331
sizes, \
3432
vkapi::kFloat, \
3533
utils::StorageType::BUFFER, \
3634
utils::GPUMemoryLayout::TENSOR_WIDTH_PACKED, \
3735
allocate_memory);
3836

39-
#define DEFINE_STAGING_BUFFER_AND_RECORD_TO_GPU_FOR(tensor) \
40-
api::StagingBuffer staging_buffer_##tensor( \
41-
api::context(), vkapi::kFloat, tensor.staging_buffer_numel()); \
42-
record_nchw_to_image_op( \
43-
api::context(), staging_buffer_##tensor.buffer(), tensor);
44-
45-
#define DEFINE_STAGING_BUFFER_AND_RECORD_FROM_GPU_FOR(tensor) \
46-
api::StagingBuffer staging_buffer_##tensor( \
47-
api::context(), vkapi::kFloat, tensor.staging_buffer_numel()); \
48-
record_image_to_nchw_op( \
49-
api::context(), tensor, staging_buffer_##tensor.buffer());
37+
#define DEFINE_STAGING_BUFFER_AND_RECORD_TO_GPU_FOR(tensor) \
38+
vkcompute::api::StagingBuffer staging_buffer_##tensor( \
39+
vkcompute::api::context(), \
40+
vkapi::kFloat, \
41+
tensor.staging_buffer_numel()); \
42+
record_nchw_to_image_op( \
43+
vkcompute::api::context(), staging_buffer_##tensor.buffer(), tensor);
44+
45+
#define DEFINE_STAGING_BUFFER_AND_RECORD_FROM_GPU_FOR(tensor) \
46+
vkcompute::api::StagingBuffer staging_buffer_##tensor( \
47+
vkcompute::api::context(), \
48+
vkapi::kFloat, \
49+
tensor.staging_buffer_numel()); \
50+
record_image_to_nchw_op( \
51+
vkcompute::api::context(), tensor, staging_buffer_##tensor.buffer());
5052

5153
#define CHECK_VALUE(data, idx, expected) \
5254
do { \
@@ -63,76 +65,80 @@ using namespace vkcompute;
6365
//
6466

6567
void record_nchw_to_buffer_op(
66-
api::Context* const context,
67-
vkapi::VulkanBuffer& src_buffer,
68-
api::vTensor& v_dst);
68+
vkcompute::api::Context* const context,
69+
vkcompute::vkapi::VulkanBuffer& src_buffer,
70+
vkcompute::api::vTensor& v_dst);
6971

7072
void record_buffer_to_nchw_op(
71-
api::Context* const context,
72-
api::vTensor& v_src,
73-
vkapi::VulkanBuffer& dst_buffer);
73+
vkcompute::api::Context* const context,
74+
vkcompute::api::vTensor& v_src,
75+
vkcompute::vkapi::VulkanBuffer& dst_buffer);
7476

7577
void record_nchw_to_image_op(
76-
api::Context* const context,
77-
vkapi::VulkanBuffer& src_buffer,
78-
api::vTensor& v_dst);
78+
vkcompute::api::Context* const context,
79+
vkcompute::vkapi::VulkanBuffer& src_buffer,
80+
vkcompute::api::vTensor& v_dst);
7981

8082
void record_image_to_nchw_op(
81-
api::Context* const context,
82-
api::vTensor& v_src,
83-
vkapi::VulkanBuffer& dst_buffer);
83+
vkcompute::api::Context* const context,
84+
vkcompute::api::vTensor& v_src,
85+
vkcompute::vkapi::VulkanBuffer& dst_buffer);
8486

8587
void record_int8_image_to_nchw_noint8_op(
86-
api::Context* const context,
87-
api::vTensor& v_src,
88-
api::StagingBuffer& dst_buffer);
88+
vkcompute::api::Context* const context,
89+
vkcompute::api::vTensor& v_src,
90+
vkcompute::api::StagingBuffer& dst_buffer);
8991

9092
void record_conv2d_prepack_weights_op(
91-
api::Context* const context,
92-
vkapi::VulkanBuffer& src_buffer,
93-
api::vTensor& v_dst,
93+
vkcompute::api::Context* const context,
94+
vkcompute::vkapi::VulkanBuffer& src_buffer,
95+
vkcompute::api::vTensor& v_dst,
9496
const std::vector<int64_t>& original_sizes,
9597
const bool transposed);
9698

9799
void record_binary_op(
98-
api::Context* const context,
100+
vkcompute::api::Context* const context,
99101
const std::string& op_name,
100-
api::vTensor& v_in1,
101-
api::vTensor& v_in2,
102-
api::vTensor& v_dst);
102+
vkcompute::api::vTensor& v_in1,
103+
vkcompute::api::vTensor& v_in2,
104+
vkcompute::api::vTensor& v_dst);
103105

104106
void execute_and_check_add(
105-
api::vTensor& a,
106-
api::vTensor& b,
107-
api::vTensor& c,
107+
vkcompute::api::vTensor& a,
108+
vkcompute::api::vTensor& b,
109+
vkcompute::api::vTensor& c,
108110
float a_val,
109111
float b_val);
110112

111-
void record_index_fill_buffer(api::Context* const context, api::vTensor& v_ten);
113+
void record_index_fill_buffer(
114+
vkcompute::api::Context* const context,
115+
vkcompute::api::vTensor& v_ten);
112116

113117
void record_scalar_add_buffer(
114-
api::Context* context,
115-
api::vTensor& v_ten,
118+
vkcompute::api::Context* context,
119+
vkcompute::api::vTensor& v_ten,
116120
float offset);
117121

118122
void record_reference_matmul(
119-
api::Context* context,
120-
api::vTensor& out,
121-
api::vTensor& mat1,
122-
api::vTensor& mat2);
123+
vkcompute::api::Context* context,
124+
vkcompute::api::vTensor& out,
125+
vkcompute::api::vTensor& mat1,
126+
vkcompute::api::vTensor& mat2);
123127

124128
void record_matmul_texture3d(
125-
api::Context* context,
126-
api::vTensor& out,
127-
api::vTensor& mat1,
128-
api::vTensor& mat2);
129+
vkcompute::api::Context* context,
130+
vkcompute::api::vTensor& out,
131+
vkcompute::api::vTensor& mat1,
132+
vkcompute::api::vTensor& mat2);
129133

130134
//
131135
// Input & Output Utilities
132136
//
133137

134-
inline void
135-
fill_staging(api::StagingBuffer& staging, float val, int numel = -1) {
138+
inline void fill_staging(
139+
vkcompute::api::StagingBuffer& staging,
140+
float val,
141+
int numel = -1) {
136142
if (numel < 0) {
137143
numel = staging.numel();
138144
}
@@ -141,9 +147,9 @@ fill_staging(api::StagingBuffer& staging, float val, int numel = -1) {
141147
staging.copy_from(data.data(), sizeof(float) * numel);
142148
}
143149

144-
void fill_vtensor(api::vTensor& vten, std::vector<float>& data);
150+
void fill_vtensor(vkcompute::api::vTensor& vten, std::vector<float>& data);
145151

146-
void fill_vtensor(api::vTensor& vten, float val, bool iota = false);
152+
void fill_vtensor(vkcompute::api::vTensor& vten, float val, bool iota = false);
147153

148154
std::vector<float> create_random_float_buffer(
149155
const size_t numel,
@@ -156,21 +162,23 @@ std::vector<uint8_t> create_random_uint8_buffer(
156162
const uint8_t max = 255);
157163

158164
void fill_vtensor(
159-
ComputeGraph& graph,
160-
const IOValueRef idx,
165+
vkcompute::ComputeGraph& graph,
166+
const vkcompute::IOValueRef idx,
161167
float val,
162168
bool iota = false);
163169

164-
void extract_vtensor(api::vTensor& vten, std::vector<float>& data);
170+
void extract_vtensor(vkcompute::api::vTensor& vten, std::vector<float>& data);
165171

166-
inline std::vector<float> extract_vtensor(api::vTensor& vten) {
172+
inline std::vector<float> extract_vtensor(vkcompute::api::vTensor& vten) {
167173
std::vector<float> data_out(vten.staging_buffer_numel());
168174
extract_vtensor(vten, data_out);
169175
return data_out;
170176
}
171177

172-
inline void
173-
check_staging_buffer(api::StagingBuffer& staging, float val, int numel = -1) {
178+
inline void check_staging_buffer(
179+
vkcompute::api::StagingBuffer& staging,
180+
float val,
181+
int numel = -1) {
174182
if (numel < 0) {
175183
numel = staging.numel();
176184
}
@@ -183,21 +191,21 @@ check_staging_buffer(api::StagingBuffer& staging, float val, int numel = -1) {
183191
}
184192

185193
inline int64_t get_buf_idx(
186-
ComputeGraph& graph,
187-
IOValueRef ref,
194+
vkcompute::ComputeGraph& graph,
195+
vkcompute::IOValueRef ref,
188196
const std::vector<int64_t>& tensor_coor) {
189-
vTensorPtr vten_ptr = graph.get_tensor(ref.value);
197+
vkcompute::vTensorPtr vten_ptr = graph.get_tensor(ref.value);
190198

191199
const std::vector<int64_t>& sizes = vten_ptr->sizes();
192200

193-
int64_t c = dim_at<kChannel4D>(sizes);
194-
int64_t h = dim_at<kHeight4D>(sizes);
195-
int64_t w = dim_at<kWidth4D>(sizes);
201+
int64_t c = vkcompute::dim_at<vkcompute::kChannel4D>(sizes);
202+
int64_t h = vkcompute::dim_at<vkcompute::kHeight4D>(sizes);
203+
int64_t w = vkcompute::dim_at<vkcompute::kWidth4D>(sizes);
196204

197-
int64_t ni = dim_at<kBatch4D>(tensor_coor);
198-
int64_t ci = dim_at<kChannel4D>(tensor_coor);
199-
int64_t hi = dim_at<kHeight4D>(tensor_coor);
200-
int64_t wi = dim_at<kWidth4D>(tensor_coor);
205+
int64_t ni = vkcompute::dim_at<vkcompute::kBatch4D>(tensor_coor);
206+
int64_t ci = vkcompute::dim_at<vkcompute::kChannel4D>(tensor_coor);
207+
int64_t hi = vkcompute::dim_at<vkcompute::kHeight4D>(tensor_coor);
208+
int64_t wi = vkcompute::dim_at<vkcompute::kWidth4D>(tensor_coor);
201209

202210
return (ni * c * h * w + ci * h * w + hi * w + wi);
203211
}
@@ -208,7 +216,8 @@ inline int64_t get_buf_idx(
208216

209217
void submit_to_gpu();
210218

211-
vkapi::Allocation allocate_memory_for(const api::vTensor& vten);
219+
vkcompute::vkapi::Allocation allocate_memory_for(
220+
const vkcompute::api::vTensor& vten);
212221

213222
VmaTotalStatistics get_vma_stats();
214223

@@ -219,7 +228,7 @@ size_t get_vma_allocation_count();
219228
//
220229

221230
void execute_graph_and_check_output(
222-
ComputeGraph& graph,
231+
vkcompute::ComputeGraph& graph,
223232
std::vector<float> input_vals,
224233
std::vector<float> expected_outputs);
225234

backends/vulkan/test/vulkan_compute_api_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <executorch/backends/vulkan/test/utils/test_utils.h>
2727

28+
using namespace vkcompute;
2829
using namespace vkcompute::api;
2930

3031
std::vector<float>

0 commit comments

Comments
 (0)