| 4313 | // ggml_clamp |
| 4314 | |
| 4315 | struct ggml_tensor * ggml_clamp( |
| 4316 | struct ggml_context * ctx, |
| 4317 | struct ggml_tensor * a, |
| 4318 | float min, |
| 4319 | float max) { |
| 4320 | // TODO: when implement backward, fix this: |
| 4321 | struct ggml_tensor * result = ggml_view_tensor(ctx, a); |
| 4322 | |
| 4323 | float params[] = { min, max }; |
| 4324 | ggml_set_op_params(result, params, sizeof(params)); |
| 4325 | |
| 4326 | result->op = GGML_OP_CLAMP; |
| 4327 | result->src[0] = a; |
| 4328 | |
| 4329 | return result; |
| 4330 | } |
| 4331 | |
| 4332 | static int64_t ggml_calc_conv_output_size(int64_t ins, int64_t ks, int s, int p, int d) { |
| 4333 | return (ins + 2 * p - d * (ks - 1) - 1) / s + 1; |