You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// implementation of the 2D RoPE without adding a new op in ggml
575
-
// this is not efficient (use double the memory), but works on all backends
576
-
// TODO: there was a more efficient which relies on ggml_view and ggml_rope_ext_inplace, but the rope inplace does not work well with non-contiguous tensors ; we should fix that and revert back to the original implementation in https://github.com/ggml-org/llama.cpp/pull/13065
577
-
static ggml_tensor * build_rope_2d(
578
-
ggml_context * ctx0,
579
-
ggml_tensor * cur,
580
-
ggml_tensor * pos_h,
581
-
ggml_tensor * pos_w,
582
-
constfloat freq_base
583
-
) {
584
-
constint64_t n_dim = cur->ne[0];
585
-
constint64_t n_head = cur->ne[1];
586
-
constint64_t n_pos = cur->ne[2];
587
-
588
-
// for example, if we have cur tensor of shape (n_dim=8, n_head, n_pos)
589
-
// we will have a list of 4 inv_freq: 1e-0, 1e-1, 1e-2, 1e-3
590
-
// first half of cur will use 1e-0, 1e-2 (even)
591
-
// second half of cur will use 1e-1, 1e-3 (odd)
592
-
// the trick here is to rotate just half of n_dim, so inv_freq will automatically be even
// implementation of the 2D RoPE without adding a new op in ggml
1402
+
// this is not efficient (use double the memory), but works on all backends
1403
+
// TODO: there was a more efficient which relies on ggml_view and ggml_rope_ext_inplace, but the rope inplace does not work well with non-contiguous tensors ; we should fix that and revert back to the original implementation in https://github.com/ggml-org/llama.cpp/pull/13065
1404
+
static ggml_tensor * build_rope_2d(
1405
+
ggml_context * ctx0,
1406
+
ggml_tensor * cur,
1407
+
ggml_tensor * pos_h,
1408
+
ggml_tensor * pos_w,
1409
+
constfloat freq_base
1410
+
) {
1411
+
constint64_t n_dim = cur->ne[0];
1412
+
constint64_t n_head = cur->ne[1];
1413
+
constint64_t n_pos = cur->ne[2];
1414
+
1415
+
// for example, if we have cur tensor of shape (n_dim=8, n_head, n_pos)
1416
+
// we will have a list of 4 inv_freq: 1e-0, 1e-1, 1e-2, 1e-3
1417
+
// first half of cur will use 1e-0, 1e-2 (even)
1418
+
// second half of cur will use 1e-1, 1e-3 (odd)
1419
+
// the trick here is to rotate just half of n_dim, so inv_freq will automatically be even
0 commit comments