From 8ec099221f26a4b99488a337503edc1950c5bb29 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Fri, 3 Jul 2020 12:37:27 +0800 Subject: [PATCH] fix(dnn): fix Image2DPack4TensorFormat check GitOrigin-RevId: b9a8ae4e1ab4bb8ca978e3664e39b509250474fd --- dnn/src/common/relayout_format.cpp | 9 +++++++++ dnn/src/naive/handle.cpp | 6 +----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dnn/src/common/relayout_format.cpp b/dnn/src/common/relayout_format.cpp index ee6d50c52..92717159e 100644 --- a/dnn/src/common/relayout_format.cpp +++ b/dnn/src/common/relayout_format.cpp @@ -306,6 +306,15 @@ void RelayoutFormat::deduce_format(TensorFormat src, TensorFormat& dst) { megdnn_throw("Invalid relayout format mode"); break; } + + if (!dst.is_default() && + ( + handle()->type() != Handle::HandleType::NAIVE)) { + megdnn_throw( + "Only naive and opencl handle support " + "Image2DPack4TensorFormat, try to export MGB_USE_MEGDNN_DBG=2 " + "to enable naive handle"); + } #undef CHECK_SRC } diff --git a/dnn/src/naive/handle.cpp b/dnn/src/naive/handle.cpp index 3de0244c0..6a1129d95 100644 --- a/dnn/src/naive/handle.cpp +++ b/dnn/src/naive/handle.cpp @@ -107,11 +107,7 @@ HandleImpl::HandleImpl(megcoreComputingHandle_t computing_handle, m_dispatcher{megcoreGetCPUDispatcher(computing_handle)} {} size_t HandleImpl::image2d_pitch_alignment() const { - if (type() == Handle::HandleType::NAIVE) { - // only naive CPU handle supports this format - return g_image2d_pitch_alignment; - } - megdnn_throw("Image2DTensorFormat is not supported on this handle"); + return g_image2d_pitch_alignment; } size_t HandleImpl::exchange_image2d_pitch_alignment(size_t alignment) { -- GitLab