| 5566 | // ggml_add_rel_pos |
| 5567 | |
| 5568 | static struct ggml_tensor * ggml_add_rel_pos_impl( |
| 5569 | struct ggml_context * ctx, |
| 5570 | struct ggml_tensor * a, |
| 5571 | struct ggml_tensor * pw, |
| 5572 | struct ggml_tensor * ph, |
| 5573 | bool inplace) { |
| 5574 | GGML_ASSERT(ggml_are_same_shape(pw, ph)); |
| 5575 | GGML_ASSERT(ggml_is_contiguous(a)); |
| 5576 | GGML_ASSERT(ggml_is_contiguous(pw)); |
| 5577 | GGML_ASSERT(ggml_is_contiguous(ph)); |
| 5578 | GGML_ASSERT(ph->type == GGML_TYPE_F32); |
| 5579 | GGML_ASSERT(pw->type == GGML_TYPE_F32); |
| 5580 | GGML_ASSERT(pw->ne[3] == a->ne[2]); |
| 5581 | GGML_ASSERT(pw->ne[0]*pw->ne[0] == a->ne[0]); |
| 5582 | GGML_ASSERT(pw->ne[1]*pw->ne[2] == a->ne[1]); |
| 5583 | |
| 5584 | struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a); |
| 5585 | ggml_set_op_params_i32(result, 0, inplace ? 1 : 0); |
| 5586 | |
| 5587 | result->op = GGML_OP_ADD_REL_POS; |
| 5588 | result->src[0] = a; |
| 5589 | result->src[1] = pw; |
| 5590 | result->src[2] = ph; |
| 5591 | |
| 5592 | return result; |
| 5593 | } |
| 5594 | |
| 5595 | struct ggml_tensor * ggml_add_rel_pos( |
| 5596 | struct ggml_context * ctx, |
no test coverage detected