Lowering Overview
The lowering module is responsible for operator fusion based on loop axis fusion in a GE graph. The input of this module is the GE graph after symbolic inference, and the output is the GE graph that contains the fused operator. Fused operators are expressed using AscBackend operators. An AscBackend operator has an AscGraph attribute, which is used to express the computation logic. After the lowering phase, modules such as CanFuse, Schedule, and Codegen further complete the secondary fusion between AscBackend nodes, code generation, and build.
The lowering module consists of two layers: operator lowering and graph lowering.
- Operator lowering uses a low-level IR to express the scalars of the operator computation logic. Scalar expression describes how each output value is computed. Operators that can be used for scalar expression are classified into the following types:
- Pointwise class
In this class, the output shape is the result of multiple broadcasted inputs. Each output value is computed based on the input value at the corresponding position. Common GE IRs are of this operator class, such as Add, Mul, Exp, and Abs.
- Reduction class
Each output element is obtained by performing the reduce computation on multiple input elements. For example, ReduceSum and ReduceMax are of this class.
- View class
Each output element is equal to an element at a specific position in the input, and no computation is performed in the middle. The number of output elements may be different from the number of input elements. For example, the broadcast operator may map multiple output elements to one input element. Currently, the view class supported by lowering includes Broadcast.
- Pointwise class
- Graph lowering calls the lowering implementation of operators on the graph in sequence and completes operator fusion based on scalar expressions. Graph lowering is used for fusion in the following scenarios:
- Pointwise + Pointwise
- Pointwise + View
- Pointwise -> Reduction