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

Function ggml_conv_2d_dw

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

Source from the content-addressed store, hash-verified

4638// ggml_conv_2d_dw
4639
4640struct ggml_tensor * ggml_conv_2d_dw(
4641 struct ggml_context * ctx,
4642 struct ggml_tensor * a,
4643 struct ggml_tensor * b,
4644 int s0,
4645 int s1,
4646 int p0,
4647 int p1,
4648 int d0,
4649 int d1) {
4650 struct ggml_tensor * new_a = ggml_reshape_4d(ctx, a, a->ne[0], a->ne[1], 1, a->ne[2] * a->ne[3]);
4651 struct ggml_tensor * im2col = ggml_im2col(ctx, new_a,
4652 ggml_reshape_4d(ctx, b, b->ne[0], b->ne[1], 1, b->ne[2] * b->ne[3]),
4653 s0, s1, p0, p1, d0, d1, true, GGML_TYPE_F16); // [N * IC, OH, OW, KH * KW]
4654 struct ggml_tensor * new_b = ggml_reshape_4d(ctx, im2col, im2col->ne[0], im2col->ne[2] * im2col->ne[1], b->ne[2], b->ne[3]); // [N * IC, OH, OW, KH * KW] => [N, IC, OH * OW, KH * KW]
4655
4656 new_a = ggml_reshape_4d(ctx, new_a, (new_a->ne[0] * new_a->ne[1]), new_a->ne[2], new_a->ne[3], 1); // [OC,1, KH, KW] => [1, OC, 1, KH * KW]
4657 struct ggml_tensor * result = ggml_mul_mat(ctx, new_a, new_b);
4658 result = ggml_reshape_4d(ctx, result, im2col->ne[1], im2col->ne[2], b->ne[2], b->ne[3]); // [N, OC, OH, OW]
4659
4660 return result;
4661}
4662
4663// ggml_conv_2d_dw_direct
4664

Callers 3

build_mobilenet_attnMethod · 0.85
buildMethod · 0.85

Calls 3

ggml_reshape_4dFunction · 0.85
ggml_im2colFunction · 0.85
ggml_mul_matFunction · 0.85

Tested by

no test coverage detected