Introduction
Overview
The Compute Architecture for Neural Networks (CANN) operator library provides a series of high-performance operators, with enriched, in-depth optimizations and hardware-affinity features, laying a foundation for accelerating network computing on AI processors.
Figure 1 shows the position of the operator library in the CANN architecture. The operator library consists of the following sub-libraries:
- Math library: Mathematical calculation operator library, which provides operators like Add and Abs.
- NN library: Neural Network, that is, neural network operator library, which provides operators like Matmul.
- CV library: Computer Vision, that is, computer vision operator library, which provides operators like GridSample.
- Transformer library: Large model computing operator library, which provides operators like FlashAttention, MC2 (merged compute and communication), and mixture of experts (MoE).
- Opbase library: Basic framework layer on which each operator library depends. It provides basic scheduling capabilities (such as aclTensor creation/release and workspace reuse) and common dependency capabilities.
- The operators provided by this operator library are built-in operators. For details about how to customize operators, see Ascend C Operator Development Guide.
- The source code of certain operators in this operator library has been opened in the Gitcode CANN open-source project. Click Link to learn more about the component project of the operator library.
To facilitate the calling of the preceding operators, a set of C-based APIs (such as aclnn APIs) are provided to execute operators, without the need to provide additional Intermediate Representation (IR) definitions. This calling mode is called single-operator API execution. Figure 2 shows the calling process. For details, see "Single-Operator Call Sequence".
This document describes operator specifications and operator APIs, and details the operator specifications defined by IR in different AI deep learning frameworks (such as TensorFlow and Caffe), helping developers build required network models.
Instructions
- You are advised not to use scenarios beyond the operator APIs or operator specifications (such as product models, data types, data formats, and data dimensions). This is because the calling effect is not guaranteed in the current version.
- Operator package description: Before calling an operator, ensure that software packages for the CANN Toolkit and OPS operator have been installed. For details, see .
- Operator troubleshooting: During operator calling, various exceptions may occur. For details about how to handle the exceptions, see Troubleshooting Cases > Operator Execution Issues. The document describes typical and frequently occurred operator executions for you to locate and resolve issues.
- Ascend virtual instance: The current fusion operator does not support this function. A fusion operator, such as Flash Attention or MC2, is a combination of multiple independent basic operators (such as vector and matrix cube). It has equivalent functions as multiple basic operators and delivers better performance.
Usage Guide
Before reading this document, you are advised to get yourself familiarized with Table 1, which helps you quickly understand the application scenarios, operator classification, and operator APIs of the operator library.
Header file and library file descriptions: To call an operator API, include the dependent files. Generally, header files are stored in the ${INSTALL_DIR}/include/ directory by default, and library files are stored in the ${INSTALL_DIR}/lib64/ directory by default. Replace ${INSTALL_DIR} with the CANN component directory. For example, if the installation is performed by the root user, the default file storage path is /usr/local/Ascend/cann.
|
Use Case |
Guidance |
Description |
Dependent Header File or Library File |
|---|---|---|---|
|
1. Basic knowledge that users need to learn before using the operator library |
This section describes the basic concepts, terms, and key technologies related to the operator library, helping you better understand the operator library. |
- |
|
|
2. Common APIs on which the operator library depends during API calling |
Declares common meta APIs that the operator APIs depend on, such as the APIs for creating aclTensor, aclScalar, and aclIntArray. |
|
|
|
3. Types of operator APIs (aclnn) |
Mathematical calculation operator library, which provides operators like Add and Abs. These APIs are prefixed with aclnnXxx. |
NOTE:
|
|
|
Neural network (NN) operator library, which provides operators like Matmul. These APIs are prefixed with aclnnXxx. Currently, this type of operators accounts for the largest proportion in the operator library. |
|||
|
Computer vision (CV) operator library, which provides operators like GridSample. These APIs are prefixed with aclnnXxx. |
|||
|
Large model computing operator library, which provides operators like FlashAttention, MC2 (merged compute and communication), and mixture of experts (MoE). These APIs are prefixed with aclnnXxx. |
|||
|
4. Media data processing APIs (acldvpp) |
Digital vision preprocessing operators, which provide preprocessing APIs for high-performance video/image encoding and decoding, as well as image cropping and resizing. These APIs are prefixed with acldvppXxx. |
|
|
|
5. Operator information defined based on the Ascend IR in the operator library |
Operator information defined based on the Ascend IR. |
- |
|
|
6. Operator information defined based on the native IR of the AI framework |
Operator information defined based on the native IR of mainstream AI frameworks (such as TensorFlow and Caffe). |
- |
|
|
7. Operator library APIs |
Framework APIs on which the aclnn API for developing built-in operators depends. For details, see aclnn Development APIs. |
- |

