Case Introduction and Running

Overview

This case consists of five parts: aclnn operator, ATB operator, model, infrastructure, and main function.

  • aclnn operator: Integrates to the ATB.
  • ATB operator: Builds an ATB graph operator.
  • Model: Uses the ATB operator and those generated by the aclnn operators to build a larger graph operator, which includes the call logic related to the ATB graph operator.
  • Infrastructure: Includes logs and memory pools, which are used to locate faults and accelerate graphics memory allocation.
  • Main function: Serves as a program entry and implements the multi-thread functionality.

Directory Structure

atb-aclnn sample project
|-- CMakeLists.txt
|-- README.md
|-- aclnn  -- aclnn operator
|   |-- aclnn_gelu_operation.cpp
|   |-- aclnn_gelu_operation.h  -- Implementation of the aclnn Gelu operator integration to the ATB
|   |-- aclnn_operation_base.cpp
|   |-- aclnn_operation_base.h  -- Base class of the aclnn operator integration to the ATB
|-- atb -- atb operator
|   |-- atb_graph_op.cpp
|   |-- atb_graph_op.h
|-- build.sh  -- Project build script
|-- main.cpp  -- Main function, that is, entry point function
|-- memory  -- Memory pool in the infrastructure
|   |-- memory_env.h
|   |-- memory_utils.cpp
|   |-- memory_utils.h
|   |-- memorypool.cpp
|   |-- memorypool.h
|-- model  -- Model, including the ATB graph and the call logic of the ATB graph operator
|   |-- model.cpp
|   |-- model.h
|-- utils -- Logs and other parts in the infrastructure
|    |-- log.cpp
|    |-- log.h
|    |-- utils.cpp
|    |-- utils.h

Case Execution

  1. Go to the atb-aclnn directory.
    cd  ${Case directory}/atb-aclnn
  2. Set the CANN environment variable, for example, source /usr/local/Ascend/ascend-toolkit/set_env.sh.
    source ${Toolkit installation directory}/set_env.sh
  3. Set the ATB environment variable, for example, source /usr/local/Ascend/nnal/atb/set_env.sh.
    source ${nnal installation directory}/atb/set_env.sh
  4. Execute the build.sh script.
    bash ./build.sh
  5. Execute the case.
    ./build/test_model
  • In the current case, threads are created based on the number of devices on the physical machine. If you need to adjust the number of threads, change the number of threads created in main.cpp.
  • Ensure that the ABI version of the demo is the same as that of the ATB.
    • Run the following command to check the ABI version of the ATB:
      env | grep ATB_HOME_PATH
    • To check the ABI version of the demo, run the following command in CMakeList to check whether the ABI version is 0 or 1. OFF indicates 0, and ON indicates 1.
      option(USE_CXX11_ABI "USE_CXX11_ABI" OFF)