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

Method exec

dnn/src/cambricon/relayout/opr_impl.cpp:306–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304} // namespace
305
306void RelayoutForwardImpl::exec(
307 _megdnn_tensor_in src, _megdnn_tensor_out dst, Handle* src_handle) {
308 bool cross_dev = false;
309 int dst_dev_id = -1, src_dev_id = -1;
310
311 // check whether cross device copy
312 if (src_handle && src_handle != handle()) {
313 megcoreDeviceHandle_t dev;
314 megcoreGetDeviceHandle(src_handle->megcore_computing_handle(), &dev);
315 megcorePlatform_t plat;
316 megcoreGetPlatform(dev, &plat);
317 megdnn_throw_if(
318 plat != megcorePlatformCambricon, megdnn_error,
319 "only relayout between cambricon devices are supported");
320 megcoreGetDeviceID(dev, &src_dev_id);
321 megcoreGetDeviceHandle(this->handle()->megcore_computing_handle(), &dev);
322 megcoreGetDeviceID(dev, &dst_dev_id);
323
324 megdnn_assert(src_dev_id >= 0 && dst_dev_id >= 0);
325 cross_dev = src_dev_id != dst_dev_id;
326 }
327
328 if (!try_transpose(src, dst, this, cross_dev) &&
329 !try_boradcast(src, dst, this, cross_dev) &&
330 !try_copy_contig(src, dst, this, cross_dev, src_dev_id, dst_dev_id) &&
331 !try_copy_non_contig(src, dst, this, cross_dev)) {
332 copy_general(src, dst, this, cross_dev, src_dev_id, dst_dev_id);
333 }
334}
335
336} // namespace cambricon
337} // namespace megdnn

Callers

nothing calls this directly

Calls 10

megcoreGetDeviceHandleFunction · 0.85
megcoreGetPlatformFunction · 0.85
megcoreGetDeviceIDFunction · 0.85
try_transposeFunction · 0.85
try_boradcastFunction · 0.85
try_copy_contigFunction · 0.85
try_copy_non_contigFunction · 0.85
copy_generalFunction · 0.85
handleMethod · 0.45

Tested by

no test coverage detected