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

Method exec

dnn/src/cuda/add_update/opr_impl.cpp:9–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace cuda;
8
9void AddUpdateForwardImpl::exec(_megdnn_tensor_inout dest, _megdnn_tensor_in delta) {
10 check_exec(dest.layout, delta.layout);
11 if (!dest.layout.is_contiguous()) {
12 return exec_noncontig(dest, delta);
13 }
14 ElemwiseOpParamN<1> param;
15 param[0] = delta;
16 param[0].layout = param[0].layout.broadcast(dest.layout);
17 param.init_from_given_tensor();
18 auto stream = cuda_stream(handle());
19 switch (dest.layout.dtype.enumv()) {
20#define cb(_dt) \
21 case DTypeTrait<_dt>::enumv: { \
22 using ctype = DTypeTrait<_dt>::ctype; \
23 return run_elemwise<AddUpdateKernOp<ctype>, ctype, 1>( \
24 param, stream, {dest, m_param}); \
25 }
26 MEGDNN_FOREACH_COMPUTING_DTYPE(cb)
27#undef cb
28
29 default:
30 megdnn_throw("unsupported dtype for AddUpdate");
31 }
32}
33
34void AddUpdateForwardImpl::exec_noncontig(
35 _megdnn_tensor_inout dest, _megdnn_tensor_in delta) {

Callers

nothing calls this directly

Calls 5

cuda_streamFunction · 0.85
is_contiguousMethod · 0.45
broadcastMethod · 0.45
enumvMethod · 0.45

Tested by

no test coverage detected