Skip to content

Commit be8ddab

Browse files
committed
[ET-VK] Replace Uniform buffers with push constants for view op
This diff replaces uniform buffers with push constants for view op in the Vulkan backend of Executorch. The changes include updating the GLSL code to use push constants instead of uniform buffers and updating the C++ code to pass the sizes as push constants to the shader. Differential Revision: [D66733658](https://our.internmc.facebook.com/intern/diff/D66733658/) ghstack-source-id: 256912127 Pull Request resolved: #7229
1 parent a884ada commit be8ddab

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

backends/vulkan/runtime/graph/ops/glsl/view.glsl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ layout(std430) buffer;
1919
${layout_declare_tensor(0, "w", "t_out", DTYPE, STORAGE)}
2020
${layout_declare_tensor(1, "r", "t_in", DTYPE, STORAGE)}
2121

22-
${layout_declare_ubo(2, "ivec4", "out_sizes")}
23-
${layout_declare_ubo(3, "ivec4", "in_sizes")}
22+
layout(push_constant) uniform PRECISION restrict Block {
23+
ivec4 out_sizes;
24+
ivec4 in_sizes;
25+
};
2426

2527
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
2628

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ void add_view_node(
7676
{{out, vkapi::MemoryAccessType::WRITE},
7777
{in, vkapi::MemoryAccessType::READ}},
7878
// Parameter Buffers
79-
{t_out->sizes_ubo(), t_in->sizes_ubo()},
79+
{},
8080
// Specialization Constants
8181
{SV(t_in->packed_dim()), SV(t_out->packed_dim())},
8282
// Resizing Logic
8383
resize_view_node,
84-
{sizes}));
84+
{sizes},
85+
// Push Constants
86+
{{graph.sizes_pc_of(out), graph.sizes_pc_of(in)}}));
8587
}
8688

8789
void view(ComputeGraph& graph, const std::vector<ValueRef>& args) {

0 commit comments

Comments
 (0)