Skip to content

Commit ed0f0ef

Browse files
committed
[ET-VK][ez][testing] Remove conv2d test in compute_api_test + reduce stdout logging
## Changes Some changes to `vulkan_compute_api_test`: * Remove `conv2d_prepack_test`. D74523774 / #11306 recently changed the conv2d prepack shader to use push constants, and since this test uses the "old" vulkan compute API (which doesn't support push constants) the test broke. Operator tests at this point are handled by `compute_graph_op_tests` anyway so just remove this test. * Make it so that verbose logging in `test_to_copy` only occurs in `VULKAN_DEBUG` is defined * Disable `test_etvk_copy_channel_offset_node*` tests, as these tests fail on some platforms (i.e. devGPU, windows, mac) likely due to an error in the implementation of the op. Differential Revision: [D76156109](https://our.internmc.facebook.com/intern/diff/D76156109/) [ghstack-poisoned]
1 parent 27cb43d commit ed0f0ef

File tree

2 files changed

+7
-107
lines changed

2 files changed

+7
-107
lines changed

backends/vulkan/test/utils/test_utils.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -137,45 +137,6 @@ void record_bitw8_image_to_nchw_nobitw8buffer_op(
137137
v_src.numel_ubo());
138138
}
139139

140-
void record_conv2d_prepack_weights_op(
141-
api::Context* const context,
142-
vkapi::VulkanBuffer& src_buffer,
143-
api::vTensor& v_dst,
144-
const std::vector<int64_t>& original_sizes,
145-
const bool transposed) {
146-
vkapi::PipelineBarrier pipeline_barrier{};
147-
148-
std::string kernel_name;
149-
if (transposed) {
150-
kernel_name = "conv_transpose2d";
151-
} else {
152-
kernel_name = "conv2d";
153-
}
154-
kernel_name += "_prepack_weights";
155-
add_dtype_suffix(kernel_name, v_dst);
156-
vkapi::ShaderInfo shader = VK_KERNEL_FROM_STR(kernel_name);
157-
158-
api::ParamsBuffer original_sizes_ubo(
159-
context, utils::make_ivec4(original_sizes, /*reverse = */ true));
160-
161-
vkapi::SpecVarList specialization_constants = {};
162-
context->submit_compute_job(
163-
shader,
164-
pipeline_barrier,
165-
v_dst.logical_limits(),
166-
adaptive_work_group_size(v_dst.logical_limits()),
167-
specialization_constants,
168-
VK_NULL_HANDLE,
169-
0,
170-
v_dst.image(
171-
pipeline_barrier,
172-
vkapi::PipelineStage::COMPUTE,
173-
vkapi::MemoryAccessType::WRITE),
174-
src_buffer,
175-
v_dst.sizes_ubo(),
176-
original_sizes_ubo.buffer());
177-
}
178-
179140
void record_binary_op(
180141
api::Context* const context,
181142
const std::string& op_name,

backends/vulkan/test/vulkan_compute_api_test.cpp

Lines changed: 7 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,7 @@ TEST(VulkanComputeGraphTest, test_etvk_copy_offset_node) {
20442044
}
20452045
}
20462046

