Header Files and Library Files
Environment Requirements
- Before calling operators using aclnn APIs, install the CANN Toolkit and ops package first. For details, see CANN Software Installation.
- Before calling operators using PyTorch APIs, install the CANN Toolkit, ops, and TorchNPU packages first (ensure that the TorchNPU package matches the Toolkit package in version). For details, see CANN Software Installation and TorchNPU Software Installation.
- Before calling Ascend IR operators in GE graph mode, install the CANN Toolkit and ops packages first. For details, see CANN Software Installation.
Dependency Files
- When calling aclnn APIs, you need to include the dependent header files and library files. By default, the header files are stored in the ${INSTALL_DIR}/include/ directory, and the library files are stored in the ${INSTALL_DIR}/lib64/ directory. For details about the paths, see Table 1.
- To call torch_extension APIs, import the following modules. The cann_ops_transformer module is defined in the ${INSTALL_DIR}/python/site-packages/cann_ops_transformer directory.
import torch import torch_npu import cann_ops_transformer
- When calling Ascend IR operators, the header file path is ${INSTALL_DIR}/opp/built-in/op_graph/inc/ops_proto_*.h and the library file path is ${INSTALL_DIR}/opp/built-in/op_graph/lib/libopgraph_*.so. For details, see Table 1.
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.
API Category |
Function |
Naming Style |
Dependency Header File |
Dependency Library File |
|---|---|---|---|---|
Common meta APIs for calling aclnn APIs, such as those for creating aclTensor, aclScalar, and aclIntArray |
UpperCamelCase, with acl as the prefix |
|
libnnopbase.so |
|
A set of C APIs for calling CANN operators, including Math, NN, CV, and Transformer operators. |
The prefix is aclnn. Generally, an API is two-phase. Xxx indicates the operator name (UpperCamelCase style).
|
|
|
|
For common large model operators that are not native to PyTorch, a set of APIs compatible with the PyTorch style is provided for calling CANN operators. |
${op_name}, which must be in lowercase with underscores (_). Call method: cann_ops_transformer.${op_name} |
Defined in the ${INSTALL_DIR}/python/site-packages/cann_ops_transformer directory |
||
CANN operator specifications used in GE graph mode, including functions, data types, and formats |
UpperCamelCase (XxxYyyZzz), for example, AsinGrad |
|
|
|
Common framework capability APIs on which the aclnn API development depends. |
UpperCamelCase |
aclnn/opdev/*.h. For details about the file names, see nnopbase API List. |
- |
|
Level 0 APIs on which the aclnn API development depends |
UpperCamelCase |
aclnn_kernels/*.h. For details about the file names, see nnopbase API List. |
libopapi_math.so |
|
Common capabilities required for operator development and calls, such as log obtaining and tiling/InferShape APIs. |
UpperCamelCase |
For details about the file names, see op_common APIs. |
- |
|
- When calling the operator APIs (aclnn), pay attention to the following dependent header files:
- After the general header file of each type is referenced, the header file of a single API does not need to be referenced.
- Starting from CANN 7.0.0, the operator header file path aclnnop/level2/aclnn_*.h is deprecated. Use aclnnop/aclnn_*.h instead.
- When calling the operator APIs (aclnn), pay attention to the following dependent library files:
- Starting from CANN 9.0.0, libopapi.so is deprecated. Use libopapi_*.so to improve operator build efficiency.
- 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.