How about implement another Run() in framework::Executor
Created by: Xreki
Suggested by @qingqing01 , we may implement another Run()
in paddle/framework/executor.h which do the same things as the Run()
of Python Executor
.
The interface maybe like and will do following things:
void Run(const ProgramDesc& program,
Scope* scope,
std::map<std::string, Tensor>& feeds,
std::map<std::string, Tensor>& fetchs,
std::string& feed_var_name="feed",
std::string& fetch_var_name="fetch") {
1. clone the program
2. prepend feed_op
3. set feed variables
4. append fetch_op
5. call Run(const ProgramDesc&, Scope*, int, bool create_local_scope = true, bool create_vars = true)
6. get fetch variables
}
So that we can directly Run
both in Python API and C++ API.