1 /** 2 * Copyright 2020-2021 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_CCSRC_BACKEND_KERNEL_COMPILER_AKG_AKG_KERNEL_JSON_DECODER_H_ 18 #define MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_AKG_AKG_KERNEL_JSON_DECODER_H_ 19 #include <string> 20 #include <vector> 21 #include <map> 22 #include <nlohmann/json.hpp> 23 #include "ir/scalar.h" 24 #include "ir/anf.h" 25 #include "ir/func_graph.h" 26 27 namespace mindspore { 28 namespace kernel { 29 class AkgKernelJsonDecoder { 30 public: AkgKernelJsonDecoder()31 AkgKernelJsonDecoder() { nodes_map_.clear(); } 32 ~AkgKernelJsonDecoder() = default; 33 34 FuncGraphPtr DecodeFusedNodes(const nlohmann::json &kernel_json); 35 FuncGraphPtr DecodeFusedNodes(const std::string &kernel_json_str); 36 37 private: 38 ParameterPtr DecodeParameter(const nlohmann::json ¶meter_json, const FuncGraphPtr &func_graph); 39 CNodePtr DecodeCNode(const nlohmann::json &cnode_json, const FuncGraphPtr &func_graph, const std::string &processor); 40 AnfNodePtr DecodeOutput(const std::vector<nlohmann::json> &output_descs, const FuncGraphPtr &func_graph); 41 std::map<std::string, AnfNodePtr> nodes_map_; 42 }; 43 44 // infer abstract shape by device_shape and data_format 45 ShapeVector GetFakeAbstractShape(const ShapeVector &device_shape, const std::string &format); 46 } // namespace kernel 47 } // namespace mindspore 48 #endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_AKG_AKG_KERNEL_JSON_DECODER_H_ 49