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

Function ggml_alibi

ggml.c:5204–5231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5202// ggml_alibi
5203
5204struct ggml_tensor * ggml_alibi(
5205 struct ggml_context * ctx,
5206 struct ggml_tensor * a,
5207 int n_past,
5208 int n_head,
5209 float bias_max) {
5210 GGML_ASSERT(n_past >= 0);
5211 bool is_node = false;
5212
5213 if (a->grad) {
5214 GGML_ASSERT(false); // TODO: implement backward
5215 is_node = true;
5216 }
5217
5218 // TODO: when implement backward, fix this:
5219 //struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a);
5220 struct ggml_tensor * result = ggml_view_tensor(ctx, a);
5221
5222 int32_t op_params[3] = { n_past, n_head };
5223 memcpy(op_params + 2, &bias_max, sizeof(float));
5224 ggml_set_op_params(result, op_params, sizeof(op_params));
5225
5226 result->op = GGML_OP_ALIBI;
5227 result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
5228 result->src[0] = a;
5229
5230 return result;
5231}
5232
5233// ggml_clamp
5234

Callers 1

llm_build_kqvFunction · 0.85

Calls 3

ggml_view_tensorFunction · 0.70
ggml_set_op_paramsFunction · 0.70
ggml_dup_tensorFunction · 0.70

Tested by

no test coverage detected