From 875f5a0cb778d4792bacf1fad4e61b3e2d6f5cd7 Mon Sep 17 00:00:00 2001 From: yongqiang Date: Tue, 8 Sep 2020 08:33:02 +0000 Subject: [PATCH] add workspace --- lite/api/paddle_api.cc | 4 ++++ lite/api/paddle_api.h | 2 +- lite/core/device_info.h | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lite/api/paddle_api.cc b/lite/api/paddle_api.cc index a3d29dff93..0ec7663dfa 100644 --- a/lite/api/paddle_api.cc +++ b/lite/api/paddle_api.cc @@ -237,6 +237,10 @@ void PaddlePredictor::SaveOptimizedModel(const std::string &model_dir, << "The SaveOptimizedModel API is only supported by CxxConfig predictor."; } +PaddlePredictor::~PaddlePredictor() { + lite::DeviceInfo::Global().CleanWorkspace(); +} + template std::shared_ptr CreatePaddlePredictor(const ConfigT &) { return std::shared_ptr(); diff --git a/lite/api/paddle_api.h b/lite/api/paddle_api.h index 42a4b2228b..8f2d34001b 100644 --- a/lite/api/paddle_api.h +++ b/lite/api/paddle_api.h @@ -118,7 +118,7 @@ class LITE_API PaddlePredictor { LiteModelType model_type = LiteModelType::kProtobuf, bool record_info = false); - virtual ~PaddlePredictor() = default; + virtual ~PaddlePredictor(); protected: int threads_{1}; diff --git a/lite/core/device_info.h b/lite/core/device_info.h index f3f10c2d57..3140ca09ab 100644 --- a/lite/core/device_info.h +++ b/lite/core/device_info.h @@ -77,6 +77,11 @@ class DeviceInfo { return reinterpret_cast(workspace_.mutable_data()); } bool ExtendWorkspace(size_t size); + bool CleanWorkspace() { + // workspace_.Resize({1}); + // workspace_.mutable_data(); + workspace_.clear(); + } private: int core_num_; -- GitLab