| 2363 | split_entries.push_back(ggml_webgpu_make_bind_group_entry(split_binding_index++, ggml_webgpu_tensor_buf(dst), |
| 2364 | ggml_webgpu_tensor_align_offset(ctx, dst), |
| 2365 | ggml_webgpu_tensor_binding_size(ctx, dst))); |
| 2366 | |
| 2367 | webgpu_pipeline reduce_pipeline; |
| 2368 | std::vector<uint32_t> reduce_params; |
| 2369 | std::vector<wgpu::BindGroupEntry> reduce_entries; |
| 2370 | if (use_vec_reduce) { |
| 2371 | const uint32_t reduce_sg_size = ctx->global_ctx->capabilities.max_subgroup_size; |
| 2372 | const uint32_t reduce_wg_size = std::max( |
| 2373 | reduce_sg_size, |
| 2374 | (uint32_t) std::min<uint64_t>((uint64_t) nwg * reduce_sg_size, |
| 2375 | ctx->global_ctx->capabilities.limits.maxComputeInvocationsPerWorkgroup)); |
| 2376 | ggml_webgpu_shader_lib_context reduce_shader_ctx = op.shader_lib_ctx; |
| 2377 | reduce_shader_ctx.max_wg_size = reduce_wg_size; |
| 2378 | reduce_pipeline = ctx->shader_lib->get_flash_attn_vec_reduce_pipeline(reduce_shader_ctx); |
| 2379 | |
| 2380 | reduce_params = { |
| 2381 | (uint32_t) nrows, // nrows |
| 2382 | (uint32_t) Q->ne[1], // seq_len_q |
| 2383 | (uint32_t) Q->ne[2], // n_heads |
| 2384 | (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, dst) / ggml_type_size(dst->type)), // offset_dst |
| 2385 | nwg, // nwg |
| 2386 | 0u, // tmp_data_base |
| 2387 | (uint32_t) tmp_stats_base, // tmp_stats_base |
| 2388 | }; |
| 2389 | |
| 2390 | reduce_entries = { |
| 2391 | ggml_webgpu_make_bind_group_entry(0, tmp_buf, tmp_bind_offset, tmp_size_bytes), |
| 2392 | ggml_webgpu_make_bind_group_entry(1, ggml_webgpu_tensor_buf(dst), ggml_webgpu_tensor_align_offset(ctx, dst), |
| 2393 | ggml_webgpu_tensor_binding_size(ctx, dst)), |
| 2394 | }; |
| 2395 | } |
| 2396 | |
| 2397 | uint32_t wg_x = Q->ne[1] * Q->ne[2] * Q->ne[3]; |
| 2398 | const uint64_t split_wg_total = (uint64_t) wg_x * nwg; |
no test coverage detected