1 /** 2 * Copyright 2020 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_FRONTEND_PARALLEL_GRAPH_UTIL_NODE_INFO_H_ 18 #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_GRAPH_UTIL_NODE_INFO_H_ 19 20 #include <string> 21 #include <vector> 22 #include <memory> 23 #include <unordered_map> 24 #include <unordered_set> 25 #include "base/base.h" 26 #include "ir/anf.h" 27 #include "frontend/parallel/ops_info/operator_info.h" 28 29 namespace mindspore { 30 namespace parallel { 31 using OperatorInfoPtr = std::shared_ptr<mindspore::parallel::OperatorInfo>; 32 std::string ParameterName(const AnfNodePtr &node_ptr); 33 34 bool ParameterRequireGrad(const AnfNodePtr &node_ptr); 35 36 size_t GetLengthOfDataType(const TypePtr &type); 37 38 std::vector<bool> ExtractInputParameterByNode(const CNodePtr &node); 39 40 std::vector<size_t> ExtractInputTypeLengthByNode(const CNodePtr &node); 41 42 std::vector<TypePtr> ExtractOutputTypeByNode(const CNodePtr &node); 43 44 std::vector<AnfNodePtr> FindParameterByRefKeyNode(const AnfNodePtr &node, const FuncGraphPtr &func_graph); 45 46 bool AnfNodeIsPrimitive(const AnfNodePtr &anf_node, const std::string &prim_name); 47 48 bool FindReshape(const CNodePtr &cnode, std::unordered_set<std::string> *op_cache); 49 50 bool FindReshapePreNodeStraCosts(const AnfNodePtr &node, OperatorInfoPtr *pre_operator_info, int64_t *out_index, 51 size_t curr_depth); 52 53 bool FindReshapeNextNodeStraCosts(const CNodePtr &cnode, OperatorInfoPtr *next_operator_info, int64_t *in_index, 54 bool *is_next_reshape, size_t curr_depth); 55 void SetUserAttrs(const std::unordered_map<std::string, ValuePtr> &origin_prim_attrs, const PrimitivePtr &self_prim); 56 } // namespace parallel 57 } // namespace mindspore 58 59 #endif // MINDSPORE_CCSRC_FRONTEND_PARALLEL_GRAPH_UTIL_NODE_INFO_H_ 60