2047-
TEST(VulkanComputeGraphTest, test_etvk_copy_channel_offset_node) {
2047+
TEST(VulkanComputeGraphTest, DISABLED_test_etvk_copy_channel_offset_node) {
20482048
GraphConfig config;
20492049
ComputeGraph graph(config);
20502050

@@ -2103,7 +2103,7 @@ TEST(VulkanComputeGraphTest, test_etvk_copy_channel_offset_node) {
21032103

21042104
TEST(
21052105
VulkanComputeGraphTest,
2106-
test_etvk_copy_channel_offset_node_clean_boundary) {
2106+
DISABLED_test_etvk_copy_channel_offset_node_clean_boundary) {
21072107
// Tricky part for channel copy is handling the boundary across multiple copy.
21082108
// For example, when we concat two [3, 1, 1] nchw-tensors along the channel
21092109
// dimension, due to channel packing, elements from different source texel
@@ -2312,7 +2312,7 @@ TEST(VulkanComputeGraphTest, test_etvk_copy_offset_int_node) {
23122312
}
23132313
}
23142314

2315-
TEST(VulkanComputeGraphTest, test_etvk_copy_channel_offset_int_node) {
2315+
TEST(VulkanComputeGraphTest, DISABLED_test_etvk_copy_channel_offset_int_node) {
23162316
GraphConfig config;
23172317
ComputeGraph graph(config);
23182318

@@ -2966,71 +2966,6 @@ TEST(VulkanComputeGraphOpsTest, max_pool2d_smoke_test) {
29662966
kernel);
29672967
}
29682968

2969-
void test_conv2d(
2970-
const std::vector<int64_t>& original_sizes,
2971-
const std::vector<int64_t>& padded_sizes,
2972-
const std::vector<int64_t>& gpu_sizes,
2973-
const bool transposed,
2974-
const std::vector<float>& data_out_expected) {
2975-
vTensor vten = vTensor(
2976-
context(),
2977-
gpu_sizes,
2978-
vkapi::kFloat,
2979-
utils::StorageType::TEXTURE_2D,
2980-
utils::GPUMemoryLayout::TENSOR_CHANNELS_PACKED);
2981-
2982-
// Create and fill input staging buffer
2983-
const int64_t in_numel = utils::multiply_integers(original_sizes);
2984-
StagingBuffer staging_buffer_in(context(), vkapi::kFloat, in_numel);
2985-
2986-
std::vector<float> data_in(in_numel);
2987-
for (int i = 0; i < in_numel; i++) {
2988-
data_in[i] = i + 1;
2989-
}
2990-
staging_buffer_in.copy_from(data_in.data(), sizeof(float) * in_numel);
2991-
2992-
// Output staging buffer
2993-
const int64_t out_numel =
2994-
padded_sizes[0] * padded_sizes[1] * original_sizes[2] * original_sizes[3];
2995-
StagingBuffer staging_buffer_out(context(), vkapi::kFloat, out_numel);
2996-
2997-
// Copy data in and out of the tensor
2998-
record_conv2d_prepack_weights_op(
2999-
context(), staging_buffer_in.buffer(), vten, original_sizes, transposed);
3000-
record_image_to_nchw_op(context(), vten, staging_buffer_out.buffer());
3001-
3002-
// Execute command buffer
3003-
submit_to_gpu();
3004-
3005-
// Extract data from output staging buffer
3006-
std::vector<float> data_out(out_numel);
3007-
staging_buffer_out.copy_to(data_out.data(), sizeof(float) * out_numel);
3008-
3009-
// Check data matches results copied from ATen-VK
3010-
for (int i = 0; i < vten.numel(); i++) {
3011-
CHECK_VALUE(data_out, i, data_out_expected[i]);
3012-
}
3013-
}
3014-
3015-
TEST(VulkanComputeGraphOpsTest, conv2d_prepack_test) {
3016-
test_conv2d(
3017-
/*original_sizes = */ {2, 3, 1, 2},
3018-
/*padded_sizes = */ {4, 4},
3019-
/*gpu_sizes = */ {4, 1, 8},
3020-
/*transposed = */ false,
3021-
/*data_out_expected = */ {1, 3, 5, 0, 2, 4, 6, 0, 7, 9, 11,
3022-
0, 8, 10, 12, 0, 0, 0, 0, 0, 0, 0,
3023-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
3024-
test_conv2d(
3025-
/*original_sizes = */ {2, 3, 1, 2},
3026-
/*padded_sizes = */ {4, 4},
3027-
/*gpu_sizes = */ {4, 1, 8},
3028-
/*transposed = */ true,
3029-
/*data_out_expected = */ {2, 8, 0, 0, 1, 7, 0, 0, 4, 10, 0,
3030-
0, 3, 9, 0, 0, 6, 12, 0, 0, 5, 11,
3031-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
3032-
}
3033-
30342969
void test_grid_priors(
30352970
std::vector<int64_t> input_sizes,
30362971
std::vector<int64_t> output_sizes,
@@ -3254,6 +3189,7 @@ void test_to_copy() {
32543189
torch::executor::Half output = output_data[i];
32553190
uint16_t* output_bits = reinterpret_cast<uint16_t*>(&output);
32563191

3192+
#ifdef VULKAN_DEBUG
32573193
std::string msg;
32583194
msg.reserve(64);
32593195
msg = "input = " + std::to_string(input) + "(0b" +
@@ -3264,6 +3200,7 @@ void test_to_copy() {
32643200
std::bitset<16>(*output_bits).to_string() + ")";
32653201

32663202
std::cout << msg << std::endl;
3203+
#endif
32673204

32683205
// Note: Torch executor half "rounds up" when converting to fp16 whereas
32693206
// most driver implementations of Vulkan's opFConvert() just truncates the
@@ -3290,9 +3227,11 @@ void test_to_copy() {
32903227

32913228
mse_ex /= output_data.size();
32923229
mse_vk /= output_data.size();
3230+
#ifdef VULKAN_DEBUG
32933231
std::cout << "========================================================="
32943232
<< std::endl;
32953233
std::cout << "mse_ex = " << mse_ex << ", mse_vk = " << mse_vk << std::endl;
3234+
#endif
32963235
}
32973236

32983237
TEST(VulkanComputeGraphOpsTest, test_to_copy) {

0 commit comments

Comments
 (0)