MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / ggml_add_rel_pos_impl

Function ggml_add_rel_pos_impl

subprojects/llama.cpp/ggml/src/ggml.c:5568–5593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5566// ggml_add_rel_pos
5567
5568static 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
5595struct ggml_tensor * ggml_add_rel_pos(
5596 struct ggml_context * ctx,

Callers 2

ggml_add_rel_posFunction · 0.85
ggml_add_rel_pos_inplaceFunction · 0.85

Calls 5

ggml_are_same_shapeFunction · 0.85
ggml_is_contiguousFunction · 0.85
ggml_view_tensorFunction · 0.85
ggml_dup_tensorFunction · 0.85
ggml_set_op_params_i32Function · 0.85

Tested by

no test coverage detected