Introduction

Overview

  • The operators provided here are built-in CANN operators available for direct calls. For details about how to develop custom operators, see Ascend C Operator Development.
  • You can find the operator source code in CANN, where you have access to the wider community ecosystem or contribute operators.

CANN provides a diverse array of hardware-adaptive operators, directly applicable to AI services and laying a foundation for accelerating network computing on AI processors.

Figure 1 shows where the operator libraries sit in the CANN architecture:

  • Math: numerical calculation operators, like Add and Abs, for use cases such as tensor shape transformation, basic mathematical operations, and random number generation.
  • NN: neural network operators, common in deep learning models, for use cases such as convolution, matrix multiplication, activation functions, and normalization.
  • CV: computer vision operators, such as GridSample, for image processing and object detection.
  • Transformer: foundation model computation operators in major classes such as Attention, LayerNorm, and merged compute and communication (MC2).
  • Opbase: basic framework library on which all other operator libraries depend. It realizes basic scheduling (such as aclTensor creation/release and workspace reuse) and common dependencies.
Figure 1 Operator library architecture

Each operator has two parts: device-side kernel implementation and host-side calls (via a single-operator API, or host API, in C). Figure 2 shows the API call flow. For details, see Calling Built-in CANN Operators in Application Development (C&C++).

Figure 2 Operator API call flow

This document describes the intermediate representation (IR) specifications for operators and operator APIs, while also detailing the operator specifications defined by IR in different AI deep learning frameworks (such as TensorFlow and Caffe), helping you build required network models.

Instructions for Use

  • CANN does not guarantee operator performance in use cases beyond the operator API references or operator specifications (such as product models, data types, data formats, and data dimensions).
  • Operator packages: Before calling an operator, ensure that the CANN Toolkit and ops packages have been installed. For details, see CANN Software Installation.
  • Ascend virtual instance: Not supported for current fused operators. A fused operator, such as Flash Attention or MC2, is a combination of multiple independent basic operators (such as vector and cube). It delivers the same functions as those basic operators but with better performance.

Instructions for Use

Start with Table 1 to understand the applied use cases, operator classification, and header files of the operator libraries.

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, and library files are in ${INSTALL_DIR}/lib64/. 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.

Table 1 Wizards

Item

Guide

Description

Dependent Header File or Library File

1. Operator library basics to learn

Basic Concepts

Basic concepts, terminology, key technologies, etc.

-

2. Common APIs on which the operator library depends during API calling

Basic APIs

Common meta APIs such as those for creating aclTensor, aclScalar, and aclIntArray

  • Header files: aclnn/acl_meta.h and aclnn/aclnn_base.h (containing only aclnnInit and aclnnFinalize)
  • Library file: libnnopbase.so

3. Types of operator APIs (aclnn)

Math APIs

Mathematical calculation operators, such as Add and Abs

  • Header file: After the general header file of each type is referenced, the header file of a single API does not need to be referenced.
    • (Recommended) General header files on which each type of APIs depends: aclnnop/aclnn_ops_math.h, aclnnop/aclnn_ops_nn.h, aclnnop/aclnn_ops_cv.h, and aclnnop/aclnn_ops_transformer.h
    • Header file on which each API depends: aclnnop/aclnn_*.h (* indicates the operator name.)
  • Dynamic library:
    • General library file on which aclnn APIs depend: libopapi.so (deprecated)
    • Library files on which each type of APIs depends: libopapi_math.so, libopapi_nn.so, libopapi_cv.so, and libopapi_transformer.so
NOTE:
  • Starting from CANN 8.5.0, the static libraries (*.a) and dynamic libraries (*.so) of libaclnn_ops_infer, libaclnn_ops_train, libaclnn_math, and libaclnn_rand are deprecated. Use libopapi_*.so instead.
  • Starting from CANN 9.0.0, the general library file libopapi.so is deprecated. Use libopapi_*.so to improve operator build efficiency.
  • Starting from CANN 7.0.0, the operator header file path aclnnop/level2/aclnn_*.h is deprecated. Use aclnnop/aclnn_*.h instead.

NN APIs

Neural network operators such as Matmul.

Operators of this type account for the largest proportion in the operator library.

CV APIs

Computer vision operators such as GridSample.

Transformer APIs

Large model computation operators for use cases like FlashAttention, MC2 (merged compute and communication), and Mixture of Experts (MoE).

5. Operator information defined based on the Ascend IR in the operator library

Ascend IR Operator Specifications

Operator information defined based on the Ascend IR.

-

6. Operator information defined based on the native IR of the AI framework

Operators Specifications of the AI Framework

Operator information defined based on the native IR of mainstream AI frameworks (such as TensorFlow and Caffe).

-

7. Operator library resources

Appendix

  • Framework APIs and L0 APIs on which the aclnn APIs for built-in operators depend
  • Operator performance tuning guides
  • Operator-related FAQ

-