Skip to content

Commit 5366683

Browse files
Dark Knightfacebook-github-bot
authored andcommitted
Revert D63918659
Summary: This diff reverts D63918659 Depends on D64075419 This is breaking the OSS `unittest / linux / linux-job` build: https://github.com/pytorch/executorch/actions/runs/11242482373/job/31256276319 ``` /pytorch/executorch/backends/vulkan/runtime/graph/ops/impl/Staging.cpp:83:26: error: no member named 'starts_with' in 'std::basic_string<char>' if (shader.kernel_name.starts_with("bitw8_image_to_nchw_nobitw8buffer")) { ~~~~~~~~~~~~~~~~~~ ^ 1 error generated. gmake[2]: *** [backends/vulkan/CMakeFiles/vulkan_backend.dir/build.make:636: backends/vulkan/CMakeFiles/vulkan_backend.dir/runtime/graph/ops/impl/Staging.cpp.o] Error 1 gmake[2]: *** Waiting for unfinished jobs.... ``` Reviewed By: dbort Differential Revision: D64075435
1 parent ed9f50f commit 5366683

File tree

9 files changed

+16
-78
lines changed

9 files changed

+16
-78
lines changed

backends/vulkan/runtime/graph/ops/glsl/bitw8_image_to_nchw_nobitw8buffer.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

backends/vulkan/runtime/graph/ops/glsl/bitw8_image_to_nchw_nobitw8buffer.glsl renamed to backends/vulkan/runtime/graph/ops/glsl/int8_image_to_nchw_noint8.glsl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@
1010

1111
#define PRECISION ${PRECISION}
1212

13-
${define_active_storage_type(STORAGE)}
14-
1513
#include "indexing_utils.h"
1614

1715
layout(std430) buffer;
1816

1917
#extension GL_EXT_control_flow_attributes : require
2018

2119
${layout_declare_buffer(B, "w", "nchw_out", "int")}
22-
${layout_declare_tensor(B, "r", "t_in", DTYPE, STORAGE)}
20+
${layout_declare_tensor(B, "r", "t_in", "int8", "texture3d")}
2321
${layout_declare_ubo(B, "ivec4", "tensor_sizes")}
2422
${layout_declare_ubo(B, "ivec4", "axis_map")}
2523
${layout_declare_ubo(B, "int", "out_numel")}
@@ -46,7 +44,7 @@ void main() {
4644
const ivec4 tidx = nchwi_to_tidx(in_buf_idx, tensor_sizes);
4745
const ivec4 texture_pos = to_texture_elem_pos(
4846
tidx, tensor_sizes, packed_dim);
49-
values[i] = ivec4(load_texel(t_in, texture_pos.xyz))[texture_pos.w];
47+
values[i] = load_texel(t_in, texture_pos.xyz)[texture_pos.w];
5048
in_buf_idx++;
5149
}
5250

backends/vulkan/runtime/graph/ops/glsl/nchw_to_bitw8_image_nobitw8buffer.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

backends/vulkan/runtime/graph/ops/glsl/nchw_to_bitw8_image_nobitw8buffer.glsl renamed to backends/vulkan/runtime/graph/ops/glsl/nchw_to_int8_image_noint8.glsl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@
1010

1111
#define PRECISION ${PRECISION}
1212

13-
#define VEC4_T ${texel_load_type(DTYPE, STORAGE)}
14-
15-
${define_active_storage_type(STORAGE)}
16-
1713
#include "indexing_utils.h"
1814

1915
layout(std430) buffer;
2016

2117
#extension GL_EXT_control_flow_attributes : require
2218

23-
${layout_declare_tensor(B, "w", "t_out", DTYPE, STORAGE)}
19+
${layout_declare_tensor(B, "w", "t_out", "int8", "texture3d")}
2420
${layout_declare_buffer(B, "r", "nchw_in", "int")}
2521
${layout_declare_ubo(B, "ivec4", "sizes")}
2622
${layout_declare_ubo(B, "ivec4", "axis_map")}
@@ -75,5 +71,5 @@ void main() {
7571
return;
7672
}
7773

78-
write_texel(t_out, lpos_to_pos(lpos, axis_map), VEC4_T(read_texel(tidx)));
74+
write_texel(t_out, lpos_to_pos(lpos, axis_map), read_texel(tidx));
7975
}

