未验证 提交 bb1cf7ff 编写于 作者: Y Yiqun Liu 提交者: GitHub

Optimize the execution of RuntimeProgram by saving the bool whether the op is...

Optimize the execution of RuntimeProgram by saving the bool whether the op is feed/fetch op. (#2703)

test=develop
上级 9188571c
......@@ -137,8 +137,7 @@ void RuntimeProgram::UpdateVarsOfProgram(cpp::ProgramDesc* desc) {
void RuntimeProgram::Run() {
for (auto& inst : instructions_) {
std::string op_type = inst.op()->op_info()->Type();
if (op_type == "feed" || op_type == "fetch") continue;
if (inst.is_feed_fetch_op()) continue;
inst.Run();
#ifdef LITE_WITH_PROFILE
#ifdef LITE_WITH_PRECISION_PROFILE
......
......@@ -90,7 +90,12 @@ struct Program {
struct Instruction {
Instruction(const std::shared_ptr<OpLite>& op,
std::unique_ptr<KernelBase>&& kernel)
: op_(op), kernel_(std::move(kernel)) {}
: op_(op), kernel_(std::move(kernel)) {
std::string op_type = op->Type();
if (op_type == "feed" || op_type == "fetch") {
is_feed_fetch_op_ = true;
}
}
// Run the instruction.
void Run();
......@@ -101,6 +106,8 @@ struct Instruction {
const KernelBase* kernel() const { return kernel_.get(); }
KernelBase* mutable_kernel() { return kernel_.get(); }
bool is_feed_fetch_op() const { return is_feed_fetch_op_; }
#ifdef LITE_WITH_PROFILE
void set_profiler(profile::Profiler* profiler) {
profiler_ = profiler;
......@@ -118,6 +125,7 @@ struct Instruction {
private:
std::shared_ptr<OpLite> op_;
std::unique_ptr<KernelBase> kernel_;
bool is_feed_fetch_op_{false};
bool first_epoch_{true};
bool has_run_{false};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册