MCPcopy Create free account
hub / github.com/davisking/dlib / test_gelu

Function test_gelu

dlib/test/dnn.cpp:923–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

run_testsMethod · 0.85

Calls 6

print_spinnerFunction · 0.85
absFunction · 0.85
copy_sizeMethod · 0.80
geluFunction · 0.50
maxFunction · 0.50
matFunction · 0.50

Tested by

no test coverage detected