950基础矩阵乘法TLA示例

发布时间:2026/10/21 6:21:18
950基础矩阵乘法TLA示例 950 Basic Matmul TLA Example Readme【免费下载链接】catlass本项目是CANN的算子模板库提供NPU上高性能矩阵乘及其相关融合类算子模板样例。项目地址: https://gitcode.com/cann/catlassNote: The community package does not currently support 950 capabilities. Stay tuned for a future supported version.Code Organization├── 43_ascend950_basic_matmul │ ├── CMakeLists.txt # CMake build file │ ├── README.md │ └── basic_matmul_tla.cpp # Main fileUsage ExampleAfter obtaining the code, build the corresponding operator executable. See Template Library Quick Start. This case is a 950 operator, and-DCATLASS_ARCH3510must be added during build.Run the operator.# Build the specified case bash scripts/build.sh 43_ascend950_basic_matmul -DCATLASS_ARCH3510 cd output/bin # Executable file name | matrix m axis | n axis | k axis | Device ID # Device ID is optional and defaults to 0 ./43_ascend950_basic_matmul 256 512 1024 0The execution result is as follows, indicating that the precision comparison succeeds.Compare success.Usage NotesThe DispatchPolicy MmadPingpong used by BasicMatmul by default supports the following template parameters:Template ParameterDefault ValueParameter DescriptionArchTagNoneSpecifies the architecture modelenableUnitFlagfalseSpecifies whether to enable UnitFlag. It must be set to false when L0C multi-buffering is enableduseHF32falseSpecifies whether to enable HF32. Only the float type is supportedl0CStages1Specifies the number of L0C buffers. Set it to 2 to enable L0C double bufferingenableL1ResidentfalseSpecifies whether to enable L1 residencyl1AStages2Number of buffers for loading matrix A on L1l1BStages2Number of buffers for loading matrix B on L1l0AStages2Number of buffers for loading matrix A on L0l0BStages2Number of buffers for loading matrix B on L0Assume the matrix Shape isM N K, the tile size on L1 ism1 n1 k1, the number of tiles in the M direction ismTiles CeilDiv(M, m1), the number of tiles in the N direction isnTiles CeilDiv(N, n1), and the total number of tasks istaskBlocks mTiles * nTiles. enableL1Resident can be enabled in the following two cases:mTiles 1,nTiles CoreNum, andK 2 * k1. In this case,l0CStages2can also be set (enableUnitFlag must be disabled). If there is not enough space andl0CStages2cannot be set, setn1to half of the original value.nTiles 1,mTiles CoreNum, andK 2 * k1. In this case,l0CStages2can also be set (enableUnitFlag must be disabled). If there is not enough space andl0CStages2cannot be set, setm1to half of the original value.BasicMatmul also supports DispatchPolicy MmadPreloadAsyncWithCallback, which supports the following template parameters:Template ParameterDefault ValueParameter DescriptionArchTagNoneSpecifies the architecture modelpreloadStagesNoneSpecifies the number of preloadsl1AStages2Number of buffers for loading matrix A on L1l1BStages2Number of buffers for loading matrix B on L1l0AStages2Number of buffers for loading matrix A on L0l0BStages2Number of buffers for loading matrix B on L0l0CStages1Specifies the number of L0C buffers. Set it to 2 to enable L0C double bufferingenableUnitFlagfalseSpecifies whether to enable UnitFlag. It must be set to false when L0C multi-buffering is enabledenableShuffleKfalseSpecifies whether to enable K-direction staggered readinguseHF32falseSpecifies whether to enable HF32. Only the float type is supportedenableL1ResidentfalseSpecifies whether to enable L1 residencyCompared withMmadPingpong,MmadPreloadAsyncWithCallbackhas two more template parameters. One ispreloadStages. This parameter is usually set to 1 and specifies the number of preloads. When this parameter is set to 1, the first loop only loads data and does not perform matmul computation. The second loop first loads the data for the second loop, and then completes the Matmul computation of the previous loop, and so on. After the final loop ends, one additional Matmul computation is performed. The benefit is that the data required for the current Matmul computation has already been moved in the previous loop. Therefore, instruction issue is advanced, which reduces the performance loss caused by instruction issue latency.The second parameter isenableShuffleK. This parameter is mainly used to avoid bandwidth loss caused by same-address access conflicts. The main principle is to stagger the data read addresses of each core. This parameter does not need to be enabled on 950.Compared withMmadPingpong,MmadPreloadAsyncWithCallbackhas more optimization points, but its logic is also more complex and has higher Scalar overhead. Use it based on the scenario, especially for small Shape scenarios.【免费下载链接】catlass本项目是CANN的算子模板库提供NPU上高性能矩阵乘及其相关融合类算子模板样例。项目地址: https://gitcode.com/cann/catlass创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

关于本文作者

来自尧图内容编辑团队

尧图内容编辑团队 内容团队

尧图内容编辑团队

本文由尧图网络内容编辑团队执笔。团队由资深项目经理、前端工程师与设计师组成,所有内容均来自亲手交付的真实项目,先讲清问题、再给出可落地的解法。尧图深耕北京网站建设十年,服务过京华建材集团、智造科技等各行业客户,把一线经验沉淀为可复用的行业观察。

  • 十年建站经验,覆盖建材、制造、服务、文创等
  • 项目经理把关选题与事实准确性
  • 工程师与设计师联合撰写专业细节
  • 统一编辑规范,保证文风与排版一致
  • 每月复盘转化数据,迭代选题方向

延伸阅读

相关资讯与近期热门内容

深度阅读推荐

建站决策前值得细读的三篇

网站改版的5个关键决策
2024-08-12

网站改版的5个关键决策

什么时候该改版、改到什么程度、如何避免流量掉光,京华建材集团改版复盘给出答案。

获取专属建站方案

看完文章,把您的行业与预算告诉我们,免费获取一份量身定制的官网建设方案与报价。

立即免费咨询