| 822 | } |
| 823 | |
| 824 | static webgpu_encoded_op ggml_webgpu_pad(webgpu_context & ctx, ggml_tensor * src, ggml_tensor * dst) { |
| 825 | ggml_webgpu_shader_lib_context shader_lib_ctx = {}; |
| 826 | shader_lib_ctx.src0 = src; |
| 827 | shader_lib_ctx.dst = dst; |
| 828 | shader_lib_ctx.max_wg_size = ctx->global_ctx->capabilities.limits.maxComputeInvocationsPerWorkgroup; |
| 829 | |
| 830 | webgpu_pipeline pipeline = ctx->shader_lib->get_pad_pipeline(shader_lib_ctx); |
| 831 | |
| 832 | auto * decisions = static_cast<ggml_webgpu_generic_shader_decisions *>(pipeline.context.get()); |
| 833 | |
| 834 | const uint32_t ne = (uint32_t) ggml_nelements(dst); |
| 835 | |
| 836 | std::vector<uint32_t> params = { |
| 837 | ne, |
| 838 | (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, src) / ggml_type_size(src->type)), |
| 839 | (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, dst) / ggml_type_size(dst->type)), |
| 840 | // Strides (in elements) |
| 841 | (uint32_t) (src->nb[0] / ggml_type_size(src->type)), |
| 842 | (uint32_t) (src->nb[1] / ggml_type_size(src->type)), |
| 843 | (uint32_t) (src->nb[2] / ggml_type_size(src->type)), |
| 844 | (uint32_t) (src->nb[3] / ggml_type_size(src->type)), |
| 845 | // Shapes |
| 846 | (uint32_t) src->ne[0], |
| 847 | (uint32_t) src->ne[1], |
| 848 | (uint32_t) src->ne[2], |
| 849 | (uint32_t) src->ne[3], |
| 850 | (uint32_t) dst->ne[0], |
| 851 | (uint32_t) dst->ne[1], |
| 852 | (uint32_t) dst->ne[2], |
| 853 | (uint32_t) dst->ne[3], |
| 854 | // Pad sizes |
| 855 | (uint32_t) ggml_get_op_params_i32(dst, 0), |
| 856 | (uint32_t) ggml_get_op_params_i32(dst, 1), |
| 857 | (uint32_t) ggml_get_op_params_i32(dst, 2), |
| 858 | (uint32_t) ggml_get_op_params_i32(dst, 3), |
| 859 | (uint32_t) ggml_get_op_params_i32(dst, 4), |
| 860 | (uint32_t) ggml_get_op_params_i32(dst, 5), |
| 861 | (uint32_t) ggml_get_op_params_i32(dst, 6), |
| 862 | (uint32_t) ggml_get_op_params_i32(dst, 7), |
| 863 | }; |
| 864 | |
| 865 | std::vector<wgpu::BindGroupEntry> entries = { |
| 866 | ggml_webgpu_make_tensor_bind_group_entry(ctx, 0, src), |
| 867 | ggml_webgpu_make_tensor_bind_group_entry(ctx, 1, dst), |
| 868 | }; |
| 869 | |
| 870 | uint32_t wg_x = CEIL_DIV(ne, decisions->wg_size); |
| 871 | return ggml_backend_webgpu_build(ctx, pipeline, params, entries, wg_x); |
| 872 | } |
| 873 | |
| 874 | static webgpu_encoded_op ggml_webgpu_solve_tri(webgpu_context & ctx, |
| 875 | ggml_tensor * src0, |
no test coverage detected