1# Copyright 2022 Huawei Technologies Co., Ltd 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================ 15"""Rewrite module api: NodeType.""" 16from enum import Enum 17 18 19class NodeType(Enum): 20 """ 21 `NodeType` represents type of `Node`. 22 23 - Unknown: Not inited NodeType. 24 - CallCell: `CallCell` node represents invoking cell-op in forward method. 25 - CallPrimitive: `CallPrimitive` node represents invoking primitive-op in forward method. 26 - CallFunction: `CallFunction` node represents invoking a function in forward method. 27 - CallMethod: `CallMethod` node represents invoking of method in forward method which can not be mapped to 28 cell-op or primitive-op in MindSpore. 29 - Python: `Python` node holds unsupported-ast-node or unnecessary-to-parse-ast-node. 30 - Input: `Input` node represents input of `SymbolTree` corresponding to arguments of forward method. 31 - Output: `Output` node represents output of SymbolTree corresponding to return statement of forward method. 32 - Tree: `Tree` node represents sub-network invoking in forward method. 33 - CellContainer: `CellContainer` node represents invoking method :class:`mindspore.nn.SequentialCell` in 34 forward method. 35 - MathOps: `MathOps` node represents a mathematical operation, such as adding or comparing in forward method. 36 - ControlFlow: `ControlFlow` node represents a control flow statement, such as if statement. 37 38 """ 39 Unknown = 0 40 # Compute node type 41 CallCell = 1 42 CallPrimitive = 2 43 CallModule = 3 44 CallFunction = 4 45 CallMethod = 5 46 # Other node type 47 Python = 6 48 Input = 7 49 Output = 8 50 Tree = 9 51 CellContainer = 10 52 MathOps = 11 53 ControlFlow = 12 54