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

Method exec

dnn/src/cuda/group_local/bwd_data.cpp:10–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8namespace cuda {
9
10void GroupLocalBackwardDataImpl::exec(
11 _megdnn_tensor_in filter, _megdnn_tensor_in diff, _megdnn_tensor_out grad,
12 _megdnn_workspace workspace) {
13 check_exec(filter.layout, diff.layout, grad.layout, workspace.size);
14
15 auto G = filter.layout[0];
16 auto N = grad.layout.shape[0], IC = grad.layout.shape[1] / G,
17 IH = grad.layout.shape[2], IW = grad.layout.shape[3],
18 OC = diff.layout.shape[1] / G, OH = diff.layout.shape[2],
19 OW = diff.layout.shape[3];
20 auto FH = filter.layout.shape[4], FW = filter.layout.shape[5];
21 auto PH = param().pad_h, PW = param().pad_w;
22 auto SH = param().stride_h, SW = param().stride_w;
23 float* sptr = grad.ptr<dt_float32>();
24 const float* fptr = filter.ptr<dt_float32>();
25 const float* dptr = diff.ptr<dt_float32>();
26 float* wptr = workspace.ptr<dt_float32>();
27 auto handle = concrete_handle(this->handle());
28 auto stream = cuda_stream(this->handle());
29 auto cublas = cublas_handle(this->handle());
30 auto one = handle->one_device();
31 auto zero = handle->zero_device();
32 megdnn_assert(
33 local::can_backward_data_proxy_convnet(
34 N, IC, IH, IW, OC, OH, OW, FH, FW, G * IC * IH * IW,
35 G * OC * OH * OW, PH, PW, SH, SW),
36 "Cannot do Group Local bwd data.");
37 for (size_t g = 0; g < G; ++g) {
38 local::backward_data_proxy_convnet(
39 fptr + g * OH * OW * IC * FH * FW * OC, dptr + g * OC * OH * OW,
40 sptr + g * IC * IH * IW, wptr, N, IC, IH, IW, OC, OH, OW, FH, FW,
41 G * IC * IH * IW, G * OC * OH * OW, PH, PW, SH, SW, cublas, stream, one,
42 zero);
43 }
44}
45
46GroupLocalBackwardDataImpl::GroupLocalBackwardDataImpl(Handle* handle)
47 : GroupLocalBackwardData(handle) {}

Callers

nothing calls this directly

Calls 7

cuda_streamFunction · 0.85
cublas_handleFunction · 0.85
paramFunction · 0.50
concrete_handleFunction · 0.50
handleMethod · 0.45
one_deviceMethod · 0.45
zero_deviceMethod · 0.45

Tested by

no test coverage detected