MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / ggml_webgpu_concat

Function ggml_webgpu_concat

external/ggml/src/ggml-webgpu/ggml-webgpu.cpp:2200–2244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2198}
2199
2200static webgpu_encoded_op ggml_webgpu_concat(webgpu_context & ctx,
2201 ggml_tensor * src0,
2202 ggml_tensor * src1,
2203 ggml_tensor * dst) {
2204 uint32_t ne = (uint32_t) ggml_nelements(dst);
2205 uint32_t dim = (uint32_t) dst->op_params[0];
2206
2207 std::vector<uint32_t> params = {
2208 ne,
2209 (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, src0) / ggml_type_size(src0->type)),
2210 (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, src1) / ggml_type_size(src1->type)),
2211 (uint32_t) (ggml_webgpu_tensor_misalignment(ctx, dst) / ggml_type_size(dst->type)),
2212 (uint32_t) (src0->nb[0] / ggml_type_size(src0->type)),
2213 (uint32_t) (src0->nb[1] / ggml_type_size(src0->type)),
2214 (uint32_t) (src0->nb[2] / ggml_type_size(src0->type)),
2215 (uint32_t) (src0->nb[3] / ggml_type_size(src0->type)),
2216 (uint32_t) (src1->nb[0] / ggml_type_size(src1->type)),
2217 (uint32_t) (src1->nb[1] / ggml_type_size(src1->type)),
2218 (uint32_t) (src1->nb[2] / ggml_type_size(src1->type)),
2219 (uint32_t) (src1->nb[3] / ggml_type_size(src1->type)),
2220 (uint32_t) dst->ne[0],
2221 (uint32_t) dst->ne[1],
2222 (uint32_t) dst->ne[2],
2223 (uint32_t) dst->ne[3],
2224 dim,
2225 (uint32_t) src0->ne[dim]
2226 };
2227
2228 std::vector<wgpu::BindGroupEntry> entries = {
2229 ggml_webgpu_make_tensor_bind_group_entry(ctx, 0, src0),
2230 ggml_webgpu_make_tensor_bind_group_entry(ctx, 1, src1),
2231 ggml_webgpu_make_tensor_bind_group_entry(ctx, 2, dst),
2232 };
2233
2234 ggml_webgpu_shader_lib_context shader_lib_ctx = {};
2235 shader_lib_ctx.src0 = src0;
2236 shader_lib_ctx.src1 = src1;
2237 shader_lib_ctx.dst = dst;
2238 shader_lib_ctx.max_wg_size = ctx->global_ctx->capabilities.limits.maxComputeInvocationsPerWorkgroup;
2239
2240 webgpu_pipeline pipeline = ctx->shader_lib->get_concat_pipeline(shader_lib_ctx);
2241 auto * decisions = static_cast<ggml_webgpu_generic_shader_decisions *>(pipeline.context.get());
2242 uint32_t wg_x = CEIL_DIV(ne, decisions->wg_size);
2243 return ggml_backend_webgpu_build(ctx, pipeline, params, entries, wg_x);
2244}
2245
2246static webgpu_encoded_op ggml_webgpu_repeat(webgpu_context & ctx, ggml_tensor * src0, ggml_tensor * dst) {
2247 uint32_t ne = (uint32_t) ggml_nelements(dst);

Callers 1

ggml_webgpu_encodeFunction · 0.85

Calls 7

ggml_nelementsFunction · 0.85
ggml_type_sizeFunction · 0.85
get_concat_pipelineMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected