| 733 | } |
| 734 | |
| 735 | static webgpu_encoded_op ggml_webgpu_cpy(webgpu_context & ctx, ggml_tensor * src, ggml_tensor * dst) { |
| 736 | ggml_webgpu_shader_lib_context shader_lib_ctx = {}; |
| 737 | shader_lib_ctx.src0 = src; |
| 738 | shader_lib_ctx.dst = dst; |
| 739 | shader_lib_ctx.max_wg_size = ctx->global_ctx->capabilities.limits.maxComputeInvocationsPerWorkgroup; |
| 740 | |
| 741 | webgpu_pipeline pipeline = ctx->shader_lib->get_cpy_pipeline(shader_lib_ctx); |
| 742 | |
| 743 | auto * decisions = static_cast<ggml_webgpu_generic_shader_decisions *>(pipeline.context.get()); |
| 744 | |
| 745 | uint32_t ne = (uint32_t) ggml_nelements(dst); |
| 746 | |
| 747 | std::vector<uint32_t> params = { |
| 748 | ne, (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, src) / ggml_type_size(src->type)), |
| 749 | (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, dst) / ggml_type_size(dst->type)), |
| 750 | // Convert byte-strides to element-strides |
| 751 | (uint32_t) (src->nb[0] / ggml_type_size(src->type)), (uint32_t) (src->nb[1] / ggml_type_size(src->type)), |
| 752 | (uint32_t) (src->nb[2] / ggml_type_size(src->type)), (uint32_t) (src->nb[3] / ggml_type_size(src->type)), |
| 753 | (uint32_t) (dst->nb[0] / ggml_type_size(dst->type)), (uint32_t) (dst->nb[1] / ggml_type_size(dst->type)), |
| 754 | (uint32_t) (dst->nb[2] / ggml_type_size(dst->type)), (uint32_t) (dst->nb[3] / ggml_type_size(dst->type)), |
| 755 | // Logical shapes |
| 756 | (uint32_t) src->ne[0], (uint32_t) src->ne[1], (uint32_t) src->ne[2], (uint32_t) dst->ne[0], |
| 757 | (uint32_t) dst->ne[1], (uint32_t) dst->ne[2] |
| 758 | }; |
| 759 | |
| 760 | std::vector<wgpu::BindGroupEntry> entries = { |
| 761 | ggml_webgpu_make_tensor_bind_group_entry(ctx, 0, src), |
| 762 | ggml_webgpu_make_tensor_bind_group_entry(ctx, 1, dst), |
| 763 | }; |
| 764 | |
| 765 | uint32_t wg_x = CEIL_DIV(ne, decisions->wg_size); |
| 766 | return ggml_backend_webgpu_build(ctx, pipeline, params, entries, wg_x); |
| 767 | } |
| 768 | |
| 769 | static webgpu_encoded_op ggml_webgpu_set(webgpu_context & ctx, |
| 770 | ggml_tensor * src0, |
no test coverage detected