test-grad0 : fix test for div

nargs and ndims was swapped, corrupting the stack
This commit is contained in:
xaedes 2023-04-28 20:00:25 +02:00
parent 19f51592b5
commit b9920e5c3e
No known key found for this signature in database
GPG key ID: 30030EDD817EA2B1

View file

@ -361,9 +361,9 @@ int main(int argc, const char ** argv) {
// div // div
{ {
const int nargs = 4; const int nargs = 2;
for (int ndims = 1; ndims <= 2; ++ndims) { for (int ndims = 1; ndims <= 4; ++ndims) {
for (int i = 0; i < nargs; ++i) { for (int i = 0; i < nargs; ++i) {
x[i] = get_random_tensor(ctx0, ndims, ne, 0.5f, 1.0f); x[i] = get_random_tensor(ctx0, ndims, ne, 0.5f, 1.0f);
ggml_set_param(ctx0, x[i]); ggml_set_param(ctx0, x[i]);
@ -371,7 +371,7 @@ int main(int argc, const char ** argv) {
struct ggml_tensor * f = ggml_sum(ctx0, ggml_div(ctx0, x[0], x[1])); struct ggml_tensor * f = ggml_sum(ctx0, ggml_div(ctx0, x[0], x[1]));
check_gradient("div", ctx0, x, f, ndims, nargs, 1e-3f, INFINITY, 1e-2f); check_gradient("div", ctx0, x, f, ndims, nargs, 1e-3f, 1e-2f, 1e-1f);
} }
} }