From 67bd7f3f0a82461827fd58af7f6f1bf43576c50a Mon Sep 17 00:00:00 2001 From: zhaojiaying01 Date: Thu, 27 Dec 2018 13:33:29 +0800 Subject: [PATCH] run superresoltion on cpu --- src/framework/executor.cpp | 12 ++++++------ src/framework/executor.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/framework/executor.cpp b/src/framework/executor.cpp index f6c4678370..751d04fc65 100644 --- a/src/framework/executor.cpp +++ b/src/framework/executor.cpp @@ -238,7 +238,7 @@ void Executor::InitCombineMemory() { template void Executor::InitNoPersistableMemory( - const LoDTensor &input_tensor) { + const Tensor &input_tensor) { for (const auto &block : program_desc_->Blocks()) { for (const auto &var_desc : block->Vars()) { auto var = program_.scope->Var(var_desc->Name()); @@ -336,9 +336,9 @@ void Executor::SetInput(const Tensor &input, auto *target_tensor = target_var->template GetMutable(); if (config_.load_when_predict) { - if (target_tensor->IsInitialized() && - target_tensor->dims() != input.dims()) { - InitNoPersistableMemory(*target_tensor); + if (input_dim_last_ != input.dims()) { + InitNoPersistableMemory(input); + input_dim_last_ = input.dims(); } } @@ -355,9 +355,9 @@ void Executor::SetInput(const LoDTensor &input, auto *target_tensor = target_var->template GetMutable(); if (config_.load_when_predict) { - if (target_tensor->IsInitialized() && - target_tensor->dims() != input.dims()) { + if (input_dim_last_ != input.dims()) { InitNoPersistableMemory(*target_tensor); + input_dim_last_ = input.dims(); } } diff --git a/src/framework/executor.h b/src/framework/executor.h index e77df5174c..edbfd5cdcc 100644 --- a/src/framework/executor.h +++ b/src/framework/executor.h @@ -65,7 +65,7 @@ class Executor { LoDTensor *tensor) const; void InitMemory(); void InitCombineMemory(); - void InitNoPersistableMemory(const LoDTensor &input_tensor); + void InitNoPersistableMemory(const Tensor &input_tensor); void LoadMemory(void **data, const std::shared_ptr var_desc, LoDTensor *tensor); #ifdef PADDLE_MOBILE_CL -- GitLab