Skip to content

Commit 80f7005

Browse files
pytorchbotSS-JIA
andauthored
[ET-VK][ops] Move group norm reduction lanes to Z (pytorch#22287)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: pytorch#22222 by @SS-JIA ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/602/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/602/head Merge bot PR base: https://github.com/pytorch/executorch/tree/main Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/602/orig Differential Revision: [D117706347](https://our.internmc.facebook.com/intern/diff/D117706347/) @diff-train-skip-merge Co-authored-by: Stephen Jia <ssjia@meta.com>
1 parent d614f9d commit 80f7005

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎backends/vulkan/runtime/graph/ops/glsl/group_norm_reduce_texture.glsl‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,16 @@ shared float shared_sum_sq[LOCAL_WORK_GROUP_SIZE];
6565
* N is the number of elements in the tensor buffer; each thread computes one
6666
* output element.
6767
*
68-
* Local work group size: {1, float, 1}
69-
* float should be a power of 2, recommended 64 or 128 threads. This allows
70-
* efficient tree-based reduction in shared memory. Each local group will
71-
* cooperate to compute the output element.
68+
* Local work group size: {1, 1, 64}
69+
* This allows efficient tree-based reduction in shared memory. Each local
70+
* group cooperates to compute one output element.
7271
*
7372
* Each shader invocation will compute the mean and standard deviation for one
7473
* channel group in the input, and write out the corresponding result.
7574
*/
7675
void group_norm_reduce_C_packed() {
7776
const int global_idx = int(gl_GlobalInvocationID.x);
78-
const int local_idx = int(gl_LocalInvocationID.y);
77+
const int local_idx = int(gl_LocalInvocationID.z);
7978

8079
// Calculate group dimensions
8180
const int D = in_sizes.z / group; // channels per group

‎backends/vulkan/runtime/graph/ops/impl/GroupNorm.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ utils::uvec3 group_norm_local_wg_size(
2929
(void)args;
3030
(void)resize_args;
3131

32-
return {1, 64, 1};
32+
return {1u, 1u, 64u};
3333
}
3434

3535
void resize_group_norm_texture_node(
3636
ComputeGraph* graph,
3737
const std::vector<ArgGroup>& args,
3838
const std::vector<ValueRef>& resize_args) {
39+
VK_CHECK_COND(graph != nullptr);
40+
3941
// Extract tensor references from args
4042
const ValueRef out = args.at(0).refs.at(0);
4143
const ValueRef in = args.at(1).refs.at(0);

0 commit comments

Comments
 (0)