@@ -65,10 +65,6 @@ Tensor::operator bool() const {
6565 return impl_ != nullptr ;
6666}
6767
68- void Tensor::resume_from_blob_ () const {
69- context::reinstantiateBlob (impl_->data_ .memory );
70- }
71-
7268TensorMetaData::TensorMetaData (const Shape &_shape, const Strides &_strides, const DataType &_dtype)
7369 : shape(_shape), strides(_strides), dtype(_dtype) {
7470 INFINICORE_CHECK_ERROR (infiniopCreateTensorDescriptor (&desc, shape.size (), shape.data (), strides.data (), (infiniDtype_t)dtype));
@@ -280,10 +276,22 @@ std::shared_ptr<TensorImpl> TensorImpl::strided_from_blob(
280276 return t;
281277}
282278
283- Tensor TensorImpl::to_blob () const {
279+ Tensor TensorImpl::to_blob_ () const {
284280 auto t = std::shared_ptr<TensorImpl>(new TensorImpl (shape (), strides (), dtype ()));
285281 t->data_ .offset = this ->data_ .offset ;
286282 t->data_ .memory = std::make_shared<Memory>(this ->data_ .memory ->data (), this ->data_ .memory ->size (), this ->data_ .memory ->device (), nullptr );
283+ t->to_blob_mark_ = true ;
284+ return Tensor{t};
285+ }
286+
287+ Tensor TensorImpl::resume_from_blob_ () const {
288+ auto t = std::shared_ptr<TensorImpl>(new TensorImpl (shape (), strides (), dtype ()));
289+ t->data_ .offset = this ->data_ .offset ;
290+ if (to_blob_mark_) {
291+ t->data_ .memory = context::reinstantiateBlob (this ->data_ .memory );
292+ } else {
293+ t->data_ .memory = this ->data_ .memory ;
294+ }
287295
288296 return Tensor{t};
289297}
0 commit comments