### Configure NNAL Environment Source: https://github.com/cann/ascend-transformer-boost/blob/master/ops_customize/README.md Sources the environment setup script for NNAL. Assumes installation path is ${HOME}/Ascend. ```shell source ${HOME}/Ascend/nnal/atb/set_env.sh ``` -------------------------------- ### mlapa_demo.cpp Example Configuration Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/op_demo/multi_latent_attention/README.md Illustrates the parameter settings for the mlapa_demo.cpp example. Note the qkScale value represents the headSize before MLA's rope projection. ```cpp #define headNum 128 #define qkScale (1.0/sqrt(576)) #define kvHeadNum 1 #define maskType UNDEFINED #define calcType CALC_TYPE_UNDEFINED #define cacheMode INT8_NZCACHE ``` -------------------------------- ### mlapa_ds_demo.cpp Example Configuration Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/op_demo/multi_latent_attention/README.md Shows the parameter configuration for the mlapa_ds_demo.cpp example. The qkScale value is a specific floating-point number. ```cpp #define headNum 128 #define qkScale 0.1352667747812271 #define kvHeadNum 1 #define maskType UNDEFINED #define calcType CALC_TYPE_UNDEFINED #define cacheMode KROPE_CTKV ``` -------------------------------- ### Compiling Operation Example Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/日志与调试.md Navigate to the specific operation's demo directory and execute the build script to compile the operation example. This is part of running ATB acceleration library op_demo calls. ```bash bash build.sh ``` -------------------------------- ### Install msprobe and atb_probe Module (8.5.0+) Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/日志与调试.md For CANN 8.5.0 and later, clone the msprobe repository, install necessary packages, and build the atb_probe module. This prepares the environment for data dumping. ```bash git clone https://gitcode.com/Ascend/msprobe.git cd msprobe pip install setuptools wheel python3 setup.py bdist_wheel --include-mod=atb_probe --no-check cd ./dist pip install ./mindstudio_probe*.whl ``` -------------------------------- ### Install NPU Driver with Debug Parameter Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/日志与调试.md Install the NPU driver using the --debug parameter. Refer to the official documentation for specific installation instructions. ```bash ./Ascend-hdk--npu-driver__linux-.run --debug ``` -------------------------------- ### Install CANN Toolkit Source: https://github.com/cann/ascend-transformer-boost/blob/master/README.md Execute the CANN toolkit installer script to perform the installation. Ensure the toolkit version matches the ATB version. ```shell ./Ascend-cann-toolkit_${VERSION}_linux-$(arch).run --install ``` -------------------------------- ### Execute the Example Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/atb_aclnn/README.md Run the compiled test_model executable to perform the integrated ACLNN and ATB operation test. ```sh ./build/test_model ``` -------------------------------- ### Install NPU Driver with Full Debugging Support Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/日志与调试.md Install the NPU driver with the --full parameter and enable the debug channel by writing 1 to /proc/debug_switch. This method is recommended for versions after CANN 8.1.RC1 with drivers after 25.0.RC1. ```bash ./Ascend-hdk--npu-driver__linux-.run --full ``` -------------------------------- ### Navigate to atb-aclnn Directory Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/atb_aclnn/README.md Change the current directory to the atb-aclnn directory to begin the setup process. ```sh cd ${用例所在目录}/atb-aclnn ``` -------------------------------- ### Install torch_atb WHL Package Source: https://github.com/cann/ascend-transformer-boost/blob/master/README.md Install the torch_atb Python package from a generated WHL file. This is part of the ATB Python API setup. ```sh pip3 install torch_atb-{version}-py3-none-any.whl ``` -------------------------------- ### Set up ATB Environment Variables Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/atb_aclnn/README.md Source the set_env.sh script from the ATB installation directory to configure ATB-specific environment variables. Replace ${nnal安装目录} with the actual installation path. ```sh source ${nnal安装目录}/atb/set_env.sh ``` -------------------------------- ### Install CANN Toolkit Source: https://github.com/cann/ascend-transformer-boost/blob/master/ops_customize/README.md Installs the CANN toolkit. Ensure you replace $(version) and $(arch) with your specific version and architecture. ```shell chmod +x Ascend-cann-toolkit_$(version)_linux-$(arch).run ./Ascend-cann-toolkit_$(version)_linux-$(arch).run --install ``` -------------------------------- ### Install Ascend-cann-nnal run package Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/常见问题与回答.md Install the Ascend-cann-nnal run package. This requires the CANN environment. You can check package integrity and install it using the provided commands. ```shell chmod +x 软件包名.run ``` ```shell ./软件包名.run --check ``` ```shell ./软件包名.run --install ``` -------------------------------- ### Install NNAL Source: https://github.com/cann/ascend-transformer-boost/blob/master/ops_customize/README.md Installs the NNAL component. Replace $(version) and $(arch) with your specific version and architecture. ```shell chmod +x Ascend-cann-nnal_$(version)_linux-$(arch).run ./Ascend-cann-nnal_$(version)_linux-$(arch).run --install ``` -------------------------------- ### Install Python Dependencies for CANN Source: https://github.com/cann/ascend-transformer-boost/blob/master/README.md Install necessary Python third-party libraries for CANN runtime. Use the --user flag unless installing as root. ```shell pip3 install attrs cython 'numpy>=1.19.2,<=1.24.0' decorator sympy cffi pyyaml pathlib2 psutil protobuf==3.20.0 scipy requests absl-py --user ``` -------------------------------- ### Install CANN Operator Package Source: https://github.com/cann/ascend-transformer-boost/blob/master/README.md Execute the CANN operator package installer. Ensure the corresponding Toolkit version is installed and environment variables are configured. ```shell ./Ascend-cann-${chip_type}-ops_${VERSION}_linux-$(arch).run --install ``` -------------------------------- ### Environment Variable Setup Script Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/编译与构建.md After installation, the `scripts/set_env.sh` script can be used to set process-level environment variables for the ATB library. These variables are automatically unset when the user process ends. ```shell source scripts/set_env.sh ``` -------------------------------- ### Prepare Environment for Integrated Compilation Source: https://github.com/cann/ascend-transformer-boost/blob/master/ops_customize/README.md Sets up environment variables required for compiling the ATB acceleration library with custom operators. Assumes installation path is ${HOME}/Ascend. ```shell source ${HOME}/Ascend/ascend-toolkit/set_env.sh source ${HOME}/Ascend/nnal/atb/set_env.sh export ATB_BUILD_DEPENDENCY_PATH=${ATB_HOME_PATH} ``` -------------------------------- ### Compile and Run rope_qwen_demo_0.cpp Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/op_demo/rope/README.md To compile and run rope_qwen_demo_0.cpp, replace 'rope_demo.cpp' with the new filename in the build script. This example is specific to certain Atlas hardware series. ```sh # Replace rope_demo.cpp with rope_qwen_demo_0.cpp in build script ``` -------------------------------- ### Compile and Run rope_qwen_demo_1.cpp Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/op_demo/rope/README.md To compile and run rope_qwen_demo_1.cpp, replace 'rope_demo.cpp' with the new filename in the build script. This example is specific to certain Atlas hardware series. ```sh # Replace rope_demo.cpp with rope_qwen_demo_1.cpp in build script ``` -------------------------------- ### Compile and Run rope_qwen_demo_2.cpp Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/op_demo/rope/README.md To compile and run rope_qwen_demo_2.cpp, replace 'rope_demo.cpp' with the new filename in the build script. This example is specific to certain Atlas hardware series. ```sh # Replace rope_demo.cpp with rope_qwen_demo_2.cpp in build script ``` -------------------------------- ### Project Directory Setup Source: https://github.com/cann/ascend-transformer-boost/blob/master/src/kernels/CMakeLists.txt Sets key project directories, including the project root and third-party directory. These variables are used to locate project-specific files and dependencies. ```cmake set(OPS_PROJECT_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}") set(OPS_THIRD_PARTY_DIR "${PROJECT_SOURCE_DIR}/3rdparty") set(MKI_PACKAGE_DIR "${OPS_THIRD_PARTY_DIR}/mki") set(MKI_SCRIPT_DIR "${MKI_PACKAGE_DIR}/scripts") ``` -------------------------------- ### Set up CANN Environment Variables Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/atb_aclnn/README.md Source the set_env.sh script to configure the necessary environment variables for the CANN toolkit. Replace ${toolkit安装目录} with the actual installation path. ```sh source ${toolkit安装目录}/set_env.sh ``` -------------------------------- ### Make CANN Toolkit Executable Source: https://github.com/cann/ascend-transformer-boost/blob/master/README.md Before running the CANN toolkit installer, make it executable using chmod. Replace ${VERSION} with the specific CANN version. ```shell chmod +x Ascend-cann-toolkit_${VERSION}_linux-$(arch).run # 其中${VERSION}表示对应的CANN版本,如9.1.0 ``` -------------------------------- ### Registering Kernel Functions with add_kernel Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/开发指南.md This example demonstrates the usage of the `add_kernel` command in CMakeLists.txt to register kernel functions with the Ascend runtime system. It specifies the operator name, SOC version, operator type, kernel file path, and kernel class name. ```cmake add_kernel(算子名称 [soc_version] 算子类型 文件路径 kernel类名称) ``` -------------------------------- ### Set ATB_BUILD_DEPENDENCY_PATH for nnal Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/常见问题与回答.md Set the ATB_BUILD_DEPENDENCY_PATH environment variable to point to the nnal installation. This is required to resolve the 'libtbe_adapter.so does not exist' error. Ensure nnal package versions match toolkit and kernels. ```shell export ATB_BUILD_DEPENDENCY_PATH={nnal install path}/nnal/atb/latest/atb/cxx_abi_{cxx_abi_version} ``` -------------------------------- ### Python ATB Operator Call Example Source: https://github.com/cann/ascend-transformer-boost/blob/master/README.md Example demonstrating how to call an ATB operator using the Python API. Ensure PyTorch and torch_npu are installed and torch_atb is imported. ```python import torch import torch_atb#导入ATB Python API模块 #创建参数对象 linear_param = torch_atb.LinearParam() linear_param.has_bias = False #创建算子对象 op = torch_atb.Operation(linear_param) #准备输入数据 x = torch.randn(2, 3, dtype=torch.float16).npu() y = torch.randn(2, 3, dtype=torch.float16).npu() #使用forward方法完成操作,并获取输出 outputs = op.forward([x, y]) torch.npu.synchronize() ``` -------------------------------- ### Build Demo Script Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/op_demo/activation/README.md Execute this shell script to build the C++ demo. Ensure environment variables are set correctly before running. ```shell bash build.sh ``` -------------------------------- ### Run Quantization Demo Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/op_demo/linear_parallel/README.md Execute the compiled demo for the quantization scenario. ```sh ./linear_parallel_demo ``` -------------------------------- ### Build the Project Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/atb_aclnn/README.md Execute the build.sh script to compile the project and generate the necessary executable files. ```sh bash ./build.sh ``` -------------------------------- ### Build Script for Addcustom Demo Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/从开发一个简单算子出发.md Compiles and executes the addcustom_demo.cpp file. It determines the correct C++ ABI flag and links against ATB and Ascend CL libraries. ```shell cxx_abi=$(python3 -c ' try: import torch print("1" if torch.compiled_with_cxx11_abi() else "0") except ImportError: print("1") ') echo "Using cxx_abi=$cxx_abi" g++ -D_GLIBCXX_USE_CXX11_ABI=$cxx_abi -I "${ATB_HOME_PATH}/include" -I "${ASCEND_HOME_PATH}/include" -L "${ATB_HOME_PATH}/lib" -L "${ASCEND_HOME_PATH}/lib64" \ addcustom_demo.cpp ../demo_util.h -l atb -l ascendcl -o addcustom_demo ./addcustom_demo ``` -------------------------------- ### Determine CXX ABI Version Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/常见问题与回答.md Determine the correct CXX ABI version (0 or 1) to use for the ATB_BUILD_DEPENDENCY_PATH. This is based on your PyTorch installation. If PyTorch is not installed, cxx_abi_1 is used by default. ```python import torch print(1 if torch.compiled_with_cxx11_abi() else 0) ``` -------------------------------- ### Full Compilation Process for ATB Test Framework Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/测试框架指南.md This snippet outlines the complete steps to compile the ATB test framework, including setting up CANN environment variables, building the framework, and setting up the ATB runtime environment. ```shell cd ascend-transformer-boost # 1. Set CANN environment variables (based on actual installation path) source /usr/local/Ascend/ascend-toolkit/set_env.sh # 2. Compile the test framework (including ATB core library + C++ test framework + Python test tools) bash scripts/build.sh testframework # 3. Set up ATB runtime environment source output/atb/set_env.sh ``` -------------------------------- ### CSV Test Case Example: Parameter Validation Error Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/测试框架指南.md A negative test case example demonstrating a parameter validation error. It specifies an expected error code 'C:ERROR_INVALID_PARAM' for the 'LinearOperation' operator. ```default 146|MatmulCError|LinearOperation|{"hasBias":false,"enAccum":true}|0||||0|||||||||||Ascend310P|C:ERROR_INVALID_PARAM ``` -------------------------------- ### CSV Test Case Example: Matrix Multiplication with Transpose Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/测试框架指南.md A positive test case example for matrix multiplication with transpose parameters enabled. It includes specific operator parameters like 'transposeA' and 'transposeB'. ```default 23|MatmulTransposeA|LinearOperation|{"transposeA":true,"transposeB":false}|3|float16;float16;float16|nd;nd;nd|3,2;3,4;1,4|1|float16|nd|2,4|customize;customize;customize|-2,2;-2,2;-2,2||||||Ascend910B,Ascend310P|NO_ERROR ``` -------------------------------- ### Configure and Load ATB Probe for Data Collection (8.5.0+) Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/日志与调试.md Create a config.json file to specify dump parameters. Then, load the atb_probe module using the provided script, pointing to the output directory and configuration file. This prepares for data collection. ```json { "task": "tensor", "dump_enable": true, "exec_range": "all", "ids": "0", "op_name": "", "save_child": false, "device": "", "filter_level": 1 } ``` ```bash MSPROBE_HOME_PATH=/usr/local/lib/python3.11/site-packages source $MSPROBE_HOME_PATH/msprobe/scripts/atb/load_atb_probe.sh --output=$PWD --config=$PWD/config.json # 以ATB加速库中的demo为例: cd ${home_path}/example/op_demo/mla_preprocess && bash build.sh ``` -------------------------------- ### CSV Test Case Example: Basic Matrix Multiplication Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/测试框架指南.md A positive test case example for basic matrix multiplication using the CSV format. It specifies input tensor details, operator parameters, and expected output format. ```default 1|MatmulElewiseAdd|LinearOperation|{}|3|float16;float16;float16|nd;nd;nd|2,3;4,3;4|1|float16|nd|2,4|customize;customize;customize|-2,2;-2,2;-2,2||||||Ascend910B,Ascend310P|NO_ERROR ``` -------------------------------- ### Generate Build System with CXX11 ABI Enabled Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/multiStream/README.md Create a build directory and generate the build system using CMake, enabling the C++11 ABI. ```sh mkdir build && cd build cmake .. -DUSE_CXX11_ABI=ON ``` -------------------------------- ### Compile and Run Project Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/multiStream/README.md Compile the project using CMake and then run the executable. ```sh cmake --build . ./multiStreamDemo ``` -------------------------------- ### Configure Executable for Inter Graph Synchronization Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/multiStream/README.md Modify the CMakeLists.txt file to specify the executable for the inter-graph synchronization example. ```sh add_executable(multiStreamDemo multiStream_multiGraph_demo.cpp) ``` -------------------------------- ### Build ATB Library Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/编译与构建.md Navigate to the ATB root directory and execute the build script. This process involves fetching and compiling operator libraries (MKI) and then compiling the ATB library itself. ```shell cd ascend-transformer-boost bash scripts/build.sh ``` -------------------------------- ### Configure Executable for Single Graph Multi-Stream Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/multiStream/README.md Modify the CMakeLists.txt file to specify the executable for the intra-graph multi-stream parallel example. ```sh add_executable(multiStreamDemo multiStream_singleGraph_demo.cpp) ``` -------------------------------- ### SelfAttentionParam Configuration for Encoder Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/doxygen/atb_document.txt Illustrates the configuration of SelfAttentionParam for the PA_ENCODER calculation type. This setup is used for the full pass stage. ```cpp SelfAttentionParam.calcType = PA_ENCODER; ``` -------------------------------- ### Transpose Operation Example Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/doxygen/atb_document.txt Demonstrates how to use the TransposeParam to permute the dimensions of a tensor. Ensure the input and output tensors are correctly defined. ```cpp intensor0: tensor([[0, 1], [2, 3]]) atb::infer::TransposeParam transposeParam; transposeParam.perm ={1, 0}; out_tensor: tensor([[0, 2], [1, 3]]) ``` -------------------------------- ### Compile ATB Acceleration Library Source: https://github.com/cann/ascend-transformer-boost/blob/master/README.md Navigate to the ATB directory and run the build script to compile the acceleration library. Source the environment script after compilation. ```sh cd ascend-transformer-boost bash scripts/build.sh source output/atb/set_env.sh ``` -------------------------------- ### Get Tiling Data for FastSoftMax Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/开发指南.md Defines a function to retrieve `FastSoftMaxTilingData` from a given `tiling` address. This is used in ATB operator development. ```C++ inline __aicore__ FastSoftMaxTilingData GetTilingData(const GM_ADDR tiling) { auto tilingDataPointer = reinterpret_cast(tiling); FastSoftMaxTilingData tilingData; tilingData.batchSize = tilingDataPointer->batchSize; tilingData.headNum = tilingDataPointer->headNum; return tilingData; } ``` -------------------------------- ### Addcustom Demo C++ Code Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/从开发一个简单算子出发.md Demonstrates how to create and call the AddcustomOperation. This code prepares input tensors, sets up the operation, executes it, and cleans up resources. ```c++ #include "../demo_util.h" const int32_t DEVICE_ID = 0; const uint32_t DIM_0 = 8; const uint32_t DIM_1 = 512; /** * @brief 准备 Addcustom 输入 tensor(两输入同 shape) */ atb::Status PrepareInTensor(atb::Context *contextPtr, aclrtStream stream, atb::SVector &inTensors) { // 输入 x:[8, 512],int32,全 1 atb::Tensor x; CHECK_STATUS(CreateTensorFromVector(contextPtr, stream, std::vector(DIM_0 * DIM_1, 1), ACL_INT32, aclFormat::ACL_FORMAT_ND, {DIM_0, DIM_1}, x)); // 输入 y:[8, 512],int32,全 2 atb::Tensor y; CHECK_STATUS(CreateTensorFromVector(contextPtr, stream, std::vector(DIM_0 * DIM_1, 2), ACL_INT32, aclFormat::ACL_FORMAT_ND, {DIM_0, DIM_1}, y)); inTensors = {x, y}; return atb::ErrorType::NO_ERROR; } /** * @brief 创建 AddcustomOperation */ atb::Status CreateAddcustomOperation(atb::Operation **addOp) { atb::infer::AddcustomParam param; param.addcustomDim = 0; CHECK_STATUS(atb::CreateOperation(param, addOp)); return atb::ErrorType::NO_ERROR; } int main(int argc, char **argv) { CHECK_STATUS(aclInit(nullptr)); int32_t deviceId = 0; CHECK_STATUS(aclrtSetDevice(deviceId)); atb::Context *context = nullptr; CHECK_STATUS(atb::CreateContext(&context)); void *stream = nullptr; CHECK_STATUS(aclrtCreateStream(&stream)); context->SetExecuteStream(stream); /* 创建 op */ atb::Operation *addOp = nullptr; CHECK_STATUS(CreateAddcustomOperation(&addOp)); /* 准备输入输出 */ atb::VariantPack variantPack; CHECK_STATUS(PrepareInTensor(context, stream, variantPack.inTensors)); atb::Tensor output; CHECK_STATUS(CreateTensorFromVector(context, stream, std::vector(DIM_0 * DIM_1, 0), // 占位即可 ACL_INT32, aclFormat::ACL_FORMAT_ND, {DIM_0, DIM_1}, output)); variantPack.outTensors = {output}; /* Setup -> Execute */ uint64_t workspaceSize = 0; CHECK_STATUS(addOp->Setup(variantPack, workspaceSize, context)); uint8_t *workspacePtr = nullptr; if (workspaceSize > 0) { CHECK_STATUS(aclrtMalloc((void **)&workspacePtr, workspaceSize, ACL_MEM_MALLOC_HUGE_FIRST)); } CHECK_STATUS(addOp->Execute(variantPack, workspacePtr, workspaceSize, context)); CHECK_STATUS(aclrtSynchronizeStream(stream)); /* 释放资源 */ for (auto &t : variantPack.inTensors) aclrtFree(t.deviceData); for (auto &t : variantPack.outTensors) aclrtFree(t.deviceData); if (workspacePtr) { aclrtFree(workspacePtr); } atb::DestroyOperation(addOp); aclrtDestroyStream(stream); DestroyContext(context); aclFinalize(); std::cout << "Addcustom demo success!" << std::endl; return 0; } ``` -------------------------------- ### Set Environment Script Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/op_demo/linear_parallel/README.md Source these scripts to set up the necessary environment variables for CANN and nnal packages. Ensure the paths are correct for your installation. ```sh source [cann安装路径]/set_env.sh 默认:source /usr/local/Ascend/ascend-toolkit/set_env.sh ``` ```sh source [nnal安装路径]/set_env.sh 默认:source /usr/local/Ascend/nnal/atb/set_env.sh ①. 如果使用加速库源码编译,source [加速库源码路径]/output/atb/set_env.sh 例如: source ./ascend-transformer-boost/output/atb/set_env.sh ``` -------------------------------- ### Create Local Working Directory Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/contributors/gitcode-workflow.md Use this command to create a directory on your local machine to store the project's code. ```default mkdir ${your_working_dir} ``` -------------------------------- ### ATB算子接入:op_list.yaml 配置 Source: https://github.com/cann/ascend-transformer-boost/blob/master/docs/开发指南.md 在op_list.yaml文件中添加新增算子信息,以确保后续构建能够正确编译新增算子的实现和接口。此配置对于非融合算子需要修改kernels/op_list.yaml。 ```yaml FastSoftMaxOperation: FastSoftMaxKernel: ascend910b: true ``` -------------------------------- ### Configure CANN Environment Variables Source: https://github.com/cann/ascend-transformer-boost/blob/master/README.md Source the set_env.sh script to configure the environment variables for the CANN toolkit. The installation path is assumed to be ${HOME}/Ascend. ```shell source ${HOME}/Ascend/ascend-toolkit/set_env.sh ``` -------------------------------- ### Include Directories Setup Source: https://github.com/cann/ascend-transformer-boost/blob/master/src/kernels/CMakeLists.txt Configures include directories for the project. This allows the compiler to find header files located in the project root and its tbe_adapter subdirectory. ```cmake include_directories( ${OPS_PROJECT_ROOT_DIR} ${OPS_PROJECT_ROOT_DIR}/tbe_adapter/include ) ``` -------------------------------- ### Set Environment Script for NNAL Source: https://github.com/cann/ascend-transformer-boost/blob/master/example/op_demo/paged_cache_load/README.md Source this script to set up the environment for NNAL. The default path is /usr/local/Ascend/nnal/atb/set_env.sh. If compiling from source, use the provided path. ```sh source /usr/local/Ascend/nnal/atb/set_env.sh ``` ```sh source ./ascend-transformer-boost/output/atb/set_env.sh ```