implement non-contiguous d2d copy
| 16 | |
| 17 | //! implement non-contiguous d2d copy |
| 18 | void noncont_tensor_copy( |
| 19 | const DeviceTensorND& dest, const DeviceTensorND& src, bool contig_dest, |
| 20 | bool contig_src) { |
| 21 | auto src_cn = src.comp_node(); |
| 22 | auto dst_cn = dest.comp_node(); |
| 23 | if (src_cn.device_type() == dst_cn.device_type()) { |
| 24 | // perform relayout op for better performance when src and dst are |
| 25 | // placed on comp nodes with the same device type |
| 26 | auto&& src_env = CompNodeEnv::from_comp_node(src.comp_node()); |
| 27 | auto relayout = opr::intl::get_megdnn_global_opr<megdnn::Relayout>(dst_cn); |
| 28 | dst_cn.activate(); |
| 29 | relayout->exec( |
| 30 | const_cast<DeviceTensorND&>(src).as_megdnn(), dest.as_megdnn(), |
| 31 | MegDNNHandle::get(src_env).handle()); |
| 32 | } else { |
| 33 | if (contig_src) { |
| 34 | mgb_assert(!contig_dest); |
| 35 | DeviceTensorND tmp{dst_cn}; |
| 36 | tmp.copy_from(src); |
| 37 | dest.copy_from_fixlayout(tmp); |
| 38 | return; |
| 39 | } |
| 40 | DeviceTensorND tmp; |
| 41 | tmp.copy_from(src); |
| 42 | dest.copy_from_fixlayout(tmp); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | //! implement non-contiguous h2h copy |
| 47 | void noncont_tensor_copy( |
no test coverage detected