Operator Implementation Flow
During TBE operator development in DSL mode, the operator scheduling depends on the auto schedule mechanism and cannot be directly controlled at the operator development layer. Therefore, you only need to focus on the implementation of the operator compute process. You can improve the operator accuracy and performance by various methods.
Figure 6-3 shows the workflow of implementing a TBE operator in DSL mode.
- Operator implementation analysis: Before developing the operator code, analyze the mathematical expression, input, output, and compute logic implementation of the operator, and specify the TBE DSL API to be called.
If a third-party open-source network is used and some operators are not supported by the Ascend AI processor, you can analyze the operator implementation on the third-party open-source website to obtain the mathematical expression of the operator.
If the TBE DSL APIs cannot meet the operator implementation requirements, use the TIK development mode.
For details about operator analysis, see Operator Analysis.
- Compute implementation: Implements the operator compute logic, including importing Python modules, declaring APIs, initializing parameters and verifying arguments, and describing the compute process.
The operator implementation file contains two modules: operator API function and compute function. The operator API function is used to initialize the input tensor and verify parameters. The compute function is used to describe the operator compute process and is called in the operator API function.
Compute implementation is of the major concern in TBE development using DSL. How to implement the functionality of an operator and how to further optimize the accuracy and performance must be fully considered in this phase.
- Operator scheduling: Call the generic.auto_schedule() API to automatically schedule the operator.
- Operator building: Call the te.lang.cce.cce_build_code API to build the operator and generate an .o binary file and a .json description file of the operator.