Skip to content

Commit 73e5685

Browse files
trivedivivekfacebook-github-bot
authored andcommitted
Using push constants for softmax op. (#16112)
Summary: The softmax operation has been updated to utilize push constants for efficient data transfer. Differential Revision: D88097603
1 parent 4014597 commit 73e5685

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ layout(std430) buffer;
2323
${layout_declare_tensor(B, "w", "tout", DTYPE, STORAGE)}
2424
${layout_declare_tensor(B, "r", "tin", DTYPE, STORAGE)}
2525

26-
${layout_declare_ubo(B, "ivec3", "tout_limits")}
27-
${layout_declare_ubo(B, "ivec4", "tin_sizes")}
26+
layout(push_constant) uniform restrict Block {
27+
ivec4 tin_sizes;
28+
ivec3 tout_limits;
29+
};
2830

2931
layout(local_size_x_id = 0, local_size_y_id = 1, local_size_z_id = 2) in;
3032

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ void add_softmax_node(
139139
// Inputs and Outputs
140140
{{out, vkapi::kWrite}, {in, vkapi::kRead}},
141141
// Shader params buffers
142-
{graph.logical_limits_ubo(out), graph.sizes_ubo(in)},
143-
// Push Constants
144142
{},
143+
// Push Constants
144+
{graph.sizes_pc_of(in), graph.logical_limits_pc_of(out)},
145145
// Specialization Constants
146146
{graph.packed_dim_of(out), reduce_dim_xyz, group_dim},
147147
// Resize Args

0 commit comments

Comments
 (0)