MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_add_rel_pos_impl

Function ggml_add_rel_pos_impl

ggml.c:5822–5854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5820// ggml_add_rel_pos
5821
5822static struct ggml_tensor * ggml_add_rel_pos_impl(
5823 struct ggml_context * ctx,
5824 struct ggml_tensor * a,
5825 struct ggml_tensor * pw,
5826 struct ggml_tensor * ph,
5827 bool inplace) {
5828 GGML_ASSERT(ggml_are_same_shape(pw, ph));
5829 GGML_ASSERT(ggml_is_contiguous(a));
5830 GGML_ASSERT(ggml_is_contiguous(pw));
5831 GGML_ASSERT(ggml_is_contiguous(ph));
5832 GGML_ASSERT(ph->type == GGML_TYPE_F32);
5833 GGML_ASSERT(pw->type == GGML_TYPE_F32);
5834 GGML_ASSERT(pw->ne[3] == a->ne[2]);
5835 GGML_ASSERT(pw->ne[0]*pw->ne[0] == a->ne[0]);
5836 GGML_ASSERT(pw->ne[1]*pw->ne[2] == a->ne[1]);
5837
5838 bool is_node = false;
5839
5840 if (!inplace && (a->grad || pw->grad || ph->grad)) {
5841 is_node = true;
5842 }
5843
5844 struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a);
5845 ggml_set_op_params_i32(result, 0, inplace ? 1 : 0);
5846
5847 result->op = GGML_OP_ADD_REL_POS;
5848 result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
5849 result->src[0] = a;
5850 result->src[1] = pw;
5851 result->src[2] = ph;
5852
5853 return result;
5854}
5855
5856struct ggml_tensor * ggml_add_rel_pos(
5857 struct ggml_context * ctx,

Callers 2

ggml_add_rel_posFunction · 0.70
ggml_add_rel_pos_inplaceFunction · 0.70

Calls 5

ggml_are_same_shapeFunction · 0.70
ggml_is_contiguousFunction · 0.70
ggml_view_tensorFunction · 0.70
ggml_dup_tensorFunction · 0.70
ggml_set_op_params_i32Function · 0.70

Tested by

no test coverage detected