| 478 | } |
| 479 | |
| 480 | void test_silu() |
| 481 | { |
| 482 | #ifdef DLIB_USE_CUDA |
| 483 | using namespace dlib::tt; |
| 484 | print_spinner(); |
| 485 | const long n = 4; |
| 486 | const long k = 5; |
| 487 | const long nr = 3; |
| 488 | const long nc = 3; |
| 489 | resizable_tensor src(n, k, nr, nc); |
| 490 | tt::tensor_rand rnd; |
| 491 | rnd.fill_gaussian(src); |
| 492 | resizable_tensor dest_cuda, dest_cpu; |
| 493 | dest_cuda.copy_size(src); |
| 494 | dest_cpu.copy_size(src); |
| 495 | // initialize to different values in order to make sure the output is actually changed |
| 496 | dest_cuda = 1; |
| 497 | dest_cpu = 2; |
| 498 | cuda::silu(dest_cuda, src); |
| 499 | cpu::silu(dest_cpu, src); |
| 500 | |
| 501 | DLIB_TEST_MSG(max(abs(mat(dest_cuda) - mat(dest_cpu))) < 1e-6, max(abs(mat(dest_cuda) - mat(dest_cpu)))); |
| 502 | #endif // DLIB_USE_CUDA |
| 503 | } |
| 504 | |
| 505 | void test_batch_normalize() |
| 506 | { |