From 85ea882cb5797abf958a2ff43d1f48d37225793f Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Fri, 14 Jan 2022 13:16:28 +0800 Subject: [PATCH] fix(mgb/ops): immutable tensor support empty storage GitOrigin-RevId: 2851498fce49d2c0801e1ef11cead37fbfddb974 --- src/opr/impl/io.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/opr/impl/io.cpp b/src/opr/impl/io.cpp index e18bfd944..6cbc6c045 100644 --- a/src/opr/impl/io.cpp +++ b/src/opr/impl/io.cpp @@ -100,7 +100,7 @@ void intl::HostIONodeBase::init_output_static_infer_desc() { if (fill_in_static_infer(nullptr)) { auto infer_val = [this](DeviceTensorND& dest, const InpVal&) -> bool { - if (fill_in_static_infer(&dest) && !dest.empty()) { + if (fill_in_static_infer(&dest) && dest.shape_valid()) { return true; } return false; @@ -423,8 +423,8 @@ void ImmutableTensor::Value::setup(CompNode cn, const HostTensorND& val) { DeviceTensorND& ImmutableTensor::Value::static_infer() { MGB_LOCK_GUARD(m_mtx); - if (m_static_infer.empty()) { - mgb_assert(!m_dev.empty()); + if (!m_static_infer.shape_valid()) { + mgb_assert(m_dev.shape_valid()); m_static_infer.comp_node(CompNode::default_cpu()).copy_from(m_dev); } return m_static_infer; -- GitLab