| 5511 | // ggml_pool_2d |
| 5512 | |
| 5513 | struct ggml_tensor * ggml_pool_2d( |
| 5514 | struct ggml_context * ctx, |
| 5515 | struct ggml_tensor * a, |
| 5516 | enum ggml_op_pool op, |
| 5517 | int k0, |
| 5518 | int k1, |
| 5519 | int s0, |
| 5520 | int s1, |
| 5521 | float p0, |
| 5522 | float p1) { |
| 5523 | |
| 5524 | bool is_node = false; |
| 5525 | |
| 5526 | if (a->grad) { |
| 5527 | GGML_ASSERT(false); // TODO: implement backward |
| 5528 | is_node = true; |
| 5529 | } |
| 5530 | |
| 5531 | const int64_t ne[3] = { |
| 5532 | ggml_calc_pool_output_size(a->ne[0], k0, s0, p0), |
| 5533 | ggml_calc_pool_output_size(a->ne[1], k1, s1, p1), |
| 5534 | a->ne[2], |
| 5535 | }; |
| 5536 | struct ggml_tensor * result = ggml_new_tensor(ctx, GGML_TYPE_F32, 3, ne); |
| 5537 | |
| 5538 | int32_t params[] = { op, k0, k1, s0, s1, p0, p1 }; |
| 5539 | ggml_set_op_params(result, params, sizeof(params)); |
| 5540 | |
| 5541 | result->op = GGML_OP_POOL_2D; |
| 5542 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 5543 | result->src[0] = a; |
| 5544 | |
| 5545 | return result; |
| 5546 | } |
| 5547 | |
| 5548 | // ggml_upscale |
| 5549 |
nothing calls this directly
no test coverage detected