| 4219 | // ggml_scale |
| 4220 | |
| 4221 | static struct ggml_tensor * ggml_scale_impl( |
| 4222 | struct ggml_context * ctx, |
| 4223 | struct ggml_tensor * a, |
| 4224 | struct ggml_tensor * b, |
| 4225 | bool inplace) { |
| 4226 | GGML_ASSERT(ggml_is_scalar(b)); |
| 4227 | GGML_ASSERT(ggml_is_padded_1d(a)); |
| 4228 | |
| 4229 | bool is_node = false; |
| 4230 | |
| 4231 | if (a->grad || b->grad) { |
| 4232 | is_node = true; |
| 4233 | } |
| 4234 | |
| 4235 | struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a); |
| 4236 | |
| 4237 | result->op = GGML_OP_SCALE; |
| 4238 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 4239 | result->src[0] = a; |
| 4240 | result->src[1] = b; |
| 4241 | |
| 4242 | return result; |
| 4243 | } |
| 4244 | |
| 4245 | struct ggml_tensor * ggml_scale( |
| 4246 | struct ggml_context * ctx, |
no test coverage detected