/** * Copyright 2019-2020 Huawei Technologies Co., Ltd * * 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. */ #ifndef GE_OPSKERNEL_MANAGER_OPS_KERNEL_MANAGER_H_ #define GE_OPSKERNEL_MANAGER_OPS_KERNEL_MANAGER_H_ #include #include #include #include #include #include "common/debug/log.h" #include "common/ge/plugin_manager.h" #include "common/ge/op_tiling_manager.h" #include "common/ge_inner_error_codes.h" #include "common/opskernel/ops_kernel_info_store.h" #include "common/optimizer/graph_optimizer.h" #include "graph/optimize/graph_optimize.h" #include "framework/common/ge_inner_error_codes.h" #include "ge/ge_api_types.h" #include "runtime/base.h" using std::string; using std::map; using std::vector; namespace ge { using OpsKernelInfoStorePtr = std::shared_ptr; class OpsKernelManager { public: friend class GELib; // get opsKernelInfo by type const vector &GetOpsKernelInfo(const string &op_type); // get all opsKernelInfo const map> &GetAllOpsKernelInfo() const; // get opsKernelInfoStore by name OpsKernelInfoStorePtr GetOpsKernelInfoStore(const std::string &name) const; // get all opsKernelInfoStore const map &GetAllOpsKernelInfoStores() const; // get all graph_optimizer const map &GetAllGraphOptimizerObjs() const; // get all graph_optimizer by priority const vector> &GetAllGraphOptimizerObjsByPriority() const; // get subgraphOptimizer by engine name void GetGraphOptimizerByEngine(const std::string &engine_name, vector &graph_optimizer); // get enableFeFlag bool GetEnableFeFlag() const; // get enableAICPUFlag bool GetEnableAICPUFlag() const; // get enablePluginFlag bool GetEnablePluginFlag() const; private: OpsKernelManager(); ~OpsKernelManager(); // opsKernelManager initialize, load all opsKernelInfoStore and graph_optimizer Status Initialize(const map &options); // opsKernelManager finalize, unload all opsKernelInfoStore and graph_optimizer Status Finalize(); Status InitOpKernelInfoStores(const map &options); Status CheckPluginPtr() const; void GetExternalEnginePath(std::string &path, const std::map& options); void InitOpsKernelInfo(); Status InitGraphOptimzers(const map &options); Status InitPluginOptions(const map &options); Status ParsePluginOptions(const map &options, const string &plugin_name, bool &enable_flag); Status LoadGEGraphOptimizer(map& graphOptimizer); Status InitGraphOptimizerPriority(); // Finalize other ops kernel resource Status FinalizeOpsKernel(); PluginManager plugin_manager_; OpTilingManager op_tiling_manager_; // opsKernelInfoStore map ops_kernel_store_{}; // graph_optimizer map graph_optimizers_{}; // ordered graph_optimzer vector> graph_optimizers_by_priority_{}; // opsKernelInfo map> ops_kernel_info_{}; map initialize_{}; vector empty_op_info_{}; bool init_flag_; bool enable_fe_flag_ = false; bool enable_aicpu_flag_ = false; }; } // namespace ge #endif // GE_OPSKERNEL_MANAGER_OPS_KERNEL_MANAGER_H_