已合并
docs: update references in docs/zh after rebase #5245
ai_xin创建于 8月21日
docs: update references in docs/zh after rebase #5245
已合并
ai_xin创建于 8月21日
共 26 个文件变更+120-23
@@ -114,7 +114,9 @@ struct SoftMaxShapeInfo {
114- **不支持源操作数与目的操作数地址重叠。**114- **不支持源操作数与目的操作数地址重叠。**
115- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。115- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。
116- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。116- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。
117+<!-- npu="A3,910b,310p" id7 -->
117- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。118- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。
119+<!-- end id7 -->
118 120 
119## 调用示例121## 调用示例
120 122 
@@ -88,7 +88,9 @@ bool类型,当返回true时,表示maxTensor中存在需要判断的值,若
88## 约束说明88## 约束说明
89 89 
90- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。90- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。
91+<!-- npu="A3,910b,310p" id9 -->
91- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。92- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。
93+<!-- end id9 -->
92 94 
93## 调用示例95## 调用示例
94 96 
@@ -150,7 +150,11 @@ struct SoftMaxShapeInfo {
150- inSumTensor和inMaxTensor的数据类型需要保持一致。150- inSumTensor和inMaxTensor的数据类型需要保持一致。
151- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。151- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。
152- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。152- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。
153+<!-- npu="A3,910b,310p" id14 -->
153- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。154- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。
155+<!-- end id14 -->
156+ 
157+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/activation_functions/SoftMax_interface/SimpleSoftMax_res.md#id2 -->
154 158 
155## 调用示例159## 调用示例
156 160 
@@ -189,10 +189,13 @@ struct SoftMaxShapeInfo {
189- src和dst的Tensor空间可以复用。189- src和dst的Tensor空间可以复用。
190- sumTensor和maxTensor为输出,并且last轴长度必须固定32Byte,非last轴大小需要和src以及dst保持一致。190- sumTensor和maxTensor为输出,并且last轴长度必须固定32Byte,非last轴大小需要和src以及dst保持一致。
191- sumTensor和maxTensor的数据类型需要保持一致。191- sumTensor和maxTensor的数据类型需要保持一致。
192- 
193- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。192- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。
194- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。193- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。
194+<!-- npu="A3,910b,310p" id18 -->
195- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。195- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。
196+<!-- end id18 -->
197+ 
198+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/activation_functions/SoftMax_interface/SoftMax_res.md#id2 -->
196 199 
197## 调用示例200## 调用示例
198 201 
@@ -239,7 +239,11 @@ struct SoftMaxShapeInfo {
239 239 
240- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。240- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。
241- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。241- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。
242+<!-- npu="A3,910b,310p" id11 -->
242- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。243- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。
244+<!-- end id11 -->
245+ 
246+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/activation_functions/SoftMax_interface/SoftmaxFlashV2_res.md#id2 -->
243 247 
244## 调用示例248## 调用示例
245 249 
@@ -124,7 +124,9 @@ struct SoftMaxShapeInfo {
124- srcTensor和dstTensor的Tensor空间可以复用。124- srcTensor和dstTensor的Tensor空间可以复用。
125- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。125- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。
126- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。126- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。
127+<!-- npu="A3,910b,310p" id8 -->
127- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。128- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。
129+<!-- end id8 -->
128 130 
129## 调用示例131## 调用示例
130 132 
@@ -119,7 +119,9 @@ struct SoftMaxShapeInfo {
119 119 
120- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。120- 操作数地址对齐要求请参见[通用地址对齐约束](../../../general_description_and_constraints.md#section796754519912)。
121- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。121- 不支持sharedTmpBuffer与源操作数和目的操作数地址重叠。
122+<!-- npu="A3,910b,310p" id9 -->
122- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。123- 当参数softmaxShapeInfo中srcM != oriSrcM或者srcK != oriSrcK时,开发者需要对GM上的原始输入\(oriSrcM, oriSrcK\)在M或K方向补齐数据到\(srcM, srcK\),补齐的数据会参与部分运算,在输入输出复用的场景下,API的计算结果会覆盖srcTensor中补齐的原始数据,在输入输出不复用的场景下,API的计算结果会覆盖dstTensor中对应srcTensor补齐位置的数据。
124+<!-- end id9 -->
123 125 
124## 调用示例126## 调用示例
125 127 
@@ -68,6 +68,8 @@ __aicore__ constexpr MatmulConfig GetMDLConfig(const bool intrinsicsLimit = fals
68 68 
69无69无
70 70 
71+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/GetMDLConfig_res.md#id2 -->
72+ 
71## 调用示例73## 调用示例
72 74 
73```75```
@@ -70,6 +70,8 @@ __aicore__ constexpr MatmulApiStaticTiling GetMatmulApiTiling(const MatmulConfig
70- 入参mmCFG,在调用获取MatmulConfig模板的接口获取时,需要使用常数值指定\(baseM, baseN, baseK\)或者指定\(baseM, baseN, baseK, singleCoreM, singleCoreN, singleCoreK\),并且指定的参数值需要和Tiling计算的值保持一致。70- 入参mmCFG,在调用获取MatmulConfig模板的接口获取时,需要使用常数值指定\(baseM, baseN, baseK\)或者指定\(baseM, baseN, baseK, singleCoreM, singleCoreN, singleCoreK\),并且指定的参数值需要和Tiling计算的值保持一致。
71- Batch Matmul场景支持全量常量化,但不支持使用空指针替代REGIST\_MATMUL\_OBJ的入参Tiling。71- Batch Matmul场景支持全量常量化,但不支持使用空指针替代REGIST\_MATMUL\_OBJ的入参Tiling。
72 72 
73+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/GetMatmulApiTiling_res.md#id2 -->
74+ 
73## 调用示例75## 调用示例
74 76 
75```77```
@@ -66,6 +66,8 @@ __aicore__ constexpr MatmulConfig GetNormalConfig(const bool intrinsicsLimit = f
66 66 
67无67无
68 68 
69+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/GetNormalConfig_res.md#id2 -->
70+ 
69## 调用示例71## 调用示例
70 72 
71```73```
@@ -131,6 +131,7 @@ __aicore__ inline void GetTensorC(const LocalTensor<DstT>& c, uint8_t enAtomic =
131- 传入的C矩阵地址空间大小需要保证不小于baseM \* baseN。131- 传入的C矩阵地址空间大小需要保证不小于baseM \* baseN。
132- 异步场景时,需要使用一块临时空间来缓存Iterate计算结果,调用GetTensorC时会在该临时空间中获取C的矩阵分片。临时空间通过[SetWorkspace](SetWorkspace.md)接口进行设置。SetWorkspace接口需要在Iterate接口之前调用。132- 异步场景时,需要使用一块临时空间来缓存Iterate计算结果,调用GetTensorC时会在该临时空间中获取C的矩阵分片。临时空间通过[SetWorkspace](SetWorkspace.md)接口进行设置。SetWorkspace接口需要在Iterate接口之前调用。
133- 当开启MixDualMaster(双主模式)场景时,即模板参数[enableMixDualMaster](MatmulConfig.md#matmulconfig-params)设置为true,不支持使用该接口。133- 当开启MixDualMaster(双主模式)场景时,即模板参数[enableMixDualMaster](MatmulConfig.md#matmulconfig-params)设置为true,不支持使用该接口。
134+<!-- npu="950,A3,910b,310p,310b,x90,9030" id28 -->
134- 支持的数据类型<a id="li12616155731720"></a>135- 支持的数据类型<a id="li12616155731720"></a>
135 136 
136 <!-- npu="950" id14 -->137 <!-- npu="950" id14 -->
@@ -182,6 +183,9 @@ __aicore__ inline void GetTensorC(const LocalTensor<DstT>& c, uint8_t enAtomic =
182 <!-- npu="310b" id23 -->183 <!-- npu="310b" id23 -->
183 Atlas 200I/500 A2 推理产品,支持的数据类型为:ND、NZ。184 Atlas 200I/500 A2 推理产品,支持的数据类型为:ND、NZ。
184 <!-- end id23 -->185 <!-- end id23 -->
186+<!-- end id28 -->
187+ 
188+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/GetTensorC_res.md#id2 -->
185 189 
186## 调用示例190## 调用示例
187 191 
@@ -66,6 +66,7 @@ template <bool sync = true> __aicore__ inline void IterateAll(const LocalTensor<
66## 约束说明66## 约束说明
67 67 
68- 传入的C矩阵地址空间大小需要保证不小于singleCoreM \* singleCoreN个元素。68- 传入的C矩阵地址空间大小需要保证不小于singleCoreM \* singleCoreN个元素。
69+<!-- npu="950,A3,910b,310p,310b,x90" id18 -->
69- 支持的数据类型<a id="li12616155731720"></a>70- 支持的数据类型<a id="li12616155731720"></a>
70 71 
71 <!-- npu="950" id9 -->72 <!-- npu="950" id9 -->
@@ -92,6 +93,10 @@ template <bool sync = true> __aicore__ inline void IterateAll(const LocalTensor<
92 Kirin X90,支持的数据类型为:half、int8_t、int32_t。93 Kirin X90,支持的数据类型为:half、int8_t、int32_t。
93 <!-- end id2 -->94 <!-- end id2 -->
94 95 
96+<!-- end id18 -->
97+ 
98+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/IterateAll_res.md#id2 -->
99+ 
95## 调用示例100## 调用示例
96 101 
97IterateAll接口的调用示例如下。102IterateAll接口的调用示例如下。
@@ -152,6 +152,7 @@
152- Atlas 推理系列产品AI Core上,Bias不支持复用,Bias的shape大小必须为Batch \* N。152- Atlas 推理系列产品AI Core上,Bias不支持复用,Bias的shape大小必须为Batch \* N。
153<!-- end id12 -->153<!-- end id12 -->
154- 使用该接口时,A矩阵、B矩阵不支持int4b\_t类型的输入,即BatchMatmul不支持int4b\_t类型的矩阵输入。154- 使用该接口时,A矩阵、B矩阵不支持int4b\_t类型的输入,即BatchMatmul不支持int4b\_t类型的矩阵输入。
155+<!-- npu="950,A3,910b,310p,x90" id17 -->
155- 支持的数据类型<a id="li12616155731722"></a>156- 支持的数据类型<a id="li12616155731722"></a>
156 157 
157 <!-- npu="950" id13 -->158 <!-- npu="950" id13 -->
@@ -173,6 +174,9 @@
173 <!-- npu="x90" id2 -->174 <!-- npu="x90" id2 -->
174 Kirin X90,支持的数据类型为:half、int32_t。175 Kirin X90,支持的数据类型为:half、int32_t。
175 <!-- end id2 -->176 <!-- end id2 -->
177+<!-- end id17 -->
178+ 
179+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/IterateBatch_res.md#id2 -->
176 180 
177## 调用示例181## 调用示例
178 182 
@@ -74,6 +74,8 @@ __aicore__ inline void IterateNBatch(const uint32_t batchLoop, uint32_t batchA,
74- 当开启MixDualMaster(双主模式)场景时,即模板参数[enableMixDualMaster](MatmulConfig.md#matmulconfig-params)设置为true,不支持使用该接口。74- 当开启MixDualMaster(双主模式)场景时,即模板参数[enableMixDualMaster](MatmulConfig.md#matmulconfig-params)设置为true,不支持使用该接口。
75- 当使用ND格式输入,且单个BMM内A或B矩阵的[源矩阵内轴](IterateBatch.md#row_width)大于65535时,需在MatmulConfig中设置intrinsicsCheck为true。开启此选项后,API会将一次从Global Memory到L1 Buffer的ND2NZ搬运操作拆分为多次循环搬运,从而避免单次搬运指令参数超限。75- 当使用ND格式输入,且单个BMM内A或B矩阵的[源矩阵内轴](IterateBatch.md#row_width)大于65535时,需在MatmulConfig中设置intrinsicsCheck为true。开启此选项后,API会将一次从Global Memory到L1 Buffer的ND2NZ搬运操作拆分为多次循环搬运,从而避免单次搬运指令参数超限。
76 76 
77+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/IterateNBatch_res.md#id2 -->
78+ 
77## 调用示例79## 调用示例
78 80 
79实例功能:完成aGM、bGM矩阵乘,结果保存到cGm上,其中aGM数据的layout格式为BSNGD,bGM数据的layout格式为BSNGD,cGM的layout格式为BNGS1S2,左矩阵每次计算batchA个SD数据,右矩阵每次计算batchB个SD数据。81实例功能:完成aGM、bGM矩阵乘,结果保存到cGm上,其中aGM数据的layout格式为BSNGD,bGM数据的layout格式为BSNGD,cGM的layout格式为BNGS1S2,左矩阵每次计算batchA个SD数据,右矩阵每次计算batchB个SD数据。
@@ -74,3 +74,5 @@
74| bmmOutMode | 预留参数,默认值为BatchOutMode::SINGLE_BATCH。 | 预留参数 |74| bmmOutMode | 预留参数,默认值为BatchOutMode::SINGLE_BATCH。 | 预留参数 |
75| enableL1BankConflictOptimise<a name="p84588523128"></a> | 是否开启L1上的Bank冲突优化。在Tiling侧调用[EnableL1BankConflictOptimise](../Matmul_Tiling/EnableL1BankConflictOptimise.md)接口获取能否开启该优化的结果,并与TilingKey机制配合使用,在核函数(Kernel)侧增加代码实现分支。若开启该优化,基于相同Tiling参数执行Matmul计算时,对A、B矩阵和MxMatmul场景的ScaleA、ScaleB矩阵不再连续分配L1 Buffer的空间,在DoubleBuffer场景下,并行计算的数据分别被分配在L1 Buffer的上半部空间和下半部空间,非DoubleBuf场景,数据被分配在L1 Buffer的上半部空间;另外,Bias被分配在L1 Buffer的上半部空间,向量的量化/反量化场景的量化系数被分配在L1 Buffer的下半部空间。参数取值如下。<br>false:默认值,关闭L1 Bank冲突优化。true:开启L1 Bank冲突优化。<!-- npu="950" id89 --><br><br>除MxMatmul场景外,Ascend 950PR/Ascend 950DT支持该参数。<!-- end id89 --><!-- npu="A3" id107 --><br><br>Atlas A3 训练系列产品/Atlas A3 推理系列产品不支持该参数。<!-- end id107 --><!-- npu="910b" id125 --><br><br>Atlas A2 训练系列产品/Atlas A2 推理系列产品不支持该参数。<!-- end id125 --><!-- npu="310p" id143 --><br><br>Atlas 推理系列产品AI Core不支持该参数。<!-- end id143 --><!-- npu="310b" id161 --><br><br>Atlas 200I/500 A2 推理产品不支持该参数。<!-- end id161 --><!-- npu="x90" id55 --><br><br>Kirin X90不支持此参数。<!-- end id55 --><!-- npu="9030" id56 --><br><br>Kirin 9030不支持此参数。<!-- end id56 --> | MDL |75| enableL1BankConflictOptimise<a name="p84588523128"></a> | 是否开启L1上的Bank冲突优化。在Tiling侧调用[EnableL1BankConflictOptimise](../Matmul_Tiling/EnableL1BankConflictOptimise.md)接口获取能否开启该优化的结果,并与TilingKey机制配合使用,在核函数(Kernel)侧增加代码实现分支。若开启该优化,基于相同Tiling参数执行Matmul计算时,对A、B矩阵和MxMatmul场景的ScaleA、ScaleB矩阵不再连续分配L1 Buffer的空间,在DoubleBuffer场景下,并行计算的数据分别被分配在L1 Buffer的上半部空间和下半部空间,非DoubleBuf场景,数据被分配在L1 Buffer的上半部空间;另外,Bias被分配在L1 Buffer的上半部空间,向量的量化/反量化场景的量化系数被分配在L1 Buffer的下半部空间。参数取值如下。<br>false:默认值,关闭L1 Bank冲突优化。true:开启L1 Bank冲突优化。<!-- npu="950" id89 --><br><br>除MxMatmul场景外,Ascend 950PR/Ascend 950DT支持该参数。<!-- end id89 --><!-- npu="A3" id107 --><br><br>Atlas A3 训练系列产品/Atlas A3 推理系列产品不支持该参数。<!-- end id107 --><!-- npu="910b" id125 --><br><br>Atlas A2 训练系列产品/Atlas A2 推理系列产品不支持该参数。<!-- end id125 --><!-- npu="310p" id143 --><br><br>Atlas 推理系列产品AI Core不支持该参数。<!-- end id143 --><!-- npu="310b" id161 --><br><br>Atlas 200I/500 A2 推理产品不支持该参数。<!-- end id161 --><!-- npu="x90" id55 --><br><br>Kirin X90不支持此参数。<!-- end id55 --><!-- npu="9030" id56 --><br><br>Kirin 9030不支持此参数。<!-- end id56 --> | MDL |
76| enableRelu | 是否开启对矩阵乘的输出矩阵C做Relu修正。开启该功能后,输出矩阵中负数值被修正为0。参数取值如下。<br>false:默认值,关闭对输出矩阵C的Relu修正功能。true:开启对输出矩阵C的Relu修正功能。<!-- npu="950" id90 --><br><br>除MxMatmul场景外,Ascend 950PR/Ascend 950DT支持该参数。<!-- end id90 --><!-- npu="A3" id108 --><br><br>Atlas A3 训练系列产品/Atlas A3 推理系列产品不支持该参数。<!-- end id108 --><!-- npu="910b" id126 --><br><br>Atlas A2 训练系列产品/Atlas A2 推理系列产品不支持该参数。<!-- end id126 --><!-- npu="310p" id144 --><br><br>Atlas 推理系列产品AI Core不支持该参数。<!-- end id144 --><!-- npu="310b" id162 --><br><br>Atlas 200I/500 A2 推理产品不支持该参数。<!-- end id162 --><!-- npu="x90" id57 --><br><br>Kirin X90不支持此参数。<!-- end id57 --><!-- npu="9030" id58 --><br><br>Kirin 9030不支持此参数。<!-- end id58 --> | 所有模板 |76| enableRelu | 是否开启对矩阵乘的输出矩阵C做Relu修正。开启该功能后,输出矩阵中负数值被修正为0。参数取值如下。<br>false:默认值,关闭对输出矩阵C的Relu修正功能。true:开启对输出矩阵C的Relu修正功能。<!-- npu="950" id90 --><br><br>除MxMatmul场景外,Ascend 950PR/Ascend 950DT支持该参数。<!-- end id90 --><!-- npu="A3" id108 --><br><br>Atlas A3 训练系列产品/Atlas A3 推理系列产品不支持该参数。<!-- end id108 --><!-- npu="910b" id126 --><br><br>Atlas A2 训练系列产品/Atlas A2 推理系列产品不支持该参数。<!-- end id126 --><!-- npu="310p" id144 --><br><br>Atlas 推理系列产品AI Core不支持该参数。<!-- end id144 --><!-- npu="310b" id162 --><br><br>Atlas 200I/500 A2 推理产品不支持该参数。<!-- end id162 --><!-- npu="x90" id57 --><br><br>Kirin X90不支持此参数。<!-- end id57 --><!-- npu="9030" id58 --><br><br>Kirin 9030不支持此参数。<!-- end id58 --> | 所有模板 |
77+ 
78+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/MatmulConfig_res.md#id1 -->
@@ -38,6 +38,7 @@
38 38 
39 <!-- npu="310b" id11 -->针对Atlas 200I/500 A2 推理产品,当前只支持使用默认的Norm模板。<!-- end id11 -->39 <!-- npu="310b" id11 -->针对Atlas 200I/500 A2 推理产品,当前只支持使用默认的Norm模板。<!-- end id11 -->
40 40 
41+<!-- npu="950,A3,910b,310p,310b,x90" id20 -->
41<a id="matmul-callback-func"></a>42<a id="matmul-callback-func"></a>
42 43 
43- MatmulCallBackFunc回调函数信息(可选),用于配置A矩阵从GM拷贝到L1 Buffer(A1)、B矩阵从GM拷贝到L1 Buffer(B1)、计算结果从L0C Buffer(CO1)拷贝到GM的自定义函数。当前支持如下产品型号:44- MatmulCallBackFunc回调函数信息(可选),用于配置A矩阵从GM拷贝到L1 Buffer(A1)、B矩阵从GM拷贝到L1 Buffer(B1)、计算结果从L0C Buffer(CO1)拷贝到GM的自定义函数。当前支持如下产品型号:
@@ -75,6 +76,7 @@
75 <!-- npu="x90" id4 -->76 <!-- npu="x90" id4 -->
76 Kirin X9077 Kirin X90
77 <!-- end id4 -->78 <!-- end id4 -->
79+<!-- end id20 -->
78 80 
79## 函数原型81## 函数原型
80 82 
@@ -65,14 +65,15 @@ Matmul的计算公式为:C = A \* B + Bias,其示意图如下。
65 <a name="table1188045714378"></a>65 <a name="table1188045714378"></a>
66 | 参数 | 说明 |66 | 参数 | 说明 |
67 | --- | --- |67 | --- | --- |
68- | POSITION | 内存逻辑位置。<!-- npu="950" id15 --><br><br>针对Ascend 950PR/Ascend 950DT:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>Bias可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>C矩阵可设置为TPosition::GM,TPosition::VECIN<br> 注意,A矩阵、B矩阵或Bias矩阵设置为TPosition::VECOUT或TPosition::TSCM时,对应矩阵用于单核计算的数据必须全部在Unified Buffer(UB)或L1 Buffer上,具体样例请参考[matmul_vecout样例](../../../../../../../examples/01_simd_cpp_api/04_advanced_api/00_matmul/matmul_vecout)、[自定义数据来源为VECOUT的TSCM输入的Matmul算子样例](../../../../../../../examples/01_simd_cpp_api/04_advanced_api/00_matmul/matmul_tscm_src_vecout)、[自定义数据来源为GM的TSCM输入的Matmul算子样例](../../../../../../../examples/01_simd_cpp_api/04_advanced_api/00_matmul/matmul_tscm)。<!-- end id15 --><!-- npu="A3" id16 --><br><br>针对Atlas A3 训练系列产品/Atlas A3 推理系列产品:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>Bias可设置为TPosition::GM,TPosition::VECOUT<br>C矩阵可设置为TPosition::GM,TPosition::VECIN, TPosition::CO1<br> 注意,C矩阵设置为TPosition::CO1时,C矩阵的数据排布格式仅支持CubeFormat::NZ,C矩阵的数据类型仅支持float、int32_t。<!-- end id16 --><!-- npu="910b" id17 --><br> <br>针对Atlas A2 训练系列产品/Atlas A2 推理系列产品:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>Bias可设置为TPosition::GM,TPosition::VECOUT<br>C矩阵可设置为TPosition::GM,TPosition::VECIN, TPosition::CO1<br> 注意,C矩阵设置为TPosition::CO1时,C矩阵的数据排布格式仅支持CubeFormat::NZ,C矩阵的数据类型仅支持float、int32_t。<!-- end id17 --><!-- npu="310p" id18 --><br><br>针对Atlas 推理系列产品AI Core:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT<br>Bias可设置为TPosition::GM,TPosition::VECOUT<br>C矩阵可设置为TPosition::GM,TPosition::VECIN<!-- end id18 --><!-- npu="310b" id19 --><br> <br>针对Atlas 200I/500 A2 推理产品:<br> A矩阵可设置为TPosition::GM<br>B矩阵可设置为TPosition::GM<br>Bias可设置为TPosition::GM<br>C矩阵可设置为TPosition::GM<!-- end id19 --><!-- npu="x90" id1 --><br> <br>针对Kirin X90:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT, TPosition::TSCM<br>Bias可设置为TPosition::GM,TPosition::VECOUT<br>C矩阵可设置为TPosition::GM,TPosition::CO1<!-- end id1 --><!-- npu="9030" id2 --><br> <br>针对Kirin 9030:<br> A矩阵可设置为TPosition::TSCM<br>B矩阵可设置为TPosition::TSCM<br>Bias可设置为TPosition::GM<br>C矩阵可设置为TPosition::GM<!-- end id2 --> |68+ | POSITION | 内存逻辑位置。<!-- npu="950" id15 --><br><br>针对Ascend 950PR/Ascend 950DT:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>Bias可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>C矩阵可设置为TPosition::GM,TPosition::VECIN<br> 注意,A矩阵、B矩阵或Bias矩阵设置为TPosition::VECOUT或TPosition::TSCM时,对应矩阵用于单核计算的数据必须全部在Unified Buffer(UB)或L1 Buffer上,具体样例请参考[matmul_vecout样例](../../../../../../../examples/01_simd_cpp_api/04_advanced_api/00_matmul/matmul_vecout)、[自定义数据来源为VECOUT的TSCM输入的Matmul算子样例](../../../../../../../examples/01_simd_cpp_api/04_advanced_api/00_matmul/matmul_tscm_src_vecout)、[自定义数据来源为GM的TSCM输入的Matmul算子样例](../../../../../../../examples/01_simd_cpp_api/04_advanced_api/00_matmul/matmul_tscm)。<!-- end id15 --><!-- npu="A3" id16 --><br><br>针对Atlas A3 训练系列产品/Atlas A3 推理系列产品:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>Bias可设置为TPosition::GM,TPosition::VECOUT<br>C矩阵可设置为TPosition::GM,TPosition::VECIN, TPosition::CO1<br> 注意,C矩阵设置为TPosition::CO1时,C矩阵的数据排布格式仅支持CubeFormat::NZ,C矩阵的数据类型仅支持float、int32_t。<!-- end id16 --><!-- npu="910b" id17 --><br> <br>针对Atlas A2 训练系列产品/Atlas A2 推理系列产品:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>Bias可设置为TPosition::GM,TPosition::VECOUT<br>C矩阵可设置为TPosition::GM,TPosition::VECIN, TPosition::CO1<br> 注意,C矩阵设置为TPosition::CO1时,C矩阵的数据排布格式仅支持CubeFormat::NZ,C矩阵的数据类型仅支持float、int32_t。<!-- end id17 --><!-- npu="310p" id18 --><br><br>针对Atlas 推理系列产品AI Core:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT<br>Bias可设置为TPosition::GM,TPosition::VECOUT<br>C矩阵可设置为TPosition::GM,TPosition::VECIN<!-- end id18 --><!-- npu="310b" id19 --><br> <br>针对Atlas 200I/500 A2 推理产品:<br> A矩阵可设置为TPosition::GM<br>B矩阵可设置为TPosition::GM<br>Bias可设置为TPosition::GM<br>C矩阵可设置为TPosition::GM<!-- end id19 --><!-- npu="x90" id1 --><br> <br>针对Kirin X90:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT,TPosition::TSCM<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT, TPosition::TSCM<br>Bias可设置为TPosition::GM,TPosition::VECOUT<br>C矩阵可设置为TPosition::GM,TPosition::CO1<!-- end id1 --><!-- npu="9030" id2 --><br> <br>针对Kirin 9030:<br> A矩阵可设置为TPosition::TSCM<br>B矩阵可设置为TPosition::TSCM<br>Bias可设置为TPosition::GM<br>C矩阵可设置为TPosition::GM<!-- end id2 --> <!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/Matmul_usage_res.md#id1 -->|
69- | FORMAT | 数据的物理排布格式。<!-- npu="950" id20 --><br><br>针对Ascend 950PR/Ascend 950DT:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::COLUMN_MAJOR,CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::COLUMN_MAJOR<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN,CubeFormat::COLUMN_MAJOR<br> <br>针对Ascend 950PR/Ascend 950DT,请注意:<br> 仅在非MxMatmul场景中,A、B、C矩阵Format支持CubeFormat::COLUMN_MAJOR。当Format为CubeFormat::COLUMN_MAJOR时,对应矩阵仅支持内存逻辑位置为TPosition::GM。<br>输入A矩阵或B矩阵设置为TPosition::TSCM时,对应的Format仅支持CubeFormat::NZ。<br>C矩阵设置为TPosition::VECIN,CubeFormat::ND时,要求尾轴32字节对齐,比如数据类型是half的情况下,N要求是16的倍数。<!-- end id20 --><!-- npu="A3" id21 --><br> <br>针对Atlas A3 训练系列产品/Atlas A3 推理系列产品:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ, CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN<!-- end id21 --><!-- npu="910b" id22 --><br> <br>针对Atlas A2 训练系列产品/Atlas A2 推理系列产品:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ, CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN<!-- end id22 --><!-- npu="310p" id23 --><br> <br>针对Atlas 推理系列产品AI Core:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN<br> 注意:针对Atlas 推理系列产品AI Core,C矩阵设置为CubeFormat::ND时,要求尾轴32字节对齐,比如数据类型是half的情况下,N要求是16的倍数。<!-- end id23 --><!-- npu="310b" id24 --><br> <br>针对Atlas 200I/500 A2 推理产品:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ<!-- end id24 --><!-- npu="x90" id3 --><br> <br>针对Kirin X90:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ, CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN<!-- end id3 --><!-- npu="9030" id4 --><br> <br>针对Kirin 9030:<br>A矩阵可设置为CubeFormat::NZ,CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND<!-- end id4 --><!-- npu="310b" id25 --><br><br>注意: 针对Atlas 200I/500 A2 推理产品,C矩阵设置为TPosition::VECIN或者TPosition::TSCM,CubeFormat::ND时,要求尾轴32字节对齐,比如数据类型是half的情况下,N要求是16的倍数;C矩阵设置为TPosition::VECIN或者TPosition::TSCM,CubeFormat::NZ时,N要求是16的倍数。<!-- end id25 --><br> <br>关于CubeFormat::NZ格式的A矩阵、B矩阵、C矩阵的对齐约束,请参考[表3](#table98851538118)。 |69+ | FORMAT | 数据的物理排布格式。<!-- npu="950" id20 --><br><br>针对Ascend 950PR/Ascend 950DT:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::COLUMN_MAJOR,CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::COLUMN_MAJOR<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN,CubeFormat::COLUMN_MAJOR<br> <br>针对Ascend 950PR/Ascend 950DT,请注意:<br> 仅在非MxMatmul场景中,A、B、C矩阵Format支持CubeFormat::COLUMN_MAJOR。当Format为CubeFormat::COLUMN_MAJOR时,对应矩阵仅支持内存逻辑位置为TPosition::GM。<br>输入A矩阵或B矩阵设置为TPosition::TSCM时,对应的Format仅支持CubeFormat::NZ。<br>C矩阵设置为TPosition::VECIN,CubeFormat::ND时,要求尾轴32字节对齐,比如数据类型是half的情况下,N要求是16的倍数。<!-- end id20 --><!-- npu="A3" id21 --><br> <br>针对Atlas A3 训练系列产品/Atlas A3 推理系列产品:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ, CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN<!-- end id21 --><!-- npu="910b" id22 --><br> <br>针对Atlas A2 训练系列产品/Atlas A2 推理系列产品:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ, CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN<!-- end id22 --><!-- npu="310p" id23 --><br> <br>针对Atlas 推理系列产品AI Core:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN<br> 注意:针对Atlas 推理系列产品AI Core,C矩阵设置为CubeFormat::ND时,要求尾轴32字节对齐,比如数据类型是half的情况下,N要求是16的倍数。<!-- end id23 --><!-- npu="310b" id24 --><br> <br>针对Atlas 200I/500 A2 推理产品:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ<!-- end id24 --><!-- npu="x90" id3 --><br> <br>针对Kirin X90:<br> A矩阵可设置为CubeFormat::ND,CubeFormat::NZ, CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::ND,CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND,CubeFormat::NZ,CubeFormat::ND_ALIGN<!-- end id3 --><!-- npu="9030" id4 --><br> <br>针对Kirin 9030:<br>A矩阵可设置为CubeFormat::NZ,CubeFormat::VECTOR<br>B矩阵可设置为CubeFormat::NZ<br>Bias可设置为CubeFormat::ND<br>C矩阵可设置为CubeFormat::ND<!-- end id4 --><!-- npu="310b" id25 --><br><br>注意: 针对Atlas 200I/500 A2 推理产品,C矩阵设置为TPosition::VECIN或者TPosition::TSCM,CubeFormat::ND时,要求尾轴32字节对齐,比如数据类型是half的情况下,N要求是16的倍数;C矩阵设置为TPosition::VECIN或者TPosition::TSCM,CubeFormat::NZ时,N要求是16的倍数。<!-- end id25 --><!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/Matmul_usage_res.md#id2 --><br> <br>关于CubeFormat::NZ格式的A矩阵、B矩阵、C矩阵的对齐约束,请参考[表3](#table98851538118)。 |
70- | TYPE | 数据类型。<!-- npu="950" id26 --><br><br>针对Ascend 950PR/Ascend 950DT:<br> 1、非MxMatmul场景:<br>A矩阵可设置为half、float、bfloat16_t 、int8_t、fp8_e4m3fn_t、fp8_e5m2_t、hifloat8_t<br>B矩阵可设置为half、float、bfloat16_t 、int8_t、fp8_e4m3fn_t、fp8_e5m2_t、hifloat8_t<br>Bias可设置为half、float、int32_t、bfloat16_t<br>C矩阵可设置为half、float、bfloat16_t、int32_t、int8_t、fp8_e4m3fn_t、hifloat8_t<br> 2、MxMatmul场景:<br>A矩阵可设置为fp8_e4m3fn_t、fp8_e5m2_t、fp4x2_e2m1_t、fp4x2_e1m2_t<br>B矩阵可设置为fp8_e4m3fn_t、fp8_e5m2_t、fp4x2_e2m1_t、fp4x2_e1m2_t<br>Bias可设置为half、float、bfloat16_t<br>C矩阵可设置为half、float、bfloat16_t<!-- end id26 --><!-- npu="A3" id27 --><br> <br>针对Atlas A3 训练系列产品/Atlas A3 推理系列产品:<br>A矩阵可设置为half、float、bfloat16_t 、int8_t、int4b_t<br>B矩阵可设置为half、float、bfloat16_t 、int8_t、int4b_t<br>Bias可设置为half、float、int32_t<br>C矩阵可设置为half、float、bfloat16_t、int32_t、int8_t<!-- end id27 --><!-- npu="910b" id28 --><br> <br>针对Atlas A2 训练系列产品/Atlas A2 推理系列产品:<br>A矩阵可设置为half、float、bfloat16_t 、int8_t、int4b_t<br>B矩阵可设置为half、float、bfloat16_t 、int8_t、int4b_t<br>Bias可设置为half、float、int32_t<br>C矩阵可设置为half、float、bfloat16_t、int32_t、int8_t<!-- end id28 --><!-- npu="310p" id29 --><br><br>针对Atlas 推理系列产品AI Core:<br> A矩阵可设置为half、int8_t<br>B矩阵可设置为half、int8_t<br>Bias可设置为float、int32_t<br>C矩阵可设置为half、float、int8_t、int32_t<!-- end id29 --><!-- npu="310b" id30 --><br> <br>针对Atlas 200I/500 A2 推理产品:<br> A矩阵可设置为half、float、bfloat16_t 、int8_t<br>B矩阵可设置为half、float、bfloat16_t 、int8_t<br>Bias矩阵可设置为half、float、int32_t<br>C矩阵可设置为half、float、bfloat16_t、int32_t<!-- end id30 --><!-- npu="x90" id5 --><br> <br>针对Kirin X90:<br> A矩阵可设置为half、int8_t<br>B矩阵可设置为half、int8_t<br>Bias可设置为half、int32_t<br>C矩阵可设置为half、int32_t、int8_t<!-- end id5 --><!-- npu="9030" id6 --><br> <br>针对Kirin 9030:<br> A矩阵可设置为half<br>B矩阵可设置为half<br>Bias可设置为half<br>C矩阵可设置为half<!-- end id6 --><br>注意:除fp8_e4m3fn_t/fp8_e5m2_t两种数据类型、B矩阵为int8_t数据类型外,A矩阵和B矩阵数据类型需要一致,具体数据类型组合关系请参考[表2](#table1996113269499)。A矩阵和B矩阵为int4b_t数据类型时,矩阵内轴的数据个数必须为偶数。例如,A矩阵为int4b_t数据类型且不转置时,[singleCoreK](../Matmul_Tiling/TCubeTiling_struct.md#p11899125875617)必须是偶数。 |70+ | TYPE | 数据类型。<!-- npu="950" id26 --><br><br>针对Ascend 950PR/Ascend 950DT:<br> 1、非MxMatmul场景:<br>A矩阵可设置为half、float、bfloat16_t 、int8_t、fp8_e4m3fn_t、fp8_e5m2_t、hifloat8_t<br>B矩阵可设置为half、float、bfloat16_t 、int8_t、fp8_e4m3fn_t、fp8_e5m2_t、hifloat8_t<br>Bias可设置为half、float、int32_t、bfloat16_t<br>C矩阵可设置为half、float、bfloat16_t、int32_t、int8_t、fp8_e4m3fn_t、hifloat8_t<br> 2、MxMatmul场景:<br>A矩阵可设置为fp8_e4m3fn_t、fp8_e5m2_t、fp4x2_e2m1_t、fp4x2_e1m2_t<br>B矩阵可设置为fp8_e4m3fn_t、fp8_e5m2_t、fp4x2_e2m1_t、fp4x2_e1m2_t<br>Bias可设置为half、float、bfloat16_t<br>C矩阵可设置为half、float、bfloat16_t<!-- end id26 --><!-- npu="A3" id27 --><br> <br>针对Atlas A3 训练系列产品/Atlas A3 推理系列产品:<br>A矩阵可设置为half、float、bfloat16_t 、int8_t、int4b_t<br>B矩阵可设置为half、float、bfloat16_t 、int8_t、int4b_t<br>Bias可设置为half、float、int32_t<br>C矩阵可设置为half、float、bfloat16_t、int32_t、int8_t<!-- end id27 --><!-- npu="910b" id28 --><br> <br>针对Atlas A2 训练系列产品/Atlas A2 推理系列产品:<br>A矩阵可设置为half、float、bfloat16_t 、int8_t、int4b_t<br>B矩阵可设置为half、float、bfloat16_t 、int8_t、int4b_t<br>Bias可设置为half、float、int32_t<br>C矩阵可设置为half、float、bfloat16_t、int32_t、int8_t<!-- end id28 --><!-- npu="310p" id29 --><br><br>针对Atlas 推理系列产品AI Core:<br> A矩阵可设置为half、int8_t<br>B矩阵可设置为half、int8_t<br>Bias可设置为float、int32_t<br>C矩阵可设置为half、float、int8_t、int32_t<!-- end id29 --><!-- npu="310b" id30 --><br> <br>针对Atlas 200I/500 A2 推理产品:<br> A矩阵可设置为half、float、bfloat16_t 、int8_t<br>B矩阵可设置为half、float、bfloat16_t 、int8_t<br>Bias矩阵可设置为half、float、int32_t<br>C矩阵可设置为half、float、bfloat16_t、int32_t<!-- end id30 --><!-- npu="x90" id5 --><br> <br>针对Kirin X90:<br> A矩阵可设置为half、int8_t<br>B矩阵可设置为half、int8_t<br>Bias可设置为half、int32_t<br>C矩阵可设置为half、int32_t、int8_t<!-- end id5 --><!-- npu="9030" id6 --><br> <br>针对Kirin 9030:<br> A矩阵可设置为half<br>B矩阵可设置为half<br>Bias可设置为half<br>C矩阵可设置为half<!-- end id6 --><!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/Matmul_usage_res.md#id3 --><br>注意:除fp8_e4m3fn_t/fp8_e5m2_t两种数据类型、B矩阵为int8_t数据类型外,A矩阵和B矩阵数据类型需要一致,具体数据类型组合关系请参考[表2](#table1996113269499)。A矩阵和B矩阵为int4b_t数据类型时,矩阵内轴的数据个数必须为偶数。例如,A矩阵为int4b_t数据类型且不转置时,[singleCoreK](../Matmul_Tiling/TCubeTiling_struct.md#p11899125875617)必须是偶数。 |
71 | ISTRANS | 是否开启支持矩阵转置的功能。<br> true:开启支持矩阵转置的功能,运行时可以分别通过[SetTensorA](SetTensorA.md)和[SetTensorB](SetTensorB.md)中的isTransposeA、isTransposeB参数设置A、B矩阵是否转置。若设置A、B矩阵转置,Matmul会认为A矩阵形状为[K, M],B矩阵形状为[N, K]。<br>false:默认值,不开启支持矩阵转置的功能,通过[SetTensorA](SetTensorA.md)和[SetTensorB](SetTensorB.md)不能设置A、B矩阵的转置情况。Matmul会认为A矩阵形状为[M, K],B矩阵形状为[K, N]。<br> <br>注意,由于L1 Buffer上的矩阵数据有分形对齐的约束,A、B矩阵转置和不转置时所需的L1空间可能不相同,在开启支持矩阵转置功能时,必须保证按照[Matmul Tiling参数](../Matmul_Tiling/TCubeTiling_struct.md)申请的L1空间不超过L1 Buffer的规格,判断方式为(depthA1*Ceil(baseM/c0Size)*baseK + depthB1*Ceil(baseN/c0Size)*baseK) * db * sizeof(dtype) < L1Size,db表示L1是否开启double buffer,取值1(不开启double buffer)或2(开启double buffer),其余参数的含义请参考[表1](../Matmul_Tiling/TCubeTiling_struct.md#tcubetiling-struct)。<!-- npu="9030" id7 --><br> <br>Kirin 9030不支持此参数。<!-- end id7 --> |71 | ISTRANS | 是否开启支持矩阵转置的功能。<br> true:开启支持矩阵转置的功能,运行时可以分别通过[SetTensorA](SetTensorA.md)和[SetTensorB](SetTensorB.md)中的isTransposeA、isTransposeB参数设置A、B矩阵是否转置。若设置A、B矩阵转置,Matmul会认为A矩阵形状为[K, M],B矩阵形状为[N, K]。<br>false:默认值,不开启支持矩阵转置的功能,通过[SetTensorA](SetTensorA.md)和[SetTensorB](SetTensorB.md)不能设置A、B矩阵的转置情况。Matmul会认为A矩阵形状为[M, K],B矩阵形状为[K, N]。<br> <br>注意,由于L1 Buffer上的矩阵数据有分形对齐的约束,A、B矩阵转置和不转置时所需的L1空间可能不相同,在开启支持矩阵转置功能时,必须保证按照[Matmul Tiling参数](../Matmul_Tiling/TCubeTiling_struct.md)申请的L1空间不超过L1 Buffer的规格,判断方式为(depthA1*Ceil(baseM/c0Size)*baseK + depthB1*Ceil(baseN/c0Size)*baseK) * db * sizeof(dtype) < L1Size,db表示L1是否开启double buffer,取值1(不开启double buffer)或2(开启double buffer),其余参数的含义请参考[表1](../Matmul_Tiling/TCubeTiling_struct.md#tcubetiling-struct)。<!-- npu="9030" id7 --><br> <br>Kirin 9030不支持此参数。<!-- end id7 --> |
72 | LAYOUT | 表征数据的排布。<br> <br>NONE:默认值,表示不使用BatchMatmul;其他选项表示使用BatchMatmul。<br> <br>NORMAL:BMNK的数据排布格式,具体可参考[IterateBatch](IterateBatch.md#功能说明)中对该数据排布的介绍。<br> <br>BSNGD:原始BSH shape做reshape后的数据排布,具体可参考[IterateBatch](IterateBatch.md#功能说明)中对该数据排布的介绍。<br> <br>SBNGD:原始SBH shape做reshape后的数据排布,具体可参考[IterateBatch](IterateBatch.md#功能说明)中对该数据排布的介绍。<br> <br>BNGS1S2:一般为前两种数据排布进行矩阵乘的输出,S1S2数据连续存放,一个S1S2为一个batch的计算数据,具体可参考[IterateBatch](IterateBatch.md#功能说明)中对该数据排布的介绍。<!-- npu="9030" id8 --><br> <br>Kirin 9030不支持此参数。<!-- end id8 --> |72 | LAYOUT | 表征数据的排布。<br> <br>NONE:默认值,表示不使用BatchMatmul;其他选项表示使用BatchMatmul。<br> <br>NORMAL:BMNK的数据排布格式,具体可参考[IterateBatch](IterateBatch.md#功能说明)中对该数据排布的介绍。<br> <br>BSNGD:原始BSH shape做reshape后的数据排布,具体可参考[IterateBatch](IterateBatch.md#功能说明)中对该数据排布的介绍。<br> <br>SBNGD:原始SBH shape做reshape后的数据排布,具体可参考[IterateBatch](IterateBatch.md#功能说明)中对该数据排布的介绍。<br> <br>BNGS1S2:一般为前两种数据排布进行矩阵乘的输出,S1S2数据连续存放,一个S1S2为一个batch的计算数据,具体可参考[IterateBatch](IterateBatch.md#功能说明)中对该数据排布的介绍。<!-- npu="9030" id8 --><br> <br>Kirin 9030不支持此参数。<!-- end id8 --> |
73- | IBSHARE<a name="p84551411817"></a> | 是否开启IBShare(IntraBlock Share)。IBShare的功能是能够复用L1 Buffer上相同的A矩阵或B矩阵数据,复用的矩阵必须在L1 Buffer上全载。A矩阵和B矩阵仅有一个开启IBShare的场景,与[IBShare模板](MatmulConfig.md#template-features)配合使用,具体参数设置详见[表2](MatmulConfig.md#matmulconfig-params)。<br> <br>注意,A矩阵和B矩阵同时开启IBShare的场景,表示L1 Buffer上的A矩阵和B矩阵同时复用,需要满足:<br> 同一算子中其它Matmul对象的A矩阵和B矩阵也必须同时开启IBShare;<!-- npu="910b" id90 --><br><br>Atlas A2 训练系列产品/Atlas A2 推理系列产品,获取矩阵计算结果时,只支持调用[IterateAll](IterateAll.md)接口,且只支持输出到GlobalTensor,即计算结果放置于Global Memory的地址。<!-- end id90 --><!-- npu="A3" id91 --><br><br>Atlas A3 训练系列产品/Atlas A3 推理系列产品,获取矩阵计算结果时,只支持调用[IterateAll](IterateAll.md)接口,且只支持输出到GlobalTensor,即计算结果放置于Global Memory的地址。<!-- end id91 --><!-- npu="950" id92 --><br><br>Ascend 950PR/Ascend 950DT,获取矩阵计算结果时,支持输出到GlobalTensor和LocalTensor。输出到LocalTensor,即计算结果放置于Local Memory的场景,默认实现策略与[SplitM模板策略](MatmulPolicy.md)相同,且仅支持输出数据类型为float,仅支持[Norm模板](MatmulConfig.md)。<!-- end id92 --><!-- npu="950" id31 --><br> <br>Ascend 950PR/Ascend 950DT支持该参数。<!-- end id31 --><!-- npu="A3" id32 --><br> <br>Atlas A3 训练系列产品/Atlas A3 推理系列产品支持该参数。<!-- end id32 --><!-- npu="910b" id33 --><br> <br>Atlas A2 训练系列产品/Atlas A2 推理系列产品支持该参数。<!-- end id33 --><!-- npu="310p" id34 --><br> <br>Atlas 推理系列产品AI Core不支持该参数。<!-- end id34 --><!-- npu="310b" id35 --><br> <br>Atlas 200I/500 A2 推理产品不支持该参数。<!-- end id35 --><!-- npu="x90" id9 --><br> <br>Kirin X90不支持此参数。<!-- end id9 --><!-- npu="9030" id10 --><br> <br>Kirin 9030不支持此参数。<!-- end id10 --> |73+ | IBSHARE<a name="p84551411817"></a> | 是否开启IBShare(IntraBlock Share)。IBShare的功能是能够复用L1 Buffer上相同的A矩阵或B矩阵数据,复用的矩阵必须在L1 Buffer上全载。A矩阵和B矩阵仅有一个开启IBShare的场景,与[IBShare模板](MatmulConfig.md#template-features)配合使用,具体参数设置详见[表2](MatmulConfig.md#matmulconfig-params)。<br> <br>注意,A矩阵和B矩阵同时开启IBShare的场景,表示L1 Buffer上的A矩阵和B矩阵同时复用,需要满足:<br> 同一算子中其它Matmul对象的A矩阵和B矩阵也必须同时开启IBShare;<!-- npu="910b" id90 --><br><br>Atlas A2 训练系列产品/Atlas A2 推理系列产品,获取矩阵计算结果时,只支持调用[IterateAll](IterateAll.md)接口,且只支持输出到GlobalTensor,即计算结果放置于Global Memory的地址。<!-- end id90 --><!-- npu="A3" id91 --><br><br>Atlas A3 训练系列产品/Atlas A3 推理系列产品,获取矩阵计算结果时,只支持调用[IterateAll](IterateAll.md)接口,且只支持输出到GlobalTensor,即计算结果放置于Global Memory的地址。<!-- end id91 --><!-- npu="950" id92 --><br><br>Ascend 950PR/Ascend 950DT,获取矩阵计算结果时,支持输出到GlobalTensor和LocalTensor。输出到LocalTensor,即计算结果放置于Local Memory的场景,默认实现策略与[SplitM模板策略](MatmulPolicy.md)相同,且仅支持输出数据类型为float,仅支持[Norm模板](MatmulConfig.md)。<!-- end id92 --><!-- npu="950" id31 --><br> <br>Ascend 950PR/Ascend 950DT支持该参数。<!-- end id31 --><!-- npu="A3" id32 --><br> <br>Atlas A3 训练系列产品/Atlas A3 推理系列产品支持该参数。<!-- end id32 --><!-- npu="910b" id33 --><br> <br>Atlas A2 训练系列产品/Atlas A2 推理系列产品支持该参数。<!-- end id33 --><!-- npu="310p" id34 --><br> <br>Atlas 推理系列产品AI Core不支持该参数。<!-- end id34 --><!-- npu="310b" id35 --><br> <br>Atlas 200I/500 A2 推理产品不支持该参数。<!-- end id35 --><!-- npu="x90" id9 --><br> <br>Kirin X90不支持此参数。<!-- end id9 --><!-- npu="9030" id10 --><br> <br>Kirin 9030不支持此参数。<!-- end id10 --><!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/Matmul_usage_res.md#id4 --> |
74- | SRC_POSITION | <!-- npu="950" id36 -->该参数仅支持Ascend 950PR/Ascend 950DT。<br> <br><!-- end id36 -->A/B矩阵的POSITION参数配置为TPosition::TSCM时,必须要设置TSCM中矩阵数据的来源的内存逻辑位置,默认为TPosition::GM。<!-- npu="950" id37 --><br><br>针对Ascend 950PR/Ascend 950DT:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT<!-- end id37 --> |74+ | SRC_POSITION | <!-- npu="950" id36 -->该参数仅支持Ascend 950PR/Ascend 950DT。<br> <br><!-- end id36 -->A/B矩阵的POSITION参数配置为TPosition::TSCM时,必须要设置TSCM中矩阵数据的来源的内存逻辑位置,默认为TPosition::GM。<!-- npu="950" id37 --><br><br>针对Ascend 950PR/Ascend 950DT:<br> A矩阵可设置为TPosition::GM,TPosition::VECOUT<br>B矩阵可设置为TPosition::GM,TPosition::VECOUT<!-- end id37 --> <!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/Matmul_usage_res.md#id5 -->|
75 75 
76+ <!-- npu="950,A3,910b,310p,310b,x90,9030" id102 -->
76 **表2** Matmul输入输出数据类型的支持列表77 **表2** Matmul输入输出数据类型的支持列表
77 78 
78 <a name="table1996113269499"></a>79 <a name="table1996113269499"></a>
@@ -98,6 +99,9 @@ Matmul的计算公式为:C = A \* B + Bias,其示意图如下。
98 | bfloat16_t | bfloat16_t | bfloat16_t | float/half/bfloat16_t | <!-- npu="950" id83 -->Ascend 950PR/Ascend 950DT<!-- end id83 --> |99 | bfloat16_t | bfloat16_t | bfloat16_t | float/half/bfloat16_t | <!-- npu="950" id83 -->Ascend 950PR/Ascend 950DT<!-- end id83 --> |
99 | half | half | bfloat16_t | float/half/bfloat16_t | <!-- npu="950" id84 -->Ascend 950PR/Ascend 950DT<!-- end id84 --> |100 | half | half | bfloat16_t | float/half/bfloat16_t | <!-- npu="950" id84 -->Ascend 950PR/Ascend 950DT<!-- end id84 --> |
100 | int8_t | int8_t | int32_t | bfloat16_t | <!-- npu="950" id85 -->Ascend 950PR/Ascend 950DT<!-- end id85 --> |101 | int8_t | int8_t | int32_t | bfloat16_t | <!-- npu="950" id85 -->Ascend 950PR/Ascend 950DT<!-- end id85 --> |
102+ <!-- end id102 -->
103+ 
104+ <!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/Matmul_usage_res.md#id6 -->
101 105 
1022. 初始化操作。1062. 初始化操作。
103<a name="li5878185413338"></a>107<a name="li5878185413338"></a>
@@ -155,6 +159,7 @@ Matmul的计算公式为:C = A \* B + Bias,其示意图如下。
155 <!-- npu="310b" id89 -->159 <!-- npu="310b" id89 -->
156 - Atlas 200I/500 A2 推理产品暂不支持该方式。160 - Atlas 200I/500 A2 推理产品暂不支持该方式。
157 <!-- end id89 -->161 <!-- end id89 -->
162+ <!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/Matmul_usage_res.md#id7 -->
158 163 
159 ```164 ```
160 // 定义C矩阵的类型信息165 // 定义C矩阵的类型信息
@@ -194,17 +199,43 @@ Matmul的计算公式为:C = A \* B + Bias,其示意图如下。
194 mm.End();199 mm.End();
195 ```200 ```
196 201 
197-**表3** CubeFormat::NZ格式的矩阵对齐要求
198- 
199<a name="table98851538118"></a>202<a name="table98851538118"></a>
200-| 源/目的操作数 | 外轴 | 内轴 |203+CubeFormat::NZ格式的矩阵对齐要求为:
201-| --- | --- | --- |204+- A矩阵/B矩阵:外轴为16的倍数,内轴为C0_size的倍数。
202-| A矩阵/B矩阵 | 16的倍数 | C0_size的倍数 |205+<!-- npu="310p,310b" id103 -->
203-| C矩阵 | 16的倍数 | 16的倍数 |206+对于如下产品型号:
204-| C矩阵(开启channel_split功能) | 16的倍数 | C0_size的倍数 |
205-| C矩阵(不开启channel_split功能) | 16的倍数 | float/int32_t:16的倍数<br><br>half/bfloat16_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/hifloat8_t:C0_size的倍数 |
206 207 
207-对于上表中相关参数和概念的补充说明如下:208+<!-- npu="310p" id105 -->
209+Atlas 推理系列产品AI Core
210+<!-- end id105 -->
211+ 
212+<!-- npu="310b" id106 -->
213+Atlas 200I/500 A2 推理产品
214+<!-- end id106 -->
215+ 
216+- C矩阵:外轴为16的倍数,内轴为16的倍数。
217+<!-- end id103 -->
218+<!-- npu="950,A3,910b" id104 -->
219+对于如下产品型号:
220+ 
221+<!-- npu="950" id107 -->
222+Ascend 950PR/Ascend 950DT
223+<!-- end id107 -->
224+ 
225+<!-- npu="A3" id108 -->
226+Atlas A3 训练系列产品/Atlas A3 推理系列产品
227+<!-- end id108 -->
228+ 
229+<!-- npu="910b" id109 -->
230+Atlas A2 训练系列产品/Atlas A2 推理系列产品
231+<!-- end id109 -->
232+ 
233+- C矩阵(开启channel_split功能):外轴为16的倍数,内轴为C0_size的倍数。
234+- C矩阵(不开启channel_split功能):外轴为16的倍数,对于float/int32_t类型内轴为16的倍数,对于half/bfloat16_t/int8_t/fp8_e4m3fn_t/fp8_e5m2_t/hifloat8_t类型内轴为C0_size的倍数。
235+<!-- end id104 -->
236+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/Matmul_usage_res.md#id8 -->
237+ 
238+上述参数和概念的补充说明如下:
208 239 
209- float/int32\_t数据类型的C0\_size为8,half/bfloat16\_t数据类型的C0\_size为16,int8\_t/fp8\_e4m3fn\_t/fp8\_e5m2\_t/hifloat8\_t数据类型的C0\_size为32,int4b\_t/fp4x2\_e2m1\_t/fp4x2\_e1m2\_t数据类型的C0\_size为64。240- float/int32\_t数据类型的C0\_size为8,half/bfloat16\_t数据类型的C0\_size为16,int8\_t/fp8\_e4m3fn\_t/fp8\_e5m2\_t/hifloat8\_t数据类型的C0\_size为32,int4b\_t/fp4x2\_e2m1\_t/fp4x2\_e1m2\_t数据类型的C0\_size为64。
210- channel\_split功能通过[MatmulConfig](MatmulConfig.md#matmulconfig-params)中的isEnableChannelSplit参数配置,具体内容请参考[MatmulConfig](MatmulConfig.md#matmulconfig-params)。241- channel\_split功能通过[MatmulConfig](MatmulConfig.md#matmulconfig-params)中的isEnableChannelSplit参数配置,具体内容请参考[MatmulConfig](MatmulConfig.md#matmulconfig-params)。
@@ -60,6 +60,7 @@ __aicore__ inline void SetBias(const LocalTensor<BiasT>& inputBias)
60<!-- npu="950" id13 -->60<!-- npu="950" id13 -->
61- 对于Ascend 950PR/Ascend 950DT,Bias矩阵的内存逻辑位置为TSCM且数据类型为float或int32\_t时,Bias矩阵的LocalTensor空间必须64字节对齐。61- 对于Ascend 950PR/Ascend 950DT,Bias矩阵的内存逻辑位置为TSCM且数据类型为float或int32\_t时,Bias矩阵的LocalTensor空间必须64字节对齐。
62<!-- end id13 -->62<!-- end id13 -->
63+<!-- npu="950,A3,910b,310p,310b,x90" id14 -->
63- 支持的数据类型<a id="li12616155731720"></a>64- 支持的数据类型<a id="li12616155731720"></a>
64 65 
65 <!-- npu="950" id8 -->66 <!-- npu="950" id8 -->
@@ -82,9 +83,13 @@ __aicore__ inline void SetBias(const LocalTensor<BiasT>& inputBias)
82 Atlas 200I/500 A2 推理产品,支持的数据类型为:half、float、int32_t,其中仅在A、B的数据类型为int8_t时,Bias的数据类型可以设置为int32_t。83 Atlas 200I/500 A2 推理产品,支持的数据类型为:half、float、int32_t,其中仅在A、B的数据类型为int8_t时,Bias的数据类型可以设置为int32_t。
83 <!-- end id12 -->84 <!-- end id12 -->
84 85 
85- <!-- npu="x90" id2 -->86+ <!-- npu="x90" id15 -->
86 Kirin X90,支持的数据类型为:half、int32_t,其中仅在A、B的数据类型为int8_t时,Bias的数据类型可以设置为int32_t。87 Kirin X90,支持的数据类型为:half、int32_t,其中仅在A、B的数据类型为int8_t时,Bias的数据类型可以设置为int32_t。
87- <!-- end id2 -->88+ <!-- end id15 -->
89+ 
90+<!-- end id14 -->
91+ 
92+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/SetBias_res.md#id2 -->
88 93 
89## 调用示例94## 调用示例
90 95 
@@ -73,6 +73,7 @@ Atlas 200I/500 A2 推理产品,不支持SetTensorA\(SrcAT aScalar\)接口原
73## 约束说明73## 约束说明
74 74 
75- 传入的TensorA地址空间大小需要保证不小于singleM \* singleK。75- 传入的TensorA地址空间大小需要保证不小于singleM \* singleK。
76+<!-- npu="950,A3,910b,310p,310b,x90,9030" id24 -->
76- gm和leftMatrix支持的数据类型<a id="li12616155731720"></a>77- gm和leftMatrix支持的数据类型<a id="li12616155731720"></a>
77 78 
78 <!-- npu="950" id9 -->79 <!-- npu="950" id9 -->
@@ -133,6 +134,10 @@ Atlas 200I/500 A2 推理产品,不支持SetTensorA\(SrcAT aScalar\)接口原
133 Kirin 9030,支持的数据类型为:half。134 Kirin 9030,支持的数据类型为:half。
134 <!-- end id6 -->135 <!-- end id6 -->
135 136 
137+<!-- end id24 -->
138+ 
139+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/SetTensorA_res.md#id2 -->
140+ 
136## 调用示例141## 调用示例
137 142 
138```143```
@@ -79,6 +79,7 @@ Atlas 200I/500 A2 推理产品,不支持SetTensorB\(SrcBT bScalar\)接口原
79## 约束说明79## 约束说明
80 80 
81- 传入的TensorB地址空间大小需要保证不小于singleK \* singleN。81- 传入的TensorB地址空间大小需要保证不小于singleK \* singleN。
82+<!-- npu="950,A3,910b,310p,310b,x90,9030" id25 -->
82- gm和rightMatrix支持的数据类型<a id="li12616155731720"></a>83- gm和rightMatrix支持的数据类型<a id="li12616155731720"></a>
83 84 
84 <!-- npu="950" id15 -->85 <!-- npu="950" id15 -->
@@ -139,6 +140,10 @@ Atlas 200I/500 A2 推理产品,不支持SetTensorB\(SrcBT bScalar\)接口原
139 Kirin 9030,支持的数据类型为:half。140 Kirin 9030,支持的数据类型为:half。
140 <!-- end id6 -->141 <!-- end id6 -->
141 142 
143+<!-- end id25 -->
144+ 
145+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Kernel/SetTensorB_res.md#id2 -->
146+ 
142## 调用示例147## 调用示例
143 148 
144```149```
@@ -33,6 +33,7 @@
33 explicit MultiCoreMatmulTiling(const PlatformInfo& platform)33 explicit MultiCoreMatmulTiling(const PlatformInfo& platform)
34 ```34 ```
35 35 
36+<!-- npu="A3,910b" id3 -->
36- 无参构造函数37- 无参构造函数
37 38 
38 ```39 ```
@@ -56,6 +57,7 @@
56 <!-- npu="A3" id2 -->57 <!-- npu="A3" id2 -->
57 Atlas A3 训练系列产品58 Atlas A3 训练系列产品
58 <!-- end id2 -->59 <!-- end id2 -->
60+<!-- end id3 -->
59 61 
60- 基类构造函数62- 基类构造函数
61 63 
@@ -18,7 +18,7 @@ int32_t SetBType(TPosition pos, CubeFormat type, DataType dataType, bool isTrans
18| --- | --- | --- |18| --- | --- | --- |
19| pos | 输入 | B矩阵所在的buffer位置,可设置为:TPosition::GM, TPosition::VECOUT, TPosition::TSCM。 |19| pos | 输入 | B矩阵所在的buffer位置,可设置为:TPosition::GM, TPosition::VECOUT, TPosition::TSCM。 |
20| type | 输入 | B矩阵的数据格式,可设置为:CubeFormat::ND,CubeFormat::NZ。 |20| type | 输入 | B矩阵的数据格式,可设置为:CubeFormat::ND,CubeFormat::NZ。 |
21-| dataType | 输入 | B矩阵的数据类型,可设置为:DataType::DT_FLOAT、DataType::DT_FLOAT16、DataType::DT_BFLOAT16 、DataType::DT_INT8、DataType::DT_INT4、DataType::DT_FLOAT8_E4M3FN、DataType::DT_FLOAT8_E5M2、DataType::DT_HIFLOAT8。 |21+| dataType | 输入 | B矩阵的数据类型,可设置为:DataType::DT_FLOAT、DataType::DT_FLOAT16、DataType::DT_BFLOAT16 、DataType::DT_INT8、DataType::DT_INT4、DataType::DT_FLOAT8_E4M3FN、DataType::DT_FLOAT8_E5M2、DataType::DT_HIFLOAT8。<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Tiling/SetBType_res.md#id1 --> |
22| isTrans<a name="p47369411111"></a> | 输入 | B矩阵是否转置。<br><br>参数取值:<br>true:B矩阵转置;false:B矩阵不转置。 |22| isTrans<a name="p47369411111"></a> | 输入 | B矩阵是否转置。<br><br>参数取值:<br>true:B矩阵转置;false:B矩阵不转置。 |
23 23 
24## 返回值说明24## 返回值说明
@@ -16,9 +16,9 @@ int32_t SetBiasType(TPosition pos, CubeFormat type, DataType dataType)
16 16 
17| 参数名 | 输入/输出 | 描述 |17| 参数名 | 输入/输出 | 描述 |
18| --- | --- | --- |18| --- | --- | --- |
19-| pos | 输入 | Bias矩阵所在的buffer位置,可设置为:TPosition::GM, TPosition::VECOUT, TPosition::TSCM。 |19+| pos | 输入 | Bias矩阵所在的buffer位置,可设置为:TPosition::GM, TPosition::VECOUT<!-- npu="950" id1 -->, TPosition::TSCM<!-- end id1 -->。 |
20| type | 输入 | Bias矩阵的数据格式,可设置为:CubeFormat::ND。 |20| type | 输入 | Bias矩阵的数据格式,可设置为:CubeFormat::ND。 |
21-| dataType | 输入 | Bias矩阵的数据类型,可设置为:DataType::DT_FLOAT、DataType::DT_FLOAT16、DataType::DT_INT32、DataType::DT_BFLOAT16。<br><br>其中,仅在A、B的数据类型均为int8_t时,Bias的数据类型可以设置为int32_t。 |21+| dataType | 输入 | Bias矩阵的数据类型,可设置为:DataType::DT_FLOAT、DataType::DT_FLOAT16、DataType::DT_INT32<!-- npu="950" id2 -->、DataType::DT_BFLOAT16<!-- end id2 -->。<br><br>其中,仅在A、B的数据类型均为int8_t时,Bias的数据类型可以设置为int32_t。 |
22 22 
23## 返回值说明23## 返回值说明
24 24 
@@ -20,7 +20,7 @@ int32_t SetMadType(MatrixMadType madType)
20 20 
21| 参数名 | 输入/输出 | 描述 |21| 参数名 | 输入/输出 | 描述 |
22| --- | --- | --- |22| --- | --- | --- |
23-| madType | 输入 | 设置Matmul模式。MatrixMadType类型,定义如下方代码所示,其中参数的含义为:<br><br>MatrixMadType::NORMAL:普通模式,即非HF32模式、非MxMatmul场景。<br><br>MatrixMadType::HF32:开启HF32模式。<br><br>MatrixMadType::MXMODE:开启MxMatmul场景。 |23+| madType | 输入 | 设置Matmul模式。MatrixMadType类型,定义如下方代码所示,其中参数的含义为:<br><br>MatrixMadType::NORMAL:普通模式,即非HF32模式、非MxMatmul场景。<br><br>MatrixMadType::HF32:开启HF32模式。<!-- npu="950" id2 --><br><br>MatrixMadType::MXMODE:开启MxMatmul场景。<!-- end id2 --> |
24 24 
25```25```
26enum class MatrixMadType : int32_t {26enum class MatrixMadType : int32_t {
@@ -38,6 +38,7 @@ enum class MatrixMadType : int32_t {
38 38 
39无39无
40 40 
41+<!-- npu="950" id3 -->
41## 调用示例42## 调用示例
42 43 
43```44```
@@ -46,3 +47,4 @@ matmul_tiling::MatmulApiTiling tiling(ascendcPlatform);
46tiling.SetTraverse(MatrixTraverse::FIRSTM); // 设置遍历方式47tiling.SetTraverse(MatrixTraverse::FIRSTM); // 设置遍历方式
47tiling.SetMadType(MatrixMadType::MXMODE); // 开启MxMatmul场景48tiling.SetMadType(MatrixMadType::MXMODE); // 开启MxMatmul场景
48```49```
50+<!-- end id3 -->
@@ -26,8 +26,11 @@ int32_t SetSingleShape(int32_t singleMIn = -1, int32_t singleNIn = -1, int32_t s
26 26 
27## 约束说明27## 约束说明
28 28 
29+<!-- npu="950" id1 -->
29- 在MxMatmul场景中,如果A与B矩阵的位置同时为GM,对singleKIn没有特殊限制,在这种情况下,若scaleA和scaleB的K方向大小(即Ceil\(singleKIn, 32\))为奇数,用户需自行在scaleA和scaleB的K方向补0至偶数。例如,当singleKIn为30时,Ceil\(singleKIn, 32\)为1,用户需要自行在scaleA和scaleB的K方向补0,使K方向为偶数。对于其它A、B矩阵逻辑位置的组合情况,即A与B矩阵的位置不同时为GM,singleKIn以32个元素向上对齐后的数值必须是32的偶数倍。30- 在MxMatmul场景中,如果A与B矩阵的位置同时为GM,对singleKIn没有特殊限制,在这种情况下,若scaleA和scaleB的K方向大小(即Ceil\(singleKIn, 32\))为奇数,用户需自行在scaleA和scaleB的K方向补0至偶数。例如,当singleKIn为30时,Ceil\(singleKIn, 32\)为1,用户需要自行在scaleA和scaleB的K方向补0,使K方向为偶数。对于其它A、B矩阵逻辑位置的组合情况,即A与B矩阵的位置不同时为GM,singleKIn以32个元素向上对齐后的数值必须是32的偶数倍。
30- 在MxMatmul场景中,当输入数据类型为fp4x2\_e2m1\_t、fp4x2\_e1m2\_t时,内轴必须为偶数。31- 在MxMatmul场景中,当输入数据类型为fp4x2\_e2m1\_t、fp4x2\_e1m2\_t时,内轴必须为偶数。
32+<!-- end id1 -->
33+<!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Tiling/SetSingleShape_res.md#id1 -->
31 34 
32## 调用示例35## 调用示例
33 36 
@@ -8,9 +8,9 @@ TCubeTiling结构体包含Matmul Tiling切分算法的相关参数,被传递
8| 参数名称 | 数据类型 | 说明 |8| 参数名称 | 数据类型 | 说明 |
9| --- | --- | --- |9| --- | --- | --- |
10| usedCoreNum | int | 使用的AI处理器核数,请根据实际情况设置。取值范围为:[1, AI处理器最大核数]。该参数与shape相关参数的关系为:usedCoreNum = (M / singleCoreM) * (N / singleCoreN)。 |10| usedCoreNum | int | 使用的AI处理器核数,请根据实际情况设置。取值范围为:[1, AI处理器最大核数]。该参数与shape相关参数的关系为:usedCoreNum = (M / singleCoreM) * (N / singleCoreN)。 |
11-| M, N, Ka, Kb | int | A、B、C矩阵原始输入的shape大小,以元素为单位。M, Ka为A矩阵原始输入的Shape,Kb, N为B矩阵原始输入的Shape。<br>大小约束:<br><!-- npu="950" id1 -->除Ascend 950PR/Ascend 950DT外,<!-- end id1 -->下述场景需要开启MatmulConfig中的[intrinsicsCheck](../Matmul_Kernel/MatmulConfig.md#matmulconfig-params)参数,以完成Matmul计算。<br>若A矩阵为ND格式,不进行转置,Ka大于65535时需要开启intrinsicsCheck参数,M无大小限制;进行转置,M大于65535时需要开启intrinsicsCheck参数,Ka无大小限制。<br>若B矩阵为ND格式,不进行转置,N大于65535时需要开启intrinsicsCheck参数,Kb无大小限制;进行转置,Kb大于65535时需要开启intrinsicsCheck参数,N无大小限制。<br><br>对齐约束:<br>若A矩阵以NZ格式输入,则M需要以16个元素对齐,Ka需要以C0_size对齐;若B矩阵以NZ格式输入,Kb需要以C0_size对齐,N需要以16个元素对齐。<br>若A、B矩阵为ND格式,无对齐约束。<br><br>注意:NZ格式的输入,float数据类型的C0_size为8,half/bfloat16_t数据类型的C0_size为16,int8_t/fp8_e4m3fn_t/fp8_e5m2_t/hifloat8_t数据类型的C0_size为32,int4b_t/fp4x2_e2m1_t/fp4x2_e1m2_t数据类型的C0_size为64。 |11+| M, N, Ka, Kb | int | A、B、C矩阵原始输入的shape大小,以元素为单位。M, Ka为A矩阵原始输入的Shape,Kb, N为B矩阵原始输入的Shape。<br>大小约束:<br><!-- npu="950" id1 -->除Ascend 950PR/Ascend 950DT外,<!-- end id1 --><!-- @ref: asc-devkit/res/docs/zh/api/SIMD-API/adv_api/cube_compute/Matmul_Tiling/TCubeTiling_struct_res.md#id1 -->下述场景需要开启MatmulConfig中的[intrinsicsCheck](../Matmul_Kernel/MatmulConfig.md#matmulconfig-params)参数,以完成Matmul计算。<br>若A矩阵为ND格式,不进行转置,Ka大于65535时需要开启intrinsicsCheck参数,M无大小限制;进行转置,M大于65535时需要开启intrinsicsCheck参数,Ka无大小限制。<br>若B矩阵为ND格式,不进行转置,N大于65535时需要开启intrinsicsCheck参数,Kb无大小限制;进行转置,Kb大于65535时需要开启intrinsicsCheck参数,N无大小限制。<br><br>对齐约束:<br>若A矩阵以NZ格式输入,则M需要以16个元素对齐,Ka需要以C0_size对齐;若B矩阵以NZ格式输入,Kb需要以C0_size对齐,N需要以16个元素对齐。<br>若A、B矩阵为ND格式,无对齐约束。<br><br>注意:NZ格式的输入,float数据类型的C0_size为8,half/bfloat16_t数据类型的C0_size为16,int8_t/fp8_e4m3fn_t/fp8_e5m2_t/hifloat8_t数据类型的C0_size为32,int4b_t/fp4x2_e2m1_t/fp4x2_e1m2_t数据类型的C0_size为64。 |
12| singleCoreM, singleCoreN, singleCoreK<a name="p11899125875617"></a> | int | A、B、C矩阵单核内shape大小,以元素为单位。该参数取值必须大于0。<br><br>singleCoreK = K,多核处理时不对K进行切分;singleCoreM <= M;singleCoreN <= N。<br><br>注意:若A矩阵以NZ格式输入,则singleCoreM需要以16个元素对齐,singleCoreK需要以C0_size对齐;若B矩阵以NZ格式输入,则singleCoreK需要以C0_size对齐,singleCoreN需要以16个元素对齐。 |12| singleCoreM, singleCoreN, singleCoreK<a name="p11899125875617"></a> | int | A、B、C矩阵单核内shape大小,以元素为单位。该参数取值必须大于0。<br><br>singleCoreK = K,多核处理时不对K进行切分;singleCoreM <= M;singleCoreN <= N。<br><br>注意:若A矩阵以NZ格式输入,则singleCoreM需要以16个元素对齐,singleCoreK需要以C0_size对齐;若B矩阵以NZ格式输入,则singleCoreK需要以C0_size对齐,singleCoreN需要以16个元素对齐。 |
13-| baseM, baseN, baseK<a name="p17899165811566"></a> | int | A、B、C矩阵参与一次矩阵乘指令的shape大小,以元素为单位。<br><br>A、B、C矩阵参与一次矩阵乘的shape大小需要按分形对齐,其含义请参考[Mmad](../../../basic_api/cube_compute_ISASI/mmad_compute/Mmad.md)中的数据格式说明。<br><br>注意:该参数取值必须大于0。MxMatmul场景,baseK必须为64的倍数。 |13+| baseM, baseN, baseK<a name="p17899165811566"></a> | int | A、B、C矩阵参与一次矩阵乘指令的shape大小,以元素为单位。<br><br>A、B、C矩阵参与一次矩阵乘的shape大小需要按分形对齐,其含义请参考[Mmad](../../../basic_api/cube_compute_ISASI/mmad_compute/Mmad.md)中的数据格式说明。<br><br>注意:该参数取值必须大于0。<!-- npu="950" id2 -->MxMatmul场景,baseK必须为64的倍数。<!-- end id2 --> |
14| <a id="deptha1"></a>depthA1, depthB1 | int | depthA1、depthB1分别表示L1 Buffer(A1)、L1 Buffer(B1)中全载基本块的份数,depthA1为L1 Buffer(A1)中全载baseM * baseK的份数,depthB1为L1 Buffer(B1)中全载baseN * baseK的份数。<br><br>注意:该参数取值必须大于0。 |14| <a id="deptha1"></a>depthA1, depthB1 | int | depthA1、depthB1分别表示L1 Buffer(A1)、L1 Buffer(B1)中全载基本块的份数,depthA1为L1 Buffer(A1)中全载baseM * baseK的份数,depthB1为L1 Buffer(B1)中全载baseN * baseK的份数。<br><br>注意:该参数取值必须大于0。 |
15| stepM, stepN,stepKa,stepKb<a name="p139009583566"></a> | int | stepM为左矩阵在L1 Buffer(A1)中缓存的buffer M方向上baseM的倍数。<br><br>stepN为右矩阵在L1 Buffer(B1)中缓存的buffer N方向上baseN的倍数。<br><br>stepKa为左矩阵在L1 Buffer(A1)中缓存的buffer Ka方向上baseK的倍数。<br><br>stepKb为右矩阵在L1 Buffer(B1)中缓存的buffer Kb方向上baseK的倍数。<br><br>注意:该参数取值必须大于0。 |15| stepM, stepN,stepKa,stepKb<a name="p139009583566"></a> | int | stepM为左矩阵在L1 Buffer(A1)中缓存的buffer M方向上baseM的倍数。<br><br>stepN为右矩阵在L1 Buffer(B1)中缓存的buffer N方向上baseN的倍数。<br><br>stepKa为左矩阵在L1 Buffer(A1)中缓存的buffer Ka方向上baseK的倍数。<br><br>stepKb为右矩阵在L1 Buffer(B1)中缓存的buffer Kb方向上baseK的倍数。<br><br>注意:该参数取值必须大于0。 |
16| isBias<a name="p2051215216314"></a> | int | 是否启用Bias,参数取值如下:<br>0:不启用Bias(默认值)。1:启用Bias。<br><br>注意:该参数不支持除上述外的其他取值,设置为其他值时参数行为未定义。 |16| isBias<a name="p2051215216314"></a> | int | 是否启用Bias,参数取值如下:<br>0:不启用Bias(默认值)。1:启用Bias。<br><br>注意:该参数不支持除上述外的其他取值,设置为其他值时参数行为未定义。 |