未验证 提交 4c8ff726 编写于 作者: A Abhinav Arora 提交者: GitHub

Fix CPPLint errors with rxecutor (#10212)

上级 5fe1fe3a
...@@ -226,15 +226,15 @@ static bool has_fetch_operators( ...@@ -226,15 +226,15 @@ static bool has_fetch_operators(
} }
void Executor::Run(const ProgramDesc& program, Scope* scope, void Executor::Run(const ProgramDesc& program, Scope* scope,
std::map<std::string, const LoDTensor*>& feed_targets, std::map<std::string, const LoDTensor*>* feed_targets,
std::map<std::string, LoDTensor*>& fetch_targets, std::map<std::string, LoDTensor*>* fetch_targets,
bool create_vars, const std::string& feed_holder_name, bool create_vars, const std::string& feed_holder_name,
const std::string& fetch_holder_name) { const std::string& fetch_holder_name) {
platform::RecordBlock b(kProgramId); platform::RecordBlock b(kProgramId);
bool has_feed_ops = bool has_feed_ops =
has_feed_operators(program.Block(0), feed_targets, feed_holder_name); has_feed_operators(program.Block(0), *feed_targets, feed_holder_name);
bool has_fetch_ops = bool has_fetch_ops =
has_fetch_operators(program.Block(0), fetch_targets, fetch_holder_name); has_fetch_operators(program.Block(0), *fetch_targets, fetch_holder_name);
ProgramDesc* copy_program = const_cast<ProgramDesc*>(&program); ProgramDesc* copy_program = const_cast<ProgramDesc*>(&program);
if (!has_feed_ops || !has_fetch_ops) { if (!has_feed_ops || !has_fetch_ops) {
...@@ -250,7 +250,7 @@ void Executor::Run(const ProgramDesc& program, Scope* scope, ...@@ -250,7 +250,7 @@ void Executor::Run(const ProgramDesc& program, Scope* scope,
feed_holder->SetPersistable(true); feed_holder->SetPersistable(true);
int i = 0; int i = 0;
for (auto& feed_target : feed_targets) { for (auto& feed_target : (*feed_targets)) {
std::string var_name = feed_target.first; std::string var_name = feed_target.first;
VLOG(3) << "feed target's name: " << var_name; VLOG(3) << "feed target's name: " << var_name;
...@@ -273,7 +273,7 @@ void Executor::Run(const ProgramDesc& program, Scope* scope, ...@@ -273,7 +273,7 @@ void Executor::Run(const ProgramDesc& program, Scope* scope,
fetch_holder->SetPersistable(true); fetch_holder->SetPersistable(true);
int i = 0; int i = 0;
for (auto& fetch_target : fetch_targets) { for (auto& fetch_target : (*fetch_targets)) {
std::string var_name = fetch_target.first; std::string var_name = fetch_target.first;
VLOG(3) << "fetch target's name: " << var_name; VLOG(3) << "fetch target's name: " << var_name;
...@@ -361,16 +361,16 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope, ...@@ -361,16 +361,16 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope,
void Executor::RunPreparedContext( void Executor::RunPreparedContext(
ExecutorPrepareContext* ctx, Scope* scope, ExecutorPrepareContext* ctx, Scope* scope,
std::map<std::string, const LoDTensor*>& feed_targets, std::map<std::string, const LoDTensor*>* feed_targets,
std::map<std::string, LoDTensor*>& fetch_targets, bool create_vars, std::map<std::string, LoDTensor*>* fetch_targets, bool create_vars,
const std::string& feed_holder_name, const std::string& fetch_holder_name) { const std::string& feed_holder_name, const std::string& fetch_holder_name) {
auto& global_block = ctx->prog_.Block(ctx->block_id_); auto& global_block = ctx->prog_.Block(ctx->block_id_);
PADDLE_ENFORCE( PADDLE_ENFORCE(
has_feed_operators(global_block, feed_targets, feed_holder_name), has_feed_operators(global_block, *feed_targets, feed_holder_name),
"Program in ExecutorPrepareContext should has feed_ops."); "Program in ExecutorPrepareContext should has feed_ops.");
PADDLE_ENFORCE( PADDLE_ENFORCE(
has_fetch_operators(global_block, fetch_targets, fetch_holder_name), has_fetch_operators(global_block, *fetch_targets, fetch_holder_name),
"Program in the prepared context should has fetch_ops."); "Program in the prepared context should has fetch_ops.");
// map the data of feed_targets to feed_holder // map the data of feed_targets to feed_holder
...@@ -378,8 +378,8 @@ void Executor::RunPreparedContext( ...@@ -378,8 +378,8 @@ void Executor::RunPreparedContext(
if (op->Type() == kFeedOpType) { if (op->Type() == kFeedOpType) {
std::string feed_target_name = op->Output("Out")[0]; std::string feed_target_name = op->Output("Out")[0];
int idx = boost::get<int>(op->GetAttr("col")); int idx = boost::get<int>(op->GetAttr("col"));
SetFeedVariable(scope, *feed_targets[feed_target_name], feed_holder_name, SetFeedVariable(scope, *(*feed_targets)[feed_target_name],
idx); feed_holder_name, idx);
} }
} }
...@@ -390,7 +390,7 @@ void Executor::RunPreparedContext( ...@@ -390,7 +390,7 @@ void Executor::RunPreparedContext(
if (op->Type() == kFetchOpType) { if (op->Type() == kFetchOpType) {
std::string fetch_target_name = op->Input("X")[0]; std::string fetch_target_name = op->Input("X")[0];
int idx = boost::get<int>(op->GetAttr("col")); int idx = boost::get<int>(op->GetAttr("col"));
*fetch_targets[fetch_target_name] = *(*fetch_targets)[fetch_target_name] =
GetFetchVariable(*scope, fetch_holder_name, idx); GetFetchVariable(*scope, fetch_holder_name, idx);
} }
} }
......
...@@ -55,8 +55,8 @@ class Executor { ...@@ -55,8 +55,8 @@ class Executor {
bool create_local_scope = true, bool create_vars = true); bool create_local_scope = true, bool create_vars = true);
void Run(const ProgramDesc& program, Scope* scope, void Run(const ProgramDesc& program, Scope* scope,
std::map<std::string, const LoDTensor*>& feed_targets, std::map<std::string, const LoDTensor*>* feed_targets,
std::map<std::string, LoDTensor*>& fetch_targets, std::map<std::string, LoDTensor*>* fetch_targets,
bool create_vars = true, bool create_vars = true,
const std::string& feed_holder_name = "feed", const std::string& feed_holder_name = "feed",
const std::string& fetch_holder_name = "fetch"); const std::string& fetch_holder_name = "fetch");
...@@ -74,8 +74,8 @@ class Executor { ...@@ -74,8 +74,8 @@ class Executor {
bool create_vars = true); bool create_vars = true);
void RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope, void RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope,
std::map<std::string, const LoDTensor*>& feed_targets, std::map<std::string, const LoDTensor*>* feed_targets,
std::map<std::string, LoDTensor*>& fetch_targets, std::map<std::string, LoDTensor*>* fetch_targets,
bool create_vars = true, bool create_vars = true,
const std::string& feed_holder_name = "feed", const std::string& feed_holder_name = "feed",
const std::string& fetch_holder_name = "fetch"); const std::string& fetch_holder_name = "fetch");
......
...@@ -178,10 +178,10 @@ void TestInference(const std::string& dirname, ...@@ -178,10 +178,10 @@ void TestInference(const std::string& dirname,
std::unique_ptr<paddle::framework::ExecutorPrepareContext> ctx; std::unique_ptr<paddle::framework::ExecutorPrepareContext> ctx;
if (PrepareContext) { if (PrepareContext) {
ctx = executor.Prepare(*inference_program, 0); ctx = executor.Prepare(*inference_program, 0);
executor.RunPreparedContext(ctx.get(), scope, feed_targets, fetch_targets, executor.RunPreparedContext(ctx.get(), scope, &feed_targets,
CreateVars); &fetch_targets, CreateVars);
} else { } else {
executor.Run(*inference_program, scope, feed_targets, fetch_targets, executor.Run(*inference_program, scope, &feed_targets, &fetch_targets,
CreateVars); CreateVars);
} }
...@@ -197,10 +197,10 @@ void TestInference(const std::string& dirname, ...@@ -197,10 +197,10 @@ void TestInference(const std::string& dirname,
if (PrepareContext) { if (PrepareContext) {
// Note: if you change the inference_program, you need to call // Note: if you change the inference_program, you need to call
// executor.Prepare() again to get a new ExecutorPrepareContext. // executor.Prepare() again to get a new ExecutorPrepareContext.
executor.RunPreparedContext(ctx.get(), scope, feed_targets, executor.RunPreparedContext(ctx.get(), scope, &feed_targets,
fetch_targets, CreateVars); &fetch_targets, CreateVars);
} else { } else {
executor.Run(*inference_program, scope, feed_targets, fetch_targets, executor.Run(*inference_program, scope, &feed_targets, &fetch_targets,
CreateVars); CreateVars);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册