| 3453 | // ggml_div |
| 3454 | |
| 3455 | static struct ggml_tensor * ggml_div_impl( |
| 3456 | struct ggml_context * ctx, |
| 3457 | struct ggml_tensor * a, |
| 3458 | struct ggml_tensor * b, |
| 3459 | bool inplace) { |
| 3460 | GGML_ASSERT(ggml_are_same_shape(a, b)); |
| 3461 | |
| 3462 | bool is_node = false; |
| 3463 | |
| 3464 | if (!inplace && (a->grad || b->grad)) { |
| 3465 | is_node = true; |
| 3466 | } |
| 3467 | |
| 3468 | if (inplace) { |
| 3469 | GGML_ASSERT(!is_node); |
| 3470 | } |
| 3471 | |
| 3472 | struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a); |
| 3473 | |
| 3474 | result->op = GGML_OP_DIV; |
| 3475 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 3476 | result->src[0] = a; |
| 3477 | result->src[1] = b; |
| 3478 | |
| 3479 | return result; |
| 3480 | } |
| 3481 | |
| 3482 | struct ggml_tensor * ggml_div( |
| 3483 | struct ggml_context * ctx, |
no test coverage detected