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

Method exec

dnn/src/cuda/relayout/opr_impl.cpp:179–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void RelayoutForwardImpl::exec(
180 _megdnn_tensor_in src, _megdnn_tensor_out dst, Handle* src_handle) {
181 bool cross_dev = false;
182
183 // check whether cross device copy
184 if (src_handle && src_handle != handle()) {
185 megcoreDeviceHandle_t dev;
186 megcoreGetDeviceHandle(src_handle->megcore_computing_handle(), &dev);
187 megcorePlatform_t plat;
188 megcoreGetPlatform(dev, &plat);
189 megdnn_throw_if(
190 plat != megcorePlatformCUDA, megdnn_error,
191 "only relayout between cuda devices are supported");
192 int dst_dev_id = -1, src_dev_id = -1;
193 megcoreGetDeviceID(dev, &src_dev_id);
194
195 megcoreGetDeviceHandle(this->handle()->megcore_computing_handle(), &dev);
196 megcoreGetDeviceID(dev, &dst_dev_id);
197
198 megdnn_assert(src_dev_id >= 0 && dst_dev_id >= 0);
199 cross_dev = src_dev_id != dst_dev_id;
200 }
201 Param param{src, dst, this};
202 if (!param.try_transpose() && !param.try_copy_contig() &&
203 !param.try_copy_2d(cross_dev) && !param.try_copy_last_contig()) {
204 megdnn_assert(!cross_dev, "cross-device general non-contig copy unsupported");
205 param.copy_general();
206 }
207}
208
209// vim: syntax=cpp.doxygen

Callers

nothing calls this directly

Calls 10

megcoreGetDeviceHandleFunction · 0.85
megcoreGetPlatformFunction · 0.85
megcoreGetDeviceIDFunction · 0.85
try_transposeMethod · 0.80
handleMethod · 0.45
try_copy_contigMethod · 0.45
try_copy_2dMethod · 0.45
try_copy_last_contigMethod · 0.45
copy_generalMethod · 0.45

Tested by

no test coverage detected