| 707 | } |
| 708 | |
| 709 | static webgpu_encoded_op ggml_webgpu_cpy(webgpu_context & ctx, ggml_tensor * src, ggml_tensor * dst) { |
| 710 | ggml_webgpu_shader_lib_context shader_lib_ctx = {}; |
| 711 | shader_lib_ctx.src0 = src; |
| 712 | shader_lib_ctx.dst = dst; |
| 713 | shader_lib_ctx.max_wg_size = ctx->global_ctx->capabilities.limits.maxComputeInvocationsPerWorkgroup; |
| 714 | |
| 715 | webgpu_pipeline pipeline = ctx->shader_lib->get_cpy_pipeline(shader_lib_ctx); |
| 716 | |
| 717 | auto * decisions = static_cast<ggml_webgpu_generic_shader_decisions *>(pipeline.context.get()); |
| 718 | |
| 719 | uint32_t ne = (uint32_t) ggml_nelements(dst); |
| 720 | |
| 721 | std::vector<uint32_t> params = { |
| 722 | ne, (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, src) / ggml_type_size(src->type)), |
| 723 | (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, dst) / ggml_type_size(dst->type)), |
| 724 | // Convert byte-strides to element-strides |
| 725 | (uint32_t) (src->nb[0] / ggml_type_size(src->type)), (uint32_t) (src->nb[1] / ggml_type_size(src->type)), |
| 726 | (uint32_t) (src->nb[2] / ggml_type_size(src->type)), (uint32_t) (src->nb[3] / ggml_type_size(src->type)), |
| 727 | (uint32_t) (dst->nb[0] / ggml_type_size(dst->type)), (uint32_t) (dst->nb[1] / ggml_type_size(dst->type)), |
| 728 | (uint32_t) (dst->nb[2] / ggml_type_size(dst->type)), (uint32_t) (dst->nb[3] / ggml_type_size(dst->type)), |
| 729 | // Logical shapes |
| 730 | (uint32_t) src->ne[0], (uint32_t) src->ne[1], (uint32_t) src->ne[2], (uint32_t) dst->ne[0], |
| 731 | (uint32_t) dst->ne[1], (uint32_t) dst->ne[2] |
| 732 | }; |
| 733 | |
| 734 | std::vector<wgpu::BindGroupEntry> entries = { |
| 735 | ggml_webgpu_make_tensor_bind_group_entry(ctx, 0, src), |
| 736 | ggml_webgpu_make_tensor_bind_group_entry(ctx, 1, dst), |
| 737 | }; |
| 738 | |
| 739 | uint32_t wg_x = CEIL_DIV(ne, decisions->wg_size); |
| 740 | return ggml_backend_webgpu_build(ctx, pipeline, params, entries, wg_x); |
| 741 | } |
| 742 | |
| 743 | static webgpu_encoded_op ggml_webgpu_set(webgpu_context & ctx, |
| 744 | ggml_tensor * src0, |
no test coverage detected