Skip to content

Commit 7bb4ea9

Browse files
authored
Add an argument in Executor.Run to allow users to choose whether to create and destroy variables every time. (#9242)
1 parent 7c041e4 commit 7bb4ea9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

paddle/fluid/framework/executor.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void Executor::Run(const ProgramDesc& program, Scope* scope,
185185
std::map<std::string, const LoDTensor*>& feed_targets,
186186
std::map<std::string, LoDTensor*>& fetch_targets,
187187
const std::string& feed_holder_name,
188-
const std::string& fetch_holder_name) {
188+
const std::string& fetch_holder_name, bool create_vars) {
189189
platform::RecordBlock b(kProgramId);
190190
bool has_feed_ops =
191191
has_feed_operators(program.Block(0), feed_targets, feed_holder_name);
@@ -255,7 +255,7 @@ void Executor::Run(const ProgramDesc& program, Scope* scope,
255255
}
256256
}
257257

258-
Run(*copy_program, scope, 0, true, true);
258+
Run(*copy_program, scope, 0, create_vars, create_vars);
259259

260260
// obtain the data of fetch_targets from fetch_holder
261261
for (auto* op : global_block->AllOps()) {

paddle/fluid/framework/executor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class Executor {
5454
std::map<std::string, const LoDTensor*>& feed_targets,
5555
std::map<std::string, LoDTensor*>& fetch_targets,
5656
const std::string& feed_holder_name = "feed",
57-
const std::string& fetch_holder_name = "fetch");
57+
const std::string& fetch_holder_name = "fetch",
58+
bool create_vars = true);
5859

5960
static std::unique_ptr<ExecutorPrepareContext> Prepare(
6061
const ProgramDesc& program, int block_id);

0 commit comments

Comments
 (0)