From 80223d98fdaea913ba00aee4fbac3a0d0de779e7 Mon Sep 17 00:00:00 2001 From: xaedes Date: Sat, 6 May 2023 18:01:32 +0200 Subject: [PATCH] add test for ggml_sum_rows gradients --- tests/test-grad0.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test-grad0.c b/tests/test-grad0.c index d9115bdc8..edb3c514a 100644 --- a/tests/test-grad0.c +++ b/tests/test-grad0.c @@ -494,6 +494,23 @@ int main(int argc, const char ** argv) { } } + + // sum_rows + { + const int nargs = 1; + + for (int ndims = 1; ndims <= 4; ++ndims) { + for (int i = 0; i < nargs; ++i) { + x[i] = get_random_tensor(ctx0, ndims, ne, -1.0f, 1.0f); + ggml_set_param(ctx0, x[i]); + } + + struct ggml_tensor * f = ggml_sum(ctx0, ggml_sqr(ctx0, ggml_sum_rows(ctx0, x[0]))); + + check_gradient("sum_rows", ctx0, x, f, ndims, nargs, 1e-3f, 1e-2f, INFINITY); + } + } + // repeat { int64_t ne2[4];