| 351 | } |
| 352 | |
| 353 | void TensorImplDft::copy_from_continue(const TensorImplBase* src_impl) { |
| 354 | auto src = static_cast<const TensorImplDft*>(src_impl); |
| 355 | if (is_host()) { |
| 356 | //! host to host |
| 357 | if (src->is_host()) { |
| 358 | m_host_tensor->copy_from(*src->m_host_tensor); |
| 359 | //! device to host |
| 360 | } else { |
| 361 | auto src_cn = src->m_dev_tensor->comp_node(); |
| 362 | auto dst_cn = m_host_tensor->comp_node(); |
| 363 | if (src_cn != dst_cn && m_host_tensor->layout().ndim > 0) { |
| 364 | LITE_WARN( |
| 365 | "The dst tensor memroy is alloced before coping, " |
| 366 | "then pinned memroy would not use to optmize the " |
| 367 | "copy performance."); |
| 368 | //! When D2H in megbrain and the compnode of src and dst is not |
| 369 | //! equal, there must be one compnode that is cpu-default, so |
| 370 | //! here, we use temp tensor for transition |
| 371 | auto tmp_impl = std::make_shared<TensorImplDft>(); |
| 372 | tmp_impl->set_mge_tensor_compnode(src_cn); |
| 373 | tmp_impl->m_host_tensor->copy_from(*src->m_dev_tensor).sync(); |
| 374 | m_host_tensor->copy_from(*tmp_impl->m_host_tensor); |
| 375 | } else { |
| 376 | //! if dst compnode is not valid(memory is not alloced), the |
| 377 | //! tensor is pinned host tensor |
| 378 | m_host_tensor->comp_node(src_cn, true); |
| 379 | m_host_tensor->copy_from(*src->m_dev_tensor).sync(); |
| 380 | } |
| 381 | } |
| 382 | } else { |
| 383 | //! host to device |
| 384 | if (src->is_host()) { |
| 385 | m_dev_tensor->copy_from(*src->m_host_tensor).sync(); |
| 386 | //! device to device |
| 387 | } else { |
| 388 | m_dev_tensor->copy_from(*src->m_dev_tensor).sync(); |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | void TensorImplDft::copy_from_fixlayout(const TensorImplBase* src_impl) { |
| 394 | auto src = static_cast<const TensorImplDft*>(src_impl); |