backends/vulkan/runtime/graph/ops/impl/Staging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void add_tensor_to_staging_node(
8080
// output buffer. Therefore, the global work group size for this shader will
8181
// be the number of elements in the output buffer divided by 4, as opposed to
8282
// the extents of the input texture.
83-
if (shader.kernel_name.starts_with("bitw8_image_to_nchw_nobitw8buffer")) {
83+
if (shader.kernel_name == "int8_image_to_nchw_noint8") {
8484
uint32_t buffer_len = graph.get_staging(out_staging)->numel() / 4;
8585
global_wg_size = {buffer_len, 1, 1};
8686
ubos.append({graph.numel_ubo(in_tensor)});

backends/vulkan/runtime/graph/ops/utils/StagingUtils.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,15 @@
1515

1616
namespace vkcompute {
1717

18-
bool is_bitw8(vkapi::ScalarType dtype) {
19-
return dtype == vkapi::kByte || dtype == vkapi::kChar ||
20-
dtype == vkapi::kQInt8 || dtype == vkapi::kQUInt8;
21-
}
22-
2318
vkapi::ShaderInfo get_nchw_to_tensor_shader(
2419
const api::vTensor& v_dst,
2520
const bool int8_buffer_enabled) {
2621
std::string kernel_name;
2722
kernel_name.reserve(kShaderNameReserve);
2823

29-
if (is_bitw8(v_dst.dtype()) && v_dst.storage_type() != utils::kBuffer &&
30-
!int8_buffer_enabled) {
31-
kernel_name = "nchw_to_bitw8_image_nobitw8buffer";
32-
add_dtype_suffix(kernel_name, v_dst);
33-
add_storage_type_suffix(kernel_name, v_dst);
34-
return VK_KERNEL_FROM_STR(kernel_name);
24+
if (v_dst.dtype() == vkapi::kChar &&
25+
v_dst.storage_type() == utils::kTexture3D && !int8_buffer_enabled) {
26+
return VK_KERNEL(nchw_to_int8_image_noint8);
3527
}
3628

3729
if (v_dst.storage_type() == utils::kBuffer) {
@@ -53,12 +45,9 @@ vkapi::ShaderInfo get_tensor_to_nchw_shader(
5345
std::string kernel_name;
5446
kernel_name.reserve(kShaderNameReserve);
5547

56-
if (is_bitw8(v_src.dtype()) && v_src.storage_type() != utils::kBuffer &&
57-
!int8_buffer_enabled) {
58-
kernel_name = "bitw8_image_to_nchw_nobitw8buffer";
59-
add_dtype_suffix(kernel_name, v_src);
60-
add_storage_type_suffix(kernel_name, v_src);
61-
return VK_KERNEL_FROM_STR(kernel_name);
48+
if (v_src.dtype() == vkapi::kChar &&
49+
v_src.storage_type() == utils::kTexture3D && !int8_buffer_enabled) {
50+
return VK_KERNEL(int8_image_to_nchw_noint8);
6251
}
6352

6453
if (v_src.storage_type() == utils::kBuffer) {

backends/vulkan/test/utils/test_utils.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,15 @@ void record_image_to_nchw_op(
111111
v_src.axis_map_ubo());
112112
}
113113

114-
void record_bitw8_image_to_nchw_nobitw8buffer_op(
114+
void record_int8_image_to_nchw_noint8_op(
115115
api::Context* const context,
116116
api::vTensor& v_src,
117117
api::StagingBuffer& dst_buffer) {
118118
vkapi::PipelineBarrier pipeline_barrier{};
119119
uint32_t buffer_len = utils::safe_downcast<uint32_t>(dst_buffer.numel() / 4);
120120
utils::uvec3 global_wg_size = {buffer_len, 1, 1};
121-
122-
std::string kernel_name = "bitw8_image_to_nchw_nobitw8buffer";
123-
add_dtype_suffix(kernel_name, v_src);
124-
add_storage_type_suffix(kernel_name, v_src);
125-
126121
context->submit_compute_job(
127-
VK_KERNEL_FROM_STR(kernel_name),
122+
VK_KERNEL(int8_image_to_nchw_noint8),
128123
pipeline_barrier,
129124
global_wg_size,
130125
adaptive_work_group_size(global_wg_size),

backends/vulkan/test/utils/test_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void record_image_to_nchw_op(
8484
vkcompute::api::vTensor& v_src,
8585
vkcompute::vkapi::VulkanBuffer& dst_buffer);
8686

87-
void record_bitw8_image_to_nchw_nobitw8buffer_op(
87+
void record_int8_image_to_nchw_noint8_op(
8888
vkcompute::api::Context* const context,
8989
vkcompute::api::vTensor& v_src,
9090
vkcompute::api::StagingBuffer& dst_buffer);

backends/vulkan/test/vulkan_compute_api_test.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,8 +2365,7 @@ void run_from_gpu_test(
23652365

23662366
if (dtype == vkapi::kChar &&
23672367
!context()->adapter_ptr()->has_full_int8_buffers_support()) {
2368-
record_bitw8_image_to_nchw_nobitw8buffer_op(
2369-
context(), vten, staging_buffer);
2368+
record_int8_image_to_nchw_noint8_op(context(), vten, staging_buffer);
23702369
} else {
23712370
record_image_to_nchw_op(context(), vten, staging_buffer.buffer());
23722371
}
@@ -2413,8 +2412,7 @@ void round_trip_test(
24132412
// Copy data in and out of the tensor
24142413
if (dtype == vkapi::kChar &&
24152414
!context()->adapter_ptr()->has_full_int8_buffers_support()) {
2416-
record_bitw8_image_to_nchw_nobitw8buffer_op(
2417-
context(), vten, staging_buffer_out);
2415+
record_int8_image_to_nchw_noint8_op(context(), vten, staging_buffer_out);
24182416
} else {
24192417
record_image_to_nchw_op(context(), vten, staging_buffer_out.buffer());
24202418
}

0 commit comments

Comments
 (0)