OP should not depend on executor
Created by: helinwang
Executor depends on OP, it will execute the OPs. However, (EDIT: Executor should not depend on OP, since we don't want executor to change once OP changed) I think OP should not depend on executor. The OP should not know anything about the class that runs it.
Currently we have few OPs that depends on executor (creates framework::Executor
instance). This creates multiple instances of executor, splitting the job to execute OPs to multiple different executors, making OP execution optimization much harder - each executor does not know about its peer executors, thus harder to optimize. For example, the executor should have a thread-pool with the number of threads matching the number of virtual cores. With multiple executors, how many threads should each executor have?
We need to remove dependency from OP to executor.
recurrent_op.cc
16:#include "paddle/framework/executor.h"
236: framework::Executor executor(dev_ctx);
270: executor.Run(*program, &cur_scope, block->ID(),
319: framework::Executor executor(dev_ctx);
376: executor.Run(*program, &cur_scope, block->ID(),
379: VLOG(5) << "executor.Run finished ";
while_op.cc
16:#include "paddle/framework/executor.h"
48: framework::Executor executor(dev_ctx);
59: executor.Run(*program, ¤t_scope, block->ID(),
101: framework::Executor executor(dev_ctx);
158: executor.Run(*program, *cur_scope_iter, block->ID(), false);
recv_op.cc
23:#include "paddle/framework/executor.h"
77: framework::Executor executor(dev_ctx);
79: executor.Run(*program, &recv_scope, block->ID(),
conditional_block_op.cc
15:#include "paddle/framework/executor.h"