From b2bd8222da94ff438d53cc2ac066d651a31260fe Mon Sep 17 00:00:00 2001 From: xaedes Date: Wed, 26 Apr 2023 20:14:52 +0200 Subject: [PATCH] successfully test cpy backward --- tests/test-grad0.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test-grad0.c b/tests/test-grad0.c index 0a538a387..fad0aa0f8 100644 --- a/tests/test-grad0.c +++ b/tests/test-grad0.c @@ -453,6 +453,23 @@ int main(int argc, const char ** argv) { } } + // cpy + { + const int nargs = 2; + + for (int ndims = 1; ndims <= 2; ++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]); + } + // x[1] is overwritten by x[0], so the gradients don't propagate to x[1] + + struct ggml_tensor * f = ggml_sum(ctx0, ggml_cpy(ctx0, x[0], x[1])); + + check_gradient("cpy", ctx0, x, f, ndims, nargs, 1e-3f, 1e-3f, INFINITY); + } + } + // rope { const int nargs = 1;