diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 2260353af7bef11257e905d8ff2eae96268ffd01..fc5036886a95db583770dcfcf2d7b9a4b87d8ae8 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -749,7 +749,7 @@ void OperatorWithKernel::RunImpl(const Scope& scope, kernel_iter->second(ExecutionContext(*this, exec_scope, *dev_ctx)); - if (!transfered_inplace_vars.empty()) { + if (run_by_executor_ && !transfered_inplace_vars.empty()) { // there is inplace variable has been transfered. TransferInplaceVarsBack(scope, transfered_inplace_vars, *transfer_scope); } @@ -771,6 +771,7 @@ void OperatorWithKernel::RunImpl(const Scope& scope, } } } + void OperatorWithKernel::TransferInplaceVarsBack( const Scope& scope, const std::vector& inplace_vars, const Scope& transfer_scope) const {