// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include #include #include #include #include #include "paddle/fluid/framework/new_executor/interpretercore_util.h" #include "paddle/fluid/framework/new_executor/new_executor_defs.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/variable.h" namespace paddle { namespace framework { class InterpreterCore { public: InterpreterCore(const platform::Place& place, const ProgramDesc& main_prog, VariableScope* global_scope, const std::vector& feed_names, const std::vector& fetch_names); void Run(const std::vector& feed_tensors, std::vector* fetch_tensors); static void BuildOpFuncList(const platform::Place& place, const framework::ProgramDesc& pdesc, std::vector* op_list, std::vector* vec_func_list, VariableScope* var_scope); private: void Convert(); void RunInstruction(const Instruction& instr_node, const VariableScope& var_scope, const platform::Place& place); void ExecuteInstructionList(const std::vector& vec_instr, const VariableScope& var_scope, const platform::Place& place); std::vector MergeVector(const std::vector& first, const std::vector& second); void BuildVariableScope(const framework::ProgramDesc& pdesc, VariableScope* var_scope); const platform::Place& place_; const ProgramDesc& main_program_; VariableScope* global_scope_; std::vector vec_meta_info_; std::vector vec_func_list_; std::vector op_list_; std::vector vec_instruction_; InstructionInfo instruction_info_; std::vector dependecy_count_; std::vector ref_coun_info_; std::vector> input_var2op_info_; bool is_build_; std::vector feed_names_; std::vector fetch_names_; }; } // namespace framework } // namespace paddle