Merged
QuantMatmul伪量化TCGA8W4算子迁移blaze框架 #9840
QuantMatmul伪量化TCGA8W4算子迁移blaze框架 #9840
Merged
陈永康Add on Sep 3
Total: 10 files changed+108-2340
@@ -7,7 +7,7 @@
7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------9# ----------------------------------------------------------------------------
10-set(OPTENSOR_TAG_ID f5464238b64f319bd77374509db532474ecc4c00)10+set(OPTENSOR_TAG_ID 52a0fc9e1b42a9373d1a4781f4166bffd364cb9f)
11 11 
12if(EXISTS "${PROJECT_SOURCE_DIR}/../ops-tensor")12if(EXISTS "${PROJECT_SOURCE_DIR}/../ops-tensor")
13 get_filename_component(OPTENSOR_SOURCE_PATH13 get_filename_component(OPTENSOR_SOURCE_PATH
@@ -434,7 +434,8 @@ static bool CheckBasicInputDtypes(const aclTensor* x1, const aclTensor* x2, cons
434 return true;434 return true;
435}435}
436 436 
437-static bool CheckA8W4FloatDtype(const aclTensor* x2Scale, const aclTensor* bias, const aclTensor* yScale)437+static bool CheckA8W4FloatDtype(const aclTensor* x2Scale, const aclTensor* bias, const aclTensor* yScale,
438+ const aclTensor* out)
438{439{
439 if (bias != nullptr) {440 if (bias != nullptr) {
440 OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(kOpName, "bias", "non-null bias",441 OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(kOpName, "bias", "non-null bias",
@@ -454,6 +455,12 @@ static bool CheckA8W4FloatDtype(const aclTensor* x2Scale, const aclTensor* bias,
454 std::string("The dtype of x2Scale must be within the range ") + op::ToString(Y_SUPPORT_LIST).GetString());455 std::string("The dtype of x2Scale must be within the range ") + op::ToString(Y_SUPPORT_LIST).GetString());
455 return false;456 return false;
456 }457 }
458+ if (x2Scale->GetDataType() != out->GetDataType()) {
459+ OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(
460+ kOpName, "x2Scale", op::ToString(x2Scale->GetDataType()).GetString(),
461+ "x2Scale and output tensor must share the same dtype when using A8W4 T-CG quantization");
462+ return false;
463+ }
457 if (!CheckType(yScale->GetDataType(), Y_SCALE_SUPPORT_LIST)) {464 if (!CheckType(yScale->GetDataType(), Y_SCALE_SUPPORT_LIST)) {
458 OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(kOpName, "yScale", op::ToString(yScale->GetDataType()).GetString(),465 OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(kOpName, "yScale", op::ToString(yScale->GetDataType()).GetString(),
459 std::string("The dtype of yScale must be within the range ") +466 std::string("The dtype of yScale must be within the range ") +
@@ -505,7 +512,7 @@ static bool CheckDtype(const TupleInput& inputTensors, const TupleQuant& quantTe
505 }512 }
506 513 
507 if (x1Scale == nullptr) {514 if (x1Scale == nullptr) {
508- return CheckA8W4FloatDtype(x2Scale, bias, yScale);515+ return CheckA8W4FloatDtype(x2Scale, bias, yScale, out);
509 } else if (IsMicroScaling(x1Scale, x2Scale)) {516 } else if (IsMicroScaling(x1Scale, x2Scale)) {
510 return CheckMxA8W4Dtype(bias, yScale, out);517 return CheckMxA8W4Dtype(bias, yScale, out);
511 } else {518 } else {
@@ -71,8 +71,7 @@
71#include "../quant_batch_matmul_v4_constant.h"71#include "../quant_batch_matmul_v4_constant.h"
72#include "quant_batch_matmul_v4_pertoken_pergroup.h"72#include "quant_batch_matmul_v4_pertoken_pergroup.h"
73#else73#else
74-#include "quant_batch_matmul_v4_constant.h"74+#include "quant_batch_matmul_v4_weight_quant_pergroup_blaze.h"
75-#include "quant_batch_matmul_v4_perchannel.h"
76#include "quant_batch_matmul_v4_weight_quant_mx_blaze.h"75#include "quant_batch_matmul_v4_weight_quant_mx_blaze.h"
77#include "../../quant_batch_matmul_v3/arch35/qbmm_mix_pertile_cmct.h"76#include "../../quant_batch_matmul_v3/arch35/qbmm_mix_pertile_cmct.h"
78#endif77#endif
@@ -86,34 +85,12 @@ using namespace AscendC;
86#if !__FIXED_POINT_ONLY_CUBE_TO_L0C__85#if !__FIXED_POINT_ONLY_CUBE_TO_L0C__
87#if !CMCT_PRETILE_INT4_INT4_ASYMMETRICAL86#if !CMCT_PRETILE_INT4_INT4_ASYMMETRICAL
88using namespace QuantBatchMatmulV4;87using namespace QuantBatchMatmulV4;
89-namespace QuantBatchMatmulV4 {
90-namespace Arch35 {
91-template <class TemplateClass>
92-__aicore__ inline void InvokeWeightQuantBmmOpImpl(GM_ADDR x1, GM_ADDR x2, GM_ADDR bias, GM_ADDR x1_scale,
93- GM_ADDR x2_scale, GM_ADDR y_scale, GM_ADDR x1_offset,
94- GM_ADDR x2_offset, GM_ADDR y_offset, GM_ADDR y, GM_ADDR workspace,
95- GM_ADDR tiling)
96-{
97- GM_ADDR userWS = AscendC::GetUserWorkspace(workspace);
98- if (userWS == nullptr) {
99- return;
100- }
101- AscendC::TPipe tPipe;
102- KERNEL_TASK_TYPE_DEFAULT(KERNEL_TYPE_MIX_AIC_1_2);
103- GET_TILING_DATA_WITH_STRUCT(qbmmv4_tiling::QuantBatchMatmulV4TilingDataParams, tilingDataIn, tiling);
104- TemplateClass op;
105- op.Init(x1, x2, bias, x1_scale, x2_scale, y_scale, x1_offset, x2_offset, y_offset, y, userWS, &tilingDataIn,
106- &tPipe);
107- op.Process();
108-}
109-} // namespace Arch35
110-} // namespace QuantBatchMatmulV4
111#endif88#endif
112#endif89#endif
113 90 
114#define QBMM_QUANT_GB_IMPL_CLASS(xLayout, wLayout, yLayout) \91#define QBMM_QUANT_GB_IMPL_CLASS(xLayout, wLayout, yLayout) \
115 do { \92 do { \
116- TPipe tPipe; \93+ AscendC::TPipe tPipe; \
117 GM_ADDR userWS = AscendC::GetUserWorkspace(workspace); \94 GM_ADDR userWS = AscendC::GetUserWorkspace(workspace); \
118 GET_TILING_DATA(tilingData, tiling); \95 GET_TILING_DATA(tilingData, tiling); \
119 QbmmCmctPertileKernel<DTYPE_X1, DTYPE_X2, DTYPE_BIAS, float, float, DTYPE_Y, xLayout, wLayout, yLayout, \96 QbmmCmctPertileKernel<DTYPE_X1, DTYPE_X2, DTYPE_BIAS, float, float, DTYPE_Y, xLayout, wLayout, yLayout, \
@@ -178,11 +155,7 @@ __global__ __aicore__ void quant_batch_matmul_v4(GM_ADDR x1, GM_ADDR x2, GM_ADDR
178#else155#else
179 REGISTER_TILING_DEFAULT(qbmmv4_tiling::QuantBatchMatmulV4TilingDataParams);156 REGISTER_TILING_DEFAULT(qbmmv4_tiling::QuantBatchMatmulV4TilingDataParams);
180 if constexpr (QUANT_TYPE == QBMMV4_PER_GROUP) {157 if constexpr (QUANT_TYPE == QBMMV4_PER_GROUP) {
181- constexpr bool isTransA = TRANS == QBMMV4_A_TRANS || TRANS == QBMMV4_ALL_TRANS;158+ QuantBatchMatmulV4::Arch35::InvokeWeightQuantPergroupBlaze<WEIGHTNZ>(
182- constexpr bool isTransB = TRANS == QBMMV4_B_TRANS || TRANS == QBMMV4_ALL_TRANS;
183- QuantBatchMatmulV4::Arch35::InvokeWeightQuantBmmOpImpl<
184- QuantBatchMatmulV4PerChannelKernel<DTYPE_X1, DTYPE_X2, DTYPE_BIAS, DTYPE_Y, isTransA, isTransB, false,
185- QuantType::PER_GROUP, DTYPE_Y, WEIGHTNZ> >(
186 x1, x2, bias, x1_scale, x2_scale, y_scale, x1_offset, x2_offset, y_offset, y, workspace, tiling);159 x1, x2, bias, x1_scale, x2_scale, y_scale, x1_offset, x2_offset, y_offset, y, workspace, tiling);
187 } else if constexpr (QUANT_TYPE == QBMMV4_MX) {160 } else if constexpr (QUANT_TYPE == QBMMV4_MX) {
188 QuantBatchMatmulV4::Arch35::InvokeWeightQuantMxBlazeSwat<WEIGHTNZ>(161 QuantBatchMatmulV4::Arch35::InvokeWeightQuantMxBlazeSwat<WEIGHTNZ>(
@@ -1,50 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-/*!
12- * \file quant_batch_matmul_v4_constant.h
13- * \brief
14- */
15-#pragma once
16-namespace QuantBatchMatmulV4 {
17-enum class QuantType : uint32_t {
18- NONE = 0,
19- PER_TENSOR = 1,
20- PER_CHANNEL = 2,
21- PER_GROUP = 3,
22- MX = 4,
23-};
24- 
25-constexpr int32_t IDX_0 = 0;
26-constexpr int32_t IDX_1 = 1;
27-constexpr int32_t IDX_2 = 2;
28-constexpr int32_t IDX_3 = 3;
29-constexpr int32_t AIV_NUM = 2;
30-constexpr int32_t OFFSET_64 = 64;
31-constexpr int32_t UB_ALIGN_SIZE_FOR_4BITS = 64;
32-constexpr int32_t OFFSET_8 = 8;
33-constexpr int32_t OFFSET_FOR_4BITS = 128;
34-constexpr int32_t GROUP_SIZE_32 = 32;
35-constexpr int32_t VECTOR_REG_WIDTH_FOR_4BITS = 512;
36-constexpr uint32_t MASK_16_BITS = 0xFFFFU;
37-constexpr uint32_t DUP_CONFIG_2 = 0x2;
38-constexpr uint32_t DUP_CONFIG_MODE_1C = 0x1C;
39-constexpr uint32_t DUP_CONFIG_4 = 0x4;
40-constexpr uint32_t DUP_CONFIG_9C = 0x9C;
41-constexpr uint32_t DUP_FLAG_80 = 0x80;
42-constexpr int32_t SCALE_COPY_GROUP_SIZE = 2;
43-constexpr int32_t SCALE_COPY_DEFAULT_STRIDE = 0;
44-constexpr int32_t SCALE_COPY_DEFAULT_NS_STRIDE = 1;
45-constexpr int32_t C0_SIZE_B8 = 32;
46-constexpr uint32_t E2M1_SHIFT_LEFT_SIZE = 0x2;
47-constexpr uint32_t SHIFT_RIGHT_SIZE = 0x4;
48-constexpr uint32_t E2M1_AND_MASK = 0x9C;
49-constexpr uint32_t PERGROUP_NZ_MASK_REG = 32;
50-} // namespace QuantBatchMatmulV4
@@ -1,389 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-/*!
12- * \file quant_batch_matmul_v4_perchannel.h
13- * \brief
14- */
15- 
16-#pragma once
17- 
18-#include "quant_batch_matmul_v4_reg_base_common.h"
19-#include "quant_batch_matmul_v4_tiling_data_apt.h"
20- 
21-using matmul::MatmulImpl;
22- 
23-namespace QuantBatchMatmulV4 {
24- 
25-template <typename xType, typename wType, typename biasType, typename yType, bool aTrans, bool bTrans,
26- bool hasAntiQuantOffset, QuantType antiQuantType, typename scaleType, bool weightNz = false>
27-class QuantBatchMatmulV4PerChannelKernel
28- : public QuantBatchMatmulV4RegBaseCommonKernel<xType, wType, biasType, yType, aTrans, bTrans, hasAntiQuantOffset,
29- antiQuantType, scaleType, weightNz> {
30-public:
31- __aicore__ inline QuantBatchMatmulV4PerChannelKernel(){};
32- __aicore__ inline void Init(GM_ADDR x1, GM_ADDR x2, GM_ADDR bias, GM_ADDR x1_scale, GM_ADDR x2_scale,
33- GM_ADDR y_scale, GM_ADDR x1_offset, GM_ADDR x2_offset, GM_ADDR y_offset, GM_ADDR y,
34- GM_ADDR workspace, const qbmmv4_tiling::QuantBatchMatmulV4TilingDataParams* tilingData,
35- TPipe* tPipe);
36- __aicore__ inline void CopyND2NZ(int aL1Idx);
37- __aicore__ inline void GetAL1(int64_t kFactorIdx, AscendC::TEventID eventIdsMte1ToMte2[MAX_AL1_BUF_NUM]);
38- __aicore__ inline void GetBL1(int64_t kFactorIdx);
39- __aicore__ inline void IterateMatmul(int64_t kFactorIdx);
40- __aicore__ inline void Process();
41- 
42- using inputXType = MatmulL1GmType<TPosition::TSCM, CubeFormat::NZ, xType, aTrans>;
43- using inputWType = MatmulL1GmType<TPosition::TSCM, CubeFormat::NZ, xType, bTrans>;
44- using outputYType = MatmulType<TPosition::GM, CubeFormat::ND, yType>;
45- using inputBiasType = MatmulType<TPosition::GM, CubeFormat::ND, biasType>;
46- MatmulImpl<inputXType, inputWType, outputYType, inputBiasType, CFG_MDL> mmObj_;
47-};
48- 
49-template <typename xType, typename wType, typename biasType, typename yType, bool aTrans, bool bTrans,
50- bool hasAntiQuantOffset, QuantType antiQuantType, typename scaleType, bool weightNz>
51-__aicore__ inline void QuantBatchMatmulV4PerChannelKernel<
52- xType, wType, biasType, yType, aTrans, bTrans, hasAntiQuantOffset, antiQuantType, scaleType,
53- weightNz>::Init(GM_ADDR x1, GM_ADDR x2, GM_ADDR bias, GM_ADDR x1_scale, GM_ADDR x2_scale, GM_ADDR y_scale,
54- GM_ADDR x1_offset, GM_ADDR x2_offset, GM_ADDR y_offset, GM_ADDR y, GM_ADDR workspace,
55- const qbmmv4_tiling::QuantBatchMatmulV4TilingDataParams* tilingData, TPipe* tPipe)
56-{
57- this->tiling_ = tilingData;
58- this->pipe_ = tPipe;
59- 
60- if ASCEND_IS_AIV {
61- this->curBlockIdx_ = GetBlockIdx() / GetTaskRation();
62- } else {
63- this->curBlockIdx_ = GetBlockIdx();
64- }
65- this->nDimIdx_ = this->curBlockIdx_ / this->tiling_->cubeNumBlocksM;
66- this->mDimIdx_ = this->curBlockIdx_ % this->tiling_->cubeNumBlocksM;
67- 
68- this->InitTilingData();
69- 
70- this->InitInputs(x1, x2, x1_scale, x2_scale, x2_offset, y_scale, y_offset, bias, y, workspace);
71- this->l1Local_ = this->l1Tbuf_.template Get<xType>();
72- 
73- if ASCEND_IS_AIC {
74- if (this->tiling_->BL1Pingpong == this->QUADRUPLE_BUFFER) {
75- // L1 布局如下:
76- // 1) AL1 使能 4 buffer 时
77- // L1 (0~256KB): BL1_P0 | BL1_P2 | AL1_P1 | AL1_P3
78- // L1 (257~512KB): BL1_P1 | BL1_P3 | AL1_P0 | AL1_P2
79- // 2) AL1 使能 2 buffer 时
80- // L1 (0~256KB): BL1_P0 | BL1_P2 | AL1_P1
81- // L1 (257~512KB): BL1_P1 | BL1_P3 | AL1_P0
82- // 3) AL1 使能 1 buffer 时
83- // L1 (0~512KB): BL1_P0 | BL1_P2 | AL1_P0 | BL1_P1 | BL1_P3
84- int32_t bL1DataSizeTotal = this->DOUBLE_BUFFER * this->bL1DataSize_ * sizeof(xType);
85- if (this->tiling_->AL1Pingpong == this->QUADRUPLE_BUFFER) {
86- this->bL1LocalBuf0_ = AscendC::LocalTensor<xType>(TPosition::TSCM, 0, this->bL1DataSize_);
87- this->bL1LocalBuf2_ = AscendC::LocalTensor<xType>(TPosition::TSCM, this->bL1DataSize_ * sizeof(xType),
88- this->bL1DataSize_);
89- this->aL1LocalBuf0_ = AscendC::LocalTensor<xType>(
90- TPosition::TSCM, this->L1_BUFFER_HALF_SIZE + bL1DataSizeTotal, this->aL1DataSize_);
91- this->aL1LocalBuf2_ = AscendC::LocalTensor<xType>(
92- TPosition::TSCM, this->L1_BUFFER_HALF_SIZE + bL1DataSizeTotal + this->aL1DataSize_ * sizeof(xType),
93- this->aL1DataSize_);
94- this->aL1LocalBuf1_ = AscendC::LocalTensor<xType>(TPosition::TSCM, bL1DataSizeTotal,
95- this->aL1DataSize_);
96- this->aL1LocalBuf3_ = AscendC::LocalTensor<xType>(
97- TPosition::TSCM, bL1DataSizeTotal + this->aL1DataSize_ * sizeof(xType), this->aL1DataSize_);
98- this->bL1LocalBuf1_ = AscendC::LocalTensor<xType>(TPosition::TSCM, this->L1_BUFFER_HALF_SIZE,
99- this->bL1DataSize_);
100- this->bL1LocalBuf3_ = AscendC::LocalTensor<xType>(
101- TPosition::TSCM, this->L1_BUFFER_HALF_SIZE + this->bL1DataSize_ * sizeof(xType),
102- this->bL1DataSize_);
103- } else if (this->tiling_->AL1Pingpong == this->DOUBLE_BUFFER) {
104- this->bL1LocalBuf0_ = AscendC::LocalTensor<xType>(TPosition::TSCM, 0, this->bL1DataSize_);
105- this->bL1LocalBuf2_ = AscendC::LocalTensor<xType>(TPosition::TSCM, this->bL1DataSize_ * sizeof(xType),
106- this->bL1DataSize_);
107- this->aL1LocalBuf0_ = AscendC::LocalTensor<xType>(
108- TPosition::TSCM, this->L1_BUFFER_HALF_SIZE + bL1DataSizeTotal, this->aL1DataSize_);
109- this->aL1LocalBuf1_ = AscendC::LocalTensor<xType>(TPosition::TSCM, bL1DataSizeTotal,
110- this->aL1DataSize_);
111- this->bL1LocalBuf1_ = AscendC::LocalTensor<xType>(TPosition::TSCM, this->L1_BUFFER_HALF_SIZE,
112- this->bL1DataSize_);
113- this->bL1LocalBuf3_ = AscendC::LocalTensor<xType>(
114- TPosition::TSCM, this->L1_BUFFER_HALF_SIZE + this->bL1DataSize_ * sizeof(xType),
115- this->bL1DataSize_);
116- } else { // this->tiling_->AL1Pingpong == 1
117- this->bL1LocalBuf0_ = AscendC::LocalTensor<xType>(TPosition::TSCM, 0, this->bL1DataSize_);
118- this->bL1LocalBuf2_ = AscendC::LocalTensor<xType>(TPosition::TSCM, this->bL1DataSize_ * sizeof(xType),
119- this->bL1DataSize_);
120- this->aL1LocalBuf0_ = AscendC::LocalTensor<xType>(TPosition::TSCM, bL1DataSizeTotal,
121- this->aL1DataSize_);
122- this->bL1LocalBuf1_ = AscendC::LocalTensor<xType>(
123- TPosition::TSCM,
124- this->Max(this->L1_BUFFER_HALF_SIZE, bL1DataSizeTotal + this->aL1DataSize_ * sizeof(xType)),
125- this->bL1DataSize_);
126- this->bL1LocalBuf3_ = AscendC::LocalTensor<xType>(
127- TPosition::TSCM,
128- this->Max(this->L1_BUFFER_HALF_SIZE, bL1DataSizeTotal + this->aL1DataSize_ * sizeof(xType)) +
129- this->bL1DataSize_ * sizeof(xType),
130- this->bL1DataSize_);
131- }
132- } else {
133- // BL1 为 single buffer 或 double buffer (未考虑 L1 bank 冲突)
134- this->bL1LocalBuf0_ = AscendC::LocalTensor<xType>(TPosition::TSCM, 0, this->bL1DataSize_);
135- if (this->tiling_->BL1Pingpong == this->DOUBLE_BUFFER) {
136- this->bL1LocalBuf1_ = AscendC::LocalTensor<xType>(TPosition::TSCM, this->bL1DataSize_ * sizeof(xType),
137- this->bL1DataSize_);
138- }
139- this->aL1LocalBuf0_ = AscendC::LocalTensor<xType>(
140- TPosition::TSCM, this->vecPingpong_ * this->bL1DataSize_ * sizeof(xType), this->aL1DataSize_);
141- if (this->tiling_->AL1Pingpong == this->QUADRUPLE_BUFFER) {
142- this->aL1LocalBuf1_ = AscendC::LocalTensor<xType>(
143- TPosition::TSCM,
144- (this->aL1DataSize_ + this->tiling_->BL1Pingpong * this->bL1DataSize_) * sizeof(xType),
145- this->aL1DataSize_);
146- this->aL1LocalBuf2_ = AscendC::LocalTensor<xType>(
147- TPosition::TSCM,
148- (this->aL1DataSize_ * IDX_2 + this->tiling_->BL1Pingpong * this->bL1DataSize_) * sizeof(xType),
149- this->aL1DataSize_);
150- this->aL1LocalBuf3_ = AscendC::LocalTensor<xType>(
151- TPosition::TSCM,
152- (this->aL1DataSize_ * IDX_3 + this->tiling_->BL1Pingpong * this->bL1DataSize_) * sizeof(xType),
153- this->aL1DataSize_);
154- } else if (this->tiling_->AL1Pingpong == this->DOUBLE_BUFFER) {
155- this->aL1LocalBuf1_ = AscendC::LocalTensor<xType>(
156- TPosition::TSCM,
157- (this->aL1DataSize_ + this->tiling_->BL1Pingpong * this->bL1DataSize_) * sizeof(xType),
158- this->aL1DataSize_);
159- }
160- }
161- mmObj_.SetSubBlockIdx(0);
162- mmObj_.Init(&this->tiling_->matmulTiling, tPipe);
163- } else {
164- this->weightInUb_ = AscendC::LocalTensor<wType>(TPosition::VECIN, 0,
165- this->vecWeightInLen_ << this->INT4_DTYPE_PARAM);
166- this->scaleInUb_ = AscendC::LocalTensor<scaleType>(TPosition::VECIN, this->vecWeightInLen_,
167- this->vecScaleOffsetLen_ / sizeof(scaleType));
168- this->weightOutUb_ = AscendC::LocalTensor<xType>(TPosition::VECOUT,
169- this->vecWeightInLen_ + this->vecScaleOffsetLen_,
170- this->vecWeightOutLen_ / sizeof(xType));
171- this->scaleMaskUb_ = AscendC::LocalTensor<uint64_t>(
172- TPosition::VECIN, this->vecWeightInLen_ + this->vecScaleOffsetLen_ + this->vecWeightOutLen_,
173- PERGROUP_NZ_MASK_REG / sizeof(uint64_t));
174- if constexpr (hasAntiQuantOffset) {
175- this->offsetInUb_ = AscendC::LocalTensor<xType>(
176- TPosition::VECIN,
177- this->vecWeightInLen_ + this->vecScaleOffsetLen_ + this->vecWeightOutLen_ + PERGROUP_NZ_MASK_REG,
178- this->vecScaleOffsetLen_ / sizeof(xType));
179- }
180- this->scaleMaskUb_.SetValue(0, 0x00000000ffffffff);
181- this->scaleMaskUb_.SetValue(1, 0x00000000ffffffff);
182- this->scaleMaskUb_.SetValue(2, 0x00000000ffffffff);
183- this->scaleMaskUb_.SetValue(3, 0x00000000ffffffff);
184- }
185-}
186- 
187-template <typename xType, typename wType, typename biasType, typename yType, bool aTrans, bool bTrans,
188- bool hasAntiQuantOffset, QuantType antiQuantType, typename scaleType, bool weightNz>
189-__aicore__ inline void
190-QuantBatchMatmulV4PerChannelKernel<xType, wType, biasType, yType, aTrans, bTrans, hasAntiQuantOffset, antiQuantType,
191- scaleType, weightNz>::CopyND2NZ(int aL1Idx)
192-{
193- AscendC::Nd2NzParams nd2nzParams;
194- nd2nzParams.ndNum = 1;
195- if constexpr (aTrans) {
196- nd2nzParams.nValue = this->kAL1Len_;
197- nd2nzParams.dValue = this->mAL1Len_;
198- nd2nzParams.srcDValue = this->tiling_->matmulTiling.M;
199- } else {
200- nd2nzParams.nValue = this->mAL1Len_;
201- nd2nzParams.dValue = this->kAL1Len_;
202- nd2nzParams.srcDValue = this->tiling_->matmulTiling.Ka;
203- }
204- nd2nzParams.srcNdMatrixStride = 0;
205- nd2nzParams.dstNzC0Stride = this->CeilAlign(nd2nzParams.nValue, BLOCK_CUBE);
206- nd2nzParams.dstNzNStride = 1;
207- nd2nzParams.dstNzMatrixStride = 0;
208- if (aL1Idx == IDX_0) {
209- DataCopy(this->aL1LocalBuf0_, this->xGlobal_[this->aGmOffset_], nd2nzParams);
210- } else if (aL1Idx == IDX_1) {
211- DataCopy(this->aL1LocalBuf1_, this->xGlobal_[this->aGmOffset_], nd2nzParams);
212- } else if (aL1Idx == IDX_2) {
213- DataCopy(this->aL1LocalBuf2_, this->xGlobal_[this->aGmOffset_], nd2nzParams);
214- } else if (aL1Idx == IDX_3) {
215- DataCopy(this->aL1LocalBuf3_, this->xGlobal_[this->aGmOffset_], nd2nzParams);
216- }
217- SetFlag<HardEvent::MTE2_MTE1>(aL1Idx);
218- WaitFlag<HardEvent::MTE2_MTE1>(aL1Idx);
219-}
220- 
221-template <typename xType, typename wType, typename biasType, typename yType, bool aTrans, bool bTrans,
222- bool hasAntiQuantOffset, QuantType antiQuantType, typename scaleType, bool weightNz>
223-__aicore__ inline void
224-QuantBatchMatmulV4PerChannelKernel<xType, wType, biasType, yType, aTrans, bTrans, hasAntiQuantOffset, antiQuantType,
225- scaleType, weightNz>::GetAL1(int64_t kFactorIdx,
226- AscendC::TEventID eventIdsMte1ToMte2[MAX_AL1_BUF_NUM])
227-{
228- if ASCEND_IS_AIC {
229- this->kAL1Offset_ = kFactorIdx / this->kAl1Factor_ * this->kAL1Size_;
230- this->kAL1Len_ = this->Min(this->tiling_->kSize - this->kAL1Offset_, this->kAL1Size_);
231- if (kFactorIdx % this->kAl1Factor_ != 0) {
232- return;
233- }
234- 
235- // 等待目标buffer可用
236- WaitFlag<HardEvent::MTE1_MTE2>(eventIdsMte1ToMte2[this->curAL1BufIdx_]);
237- this->aGmOffset_ = this->mBlockOffset_ + this->curML0Idx_ * this->tiling_->matmulTiling.baseM;
238- if constexpr (!aTrans) {
239- this->aGmOffset_ *= this->tiling_->matmulTiling.Ka;
240- this->aGmOffset_ += (kFactorIdx / this->kAl1Factor_) * this->kAL1Size_;
241- } else {
242- this->aGmOffset_ += (kFactorIdx / this->kAl1Factor_) * this->tiling_->mSize;
243- }
244- // CopyND2NZ 函数内部包含 SetFlag<MTE2_MTE1> / WaitFlag<MTE2_MTE1> 等同步指令
245- CopyND2NZ(this->curAL1BufIdx_);
246- }
247-}
248- 
249-/*
250- * 该函数作用为通过 IterMatmulOut 每次移动一个 baseM 或 baseN,并循环遍历 KL1,
251- * 计算好 AL1 和 BL1 的搬运时刻和 index 后,调用 compute 进行计算
252- */
253-template <typename xType, typename wType, typename biasType, typename yType, bool aTrans, bool bTrans,
254- bool hasAntiQuantOffset, QuantType antiQuantType, typename scaleType, bool weightNz>
255-__aicore__ inline void QuantBatchMatmulV4PerChannelKernel<
256- xType, wType, biasType, yType, aTrans, bTrans, hasAntiQuantOffset, antiQuantType, scaleType, weightNz>::Process()
257-{
258- uint64_t usedCoreNum = this->tiling_->cubeNumBlocksM * this->tiling_->cubeNumBlocksN;
259- if ((this->curBlockIdx_) >= usedCoreNum) {
260- return;
261- }
262- AscendC::TEventID eventIdsMte1ToMte2[MAX_AL1_BUF_NUM];
263- this->InitSync(eventIdsMte1ToMte2);
264- 
265- while (this->IterMatmulOut()) {
266- for (int32_t kFactorIdx = 0; kFactorIdx < this->kSingleCoreIterNum_; kFactorIdx++) {
267- this->GetAL1(kFactorIdx, eventIdsMte1ToMte2);
268- this->GetBL1(kFactorIdx);
269- this->IterateMatmul(kFactorIdx);
270- this->PostProcess(kFactorIdx, eventIdsMte1ToMte2);
271- }
272- if ASCEND_IS_AIC {
273- uint64_t outOffset = (this->mBlockOffset_ + this->curML0Idx_ * this->tiling_->matmulTiling.baseM) *
274- this->tiling_->nSize +
275- this->nBlockOffset_ + this->curNL0Idx_ * this->tiling_->matmulTiling.baseN;
276-#ifndef __CCE_KT_TEST__
277- mmObj_.GetTensorC(this->yGlobal_[outOffset]);
278-#endif
279- }
280- }
281- this->EndSync(eventIdsMte1ToMte2);
282-}
283- 
284-template <typename xType, typename wType, typename biasType, typename yType, bool aTrans, bool bTrans,
285- bool hasAntiQuantOffset, QuantType antiQuantType, typename scaleType, bool weightNz>
286-__aicore__ inline void
287-QuantBatchMatmulV4PerChannelKernel<xType, wType, biasType, yType, aTrans, bTrans, hasAntiQuantOffset, antiQuantType,
288- scaleType, weightNz>::GetBL1(int64_t kFactorIdx)
289-{
290- this->kBL1Offset_ = kFactorIdx / this->kBl1Factor_ * this->kBL1Size_;
291- this->kBL1Len_ = this->Min(this->tiling_->kSize - this->kBL1Offset_, this->kBL1Size_);
292- this->nBL1Offset_ = this->nBlockOffset_ + this->curNL1Idx_ * this->tiling_->matmulTiling.baseN;
293- if (kFactorIdx % this->kBl1Factor_ != 0) {
294- return;
295- }
296- 
297- if ASCEND_IS_AIV {
298- // WaitForCube在CopyUb2L1内
299- this->CopyUb2L1();
300- // NotifyCube在CopyUb2L1内
301- } else {
302-#if IS_MX_QUANT_TYPE
303- this->scaleBGmOffset_ = this->nBL1Offset_ * (this->tiling_->matmulTiling.Kb / GROUP_SIZE_32) +
304- (kFactorIdx / this->kBl1Factor_) * this->kBL1Size_ / GROUP_SIZE_32;
305- CopyScaleB2L1();
306-#endif
307- this->WaitForVector(this->curBL1BufIdx_);
308- }
309-}
310- 
311-template <typename xType, typename wType, typename biasType, typename yType, bool aTrans, bool bTrans,
312- bool hasAntiQuantOffset, QuantType antiQuantType, typename scaleType, bool weightNz>
313-__aicore__ inline void
314-QuantBatchMatmulV4PerChannelKernel<xType, wType, biasType, yType, aTrans, bTrans, hasAntiQuantOffset, antiQuantType,
315- scaleType, weightNz>::IterateMatmul(int64_t kFactorIdx)
316-{
317- if ASCEND_IS_AIC {
318- // 一次载入gm到L1载入,多次使用,需要有偏移
319- if constexpr (aTrans) {
320- // (m1,k1,k0,m0), offsetK(kBL1Size_肯定是16的倍数,所以不需要对齐) + offsetM
321- this->aL1Offset_ = (kFactorIdx % this->kAl1Factor_) * this->kBL1Size_ * BLOCK_CUBE +
322- (this->curML0Idx_ % this->tiling_->matmulTiling.stepM) *
323- this->tiling_->matmulTiling.baseM * this->CeilAlign(this->kAL1Len_, BLOCK_CUBE);
324- } else {
325- // (k1,m1,m0,k0), offsetM + offsetK
326- this->aL1Offset_ = (this->curML0Idx_ % this->tiling_->matmulTiling.stepM) *
327- this->tiling_->matmulTiling.baseM * BLOCK_CUBE +
328- (kFactorIdx % this->kAl1Factor_) * this->kBL1Size_ *
329- this->CeilAlign(this->mAL1Len_, BLOCK_CUBE);
330- }
331- if constexpr (aTrans) {
332- if constexpr (bTrans) {
333- mmObj_.SetOrgShape(this->mAL1Len_, this->CeilAlign(this->nBL1Len_, BLOCK_CUBE),
334- this->CeilAlign(this->kAL1Len_, BLOCK_CUBE), this->kBL1Len_, this->tiling_->nSize);
335- } else {
336- mmObj_.SetOrgShape(this->mAL1Len_, this->nBL1Len_, this->CeilAlign(this->kAL1Len_, BLOCK_CUBE),
337- this->CeilAlign(this->kBL1Len_, BLOCK_CUBE), this->tiling_->nSize);
338- }
339- } else {
340- if constexpr (bTrans) {
341- mmObj_.SetOrgShape(this->CeilAlign(this->mAL1Len_, BLOCK_CUBE),
342- this->CeilAlign(this->nBL1Len_, BLOCK_CUBE), this->kAL1Len_, this->kBL1Len_,
343- this->tiling_->nSize);
344- } else {
345- mmObj_.SetOrgShape(this->CeilAlign(this->mAL1Len_, BLOCK_CUBE), this->nBL1Len_, this->kAL1Len_,
346- this->CeilAlign(this->kBL1Len_, BLOCK_CUBE), this->tiling_->nSize);
347- }
348- }
349- if (this->curAL1BufIdx_ == IDX_0) {
350- mmObj_.SetTensorA(this->aL1LocalBuf0_[this->aL1Offset_], aTrans);
351- } else if (this->curAL1BufIdx_ == IDX_1) {
352- mmObj_.SetTensorA(this->aL1LocalBuf1_[this->aL1Offset_], aTrans);
353- } else if (this->curAL1BufIdx_ == IDX_2) {
354- mmObj_.SetTensorA(this->aL1LocalBuf2_[this->aL1Offset_], aTrans);
355- } else {
356- mmObj_.SetTensorA(this->aL1LocalBuf3_[this->aL1Offset_], aTrans);
357- }
358- if constexpr (bTrans) {
359- // (k1,n1,n0,k0), offsetN + offsetK
360- this->bL1Offset_ = (this->curNL0Idx_ % this->tiling_->matmulTiling.stepN) *
361- this->tiling_->matmulTiling.baseN * BLOCK_CUBE +
362- (kFactorIdx % this->kBl1Factor_) * this->kAL1Size_ *
363- this->CeilAlign(this->nBL1Len_, BLOCK_CUBE);
364- } else {
365- // (n1,k1,k0,n0), offsetK + offsetN
366- this->bL1Offset_ = (kFactorIdx % this->kBl1Factor_) * this->kAL1Size_ * BLOCK_CUBE +
367- (this->curNL0Idx_ % this->tiling_->matmulTiling.stepN) *
368- this->tiling_->matmulTiling.baseN * this->CeilAlign(this->kBL1Len_, BLOCK_CUBE);
369- }
370- if (this->curBL1BufIdx_ == IDX_0) {
371- mmObj_.SetTensorB(this->bL1LocalBuf0_[this->bL1Offset_], bTrans);
372- } else if (this->curBL1BufIdx_ == IDX_1) {
373- mmObj_.SetTensorB(this->bL1LocalBuf1_[this->bL1Offset_], bTrans);
374- } else if (this->curBL1BufIdx_ == IDX_2) {
375- mmObj_.SetTensorB(this->bL1LocalBuf2_[this->bL1Offset_], bTrans);
376- } else {
377- mmObj_.SetTensorB(this->bL1LocalBuf3_[this->bL1Offset_], bTrans);
378- }
379- if (this->tiling_->matmulTiling.isBias) {
380- mmObj_.SetBias(
381- this->biasGlobal_[this->curNL0Idx_ * this->tiling_->matmulTiling.baseN + this->nBlockOffset_]);
382- }
383- mmObj_.SetQuantVector(
384- this->quantScaleGlobal_[this->curNL0Idx_ * this->tiling_->matmulTiling.baseN + this->nBlockOffset_]);
385- mmObj_.SetTail(this->baseUseM_, this->baseUseN_, this->Min(this->kAL1Len_, this->kBL1Len_));
386- mmObj_.Iterate(kFactorIdx != 0);
387- }
388-}
389-} // namespace QuantBatchMatmulV4
@@ -1,248 +0,0 @@
1-/**
2- * Copyright (c) 2025-2026 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-/*!
12- * \file quant_batch_matmul_v4_vf.h
13- * \brief
14- */
15- 
16-#pragma once
17- 
18-#if ASC_DEVKIT_MAJOR >= 9
19-#include "kernel_basic_intf.h"
20-#else
21-#include "kernel_operator.h"
22-#include "kernel_operator_intf.h"
23-#endif
24- 
25-namespace Reg = AscendC::Reg;
26-using AscendC::IsSameType;
27- 
28-namespace QuantBatchMatmulV4 {
29- 
30-template <typename xType, typename wType, typename scaleType>
31-struct ParamsGroupSize32 {
32- uint32_t maskWeight;
33- uint16_t outerExtend;
34- uint16_t innerExtend;
35- uint32_t outerStrideScale;
36- uint32_t outerStrideWeight;
37- uint32_t dataBlockStride;
38- uint32_t repeatStride;
39- int32_t outDimOffset;
40- __local_mem__ xType* offsetBaseAddr;
41- __local_mem__ scaleType* scaleBaseAddr;
42- __local_mem__ int8_t* weightInBaseAddr0;
43- __local_mem__ int8_t* weightInBaseAddr1;
44- __local_mem__ xType* weightOutBaseAddr;
45-};
46- 
47-template <typename xType, typename wType, typename scaleType>
48-struct ParamsGroupKN {
49- uint32_t groupNumUb; // UB上一次计算多少个group
50- uint32_t vLLoopNumInGroup; // 每个group中需要处理几次256个数据
51- uint32_t n1LoopNum; // UB上一次计算多少次n1
52- uint32_t scaleN1Stride; // scale addrReg n1轴stride
53- uint32_t bubNLen; // scale addrReg group轴stride
54- uint32_t weightInGroupIdStride;
55- uint32_t weighInN1Stride;
56- uint32_t weightOutN1Stride;
57- uint32_t weightOutGroupIdStride;
58- uint32_t weightOutVlStride;
59- __local_mem__ scaleType* scaleBaseAddr0;
60- __local_mem__ scaleType* scaleBaseAddr1;
61- __local_mem__ uint8_t* scaleMaskBaseAddr;
62- __local_mem__ int8_t* weightInBaseAddr0;
63- __local_mem__ int8_t* weightInBaseAddr1;
64- __local_mem__ xType* weightOutBaseAddr;
65-};
66- 
67-constexpr Reg::CastTrait castF162F32Trait0 = {Reg::RegLayout::ZERO, Reg::SatMode::UNKNOWN, Reg::MaskMergeMode::ZEROING,
68- AscendC::RoundMode::UNKNOWN};
69-constexpr Reg::CastTrait castF162F32Trait1 = {Reg::RegLayout::ONE, Reg::SatMode::UNKNOWN, Reg::MaskMergeMode::ZEROING,
70- AscendC::RoundMode::UNKNOWN};
71-constexpr Reg::CastTrait castF322F8Trait0 = {Reg::RegLayout::ZERO, Reg::SatMode::NO_SAT, Reg::MaskMergeMode::ZEROING,
72- AscendC::RoundMode::CAST_RINT};
73-constexpr Reg::CastTrait castF322F8Trait2 = {Reg::RegLayout::TWO, Reg::SatMode::NO_SAT, Reg::MaskMergeMode::ZEROING,
74- AscendC::RoundMode::CAST_RINT};
75-constexpr Reg::CastTrait castF42F16Trait0 = {Reg::RegLayout::ZERO, Reg::SatMode::UNKNOWN, Reg::MaskMergeMode::ZEROING,
76- AscendC::RoundMode::UNKNOWN};
77-constexpr Reg::CastTrait castBF162FP16Trait0 = {Reg::RegLayout::UNKNOWN, Reg::SatMode::NO_SAT,
78- Reg::MaskMergeMode::ZEROING, AscendC::RoundMode::CAST_RINT};
79- 
80-template <typename wType, typename scaleType>
81-__simd_callee__ inline void CastWeightF4ToF16(Reg::RegTensor<scaleType>& weightF16Reg0,
82- Reg::RegTensor<scaleType>& weightF16Reg1,
83- Reg::RegTensor<wType>& weightInReg0, Reg::RegTensor<wType>& weightInReg1,
84- Reg::MaskReg& maskRegALL)
85-{
86- if constexpr (AscendC::IsSameType<scaleType, half>::value) {
87- Reg::RegTensor<bfloat16_t> weightBF16Reg0, weightBF16Reg1;
88- // f4 -> bf16
89- Reg::Cast<bfloat16_t, wType, castF42F16Trait0>(weightBF16Reg0, weightInReg0, maskRegALL);
90- Reg::Cast<bfloat16_t, wType, castF42F16Trait0>(weightBF16Reg1, weightInReg1, maskRegALL);
91- // bf16 -> fp16
92- Reg::Cast<scaleType, bfloat16_t, castBF162FP16Trait0>(weightF16Reg0, weightBF16Reg0, maskRegALL);
93- Reg::Cast<scaleType, bfloat16_t, castBF162FP16Trait0>(weightF16Reg1, weightBF16Reg1, maskRegALL);
94- } else {
95- Reg::Cast<scaleType, wType, castF42F16Trait0>(weightF16Reg0, weightInReg0, maskRegALL);
96- Reg::Cast<scaleType, wType, castF42F16Trait0>(weightF16Reg1, weightInReg1, maskRegALL);
97- }
98-}
99- 
100-template <typename xType, typename wType, typename scaleType, bool hasAntiquantOffset>
101-__aicore__ inline void AntiquantW4Pergroup32NK(ParamsGroupSize32<xType, wType, scaleType>& p)
102-{
103- static constexpr Reg::CastTrait castTrait0 = {Reg::RegLayout::ZERO, Reg::SatMode::UNKNOWN,
104- Reg::MaskMergeMode::ZEROING, AscendC::RoundMode::UNKNOWN};
105- static constexpr Reg::CastTrait castTrait1 = {Reg::RegLayout::ONE, Reg::SatMode::UNKNOWN,
106- Reg::MaskMergeMode::ZEROING, AscendC::RoundMode::UNKNOWN};
107- static constexpr Reg::CastTrait castTrait2 = {Reg::RegLayout::ZERO, Reg::SatMode::NO_SAT,
108- Reg::MaskMergeMode::ZEROING, AscendC::RoundMode::CAST_RINT};
109- static constexpr Reg::CastTrait castTrait3 = {Reg::RegLayout::TWO, Reg::SatMode::NO_SAT,
110- Reg::MaskMergeMode::ZEROING, AscendC::RoundMode::CAST_RINT};
111- // +---------------------+------+
112- // | 主块 | 尾块 |
113- // | (1)(512 对齐) | (2) |
114- // | | |
115- // | | |
116- // | | |
117- // +---------------------+------+
118- // | 尾块 | 尾块 |
119- // | (3) | (4) |
120- // +---------------------+------+
121- // 当前外轴按照1 unroll循环, >1的时候会有尾块(3)(4)
122- 
123- Reg::RegTensor<scaleType> scaleLoad, scaleCompute0, scaleCompute1;
124- Reg::RegTensor<wType> wLoad0, wLoad1;
125- Reg::RegTensor<scaleType> wCvt0, wCvt1, wMul0, wMul1;
126- Reg::RegTensor<xType> wCvtB8N0, wCvtB8N1, wCvtB8N2, wCvtB8N3, wSel0, wSel1, wSel2, wSel3;
127- Reg::RegTensor<xType> wDIntlv0, wDIntlv1;
128- Reg::RegTensor<float> wCvtF32N0, wCvtF32N1, wCvtF32N2, wCvtF32N3;
129- 
130- Reg::MaskReg maskRegB4 = Reg::CreateMask<uint8_t, AscendC::Reg::MaskPattern::ALL>();
131- Reg::MaskReg maskRegB16 = Reg::CreateMask<uint16_t, AscendC::Reg::MaskPattern::ALL>();
132- Reg::MaskReg maskRegVsel = Reg::CreateMask<uint8_t, AscendC::Reg::MaskPattern::M4>();
133- Reg::MaskReg maskWeight;
134- uint32_t maskWeightTmp;
135- 
136- // (n, k) -> (k1, n1, n0, k0)
137- for (uint16_t outerIdx = 0; outerIdx < p.outerExtend; ++outerIdx) {
138- maskWeightTmp = p.maskWeight;
139- // 按照一行一行处理
140- for (uint16_t innerIdx = 0; innerIdx < p.innerExtend; ++innerIdx) {
141- Reg::AddrReg addrRegScale = Reg::CreateAddrReg<scaleType>(outerIdx, p.outerStrideScale, innerIdx, OFFSET_8);
142- Reg::AddrReg addrRegWeight = Reg::CreateAddrReg<uint8_t>(outerIdx, p.outerStrideWeight, innerIdx,
143- OFFSET_FOR_4BITS);
144- maskWeight = Reg::UpdateMask<xType>(maskWeightTmp);
145- // DIST_E2B_B16 表示搬运模式为
146- // SRC : 0 1 2 3 4 5 6 7
147- // DST : 00000000000000001111111111111111222222222222222233333333333333333.............7777777777777777
148- Reg::DataCopy<scaleType, Reg::LoadDist::DIST_E2B_B16>(scaleLoad, p.scaleBaseAddr, addrRegScale);
149- // Interleave后变为
150- // scale0:
151- // 00000000000000000000000000000000111111111111111111111111111111111.............333333333333333333333333333333333
152- // scale1:
153- // 44444444444444444444444444444444555555555555555555555555555555555.............777777777777777777777777777777777
154- Reg::Interleave(scaleCompute0, scaleCompute1, scaleLoad, scaleLoad);
155- // DIST_UNPACK4_B8 表示搬运模式如下,Vn中一个数字4bit(0.5Byte):
156- // Vn 0 1 2 3 4 5 6 7 8 9 a b c d e f
157- // Vd 0 1 x x x x x x 2 3 x x x x x x
158- // 对于256个数来说, 分2次处理, 每次处理128个数,即64B,应为地址按照int8存的,所以每次偏移64个int8的数
159- Reg::DataCopy<uint8_t, Reg::LoadDist::DIST_UNPACK4_B8>(
160- (Reg::RegTensor<uint8_t>&)wLoad0, (__local_mem__ uint8_t*)p.weightInBaseAddr0, addrRegWeight);
161- Reg::DataCopy<uint8_t, Reg::LoadDist::DIST_UNPACK4_B8>(
162- (Reg::RegTensor<uint8_t>&)wLoad1, (__local_mem__ uint8_t*)p.weightInBaseAddr1, addrRegWeight);
163- 
164- CastWeightF4ToF16<wType, scaleType>(wCvt0, wCvt1, wLoad0, wLoad1, maskRegB4);
165- 
166- Reg::Mul(wMul0, wCvt0, scaleCompute0, maskRegB16);
167- Reg::Mul(wMul1, wCvt1, scaleCompute1, maskRegB16);
168- // fp16 to fp32
169- Reg::Cast<float, scaleType, castTrait0>(wCvtF32N0, wMul0, maskRegB16);
170- Reg::Cast<float, scaleType, castTrait1>(wCvtF32N1, wMul0, maskRegB16);
171- Reg::Cast<float, scaleType, castTrait0>(wCvtF32N2, wMul1, maskRegB16);
172- Reg::Cast<float, scaleType, castTrait1>(wCvtF32N3, wMul1, maskRegB16);
173- // fp32 to fp8
174- Reg::Cast<xType, float, castTrait2>(wCvtB8N0, wCvtF32N0, maskRegB16);
175- Reg::Cast<xType, float, castTrait3>(wCvtB8N1, wCvtF32N1, maskRegB16);
176- Reg::Cast<xType, float, castTrait2>(wCvtB8N2, wCvtF32N2, maskRegB16);
177- Reg::Cast<xType, float, castTrait3>(wCvtB8N3, wCvtF32N3, maskRegB16);
178- // vsel M4
179- Reg::Select(wSel0, wCvtB8N0, wCvtB8N1, maskRegVsel);
180- Reg::Select(wSel1, wCvtB8N2, wCvtB8N3, maskRegVsel);
181- // 去除无效数据
182- Reg::DeInterleave(wDIntlv0, wDIntlv1, wSel0, wSel1);
183- 
184- Reg::DataCopy<xType, Reg::DataCopyMode::DATA_BLOCK_COPY, Reg::PostLiteral::POST_MODE_UPDATE>(
185- p.weightOutBaseAddr, wDIntlv0, p.dataBlockStride, p.repeatStride, maskWeight);
186- }
187- p.weightOutBaseAddr += p.outDimOffset;
188- }
189-}
190- 
191-template <typename xType, typename wType, typename scaleType, bool hasAntiquantOffset>
192-__aicore__ inline void AntiquantW4PergroupKN(ParamsGroupKN<xType, wType, scaleType>& param)
193-{
194- Reg::RegTensor<scaleType> scaleRegCompute, scaleRegAssist, weightF16Reg0, weightF16Reg1;
195- Reg::RegTensor<wType> weightInReg0, weightInReg1;
196- Reg::RegTensor<float> weightF32Reg0, weightF32Reg1, weightF32Reg2, weightF32Reg3;
197- Reg::RegTensor<xType> weightF8Reg0, weightF8Reg1, weightF8Reg2, weightF8Reg3, weightF8SelReg0, weightF8SelReg1;
198- Reg::MaskReg scaleMaskReg = Reg::CreateMask<uint8_t>();
199- Reg::MaskReg maskRegALL = Reg::CreateMask<uint8_t, AscendC::Reg::MaskPattern::ALL>();
200- Reg::MaskReg maskRegVsel = Reg::CreateMask<uint8_t, AscendC::Reg::MaskPattern::M4>();
201- 
202- Reg::DataCopy(scaleMaskReg, param.scaleMaskBaseAddr);
203- for (uint16_t n1Idx = 0; n1Idx < param.n1LoopNum; n1Idx++) {
204- for (uint16_t groupIdx = 0; groupIdx < param.groupNumUb; groupIdx++) {
205- Reg::AddrReg scaleAddrReg = Reg::CreateAddrReg<scaleType>(n1Idx, param.scaleN1Stride, groupIdx,
206- param.bubNLen);
207- Reg::DataCopy<scaleType, Reg::LoadDist::DIST_BLK>(scaleRegCompute, param.scaleBaseAddr0, scaleAddrReg);
208- Reg::DataCopy<scaleType, Reg::LoadDist::DIST_BLK>(scaleRegAssist, param.scaleBaseAddr1, scaleAddrReg);
209- Reg::Select(scaleRegCompute, scaleRegCompute, scaleRegAssist, scaleMaskReg);
210- for (uint16_t vLIdx = 0; vLIdx < param.vLLoopNumInGroup; vLIdx++) {
211- Reg::AddrReg weightInAddrReg = Reg::CreateAddrReg<uint8_t>(
212- n1Idx, param.weighInN1Stride, groupIdx, param.weightInGroupIdStride, vLIdx, OFFSET_FOR_4BITS);
213- Reg::AddrReg weightOutAddrReg = Reg::CreateAddrReg<uint8_t>(n1Idx, param.weightOutN1Stride, groupIdx,
214- param.weightOutGroupIdStride, vLIdx,
215- param.weightOutVlStride);
216- Reg::DataCopy<uint8_t, Reg::LoadDist::DIST_UNPACK4_B8>((Reg::RegTensor<uint8_t>&)weightInReg0,
217- (__local_mem__ uint8_t*)param.weightInBaseAddr0,
218- weightInAddrReg);
219- Reg::DataCopy<uint8_t, Reg::LoadDist::DIST_UNPACK4_B8>((Reg::RegTensor<uint8_t>&)weightInReg1,
220- (__local_mem__ uint8_t*)param.weightInBaseAddr1,
221- weightInAddrReg);
222- CastWeightF4ToF16<wType, scaleType>(weightF16Reg0, weightF16Reg1, weightInReg0, weightInReg1,
223- maskRegALL);
224- Reg::Mul(weightF16Reg0, weightF16Reg0, scaleRegCompute, maskRegALL);
225- Reg::Mul(weightF16Reg1, weightF16Reg1, scaleRegCompute, maskRegALL);
226- 
227- Reg::Cast<float, scaleType, castF162F32Trait0>(weightF32Reg0, weightF16Reg0, maskRegALL);
228- Reg::Cast<float, scaleType, castF162F32Trait1>(weightF32Reg1, weightF16Reg0, maskRegALL);
229- Reg::Cast<float, scaleType, castF162F32Trait0>(weightF32Reg2, weightF16Reg1, maskRegALL);
230- Reg::Cast<float, scaleType, castF162F32Trait1>(weightF32Reg3, weightF16Reg1, maskRegALL);
231- Reg::Cast<xType, float, castF322F8Trait0>(weightF8Reg0, weightF32Reg0, maskRegALL);
232- Reg::Cast<xType, float, castF322F8Trait2>(weightF8Reg1, weightF32Reg1, maskRegALL);
233- Reg::Cast<xType, float, castF322F8Trait0>(weightF8Reg2, weightF32Reg2, maskRegALL);
234- Reg::Cast<xType, float, castF322F8Trait2>(weightF8Reg3, weightF32Reg3, maskRegALL);
235- Reg::Select(weightF8SelReg0, weightF8Reg0, weightF8Reg1, maskRegVsel);
236- Reg::Select(weightF8SelReg1, weightF8Reg2, weightF8Reg3, maskRegVsel);
237- 
238- Reg::DataCopy<xType, Reg::StoreDist::DIST_PACK_B16>(param.weightOutBaseAddr, weightF8SelReg0,
239- weightOutAddrReg, maskRegALL);
240- // 第二次数据搬运,UB偏置为128个fp8
241- Reg::DataCopy<xType, Reg::StoreDist::DIST_PACK_B16>(param.weightOutBaseAddr + 128, weightF8SelReg1,
242- weightOutAddrReg, maskRegALL);
243- }
244- }
245- }
246-}
247- 
248-} // namespace QuantBatchMatmulV4
@@ -0,0 +1,92 @@
1+/**
2+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+/*!
12+ * \file quant_batch_matmul_v4_weight_quant_pergroup_blaze.h
13+ * \brief T-CG per-group weight dequant kernel entry via blaze GemmUniversal.
14+ */
15+ 
16+#pragma once
17+ 
18+#if ASC_DEVKIT_MAJOR >= 9
19+#include "kernel_basic_intf.h"
20+#else
21+#include "kernel_operator.h"
22+#endif
23+ 
24+#include "blaze/gemm/kernel/kernel_wqmm_mix_pergroup.h"
xubinglin
xubinglinxubinglinSep 23

使用#include "blaze/gemm/kernel/kernel_universal.h"

likedislike
25+#include "blaze/gemm/utils/layout_utils.h"
26+#include "quant_batch_matmul_v4_tiling_data_apt.h"
27+ 
28+namespace QuantBatchMatmulV4 {
29+namespace Arch35 {
30+ 
31+template <bool IS_WEIGHT_NZ>
32+__aicore__ inline void RunWeightQuantPergroupBlaze(GM_ADDR x1, GM_ADDR x2, GM_ADDR x2Scale, GM_ADDR yScale, GM_ADDR y,
33+ const qbmmv4_tiling::QuantBatchMatmulV4TilingDataParams& tilingData)
34+{
35+ using LayoutA = AscendC::Te::NDExtLayoutPtn;
36+ using LayoutC = AscendC::Te::NDExtLayoutPtn;
37+ using LayoutB = AscendC::Std::conditional_t<IS_WEIGHT_NZ, AscendC::Te::NZLayoutPtn, AscendC::Te::DNExtLayoutPtn>;
38+ // The B side carries the packed-FP4 weight plus the per-group scale (x2Scale, consumed
39+ // by the AIV dequant in UB). TCG has no bias input: the trailing BiasType/LayoutBias
40+ // slots only satisfy the BlockMmad template signature.
41+ using BTypeTuple = AscendC::Std::tuple<DTYPE_X2, DTYPE_X2_SCALE>;
42+ using BlockMmadType = Blaze::Gemm::Block::BlockMmad<Blaze::Gemm::MatmulWithWeightQuantPergroup, DTYPE_X1, LayoutA,
43+ BTypeTuple, LayoutB, DTYPE_Y, LayoutC, void, void>;
44+ using ProblemShape = AscendC::Te::Shape<int64_t, int64_t, int64_t>;
45+ using BlockSchedulerType = Blaze::Gemm::Block::BlockSchedulerWqmmBlockSplit<ProblemShape, LayoutB, DTYPE_X1>;
xubinglin
xubinglinxubinglinSep 23

没有include scheduler头文件

likedislike
46+ using KernelImpl = Blaze::Gemm::Kernel::GemmUniversal<ProblemShape, BlockMmadType, void, BlockSchedulerType>;
47+ 
48+ const auto& matmulTiling = tilingData.matmulTiling;
49+ // BlockMmad::Params carries both the quantized-fixpipe fields and the per-group
50+ // weight-prologue fields; fill the per-group subset by name (the GM-B streaming fields
51+ // keep their defaults).
52+ typename BlockMmadType::Params mmadParams{};
53+ mmadParams.aGmAddr = x1;
54+ mmadParams.cGmAddr = y;
55+ mmadParams.yScaleGmAddr = yScale;
56+ mmadParams.l1TileShape = asc::te::make_shape(static_cast<int64_t>(matmulTiling.stepM) * matmulTiling.baseM,
57+ static_cast<int64_t>(matmulTiling.stepN) * matmulTiling.baseN,
58+ static_cast<int64_t>(matmulTiling.stepKa) * matmulTiling.baseK,
59+ static_cast<int64_t>(matmulTiling.stepKb) * matmulTiling.baseK);
60+ mmadParams.l0TileShape = asc::te::make_shape(static_cast<int64_t>(matmulTiling.baseM),
61+ static_cast<int64_t>(matmulTiling.baseN),
62+ static_cast<int64_t>(matmulTiling.baseK));
63+ mmadParams.vecCoreParallel = tilingData.vecCoreParallel;
64+ mmadParams.AL1Pingpong = tilingData.AL1Pingpong;
65+ mmadParams.BL1Pingpong = tilingData.BL1Pingpong;
66+ mmadParams.dbL0C = static_cast<uint32_t>(matmulTiling.dbL0C);
67+ typename KernelImpl::Params params{
68+ asc::te::make_shape(static_cast<int64_t>(tilingData.mSize), static_cast<int64_t>(tilingData.nSize),
69+ static_cast<int64_t>(tilingData.kSize)),
70+ mmadParams,
71+ {x2, x2Scale, tilingData.groupSize, tilingData.nBubSize, tilingData.kBubSize},
72+ {tilingData.cubeNumBlocksM, tilingData.cubeNumBlocksN, static_cast<uint32_t>(matmulTiling.baseM),
73+ static_cast<uint32_t>(matmulTiling.baseN), static_cast<uint32_t>(matmulTiling.iterateOrder)}};
74+ KernelImpl kernel;
75+ kernel(params);
76+}
77+ 
78+template <bool IS_WEIGHT_NZ>
79+__aicore__ inline void InvokeWeightQuantPergroupBlaze(GM_ADDR x1, GM_ADDR x2, [[maybe_unused]] GM_ADDR bias,
80+ [[maybe_unused]] GM_ADDR x1_scale, GM_ADDR x2_scale,
81+ GM_ADDR y_scale, [[maybe_unused]] GM_ADDR x1_offset,
82+ [[maybe_unused]] GM_ADDR x2_offset,
83+ [[maybe_unused]] GM_ADDR y_offset, GM_ADDR y,
84+ [[maybe_unused]] GM_ADDR workspace, const GM_ADDR tiling)
85+{
86+ KERNEL_TASK_TYPE_DEFAULT(KERNEL_TYPE_MIX_AIC_1_2);
xubinglin
xubinglinxubinglinSep 23

不需要写在代码里

likedislike
87+ GET_TILING_DATA_WITH_STRUCT(qbmmv4_tiling::QuantBatchMatmulV4TilingDataParams, tilingDataIn, tiling);
88+ RunWeightQuantPergroupBlaze<IS_WEIGHT_NZ>(x1, x2, x2_scale, y_scale, y, tilingDataIn);
89+}
90+ 
91+} // namespace Arch35
92+} // namespace QuantBatchMatmulV4
@@ -498,7 +498,7 @@ TEST_F(l2_QuantBatchMatmulV5_test_950, ascend950_A8W4F_TCG_fp16_ok)
498 SocVersionManager versionManager(SocVersion::ASCEND950);498 SocVersionManager versionManager(SocVersion::ASCEND950);
499 TensorDesc x1_desc = TensorDesc({16, 64}, ACL_FLOAT8_E4M3FN, ACL_FORMAT_ND);499 TensorDesc x1_desc = TensorDesc({16, 64}, ACL_FLOAT8_E4M3FN, ACL_FORMAT_ND);
500 TensorDesc x2_desc = TensorDesc({16, 64}, ACL_FLOAT4_E2M1, ACL_FORMAT_ND);500 TensorDesc x2_desc = TensorDesc({16, 64}, ACL_FLOAT4_E2M1, ACL_FORMAT_ND);
501- TensorDesc x2scale_desc = TensorDesc({16, 2}, ACL_BF16, ACL_FORMAT_ND);501+ TensorDesc x2scale_desc = TensorDesc({16, 2}, ACL_FLOAT16, ACL_FORMAT_ND);
502 TensorDesc yscale_desc = TensorDesc({1, 16}, ACL_UINT64, ACL_FORMAT_ND);502 TensorDesc yscale_desc = TensorDesc({1, 16}, ACL_UINT64, ACL_FORMAT_ND);
503 TensorDesc out_desc = TensorDesc({16, 16}, ACL_FLOAT16, ACL_FORMAT_ND);503 TensorDesc out_desc = TensorDesc({16, 16}, ACL_FLOAT16, ACL_FORMAT_ND);
504 auto ut = OP_API_UT(aclnnQuantMatmulV5,504 auto ut = OP_API_UT(aclnnQuantMatmulV5,
@@ -138,8 +138,8 @@ Ascend950,ascend910D_A4W4_test_case_PERTOKEN_PERGROUP_4,9 1024,1024 256,,,4 256,
138Ascend910B2,ascend910B2_test_case_A4W4_7,16 32,32 16,,10 10 16 32,16,,,,,,,16 16,,1 1,ACL_INT4,ACL_INT4,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,false,0,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_FRACTAL_NZ138Ascend910B2,ascend910B2_test_case_A4W4_7,16 32,32 16,,10 10 16 32,16,,,,,,,16 16,,1 1,ACL_INT4,ACL_INT4,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,false,0,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_FRACTAL_NZ
139Ascend910B2,ascend910B2_test_case_A4W4_18,128 128,128 128,,2 8 16 64,128,,128,,,,,128 128,,128 1,ACL_INT4,ACL_INT4,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,false,0,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_FRACTAL_NZ139Ascend910B2,ascend910B2_test_case_A4W4_18,128 128,128 128,,2 8 16 64,128,,128,,,,,128 128,,128 1,ACL_INT4,ACL_INT4,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,false,0,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_FRACTAL_NZ
140Ascend910B2,ascend910B2_test_case_A4W4_22,64 8,8 280,,,280,,,,,,,64 280,,,ACL_INT4,ACL_INT4,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,false,0,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_FRACTAL_NZ,ACL_FORMAT_FRACTAL_NZ140Ascend910B2,ascend910B2_test_case_A4W4_22,64 8,8 280,,,280,,,,,,,64 280,,,ACL_INT4,ACL_INT4,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,false,0,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_FRACTAL_NZ,ACL_FORMAT_FRACTAL_NZ
141-Ascend950,ascend950_A8W4F_TCG_fp16_ok,16 64,16 64,,,16 2,,,,1 16,,,16 16,64 1,64 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_BF16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,true,32,ACLNN_SUCCESS,true,ACL_FORMAT_ND,ACL_FORMAT_ND141+Ascend950,ascend950_A8W4F_TCG_fp16_ok,16 64,16 64,,,16 2,,,,1 16,,,16 16,64 1,64 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_FLOAT16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,true,32,ACLNN_SUCCESS,true,ACL_FORMAT_ND,ACL_FORMAT_ND
142-Ascend950,ascend950_A8W4F_TCG_yscale_int64,16 64,16 64,,,16 2,,,,1 16,,,16 16,64 1,64 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_BF16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_INT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,true,32,ACLNN_SUCCESS,true,ACL_FORMAT_ND,ACL_FORMAT_ND142+Ascend950,ascend950_A8W4F_TCG_yscale_int64,16 64,16 64,,,16 2,,,,1 16,,,16 16,64 1,64 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_FLOAT16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_INT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,true,32,ACLNN_SUCCESS,true,ACL_FORMAT_ND,ACL_FORMAT_ND
143Ascend950,ascend950_A8W4F_TCG_transposeX1_err,16 64,16 64,,,16 2,,,,1 16,,,16 16,64 1,64 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_BF16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,true,true,32,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_ND143Ascend950,ascend950_A8W4F_TCG_transposeX1_err,16 64,16 64,,,16 2,,,,1 16,,,16 16,64 1,64 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_BF16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,true,true,32,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_ND
144Ascend950,ascend950_A8W4F_TCG_transposeX2_err,16 64,64 16,,,2 16,,,,1 16,,,16 16,64 1,16 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_BF16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,false,32,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_ND144Ascend950,ascend950_A8W4F_TCG_transposeX2_err,16 64,64 16,,,2 16,,,,1 16,,,16 16,64 1,16 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_BF16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,false,32,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_ND
145Ascend950,ascend950_A8W4F_TCG_bias_err,16 64,16 64,,,16 2,,,1 16,1 16,,,16 16,64 1,64 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_BF16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,true,32,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_ND145Ascend950,ascend950_A8W4F_TCG_bias_err,16 64,16 64,,,16 2,,,1 16,1 16,,,16 16,64 1,64 1,ACL_FLOAT8_E4M3FN,ACL_FLOAT4_E2M1,ACL_BF16,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,ACL_UINT64,ACL_FLOAT,ACL_FLOAT,ACL_FLOAT16,false,true,32,ACLNN_ERR_PARAM_INVALID,true,ACL_FORMAT_ND,ACL_FORMAT_ND