successfully test diag_mask_inf and diag_mask_zero backward

This commit is contained in:
xaedes 2023-04-28 18:43:58 +02:00
parent d42531fa56
commit 19f51592b5
No known key found for this signature in database
GPG key ID: 30030EDD817EA2B1

View file

@ -627,7 +627,6 @@ int main(int argc, const char ** argv) {
}
}
// transpose
{
int64_t ne2[4];
@ -655,6 +654,36 @@ int main(int argc, const char ** argv) {
}
}
// diag_mask_inf
{
const int nargs = 1;
const int ndims = 2;
x[0] = get_random_tensor(ctx0, ndims, ne, -1.0f, 1.0f);
ggml_set_param(ctx0, x[0]);
int n_past = irand(ne[0]);
struct ggml_tensor * f = ggml_sum(ctx0, ggml_diag_mask_inf(ctx0, x[0], n_past));
check_gradient("diag_mask_inf", ctx0, x, f, ndims, nargs, 1e-3f, 1e-3f, INFINITY);
}
// diag_mask_zero
{
const int nargs = 1;
const int ndims = 2;
x[0] = get_random_tensor(ctx0, ndims, ne, -1.0f, 1.0f);
ggml_set_param(ctx0, x[0]);
int n_past = irand(ne[0]);
struct ggml_tensor * f = ggml_sum(ctx0, ggml_diag_mask_zero(ctx0, x[0], n_past));
check_gradient("diag_mask_zero", ctx0, x, f, ndims, nargs, 1e-3f, 1e-3f, INFINITY);
}
// softmax
{
const int nargs = 1;