Skip to content

Repository files navigation

Ascend C 算子开发记录

Date: 2025/1/19 Author: Zixuan

配置环境篇

使用流程- Atlas 200I DK A2

环境准备

Atlas 200I DK A2算子开发环境搭建指导

  • 烧录TF卡的注意事项:

    • 使用Linux桌面烧录,烧录结束后会出错(暂未知原因)
    • 建议用Windows下的工具进行烧录。
  • 更新CANN toolkit 开发包的注意事项:

    • 上述链接中的 8.0.RC1.alpha001 是找不到的,这里笔者用 8.0.RC2.alpha001 替代;8.0.0.beta1 会导致驱动不兼容。

    • 其余操作大致相同。

    • $ su root
      # cd ~/Downloads
      # wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C18B800TP015/Ascend-cann-toolkit_8.0.RC2.alpha001_linux-aarch64.run
      # chmod +x Ascend-cann-toolkit_8.0.RC2.alpha001_linux-aarch64.run
      # ./Ascend-cann-toolkit_8.0.RC2.alpha001_linux-aarch64.run --uninstall
      # rm -rf /usr/local/Ascend/ascend-toolkit/*
      # ./Ascend-cann-toolkit_8.0.RC2.alpha001_linux-aarch64.run --full
      # pip install protobuf==3.20.0
      # echo "source /usr/local/Ascend/ascend-toolkit/set_env.sh" >> /root/.bashrc
      # source /root/.bashrc
  • 测试范例下载

    • 注意用tag为 8.0.RC2 的git仓库。

    • # git clone gitee.com/ascend/samples
      # cd samples
      # git checkout 8.0.RC2
    • 对于 核函数 下的 AddKernelInvocation 方式,[该算子编译调用方式转维护,特性不再更新,不推荐使用。推荐使用Neo样例。]

Vscode 头文件报错

  • 增加下述链接至包含路径
${workspaceFolder}/**
/usr/local/Ascend/ascend-toolkit/latest/include/**
/usr/local/Ascend/ascend-toolkit/8.0.RC2.alpha001/aarch64-linux/tikcpp/tikcfw
/usr/local/Ascend/ascend-toolkit/8.0.RC2.alpha001/aarch64-linux/tikcpp/tikcfw/impl
/usr/local/Ascend/ascend-toolkit/8.0.RC2.alpha001/aarch64-linux/tikcpp/tikcfw/interface

Asinh

$y=arsinhx = ln(x+\sqrt{x^2+1})$

需要half和float

Mul(tmp,x,x,tileLength);

DTYPE_X val = 1;

Add(tmp1,x,val,tileLength);

Sqrt(tmp2, tmp1,tileLength);

Add(tmp3,x,tmp2,tileLength);

Ln(tmp4,tmp3,tileLength);

S

BEGIN_TILING_DATA_DEF(TilingData)                      // Register a Tiling class, taking tiling's name as an entry
  TILING_DATA_FIELD_DEF(uint32_t, smallCoreDataNum);   // Adds the tiling field to the size of the total data processed by the small kernel
  TILING_DATA_FIELD_DEF(uint32_t, bigCoreDataNum);     // Adds the tiling field to the total data size for kernel processing
  TILING_DATA_FIELD_DEF(uint32_t, finalBigTileNum);    // Add the tiling field, the number of data transfers on the large kernel
  TILING_DATA_FIELD_DEF(uint32_t, finalSmallTileNum);  // Added the number of data transfers on the tiling field kernel
  TILING_DATA_FIELD_DEF(uint32_t, tileDataNum);        // The tiling field is added. The amount of data that can be processed in a single transfer on a single core is added
  TILING_DATA_FIELD_DEF(uint32_t, smallTailDataNum);   // Add the size of the last data processed by the tiling field small core
  TILING_DATA_FIELD_DEF(uint32_t, bigTailDataNum);     // The size of the data processed by the last transfer of the large core
  TILING_DATA_FIELD_DEF(uint32_t, tailBlockNum);       // Add the tiling field, the number of large cores
END_TILING_DATA_DEF;
# /usr/local/Ascend/ascend-toolkit/latest/python/site-packages/bin/msopgen gen -i ./Softmax.json -c ai_core-Ascend310B1 -lan cpp -out ./Softmax

About

This is Uniya's development workspace about Ascend C operators.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages