@@ -4851,6 +4851,21 @@ struct test_rope : public test_case {
48514851
48524852 a = ggml_view_4d (ctx, a, ne_a[0 ], ne_a[1 ], ne_a[2 ], ne_a[3 ], a->nb [1 ], a->nb [2 ], a->nb [3 ], 0 );
48534853 ggml_set_name (a, " view_of_a" );
4854+ } else if (v == 2 ) {
4855+ // second-half slice along dim 0 (mimics build_rope_2d in clip.cpp).
4856+ // The non-zero view offset (ne_a[0] * elem_size) often produces a
4857+ // non-aligned buffer offset, which exercises backends' alignment paths.
4858+ auto ne = ne_a; ne[0 ] *= 2 ;
4859+ a = ggml_new_tensor (ctx, type, 4 , ne.data ());
4860+ if (forward) {
4861+ ggml_set_param (a);
4862+ }
4863+ ggml_set_name (a, " a" );
4864+
4865+ a = ggml_view_4d (ctx, a, ne_a[0 ], ne_a[1 ], ne_a[2 ], ne_a[3 ],
4866+ a->nb [1 ], a->nb [2 ], a->nb [3 ],
4867+ ne_a[0 ] * ggml_element_size (a));
4868+ ggml_set_name (a, " view_of_a" );
48544869 } else {
48554870 a = ggml_new_tensor (ctx, type, 4 , ne_a.data ());
48564871 if (forward) {
@@ -4913,8 +4928,6 @@ struct test_rope : public test_case {
49134928 } else {
49144929 out = ggml_rope_ext_back (ctx, a, pos, freq, n_dims, mode, 0 , 10000 .0f , fs, ef, af, 1 .0f , 1 .0f );
49154930 }
4916-
4917- // TODO: add test with a non-contiguous view as input ; this case is needed for build_rope_2d in clip.cpp
49184931 }
49194932 ggml_set_name (out, " out" );
49204933
@@ -8687,6 +8700,13 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
86878700
86888701 test_cases.emplace_back (new test_rope (type, { 64 , 128 , 2 , 1 }, 64 , GGML_ROPE_TYPE_NEOX , 512 , fs, ef, af, ff, v, fw)); // neox (falcon 40B)
86898702 }
8703+
8704+ // build_rope_2d-style: ROPE on a non-contiguous view
8705+ // that starts at a non-zero offset along dim 0
8706+ // (e.g. gemma4v vision second-half view).
8707+ for (int rmode : { GGML_ROPE_TYPE_NORMAL , GGML_ROPE_TYPE_NEOX , GGML_ROPE_TYPE_MROPE , GGML_ROPE_TYPE_IMROPE , GGML_ROPE_TYPE_VISION }) {
8708+ test_cases.emplace_back (new test_rope (type, { 36 , 16 , 2457 , 1 }, 36 , rmode, 512 , fs, ef, af, ff, 2 , fw));
8709+ }
86908710 }
86918711
86928712 all = false ;
0 commit comments