| 3708 | // ggml_repeat_back |
| 3709 | |
| 3710 | struct ggml_tensor * ggml_repeat_back( |
| 3711 | struct ggml_context * ctx, |
| 3712 | struct ggml_tensor * a, |
| 3713 | struct ggml_tensor * b) { |
| 3714 | GGML_ASSERT(ggml_can_repeat(b, a)); |
| 3715 | |
| 3716 | bool is_node = false; |
| 3717 | |
| 3718 | if (a->grad) { |
| 3719 | is_node = true; |
| 3720 | } |
| 3721 | |
| 3722 | if (ggml_are_same_shape(a, b) && !is_node) { |
| 3723 | return a; |
| 3724 | } |
| 3725 | |
| 3726 | struct ggml_tensor * result = ggml_new_tensor(ctx, a->type, b->n_dims, b->ne); |
| 3727 | |
| 3728 | result->op = GGML_OP_REPEAT_BACK; |
| 3729 | result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; |
| 3730 | result->src[0] = a; |
| 3731 | |
| 3732 | return result; |
| 3733 | } |
| 3734 | |
| 3735 | // ggml_concat |
| 3736 | |