| 7 | using namespace cuda; |
| 8 | |
| 9 | void 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 | |
| 34 | void AddUpdateForwardImpl::exec_noncontig( |
| 35 | _megdnn_tensor_inout dest, _megdnn_tensor_in delta) { |
nothing calls this directly
no test coverage detected