1 /** 2 * Copyright 2023 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_LITE_TOOLS_GRAPH_KERNEL_CONVERTER_AKG_UTILS_H_ 18 #define MINDSPORE_LITE_TOOLS_GRAPH_KERNEL_CONVERTER_AKG_UTILS_H_ 19 #include <string> 20 #include <map> 21 #include <set> 22 #include <vector> 23 #include "utils/anf_utils.h" 24 #include "kernel/graph_kernel/graph_kernel_json_generator.h" 25 26 constexpr auto kAkgKernelSo = "akgkernels.so"; 27 namespace mindspore::graphkernel { 28 constexpr int PROCESS_LIMIT = 8; 29 constexpr size_t TIME_OUT = 100; 30 constexpr auto kTunedSign = "tuned_signature"; 31 constexpr auto kAddMSLiteAkg = 32 "try:\n" 33 " import mindspore_lite.akg as akg\n" 34 "except Exception:\n" 35 " import akg as akg\n"; 36 37 std::string SaveNodesInfo(const AnfNodePtrList &nodes, const std::string &dir, const DumpOption &option, 38 std::map<AnfNodePtr, std::string> *node_kernel, std::set<std::string> *kernel_names); 39 std::string GetCNodeDynamicInputIndex(const CNodePtr &cnode); 40 std::string GetCNodeInputShapeStr(const CNodePtr &cnode); 41 std::string GetCNodeOutputShapeStr(const CNodePtr &cnode); 42 std::string GetCNodeOutputTypeStr(const CNodePtr &cnode); 43 std::string GetCNodeOutputFormatStr(const CNodePtr &cnode); 44 ParameterPtr CreateAkgKernelParameter(const FuncGraphPtr &func_graph, const std::string &path, 45 const std::string &kernel_name); 46 bool CompileJsonsInList(const std::string &dir_path, const std::vector<std::string> &json_list); 47 void ExcludeTunedObj(const std::string &dir_path, std::set<std::string> *kernel_names, 48 std::map<AnfNodePtr, std::string> *node_kernel); 49 } // namespace mindspore::graphkernel 50 #endif // MINDSPORE_LITE_TOOLS_GRAPH_KERNEL_CONVERTER_AKG_UTILS_H_ 51