diff --git a/tests/test-backend-ops.cpp b/tests/test-backend-ops.cpp index 9abb98cdbd..e631fed8a2 100644 --- a/tests/test-backend-ops.cpp +++ b/tests/test-backend-ops.cpp @@ -6648,6 +6648,39 @@ struct test_diag : public test_case { } }; +// GGML_OP_HADAMARD +struct test_hadamard : public test_case { + const ggml_type type_a; + const std::array ne_a; + int nh; + + std::string vars() override { + return VARS_TO_STR3(type_a, ne_a, nh); + } + + test_hadamard(ggml_type type_a = GGML_TYPE_F32, + std::array ne_a = {128, 10, 10, 10}, + int nh = 128) + : type_a(type_a), ne_a(ne_a), nh(nh) {} + + ggml_tensor * build_graph(ggml_context * ctx) override { + ggml_tensor * a = ggml_new_tensor(ctx, type_a, 4, ne_a.data()); + ggml_set_param(a); + ggml_set_name(a, "a"); + + ggml_tensor * out = ggml_hadamard(ctx, a, nh); + ggml_set_name(out, "out"); + + return out; + } + + void initialize_tensors(ggml_context * ctx) override { + for (ggml_tensor * t = ggml_get_first_tensor(ctx); t != NULL; t = ggml_get_next_tensor(ctx, t)) { + init_tensor_uniform(t, -1.0f, 1.0f); + } + } +}; + // GGML_OP_SCATTER struct test_scatter : public test_case { const ggml_type type_a; @@ -8536,6 +8569,9 @@ static std::vector> make_test_cases_eval() { test_cases.emplace_back(new test_falcon(2)); #endif + // hadamard + test_cases.emplace_back(new test_hadamard()); + // scatter test_cases.emplace_back(new test_scatter(GGML_TYPE_F32, GGML_TYPE_I32, {10, 1, 1, 1}, {3, 1, 1, 1}, 0.0f, true)); test_cases.emplace_back(new test_scatter(GGML_TYPE_F32, GGML_TYPE_I32, {10, 1, 1, 1}, {3, 1, 1, 1}, 0.0f, false)); @@ -8802,6 +8838,9 @@ static std::vector> make_test_cases_perf() { test_cases.emplace_back(new test_acc(GGML_TYPE_F32, {256, 17, 2, 3}, {128, 16, 2, 3}, 2)); test_cases.emplace_back(new test_acc(GGML_TYPE_F32, {256, 17, 2, 3}, {64, 16, 2, 3}, 3)); + // hadamard + test_cases.emplace_back(new test_hadamard()); + // scatter test_cases.emplace_back(new test_scatter(GGML_TYPE_F32, GGML_TYPE_I32, {65536, 1, 1, 1}, {2048, 1, 1, 1}, 0.0f, true)); test_cases.emplace_back(new test_scatter(GGML_TYPE_F32, GGML_TYPE_I32, {65536, 1, 1, 1}, {2048, 1, 1, 1}, 0.0f, false));