MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / ggml_conv_2d

Function ggml_conv_2d

subprojects/llama.cpp/ggml/src/ggml.c:4511–4533  ·  view source on GitHub ↗

a: [OC,IC, KH, KW] b: [N, IC, IH, IW] result: [N, OC, OH, OW]

Source from the content-addressed store, hash-verified

4509// b: [N, IC, IH, IW]
4510// result: [N, OC, OH, OW]
4511struct ggml_tensor * ggml_conv_2d(
4512 struct ggml_context * ctx,
4513 struct ggml_tensor * a,
4514 struct ggml_tensor * b,
4515 int s0,
4516 int s1,
4517 int p0,
4518 int p1,
4519 int d0,
4520 int d1) {
4521 struct ggml_tensor * im2col = ggml_im2col(ctx, a, b, s0, s1, p0, p1, d0, d1, true, a->type); // [N, OH, OW, IC * KH * KW]
4522
4523 struct ggml_tensor * result =
4524 ggml_mul_mat(ctx,
4525 ggml_reshape_2d(ctx, im2col, im2col->ne[0], im2col->ne[3] * im2col->ne[2] * im2col->ne[1]), // [N, OH, OW, IC * KH * KW] => [N*OH*OW, IC * KH * KW]
4526 ggml_reshape_2d(ctx, a, (a->ne[0] * a->ne[1] * a->ne[2]), a->ne[3])); // [OC,IC, KH, KW] => [OC, IC * KH * KW]
4527
4528 result = ggml_reshape_4d(ctx, result, im2col->ne[1], im2col->ne[2], im2col->ne[3], a->ne[3]); // [OC, N, OH, OW]
4529 result = ggml_cont(ctx, ggml_permute(ctx, result, 0, 1, 3, 2)); // [N, OC, OH, OW]
4530
4531
4532 return result;
4533}
4534
4535// a: [OC*IC, KD, KH, KW]
4536// b: [N*IC, ID, IH, IW]

Callers 9

build_inpMethod · 0.85
buildMethod · 0.85
buildMethod · 0.85
buildMethod · 0.85
buildMethod · 0.85
buildMethod · 0.85
ggml_conv_2d_sk_p0Function · 0.85
ggml_conv_2d_s1_phFunction · 0.85
ggml_vk_check_results_0Function · 0.85

Calls 6

ggml_im2colFunction · 0.85
ggml_mul_matFunction · 0.85
ggml_reshape_2dFunction · 0.85
ggml_reshape_4dFunction · 0.85
ggml_contFunction · 0.85
ggml_permuteFunction · 0.85

Tested by

no test coverage detected