From acfb24691668c05d9bbd26127520987fd85b2c94 Mon Sep 17 00:00:00 2001 From: Jiaying Zhao Date: Tue, 9 Jul 2019 19:19:45 +0800 Subject: [PATCH] delete commit 'free memery when input changes smaller in lod mode' (#1737) --- src/framework/executor.cpp | 25 ------------------------- src/framework/executor.h | 3 +-- src/framework/tensor_base.h | 2 -- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/framework/executor.cpp b/src/framework/executor.cpp index aedc9307b0..c06abc8416 100644 --- a/src/framework/executor.cpp +++ b/src/framework/executor.cpp @@ -294,20 +294,6 @@ static void ClearNoPersistableTensorArray(const framework::ProgramDesc *program, } } -static void ClearNoPersistableTensor(const framework::ProgramDesc *program, - framework::Scope *scope) { - for (const auto &block : program->Blocks()) { - for (const auto &var_desc : block->Vars()) { - if (!var_desc->Persistable() && - var_desc->Type() == VARTYPE_TYPE_LOD_TENSOR) { - auto var = scope->Var(var_desc->Name()); - auto target_tensor = var->template GetMutable(); - target_tensor->reset(); - } - } - } -} - template void Executor::InitNoPersistableMemory(const Tensor &input_tensor) { for (const auto &block : program_desc_->Blocks()) { @@ -423,7 +409,6 @@ void Executor::SetInput(const Tensor &input, target.Resize(input.dims()); target.ShareDataWith(input); - input_dim_cur_ = input.dims(); } template @@ -473,16 +458,6 @@ PMStatus Executor::Predict() { // is always push back a new tensor in the array ClearNoPersistableTensorArray(program_desc_.get(), program_.scope.get()); - // in lod_mode_, free no persistable memery when input changes smaller. - if (lod_mode_) { - if (product(input_dim_cur_) <= 0.7 * product(input_dim_last_)) { - ClearNoPersistableTensor(program_desc_.get(), program_.scope.get()); - input_dim_last_ = input_dim_cur_; - } else if (product(input_dim_cur_) > product(input_dim_last_)) { - input_dim_last_ = input_dim_cur_; - } - } - #ifdef PADDLE_MOBILE_PROFILE std::vector profile(ops_of_block0_.size()); struct timespec ts; diff --git a/src/framework/executor.h b/src/framework/executor.h index 0fb2acc67f..c2d096182d 100644 --- a/src/framework/executor.h +++ b/src/framework/executor.h @@ -97,9 +97,8 @@ class Executor { std::unordered_map feed_indices_; std::unordered_map fetch_indices_; - // for lod_mode_ + // for super resoltion DDim input_dim_last_; - DDim input_dim_cur_; #ifdef PADDLE_MOBILE_PROFILE typedef typename DtypeTensorTrait::gtype ProfileTensorType; diff --git a/src/framework/tensor_base.h b/src/framework/tensor_base.h index cf977a35d8..027f1165a0 100644 --- a/src/framework/tensor_base.h +++ b/src/framework/tensor_base.h @@ -70,8 +70,6 @@ class TensorBase { inline bool IsInitialized() const { return holder_ != nullptr; } - inline void reset() { holder_ = nullptr; } - /*! Return the dimensions of the memory block. */ inline const DDim &dims() const { return dims_; } -- GitLab