diff --git a/src/opr/impl/io.sereg.h b/src/opr/impl/io.sereg.h index 00865c48e6a80e880db7bf2300c1dd7f9a0c4320..9260a1b64c294c4eeaf2ce6dd423fe04f35a2b03 100644 --- a/src/opr/impl/io.sereg.h +++ b/src/opr/impl/io.sereg.h @@ -218,11 +218,8 @@ struct OprLoadDumpImpl { auto handle = MegDNNHandle::get(CompNodeEnv::from_comp_node(i->comp_node())) .handle(); auto format = TensorFormat::deserialize(ctx.load_buf_with_len(), handle); - DeviceTensorStorage storage(i->comp_node()); TensorLayout layout_with_format{i->layout(), i->layout().dtype, format}; - auto size = layout_with_format.span().dist_byte(); - storage.ensure_size(size); if (i->storage().comp_node().mem_node() == CompNode::default_cpu().mem_node()) { mgb_assert( @@ -233,6 +230,13 @@ struct OprLoadDumpImpl { src.copy_from_fixlayout(*i).sync(); *i = DeviceTensorND::make_proxy(src); } else { + //! actually only layout of this tensor will be used later, see + //! src/serialization/impl/batched_device_value_loader.cpp:49. But we + //! have no way to reset layout only, so just construct a invalid + //! storage instead + auto size = layout_with_format.span().dist_byte(); + DeviceTensorStorage storage; + storage.reset(i->comp_node(), size, nullptr); i->reset(storage, layout_with_format); } }