add test for ggml_sum_rows gradients

This commit is contained in:
xaedes 2023-05-06 18:01:32 +02:00
parent e6186d98a5
commit 80223d98fd
No known key found for this signature in database
GPG key ID: 30030EDD817EA2B1

View file

@ -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];