@@ -4732,20 +4732,31 @@ struct test_topk_moe: public test_case {
47324732struct  test_sum  : public  test_case  {
47334733    const  ggml_type type;
47344734    const  std::array<int64_t , 4 > ne;
4735+     const  std::array<int64_t , 4 > permute;
4736+     bool  _use_permute;
47354737
47364738    std::string vars () override  {
4737-         return  VARS_TO_STR2 (type, ne);
4739+         std::string v = VARS_TO_STR2 (type, ne);
4740+         if  (_use_permute) v += " ," VAR_TO_STR (permute);
4741+         return  v;
47384742    }
47394743
47404744    test_sum (ggml_type type = GGML_TYPE_F32,
4741-             std::array<int64_t , 4 > ne = {10 , 5 , 4 , 3 })
4742-         : type(type), ne(ne) {}
4745+             std::array<int64_t , 4 > ne = {10 , 5 , 4 , 3 },
4746+             std::array<int64_t , 4 > permute = {0 , 0 , 0 , 0 })
4747+         : type(type), ne(ne), permute(permute),
4748+             _use_permute (permute[0 ] + permute[1 ] + permute[2 ] + permute[3 ] > 0 ) {}
47434749
47444750    ggml_tensor * build_graph (ggml_context * ctx) override  {
47454751        ggml_tensor * a = ggml_new_tensor (ctx, type, 4 , ne.data ());
47464752        ggml_set_param (a);
47474753        ggml_set_name (a, " a" 
47484754
4755+         if  (_use_permute) {
4756+             a = ggml_permute (ctx, a, permute[0 ], permute[1 ], permute[2 ], permute[3 ]);
4757+             ggml_set_name (a, " a_permuted" 
4758+         }
4759+ 
47494760        ggml_tensor * out = ggml_sum (ctx, a);
47504761        ggml_set_name (out, " out" 
47514762
@@ -6876,6 +6887,9 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
68766887
68776888    test_cases.emplace_back (new  test_sum ());
68786889    test_cases.emplace_back (new  test_sum_rows ());
6890+     test_cases.emplace_back (new  test_sum (GGML_TYPE_F32, {11 , 5 , 6 , 3 }, {0 , 2 , 1 , 3 }));  //  row-contiguous but non-contiguous
6891+     test_cases.emplace_back (new  test_sum (GGML_TYPE_F32, {11 , 5 , 6 , 3 }, {0 , 3 , 2 , 1 }));
6892+     test_cases.emplace_back (new  test_sum (GGML_TYPE_F32, {11 , 5 , 6 , 3 }, {0 , 1 , 3 , 2 }));
68796893    test_cases.emplace_back (new  test_sum_rows (GGML_TYPE_F32, { 11 , 5 , 6 , 3  }, true , false ));
68806894    test_cases.emplace_back (new  test_sum_rows (GGML_TYPE_F32, { 11 , 5 , 6 , 3  }, false , true ));
68816895    test_cases.emplace_back (new  test_sum_rows (GGML_TYPE_F32, { 11 , 5 , 6 , 3  }, true , true ));
@@ -6886,6 +6900,7 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
68866900    test_cases.emplace_back (new  test_sum (GGML_TYPE_F32, { 33 , 1024 , 1 , 1  }));
68876901    test_cases.emplace_back (new  test_sum_rows (GGML_TYPE_F32, { 33 , 1024 , 1 , 1  }));
68886902    test_cases.emplace_back (new  test_sum (GGML_TYPE_F32, { 33 , 256 , 1 , 1  }));
6903+     test_cases.emplace_back (new  test_sum (GGML_TYPE_F32, { 33 , 256 , 1 , 1  }, { 1 , 0 , 2 , 3  })); //  sum dst not-contiguous
68896904    test_cases.emplace_back (new  test_sum_rows (GGML_TYPE_F32, { 33 , 256 , 1 , 1  }));
68906905    test_cases.emplace_back (new  test_mean (GGML_TYPE_F32, { 33 , 256 , 1 , 1  }));
68916906    test_cases.emplace_back (new  test_mean (GGML_TYPE_F32, { 32769 , 1 , 1 , 1  }));
0 commit comments