MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / rep

Function rep

dnn/src/naive/lrn/opr_impl.cpp:18–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 auto sptr = src.ptr<T>(), dptr = dst.ptr<T>();
17 auto half_window = param.n / 2;
18 rep(n, N) rep(hw, H * W) {
19 rep(dc, C) {
20 auto didx = n * C * H * W + dc * H * W + hw;
21 size_t c_start = (dc >= half_window ? dc - half_window : 0u);
22 size_t c_end = std::min(dc + half_window, C - 1);
23 float suma2 = 0.0f;
24 for (size_t sc = c_start; sc <= c_end; ++sc) {
25 auto sidx = n * C * H * W + sc * H * W + hw;
26 suma2 += sqr(sptr[sidx]);
27 }
28 float multiplicand = std::pow(param.k + param.alpha * suma2, -param.beta);
29 float multiplier = sptr[didx];
30 dptr[didx] = T(multiplier * multiplicand);
31 }
32 }
33}
34
35template <typename T>

Callers 2

forwardFunction · 0.70
backwardFunction · 0.70

Calls 4

sqrFunction · 0.85
TClass · 0.85
minFunction · 0.50
powFunction · 0.50

Tested by

no test coverage detected