| 921 | } |
| 922 | |
| 923 | void test_gelu() |
| 924 | { |
| 925 | IF_DLIB_USE_CUDA( |
| 926 | // make sure that cuda::gelu and cpu::gelu return the same results |
| 927 | using namespace dlib::tt; |
| 928 | print_spinner(); |
| 929 | const long n = 4; |
| 930 | const long k = 5; |
| 931 | const long nr = 3; |
| 932 | const long nc = 3; |
| 933 | resizable_tensor src(n,k,nr,nc); |
| 934 | tt::tensor_rand rnd; |
| 935 | rnd.fill_gaussian(src); |
| 936 | |
| 937 | resizable_tensor dest1, dest2; |
| 938 | dest1.copy_size(src); |
| 939 | dest2.copy_size(src); |
| 940 | // initialize to different values in order to make sure the output is actually changed |
| 941 | dest1 = 1; |
| 942 | dest2 = 2; |
| 943 | cuda::gelu(dest1, src); |
| 944 | cpu::gelu(dest2, src); |
| 945 | DLIB_TEST_MSG(max(abs(mat(dest1) - mat(dest2))) < 1e-6, max(abs(mat(dest1) - mat(dest2)))); |
| 946 | ) |
| 947 | } |
| 948 | |
| 949 | void test_smelu() |
| 950 | { |