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

Function ggml_rope_impl

ggml.c:5029–5075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5027// ggml_rope
5028
5029static struct ggml_tensor * ggml_rope_impl(
5030 struct ggml_context * ctx,
5031 struct ggml_tensor * a,
5032 struct ggml_tensor * b,
5033 int n_dims,
5034 int mode,
5035 int n_ctx,
5036 int n_orig_ctx,
5037 float freq_base,
5038 float freq_scale,
5039 float ext_factor,
5040 float attn_factor,
5041 float beta_fast,
5042 float beta_slow,
5043 float xpos_base,
5044 bool xpos_down,
5045 bool inplace) {
5046 GGML_ASSERT(ggml_is_vector(b));
5047 GGML_ASSERT(b->type == GGML_TYPE_I32);
5048 GGML_ASSERT(a->ne[2] == b->ne[0]);
5049
5050 bool is_node = false;
5051
5052 if (a->grad) {
5053 is_node = true;
5054 }
5055
5056 struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a);
5057
5058 int32_t params[13] = { /*n_past*/ 0, n_dims, mode, n_ctx, n_orig_ctx };
5059 memcpy(params + 5, &freq_base, sizeof(float));
5060 memcpy(params + 6, &freq_scale, sizeof(float));
5061 memcpy(params + 7, &ext_factor, sizeof(float));
5062 memcpy(params + 8, &attn_factor, sizeof(float));
5063 memcpy(params + 9, &beta_fast, sizeof(float));
5064 memcpy(params + 10, &beta_slow, sizeof(float));
5065 memcpy(params + 11, &xpos_base, sizeof(float));
5066 memcpy(params + 12, &xpos_down, sizeof(bool));
5067 ggml_set_op_params(result, params, sizeof(params));
5068
5069 result->op = GGML_OP_ROPE;
5070 result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
5071 result->src[0] = a;
5072 result->src[1] = b;
5073
5074 return result;
5075}
5076
5077struct ggml_tensor * ggml_rope(
5078 struct ggml_context * ctx,

Callers 6

ggml_ropeFunction · 0.70
ggml_rope_inplaceFunction · 0.70
ggml_rope_customFunction · 0.70
ggml_rope_custom_inplaceFunction · 0.70
ggml_rope_xpos_inplaceFunction · 0.70
ggml_compute_backwardFunction · 0.70

Calls 4

ggml_is_vectorFunction · 0.70
ggml_view_tensorFunction · 0.70
ggml_dup_tensorFunction · 0.70
ggml_set_op_paramsFunction · 0.70

Tested by

no test coverage detected