| 5625 | } |
| 5626 | |
| 5627 | static void ggml_rope_cache_init( |
| 5628 | float theta_base, float freq_scale, const float * freq_factors, float corr_dims[2], int64_t ne0, float ext_factor, float mscale, |
| 5629 | float * cache, float sin_sign, float theta_scale) { |
| 5630 | // ref: https://github.com/jquesnelle/yarn/blob/master/scaled_rope/LlamaYaRNScaledRotaryEmbedding.py |
| 5631 | float theta = theta_base; |
| 5632 | for (int64_t i0 = 0; i0 < ne0; i0 += 2) { |
| 5633 | const float ff = freq_factors ? freq_factors[i0/2] : 1.0f; |
| 5634 | rope_yarn( |
| 5635 | theta/ff, freq_scale, corr_dims, i0, ext_factor, mscale, &cache[i0 + 0], &cache[i0 + 1] |
| 5636 | ); |
| 5637 | cache[i0 + 1] *= sin_sign; |
| 5638 | |
| 5639 | theta *= theta_scale; |
| 5640 | } |
| 5641 | } |
| 5642 | |
| 5643 | static void ggml_mrope_cache_init( |
| 5644 | float theta_base_t, float theta_base_h, float theta_base_w, float theta_base_e, int sections[4], bool is_imrope, bool indep_sects, |
no test coverage detected