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

Function gelu

dlib/cuda/cpu_dlib.cpp:2171–2180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2169 // ----------------------------------------------------------------------------------------
2170
2171 void gelu (
2172 tensor& dest,
2173 const tensor& src
2174 )
2175 {
2176 const auto d = dest.host();
2177 const auto s = src.host();
2178 for (size_t i = 0; i < src.size(); ++i)
2179 d[i] = 0.5f*s[i]*(1.0f + std::erf(s[i]/sqrt_2));
2180 }
2181
2182 void gelu_gradient (
2183 tensor& grad,

Callers 2

test_geluFunction · 0.50
forwardMethod · 0.50

Calls 2

hostMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_geluFunction · 0.40