Header Files and Library Files

Environment Requirements

Dependency Files

Different types of APIs in the operator library are defined in different paths:
  • 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.

Table 1 Dependency files

API Category

Function

Naming Style

Dependency Header File

Dependency Library File

Common APIs

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

UpperCamelCase, with acl as the prefix

  • aclnn/acl_meta.h
  • aclnn/aclnn_base.h (containing only aclnnInit and aclnnFinalize)

libnnopbase.so

Operator APIs (aclnn)

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).

  • Phase 1: aclnnXxxGetWorkspaceSize
  • Phase 2: aclnnXxx
  • (Recommended) 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、aclnnop/aclnn_ops_ras.h
  • Header file on which each API depends: aclnnop/aclnn_*.h (* indicates the operator name.)
  • 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.solibopapi_ras.so

Operator APIs (torch_extension)

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

Ascend IR operator specifications

CANN operator specifications used in GE graph mode, including functions, data types, and formats

UpperCamelCase (XxxYyyZzz), for example, AsinGrad

  • ops_proto_math.h
  • ops_proto_nn.h
  • ops_proto_cv.h
  • ops_proto_transformer.h
  • ops_proto_legacy.h
  • libopgraph_math.so
  • libopgraph_nn.so
  • libopgraph_cv.so
  • libopgraph_transformer.so
  • libopgraph_legacy.so

Appendix > nnopbase APIs > Framework Capability APIs

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.

-

Appendix > nnopbase APIs > Basic Tensor Operation APIs

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

Appendix > op_common APIs

Common capabilities required for operator development and calls, such as log obtaining and tiling/InferShape APIs.

UpperCamelCase

  • op_common/log/*.h
  • op_common/op_host/*.h
  • op_common/op_graph/*.h
  • op_common/op_kernel/*.h

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.