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_BACKEND_KERNEL_COMPILER_TBE_TBE_DYNAMINC_SHAPE_UTIL_H 18 #define MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_TBE_TBE_DYNAMINC_SHAPE_UTIL_H 19 20 #include <memory> 21 #include <string> 22 #include <utility> 23 #include <vector> 24 #include "mindspore/core/ir/anf.h" 25 #include "backend/kernel_compiler/oplib/oplib.h" 26 namespace mindspore { 27 namespace kernel { 28 namespace tbe { 29 using RangePair = std::vector<std::pair<int64_t, int64_t>>; 30 class TbeDynamicShapeUtil { 31 public: 32 TbeDynamicShapeUtil() = default; 33 ~TbeDynamicShapeUtil() = default; 34 static bool IsDynamicShapeNode(const CNodePtr &cnode); 35 static bool IsDynamicShapeNode(const AnfNodePtr &anf_node); 36 static void SetDynamicShapeAttr(const CNodePtr &cnode); 37 static bool GetDynamicShapeAttr(const CNodePtr &cnode); 38 static bool GetDynamicShapeAttr(const AnfNodePtr &anf_node); 39 static std::shared_ptr<OpInfo> FindOp(const std::string &op_name, const AnfNodePtr &anf_node); 40 static std::shared_ptr<OpInfo> FindOp(const std::string &op_name, const CNodePtr &cnode); 41 static RangePair GetInputDynamicRange(const AnfNodePtr &anf_node, size_t index, const std::string &def_format); 42 static RangePair GetOutputDynamicRange(const AnfNodePtr &anf_node, size_t index, const std::string &def_format); 43 }; 44 } // namespace tbe 45 } // namespace kernel 46 } // namespace mindspore 47 48 #endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_TBE_TBE_DYNAMINC_SHAPE_UTIL_H 49