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

Method exec_internal

dnn/src/naive/gaussian_blur/opr_impl.cpp:127–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125
126template <typename T>
127void GaussianBlurImpl::exec_internal(_megdnn_tensor_in src, _megdnn_tensor_out dst) {
128 auto N = src.layout.shape[0], IH = src.layout.shape[1], IW = src.layout.shape[2],
129 IC = src.layout.shape[3];
130
131 using namespace megcv;
132
133 Size ksize = Size(param().kernel_height, param().kernel_width);
134 Mat<float> kx(1, ksize.cols(), 1);
135 Mat<float> ky(1, ksize.rows(), 1);
136
137 gaussian_blur::createGaussianKernels<float>(
138 kx, ky, ksize, param().sigma_x, param().sigma_y);
139
140 uint32_t kernel_height = ky.width();
141 uint32_t kernel_width = kx.width();
142 uint32_t half_h = kernel_height / 2;
143 uint32_t half_w = kernel_width / 2;
144
145 rep(n, N) rep(h, IH) rep(w, IW) rep(c, IC) {
146 double val = 0;
147 rep(iy, kernel_height) {
148 int y = gaussian_blur::border_interpolate(
149 h + iy - half_h, IH, param().border_mode);
150 rep(ix, kernel_width) {
151 int x = gaussian_blur::border_interpolate(
152 w + ix - half_w, IW, param().border_mode);
153
154 //! BORDER_CONSTANT or BORDER_TRANSPARENT
155 if (x != -1 && y != -1) {
156 val += kx.at(0, ix, 0) * ky.at(0, iy, 0) *
157 src.ptr<T>()
158 [n * src.layout.stride[0] +
159 y * src.layout.stride[1] +
160 x * src.layout.stride[2] +
161 c * src.layout.stride[3]];
162 }
163 }
164 }
165 dst.ptr<T>()
166 [n * dst.layout.stride[0] + h * dst.layout.stride[1] +
167 w * dst.layout.stride[2] + c * dst.layout.stride[3]] =
168 static_cast<T>(val);
169 }
170}
171
172void GaussianBlurImpl::exec(
173 _megdnn_tensor_in src, _megdnn_tensor_in dst, _megdnn_workspace /*workspace*/) {

Callers

nothing calls this directly

Calls 6

SizeClass · 0.85
repFunction · 0.70
paramFunction · 0.50
colsMethod · 0.45
rowsMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected