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

Function noncont_tensor_copy

src/core/impl/tensor.cpp:18–44  ·  view source on GitHub ↗

implement non-contiguous d2d copy

Source from the content-addressed store, hash-verified

16
17//! implement non-contiguous d2d copy
18void 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
47void noncont_tensor_copy(

Callers 1

tensor.cppFile · 0.85

Calls 10

getFunction · 0.85
as_megdnnMethod · 0.80
copy_from_fixlayoutMethod · 0.80
comp_nodeMethod · 0.45
device_typeMethod · 0.45
activateMethod · 0.45
execMethod · 0.45
handleMethod · 0.45
copy_fromMethod · 0.45
syncMethod · 0.45

Tested by

no test coverage detected