| 4638 | // ggml_conv_2d_dw |
| 4639 | |
| 4640 | struct 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 |
no test coverage detected