| 947 | } |
| 948 | |
| 949 | void test_smelu() |
| 950 | { |
| 951 | IF_DLIB_USE_CUDA( |
| 952 | using namespace dlib::tt; |
| 953 | print_spinner(); |
| 954 | const long n = 4; |
| 955 | const long k = 5; |
| 956 | const long nr = 3; |
| 957 | const long nc = 3; |
| 958 | const float beta = 1; |
| 959 | resizable_tensor src(n, k, nr, nc); |
| 960 | tt::tensor_rand rnd; |
| 961 | rnd.fill_gaussian(src); |
| 962 | resizable_tensor dest_cuda, dest_cpu; |
| 963 | dest_cuda.copy_size(src); |
| 964 | dest_cpu.copy_size(src); |
| 965 | // initialize to different values in order to make sure the output is actually changed |
| 966 | dest_cuda = 1; |
| 967 | dest_cpu = 2; |
| 968 | cuda::smelu(dest_cuda, src, beta); |
| 969 | cpu::smelu(dest_cpu, src, beta); |
| 970 | |
| 971 | DLIB_TEST_MSG(max(abs(mat(dest_cuda) - mat(dest_cpu))) < 1e-7, max(abs(mat(dest_cuda) - mat(dest_cpu)))); |
| 972 | ) |
| 973 | } |
| 974 | |
| 975 | void test_silu() |
| 976 | { |