/** * Copyright 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_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ #define GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ #include #include "framework/common/ge_inner_error_codes.h" #include "graph/node.h" #include "graph/operator.h" #include "external/../register/register.h" namespace ge { class HostCpuEngine { public: ~HostCpuEngine() = default; static HostCpuEngine &GetInstance() { static HostCpuEngine instance; return instance; } ge::Status Initialize(); void Finalize(); static bool CheckSupported(const string &op_type); ge::Status Run(NodePtr &node, const vector &inputs, std::vector &outputs); private: HostCpuEngine() = default; void CloseSo(); ge::Status LoadLibs(std::vector &lib_paths); ge::Status LoadLib(const std::string &lib_path); static ge::Status GetRealPath(std::string &path); static ge::Status GetLibPath(std::string &lib_path); static ge::Status ListSoFiles(const std::string &base_dir, std::vector &names); static bool IsSoFile(const std::string &file_name); static ge::Status FindOpKernel(const NodePtr &node, std::unique_ptr &op_kernel); static ge::Status PrepareInputs(const ConstOpDescPtr &op_desc, const vector &inputs, std::map &named_inputs); static ge::Status PrepareOutputs(const ConstOpDescPtr &op_desc, vector &outputs, std::map &named_outputs); static ge::Status RunInternal(const OpDescPtr &op_desc, HostCpuOp &op_kernel, std::map &named_inputs, std::map &named_outputs); std::mutex mu_; std::vector lib_handles_; bool initialized_ = false; }; } // namespace ge #endif // GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_