CANN/asc-devkit:L1与L0数据搬运 L1与L0数据搬运【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit总体说明L1 Buffer与L0 Buffer之间的数据搬运提供了灵活的接口支持能够充分适配多样化的计算场景见表1。其中L1 Buffer-L0A Buffer、L1 Buffer-L0B Buffer的数据搬运用于矩阵计算参考矩阵计算的搬入L0C Buffer-L1 Buffer用于矩阵计算的搬出完成矩阵计算的输出流程参考矩阵计算的搬出。表 1L1 Buffer与L0 Buffer数据搬运接口概述数据通路功能描述L1 Buffer-L0A Buffer2D格式分形矩阵搬运(LoadData2D矩阵搬运)负责完成普通矩阵计算所需的2D格式数据的搬运。L1 Buffer-L0A Buffer2D格式分形矩阵搬运(LoadData2D矩阵搬运V2)负责完成普通矩阵计算所需的2D格式数据的搬运。L1 Buffer-L0A Buffer2D格式分形矩阵搬运(LoadDataMX矩阵搬运)负责完成矩阵计算所需的左右矩阵数据和对应的左右量化系数矩阵数据的搬运。L1 Buffer-L0A Buffer2D格式分形矩阵伴转置搬运(LoadDataWithTranspose)负责完成普通矩阵计算所需的2D格式的数据的搬运搬运过程中会伴随转置操作。L1 Buffer-L0A Buffer3D格式分形矩阵搬运(LoadData卷积数据搬运)用于将NC1HWC0格式的Feature Map完成Image to Column展开然后再从展开后的二维矩阵中选取指定数据块搬入对应内存位置。L1 Buffer-L0A Buffer3D格式分形矩阵搬运(LoadDataWithStride)用于将NC1HWC0格式的Feature Map完成Image to Column展开然后再从展开后的二维矩阵中选取指定数据块搬入对应内存位置支持配置输出矩阵K轴方向偏移量。L1 Buffer-L0B Buffer2D格式分形矩阵搬运(LoadData2D矩阵搬运)负责完成普通矩阵计算所需的2D格式数据的搬运。L1 Buffer-L0B Buffer2D格式分形矩阵搬运(LoadData2D矩阵搬运V2)负责完成普通矩阵计算所需的2D格式数据的搬运。L1 Buffer-L0B Buffer2D格式分形矩阵搬运(LoadDataMX矩阵搬运)负责完成矩阵计算所需的左右矩阵数据和对应的左右量化系数矩阵数据的搬运。L1 Buffer-L0B Buffer2D格式分形矩阵伴转置搬运(LoadDataWithTranspose)负责完成普通矩阵计算所需的2D格式的数据的搬运搬运过程中会伴随转置操作。L1 Buffer-L0B Buffer3D格式分形矩阵搬运(LoadData卷积数据搬运)用于将NC1HWC0格式的Feature Map完成Image to Column展开然后再从展开后的二维矩阵中选取指定数据块搬入对应内存位置。L1 Buffer-L0B Buffer3D格式分形矩阵搬运(LoadDataWithStride)用于将NC1HWC0格式的Feature Map完成Image to Column展开然后再从展开后的二维矩阵中选取指定数据块搬入对应内存位置支持配置输出矩阵K轴方向偏移量。L1 Buffer-L0B Buffer稠密权重矩阵搬运(LoadDataWithSparse)用于从L1 Buffer中搬运以512Byte为单位存放的稠密权重矩阵到L0B Buffer里同时搬运以128Byte为单位的索引矩阵到内置的专用buffer空间用于后续MmadWithSparse接口进行读取。L0C Buffer-L1 BufferL0C Buffer-L1 Buffer随路量化激活搬运(DataCopy)支持多种随路能力的组合需要设置不同的寄存器配合DataCopy指令使能不同的数据搬运能力。L0C Buffer-L1 BufferL0C Buffer-L1 Buffer随路量化激活搬运(FixPipe)支持多种随路能力的组合FixPipe接口内包含了设置寄存器与数据搬运能力。L1ToL0A 2D格式分形矩阵搬运(LoadData2D矩阵搬运)LoadData2D矩阵搬运能够实现L1 Buffer到L0A Buffer之间的数据搬运。负责完成普通矩阵计算所需的2D格式数据的搬运以大小为512Byte的数据分形为单位进行搬运。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0A BufferA1 - A2搬运的数据用于矩阵计算接口具体介绍请参考LoadData2D矩阵搬运。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。template typename T __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData2DParams loadDataParams)L1ToL0A 2D格式分形矩阵搬运(LoadData2D矩阵搬运V2)LoadData2D矩阵搬运V2能够实现L1 Buffer到L0A Buffer之间的数据搬运。负责完成普通矩阵计算所需的2D格式数据的搬运以大小为512Byte的数据分形为单位进行搬运。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0A BufferA1 - A2搬运的数据用于矩阵计算接口具体介绍请参考LoadData2D矩阵搬运V2。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。仅Ascend 950PR/Ascend 950DT支持template typename T __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData2DParamsV2 loadDataParams)L1ToL0A 2D格式分形矩阵搬运(LoadDataMX矩阵搬运)LoadDataMX矩阵搬运负责完成矩阵计算所需的左右矩阵数据和对应的左右量化系数矩阵数据的搬运其中左右矩阵数据以大小为512Byte的数据分形为单位进行搬运左右量化系数矩阵以32Byte的数据分形为单位进行搬运。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0A BufferA1 - A2搬运的数据用于矩阵计算接口具体介绍请参考LoadDataMX矩阵搬运。src和srcMx为源操作数dst为目的操作数loadDataParams和loadMxDataParams为搬运参数。LoadDataMX矩阵搬运接口仅Ascend 950PR/Ascend 950DT支持template typename T, typename U T __aicore__ inline void LoadData(const LocalTensorU dst, const LocalTensorT src, const LocalTensorfp8_e8m0_t srcMx, const LoadData2DParamsV2 loadDataParams, const LoadData2DMxParams loadMxDataParams)LoadDataMX矩阵搬运接口支持源操作数和目的操作数数据类型不一致仅Ascend 950PR/Ascend 950DT支持template typename T, typename U __aicore__ inline void LoadData(const LocalTensorU dst, const LocalTensorT src0, const LocalTensorfp8_e8m0_t srcMx, const LoadData2DParamsV2 loadDataParams, const LoadData2DMxParams loadMxDataParams)L1ToL0A 2D格式分形矩阵伴转置搬运(LoadDataWithTranspose)LoadDataWithTranspose能够实现L1 Buffer到L0A Buffer之间的数据搬运。负责完成普通矩阵计算所需的2D格式的数据搬运搬运过程中会伴随转置操作以大小为512Byte的数据分形为单位进行搬运。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0A BufferA1 - A2搬运的数据用于矩阵计算接口具体介绍请参考LoadDataWithTranspose。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。template typename T __aicore__ inline void LoadDataWithTranspose(const LocalTensorT dst, const LocalTensorT src, const LoadData2dTransposeParams loadDataParams)仅Ascend 950PR/Ascend 950DT支持template typename T __aicore__ inline void LoadDataWithTranspose(const LocalTensorT dst, const LocalTensorT src, const LoadData2dTransposeParamsV2 loadDataParams)L1ToL0A 3D格式分形矩阵搬运(LoadData卷积数据搬运)LoadData卷积数据搬运本质上是用于将NC1HWC0格式的Feature Map完成Image to Column展开然后再从展开后的二维矩阵中选取指定数据块搬入对应内存位置。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0A BufferA1 - A2搬运的数据用于矩阵计算接口具体介绍请参考LoadData卷积数据搬运。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。LoadData卷积数据搬运 v1接口template typename T, const IsResetLoad3dConfig defaultConfig IS_RESER_LOAD3D_DEFAULT_CONFIG, typename U PrimTT, typename Std::enable_ifStd::is_samePrimTT, U::value, bool::type true __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData3DParamsV1U loadDataParams)LoadData卷积数据搬运v2接口template typename T, const IsResetLoad3dConfig defaultConfig IS_RESER_LOAD3D_DEFAULT_CONFIG, typename U PrimTT, typename Std::enable_ifStd::is_samePrimTT, U::value, bool::type true __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData3DParamsV2U loadDataParams)LoadData卷积数据搬运v2Pro接口仅Ascend 950PR/Ascend 950DT支持template typename T __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData3DParamsV2Pro loadDataParams)L1ToL0A 3D格式分形矩阵搬运(LoadDataWithStride)LoadDataWithStride用于将NC1HWC0格式的Feature Map完成Image to Column展开然后再从展开后的二维矩阵中选取指定数据块搬入对应内存位置支持配置输出矩阵K轴方向偏移量。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0A BufferA1 - A2搬运的数据用于矩阵计算接口具体介绍请参考LoadDataWithStride。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。仅Ascend 950PR/Ascend 950DT支持template typename T, const IsResetLoad3dConfig defaultConfig IS_RESER_LOAD3D_DEFAULT_CONFIG, typename U PrimTT,typename Std::enable_ifStd::is_samePrimTT, U::value, bool::type true __aicore__ inline void LoadDataWithStride(const LocalTensorT dst, const LocalTensorT src, const LoadData3DParamsV2U loadDataParams)L1ToL0B 2D格式分形矩阵搬运(LoadData2D矩阵搬运)LoadData2D矩阵搬运能够实现L1 Buffer到L0B Buffer之间的数据搬运。负责完成普通矩阵计算所需的2D格式数据的搬运以大小为512Byte的数据分形为单位进行搬运。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0B BufferB1 - B2搬运的数据用于矩阵计算接口具体介绍请参考LoadData2D矩阵搬运。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。template typename T __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData2DParams loadDataParams)L1ToL0B 2D格式分形矩阵搬运(LoadData2D矩阵搬运V2)LoadData2D矩阵搬运V2能够实现L1 Buffer到L0B Buffer之间的数据搬运。负责完成普通矩阵计算所需的2D格式数据的搬运以大小为512Byte的数据分形为单位进行搬运。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0B BufferB1 - B2搬运的数据用于矩阵计算接口具体介绍请参考LoadData2D矩阵搬运V2。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。仅Ascend 950PR/Ascend 950DT支持template typename T __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData2DParamsV2 loadDataParams)L1ToL0B 2D格式分形矩阵搬运(LoadDataMX矩阵搬运)LoadDataMX矩阵搬运负责完成矩阵计算所需的左右矩阵数据和对应的左右量化系数矩阵数据的搬运其中左右矩阵数据以大小为512Byte的数据分形为单位进行搬运左右量化系数矩阵以32Byte的数据分形为单位进行搬运。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0B BufferB1 - B2搬运的数据用于矩阵计算接口具体介绍请参考LoadDataMX矩阵搬运。src和srcMx为源操作数dst为目的操作数loadDataParams和loadMxDataParams为搬运参数。LoadDataMX矩阵搬运接口仅Ascend 950PR/Ascend 950DT支持template typename T, typename U T __aicore__ inline void LoadData(const LocalTensorU dst, const LocalTensorT src, const LocalTensorfp8_e8m0_t srcMx, const LoadData2DParamsV2 loadDataParams, const LoadData2DMxParams loadMxDataParams)LoadDataMX矩阵搬运接口支持源操作数和目的操作数数据类型不一致仅Ascend 950PR/Ascend 950DT支持template typename T, typename U __aicore__ inline void LoadData(const LocalTensorU dst, const LocalTensorT src0, const LocalTensorfp8_e8m0_t srcMx, const LoadData2DParamsV2 loadDataParams, const LoadData2DMxParams loadMxDataParams)L1ToL0B 2D格式分形矩阵伴转置搬运(LoadDataWithTranspose)LoadDataWithTranspose能够实现L1 Buffer到L0B Buffer之间的数据搬运。负责完成普通矩阵计算所需的2D格式的数据搬运搬运过程中会伴随转置操作以大小为512Byte的数据分形为单位进行搬运。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0B BufferB1 - B2搬运的数据用于矩阵计算接口具体介绍请参考LoadDataWithTranspose。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。template typename T __aicore__ inline void LoadDataWithTranspose(const LocalTensorT dst, const LocalTensorT src, const LoadData2dTransposeParams loadDataParams)仅Ascend 950PR/Ascend 950DT支持template typename T __aicore__ inline void LoadDataWithTranspose(const LocalTensorT dst, const LocalTensorT src, const LoadData2dTransposeParamsV2 loadDataParams)L1ToL0B 3D格式分形矩阵搬运(LoadData卷积数据搬运)LoadData卷积数据搬运本质上是用于将NC1HWC0格式的Feature Map完成Image to Column展开然后再从展开后的二维矩阵中选取指定数据块搬入对应内存位置。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0B BufferB1 - B2搬运的数据用于矩阵计算接口具体介绍请参考LoadData卷积数据搬运。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。LoadData卷积数据搬运 v1接口template typename T, const IsResetLoad3dConfig defaultConfig IS_RESER_LOAD3D_DEFAULT_CONFIG, typename U PrimTT, typename Std::enable_ifStd::is_samePrimTT, U::value, bool::type true __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData3DParamsV1U loadDataParams)LoadData卷积数据搬运v2接口template typename T, const IsResetLoad3dConfig defaultConfig IS_RESER_LOAD3D_DEFAULT_CONFIG, typename U PrimTT, typename Std::enable_ifStd::is_samePrimTT, U::value, bool::type true __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData3DParamsV2U loadDataParams)LoadData卷积数据搬运v2Pro接口仅Ascend 950PR/Ascend 950DT支持template typename T __aicore__ inline void LoadData(const LocalTensorT dst, const LocalTensorT src, const LoadData3DParamsV2Pro loadDataParams)L1ToL0B 3D格式分形矩阵搬运(LoadDataWithStride)LoadDataWithStride用于将NC1HWC0格式的Feature Map完成Image to Column展开然后再从展开后的二维矩阵中选取指定数据块搬入对应内存位置支持配置输出矩阵K轴方向偏移量。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0B BufferB1 - B2搬运的数据用于矩阵计算接口具体介绍请参考LoadDataWithStride。src和dst分别为源操作数和目的操作数loadDataParams为搬运参数。仅Ascend 950PR/Ascend 950DT支持template typename T, const IsResetLoad3dConfig defaultConfig IS_RESER_LOAD3D_DEFAULT_CONFIG, typename U PrimTT,typename Std::enable_ifStd::is_samePrimTT, U::value, bool::type true __aicore__ inline void LoadDataWithStride(const LocalTensorT dst, const LocalTensorT src, const LoadData3DParamsV2U loadDataParams)L1ToL0B 稠密权重矩阵搬运(LoadDataWithSparse)用于从L1中搬运以512Byte为单位存放的稠密权重矩阵到L0B里同时搬运以128Byte为单位的索引矩阵到内置的专用buffer空间用于后续MmadWithSparse接口进行读取。具体支持的数据通路为以逻辑位置TPosition表示L1 Buffer - L0B BufferB1 - B2搬运的数据用于矩阵计算接口具体介绍请参考LoadDataWithSparse。仅如下产品型号支持Atlas A3 训练系列产品/Atlas A3 推理系列产品Atlas A2 训练系列产品/Atlas A2 推理系列产品template typename T int8_t, typename U uint8_t, typename Std::enable_ifStd::is_samePrimTT, int8_t::value, bool::type true, typename Std::enable_ifStd::is_samePrimTU, uint8_t::value, bool::type true __aicore__ inline void LoadDataWithSparse(const LocalTensorT dst, const LocalTensorT src, const LocalTensorU idx, const LoadData2dParams loadDataParam)L0CToL1随路量化激活搬运(DataCopy)该接口主要实现将数据从L0C Buffer搬运至L1 Buffer并支持多种随路能力的组合需要设置不同的寄存器。具体支持的数据通路为以逻辑位置TPosition表示L0C Buffer - L1 BufferCO1 - C1搬运的数据为矩阵计算的结果接口具体介绍请参考L0C到L1数据搬运DataCopy。src和dst分别为源操作数和目的操作数intriParams为搬运参数。template typename T, typename U __aicore__ inline void DataCopy(const LocalTensorT dst, const LocalTensorU src, const DataCopyCO12DstParams intriParams)L0CToL1随路量化激活搬运(FixPipe)该接口主要实现将数据从L0C Buffer搬运至L1 Buffer并支持多种随路能力的组合接口内包含了设置寄存器与数据搬运能力。具体支持的数据通路为以逻辑位置TPosition表示L0C Buffer - L1 BufferCO1 - C1搬运的数据为矩阵计算的结果以Ascend 950PR/Ascend 950DT为例接口示例如下注意不同产品型号的接口原型可能不同具体介绍请参考L0C到L1数据搬运Fixpipe。src和dst分别为源操作数和目的操作数intriParams为搬运参数cbufWorkspace为开启tensor量化时所需的量化参数。不开启随路tensor量化功能template typename T, typename U, const FixpipeConfig config CFG_ROW_MAJOR __aicore__ inline void Fixpipe(const LocalTensorT dst, const LocalTensorU src, const FixpipeParamsArch3510config.format intriParams)开启随路tensor量化功能template typename T, typename U, const FixpipeConfig config CFG_ROW_MAJOR __aicore__ inline void Fixpipe(const LocalTensorT dst, const LocalTensorU src, const LocalTensoruint64_t cbufWorkspace, const FixpipeParamsArch3510config.format intriParams)【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考