MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_conv_2d

Function ggml_conv_2d

ggml.c:5395–5415  ·  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

5393// b: [N, IC, IH, IW]
5394// result: [N, OC, OH, OW]
5395struct ggml_tensor * ggml_conv_2d(
5396 struct ggml_context * ctx,
5397 struct ggml_tensor * a,
5398 struct ggml_tensor * b,
5399 int s0,
5400 int s1,
5401 int p0,
5402 int p1,
5403 int d0,
5404 int d1) {
5405 struct ggml_tensor * im2col = ggml_im2col(ctx, a, b, s0, s1, p0, p1, d0, d1, true); // [N, OH, OW, IC * KH * KW]
5406
5407 struct ggml_tensor * result =
5408 ggml_mul_mat(ctx,
5409 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]
5410 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]
5411
5412 result = ggml_reshape_4d(ctx, result, im2col->ne[1], im2col->ne[2], a->ne[3], im2col->ne[3]); // [N, OC, OH, OW]
5413
5414 return result;
5415}
5416
5417// ggml_conv_2d_sk_p0
5418struct ggml_tensor * ggml_conv_2d_sk_p0(

Callers 3

ggml_conv_2d_sk_p0Function · 0.70
ggml_conv_2d_s1_phFunction · 0.70
clip_image_build_graphFunction · 0.50

Calls 4

ggml_im2colFunction · 0.70
ggml_mul_matFunction · 0.70
ggml_reshape_2dFunction · 0.70
ggml_reshape_4dFunction · 0.70

Tested by

no test coverage detected