已合并
删除冗余头文件,替换自制工具类里的GET接口,直接使用TensorApi提供的AscendC::Te::Get功能 #242
删除冗余头文件,替换自制工具类里的GET接口,直接使用TensorApi提供的AscendC::Te::Get功能 #242
已合并
chen-shuai创建于 5月13日
68 个文件变更+548-805
@@ -22,8 +22,7 @@
22#include "kernel_operator.h"22#include "kernel_operator.h"
23#endif23#endif
24#include "lib/matmul_intf.h"24#include "lib/matmul_intf.h"
25- 25+#include "include/tensor_api/tensor.h"
26-#include "integral_constant.h"
27 26 
28// On-chip buffer capacities used by the kernel helper code.27// On-chip buffer capacities used by the kernel helper code.
29constexpr static int64_t L0A_SIZE = 64 * 1024;28constexpr static int64_t L0A_SIZE = 64 * 1024;
@@ -1,36 +0,0 @@
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 integral_constant.h
13- * \brief
14- */
15-#pragma once
16-#if ASC_DEVKIT_MAJOR >= 9
17-#include "kernel_basic_intf.h"
18-#else
19-#include "kernel_operator.h"
20-#endif
21- 
22-namespace AscendC {
23-namespace Std {
24-template <typename...>
25-struct always_false : public false_type {};
26- 
27-template <typename... Tp>
28-constexpr bool always_false_v = always_false<Tp...>::value;
29-} // namespace Std
30-} // namespace AscendC
31- 
32-template <int32_t t>
33-using Int = AscendC::Std::integral_constant<int32_t, t>;
34- 
35-using _0 = Int<0>;
36- 
@@ -15,51 +15,43 @@
15 15 
16#pragma once16#pragma once
17 17 
18-// Cube format definitions.18+#include "include/tensor_api/tensor.h"
19-#include "matmul/matmul_config.h"
20-// Required by matmul_utils.h.
21-#include "matmul/tiling.h"
22 19 
23-// Provides AscendC::CeilAlign.20+template <typename LayoutPattern>
24-#include "../../impl/adv_api/detail/matmul/utils/matmul_utils.h"21+constexpr bool GetTransValue()
25-#include "./integral_constant.h"22+{
23+ constexpr bool isNonTrans =
24+ AscendC::Std::is_one_of_v<LayoutPattern, AscendC::Te::NDExtLayoutPtn, AscendC::Te::NZLayoutPtn>;
25+ constexpr bool isTrans =
26+ AscendC::Std::is_one_of_v<LayoutPattern, AscendC::Te::DNExtLayoutPtn, AscendC::Te::ZNLayoutPtn>;
26 27 
27-namespace layout {28+ constexpr bool isKnown = isNonTrans || isTrans;
28-struct RowMajor {};29+ static_assert(isKnown, "IsTrans is not implemented for this layout pattern");
29-struct ColumnMajor {};
30-} // namespace layout
31 30 
32-// Map layout tags to CubeFormat values.31+ return !isNonTrans && isTrans;
33-template <typename T>32+}
34-struct TagToFormat {33+ 
35- static_assert(AscendC::Std::always_false_v<T>, "TagToFormat is not implemented for this layout");34+template <typename LayoutPattern>
35+struct IsTrans {
36+ static constexpr bool value = GetTransValue<LayoutPattern>();
36};37};
37 38 
38-template <>39+template <typename LayoutPattern>
39-struct TagToFormat<layout::RowMajor> {40+constexpr bool GetWeightNzValue()
40- using tag = layout::RowMajor;41+{
41- static constexpr CubeFormat format = CubeFormat::ND;42+ constexpr bool isNonWeightNz =
42-};43+ AscendC::Std::is_one_of_v<LayoutPattern, AscendC::Te::NDExtLayoutPtn, AscendC::Te::DNExtLayoutPtn>;
43- 44+ constexpr bool isWeightNz =
44-template <>45+ AscendC::Std::is_one_of_v<LayoutPattern, AscendC::Te::NZLayoutPtn, AscendC::Te::ZNLayoutPtn>;
45-struct TagToFormat<layout::ColumnMajor> {46+ 
46- using tag = layout::ColumnMajor;47+ constexpr bool isKnown = isNonWeightNz || isWeightNz;
47- static constexpr CubeFormat format = CubeFormat::ND;48+ static_assert(isKnown, "IsWeightNz is not implemented for this layout");
48-};49+ 
49- 50+ return !isNonWeightNz && isWeightNz;
50-// Map layout tags to transpose flags.51+}
51-template <typename T>52+ 
52-struct TagToTrans {53+template <typename LayoutPattern>
53- static_assert(AscendC::Std::always_false_v<T>, "TagToTrans is not implemented for this layout");54+struct IsWeightNz {
54-};55+ static constexpr bool value = GetWeightNzValue<LayoutPattern>();
55- 
56-template <>
57-struct TagToTrans<layout::RowMajor> {
58- static constexpr bool value = false;
59-};
60- 
61-template <>
62-struct TagToTrans<layout::ColumnMajor> {
63- static constexpr bool value = true;
64};56};
65 57 
@@ -1,34 +0,0 @@
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 tuple_utils.h
13- * \brief
14- */
15- 
16-#pragma once
17- 
18-#include "lib/std/tuple.h"
19-#include "./integral_constant.h"
20- 
21-// Base template: handles single-index case
22-template <size_t I, typename T>
23-__aicore__ constexpr inline decltype(auto) Get(T&& t)
24-{
25- return AscendC::Std::get<I>(AscendC::Std::forward<T>(t));
26-}
27- 
28-// Recursive template: handles multiple index cases
29-template <size_t First, size_t Second, size_t... Rest, typename T>
30-__aicore__ constexpr inline decltype(auto) Get(T&& t)
31-{
32- return Get<Second, Rest...>(AscendC::Std::get<First>(AscendC::Std::forward<T>(t)));
33-}
34- 
@@ -14,7 +14,7 @@
14 */14 */
15#pragma once15#pragma once
16 16 
17-#include "kernel_utils/integral_constant.h"17+#include "kernel_utils/common_utils.h"
18 18 
19namespace Block {19namespace Block {
20 20 
@@ -22,11 +22,13 @@ template <
22 class DispatchPolicy_, class AType_, class LayoutA_, class BType_, class LayoutB_, class CType_, class LayoutC_,22 class DispatchPolicy_, class AType_, class LayoutA_, class BType_, class LayoutB_, class CType_, class LayoutC_,
23 class BiasType_ = void, class Enable = void>23 class BiasType_ = void, class Enable = void>
24class BlockMmad {24class BlockMmad {
25- static_assert(AscendC::Std::always_false_v<DispatchPolicy_>, "BlockMmad is not implemented for this DispatchPolicy");25+ static_assert(
26+ !AscendC::Std::is_same_v<DispatchPolicy_, DispatchPolicy_>,
27+ "BlockMmad is not implemented for this DispatchPolicy");
26};28};
27 29 
28} // namespace Block30} // namespace Block
29 31 
30// Include all concrete BlockMmad specializations here.32// Include all concrete BlockMmad specializations here.
31#include "weight_quant_grouped_matmul_mxfp8fp4_block_mmad_split_m.h"33#include "weight_quant_grouped_matmul_mxfp8fp4_block_mmad_split_m.h"
32-#include "quant_grouped_matmul_mx_block_mmad_split_m.h"34+#include "quant_grouped_matmul_mx_block_mmad_split_m.h"
@@ -14,7 +14,7 @@
14 */14 */
15#pragma once15#pragma once
16 16 
17-#include "kernel_utils/tuple_utils.h"17+#include "kernel_utils/common_utils.h"
18 18 
19#include "../policy/dispatch_policy.h"19#include "../policy/dispatch_policy.h"
20 20 
@@ -16,7 +16,6 @@
16 16 
17#include "kernel_utils/common_utils.h"17#include "kernel_utils/common_utils.h"
18#include "kernel_utils/layout_utils.h"18#include "kernel_utils/layout_utils.h"
19-#include "kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21 20 
22#include "../policy/dispatch_policy.h"21#include "../policy/dispatch_policy.h"
@@ -149,15 +148,15 @@ public:
149 // Force double-buffering on L1.148 // Force double-buffering on L1.
150 constexpr uint64_t l1BufNum = GroupedMatmulRecipe::DOUBLE_BUFFER;149 constexpr uint64_t l1BufNum = GroupedMatmulRecipe::DOUBLE_BUFFER;
151 150 
152- m_ = Get<GroupedMatmulRecipe::MNK_M>(problemShape);151+ m_ = AscendC::Te::Get<GroupedMatmulRecipe::MNK_M>(problemShape);
153- n_ = Get<GroupedMatmulRecipe::MNK_N>(problemShape);152+ n_ = AscendC::Te::Get<GroupedMatmulRecipe::MNK_N>(problemShape);
154- k_ = Get<GroupedMatmulRecipe::MNK_K>(problemShape);153+ k_ = AscendC::Te::Get<GroupedMatmulRecipe::MNK_K>(problemShape);
155 kAL1_ = l1Params.kAL1;154 kAL1_ = l1Params.kAL1;
156 kBL1_ = l1Params.kBL1;155 kBL1_ = l1Params.kBL1;
157 scaleKL1_ = l1Params.scaleKL1;156 scaleKL1_ = l1Params.scaleKL1;
158- baseM_ = Get<GroupedMatmulRecipe::MNK_M>(l0TileShape);157+ baseM_ = AscendC::Te::Get<GroupedMatmulRecipe::MNK_M>(l0TileShape);
159- baseN_ = Get<GroupedMatmulRecipe::MNK_N>(l0TileShape);158+ baseN_ = AscendC::Te::Get<GroupedMatmulRecipe::MNK_N>(l0TileShape);
160- baseK_ = Get<GroupedMatmulRecipe::MNK_K>(l0TileShape);159+ baseK_ = AscendC::Te::Get<GroupedMatmulRecipe::MNK_K>(l0TileShape);
161 // Prefer outer-K loops on the operand with the larger L1 K-tile to hide memory latency.160 // Prefer outer-K loops on the operand with the larger L1 K-tile to hide memory latency.
162 orderAL1BL1_ = l1Params.kAL1 >= l1Params.kBL1;161 orderAL1BL1_ = l1Params.kAL1 >= l1Params.kBL1;
163 enableL0cPingPong_ = enableL0cPingPong;162 enableL0cPingPong_ = enableL0cPingPong;
@@ -183,9 +182,9 @@ public:
183 // Update global (m,n,k) for next group182 // Update global (m,n,k) for next group
184 __aicore__ inline void UpdateParamsForNextProblem(const TupleShape& problemShape)183 __aicore__ inline void UpdateParamsForNextProblem(const TupleShape& problemShape)
185 {184 {
186- m_ = Get<GroupedMatmulRecipe::MNK_M>(problemShape);185+ m_ = AscendC::Te::Get<GroupedMatmulRecipe::MNK_M>(problemShape);
187- n_ = Get<GroupedMatmulRecipe::MNK_N>(problemShape);186+ n_ = AscendC::Te::Get<GroupedMatmulRecipe::MNK_N>(problemShape);
188- k_ = Get<GroupedMatmulRecipe::MNK_K>(problemShape);187+ k_ = AscendC::Te::Get<GroupedMatmulRecipe::MNK_K>(problemShape);
189 }188 }
190 189 
191 template <typename TensorA, typename TensorB, typename TensorScaleA, typename TensorScaleB, typename TensorC>190 template <typename TensorA, typename TensorB, typename TensorScaleA, typename TensorScaleB, typename TensorC>
@@ -390,8 +389,8 @@ private:
390 const BlockShape& singleShape)389 const BlockShape& singleShape)
391 {390 {
392 // current tile shape391 // current tile shape
393- uint64_t curM = Get<GroupedMatmulRecipe::MNK_M>(singleShape);392+ uint64_t curM = AscendC::Te::Get<GroupedMatmulRecipe::MNK_M>(singleShape);
394- uint64_t curN = Get<GroupedMatmulRecipe::MNK_N>(singleShape);393+ uint64_t curN = AscendC::Te::Get<GroupedMatmulRecipe::MNK_N>(singleShape);
395 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;394 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
396 auto tensorL0C = AscendC::Te::MakeTensor(395 auto tensorL0C = AscendC::Te::MakeTensor(
397 AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset),396 AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset),
@@ -65,10 +65,10 @@ public:
65 65 
66 __aicore__ inline void UpdateNextProblem(const TupleShape& problemShape)66 __aicore__ inline void UpdateNextProblem(const TupleShape& problemShape)
67 {67 {
68- k_ = Get<MNK_K>(problemShape);68+ k_ = AscendC::Te::Get<MNK_K>(problemShape);
69- if (m_ != Get<MNK_M>(problemShape) || n_ != Get<MNK_N>(problemShape)) {69+ if (m_ != AscendC::Te::Get<MNK_M>(problemShape) || n_ != AscendC::Te::Get<MNK_N>(problemShape)) {
70- m_ = Get<MNK_M>(problemShape);70+ m_ = AscendC::Te::Get<MNK_M>(problemShape);
71- n_ = Get<MNK_N>(problemShape);71+ n_ = AscendC::Te::Get<MNK_N>(problemShape);
72 mCnt_ = CeilDiv(m_, baseM_);72 mCnt_ = CeilDiv(m_, baseM_);
73 nCnt_ = CeilDiv(n_, baseN_);73 nCnt_ = CeilDiv(n_, baseN_);
74 mBaseTail_ = m_ - (mCnt_ - 1) * baseM_;74 mBaseTail_ = m_ - (mCnt_ - 1) * baseM_;
@@ -179,17 +179,17 @@ public:
179 }179 }
180 int64_t rowIdx = index / nCnt_ / mainMWindow_;180 int64_t rowIdx = index / nCnt_ / mainMWindow_;
181 if (rowIdx < mainRow_) {181 if (rowIdx < mainRow_) {
182- Get<MNK_M>(blockCoord) = rowIdx * mainMWindow_ + index % mainMWindow_;182+ AscendC::Std::get<MNK_M>(blockCoord) = rowIdx * mainMWindow_ + index % mainMWindow_;
183- Get<MNK_N>(blockCoord) = (index / mainMWindow_) % nCnt_;183+ AscendC::Std::get<MNK_N>(blockCoord) = (index / mainMWindow_) % nCnt_;
184 } else {184 } else {
185 rowIdx = mainRow_;185 rowIdx = mainRow_;
186 int64_t tailIndex = index - mainRow_ * mainMWindow_ * nCnt_;186 int64_t tailIndex = index - mainRow_ * mainMWindow_ * nCnt_;
187- Get<MNK_M>(blockCoord) = mainRow_ * mainMWindow_ + tailIndex % tailWindow_;187+ AscendC::Std::get<MNK_M>(blockCoord) = mainRow_ * mainMWindow_ + tailIndex % tailWindow_;
188- Get<MNK_N>(blockCoord) = (tailIndex / tailWindow_) % nCnt_;188+ AscendC::Std::get<MNK_N>(blockCoord) = (tailIndex / tailWindow_) % nCnt_;
189 }189 }
190 190 
191 if (rowIdx & 1) {191 if (rowIdx & 1) {
192- Get<MNK_N>(blockCoord) = nCnt_ - 1 - Get<MNK_N>(blockCoord);192+ AscendC::Std::get<MNK_N>(blockCoord) = nCnt_ - 1 - AscendC::Te::Get<MNK_N>(blockCoord);
193 }193 }
194 roundIdx_++;194 roundIdx_++;
195 return true;195 return true;
@@ -197,8 +197,8 @@ public:
197 197 
198 __aicore__ inline TupleShape GetBlockShape(const BlockCoord& blockCoord)198 __aicore__ inline TupleShape GetBlockShape(const BlockCoord& blockCoord)
199 {199 {
200- int64_t singleCoreM = Get<MNK_M>(blockCoord) != (mCnt_ - 1) ? baseM_ : mBaseTail_;200+ int64_t singleCoreM = AscendC::Te::Get<MNK_M>(blockCoord) != (mCnt_ - 1) ? baseM_ : mBaseTail_;
201- int64_t singleCoreN = Get<MNK_N>(blockCoord) != (nCnt_ - 1) ? baseN_ : nBaseTail_;201+ int64_t singleCoreN = AscendC::Te::Get<MNK_N>(blockCoord) != (nCnt_ - 1) ? baseN_ : nBaseTail_;
202 if (tailCnt_ == 1 || roundIdx_ < round_) { // roundIdx++ in GetTileIdx202 if (tailCnt_ == 1 || roundIdx_ < round_) { // roundIdx++ in GetTileIdx
203 return {singleCoreM, singleCoreN, 0, 0};203 return {singleCoreM, singleCoreN, 0, 0};
204 }204 }
@@ -16,6 +16,8 @@
16 16 
17#include <cstdint>17#include <cstdint>
18 18 
19+#include "kernel_utils/common_utils.h"
20+ 
19namespace Block {21namespace Block {
20 22 
21/*!23/*!
@@ -114,7 +116,7 @@ public:
114 __aicore__ inline void UpdateNextProblem(const ProblemShape& problemShape)116 __aicore__ inline void UpdateNextProblem(const ProblemShape& problemShape)
115 {117 {
116 startBasicBlockId_ = (startBasicBlockId_ + prevTileNum_) % params_.coreNum;118 startBasicBlockId_ = (startBasicBlockId_ + prevTileNum_) % params_.coreNum;
117- mSize_ = AscendC::Std::get<0>(problemShape);119+ mSize_ = AscendC::Te::Get<0>(problemShape);
118 mBlkNum_ = CeilDiv(mSize_, static_cast<uint64_t>(params_.baseM));120 mBlkNum_ = CeilDiv(mSize_, static_cast<uint64_t>(params_.baseM));
119 mStep_ = CeilDiv(mSize_, mBlkNum_);121 mStep_ = CeilDiv(mSize_, mBlkNum_);
120 tileNum_ = mBlkNum_ * nBlockNum_;122 tileNum_ = mBlkNum_ * nBlockNum_;
@@ -156,8 +158,8 @@ public:
156 // Compute tile shape from tile coordinate and segment-specific N split.158 // Compute tile shape from tile coordinate and segment-specific N split.
157 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)159 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)
158 {160 {
159- uint64_t mOffset = static_cast<uint64_t>(AscendC::Std::get<0>(blockCoord));161+ uint64_t mOffset = static_cast<uint64_t>(AscendC::Te::Get<0>(blockCoord));
160- uint64_t nOffset = static_cast<uint64_t>(AscendC::Std::get<1>(blockCoord));162+ uint64_t nOffset = static_cast<uint64_t>(AscendC::Te::Get<1>(blockCoord));
161 163 
162 uint64_t mL1Size = (mOffset + mStep_ > mSize_) ? (mSize_ - mOffset) : mStep_;164 uint64_t mL1Size = (mOffset + mStep_ > mSize_) ? (mSize_ - mOffset) : mStep_;
163 165 
@@ -15,8 +15,6 @@
15#pragma once15#pragma once
16 16 
17#include "kernel_utils/common_utils.h"17#include "kernel_utils/common_utils.h"
18-#include "kernel_utils/integral_constant.h"
19-#include "kernel_utils/tuple_utils.h"
20 18 
21struct KernelMultiBlockOnKAxisWithScale {};19struct KernelMultiBlockOnKAxisWithScale {};
22 20 
@@ -20,9 +20,11 @@ namespace Prologue {
20 20 
21template <class DispatchPolicy, class... Args>21template <class DispatchPolicy, class... Args>
22class BlockPrologue {22class BlockPrologue {
23- static_assert(AscendC::Std::always_false_v<DispatchPolicy>, "BlockPrologue is not implemented for this DispatchPolicy");23+ static_assert(
24+ !AscendC::Std::is_same_v<DispatchPolicy, DispatchPolicy>,
25+ "BlockPrologue is not implemented for this DispatchPolicy");
24};26};
25 27 
26} // namespace Prologue28} // namespace Prologue
27 29 
28-#include "weight_quant_grouped_matmul_mxfp8fp4_block_prologue_split_m.h"30+#include "weight_quant_grouped_matmul_mxfp8fp4_block_prologue_split_m.h"
@@ -22,8 +22,7 @@
22#include "kernel_operator.h"22#include "kernel_operator.h"
23#endif23#endif
24#include "lib/matmul_intf.h"24#include "lib/matmul_intf.h"
25- 25+#include "include/tensor_api/tensor.h"
26-#include "integral_constant.h"
27 26 
28// On-chip buffer capacities used by the kernel helper code.27// On-chip buffer capacities used by the kernel helper code.
29static constexpr int64_t L0A_SIZE = 64 * 1024;28static constexpr int64_t L0A_SIZE = 64 * 1024;
@@ -1,36 +0,0 @@
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 integral_constant.h
13- * \brief Minimal integral-constant aliases used by device-side template code.
14- */
15-#pragma once
16-#if ASC_DEVKIT_MAJOR >= 9
17-#include "kernel_basic_intf.h"
18-#else
19-#include "kernel_operator.h"
20-#endif
21- 
22-namespace AscendC {
23-namespace Std {
24-template <typename...>
25-struct always_false : public false_type {};
26- 
27-template <typename... Tp>
28-constexpr bool always_false_v = always_false<Tp...>::value;
29-} // namespace Std
30-} // namespace AscendC
31- 
32-template <int32_t t>
33-using Int = AscendC::Std::integral_constant<int32_t, t>;
34- 
35-using _0 = Int<0>;
36- 
@@ -1,34 +0,0 @@
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 tuple_utils.h
13- * \brief Tuple access helpers for nested Ascend C tuple-like values.
14- */
15- 
16-#pragma once
17- 
18-#include "lib/std/tuple.h"
19-#include "./integral_constant.h"
20- 
21-// Base case: return the element addressed by one tuple index.
22-template <size_t I, typename T>
23-__aicore__ constexpr inline decltype(auto) Get(T&& t)
24-{
25- return AscendC::Std::get<I>(AscendC::Std::forward<T>(t));
26-}
27- 
28-// Recursive case: walk nested tuples by consuming one index at a time.
29-template <size_t First, size_t Second, size_t... Rest, typename T>
30-__aicore__ constexpr inline decltype(auto) Get(T&& t)
31-{
32- return Get<Second, Rest...>(AscendC::Std::get<First>(AscendC::Std::forward<T>(t)));
33-}
34- 
@@ -15,14 +15,14 @@
15 15 
16#pragma once16#pragma once
17 17 
18-#include "kernel_utils/integral_constant.h"18+#include "kernel_utils/common_utils.h"
19 19 
20namespace Block {20namespace Block {
21template <21template <
22 class DispatchPolicy_, class AType_, class LayoutA_, class BType_,22 class DispatchPolicy_, class AType_, class LayoutA_, class BType_,
23 class LayoutB_, class CType_, class LayoutC_, class Enable = void>23 class LayoutB_, class CType_, class LayoutC_, class Enable = void>
24class BlockMmad {24class BlockMmad {
25- static_assert(AscendC::Std::always_false_v<DispatchPolicy_>, "Should not be here!");25+ static_assert(!AscendC::Std::is_same_v<DispatchPolicy_, DispatchPolicy_>, "Should not be here!");
26};26};
27} // namespace Block27} // namespace Block
28 28 
@@ -16,7 +16,6 @@
16#pragma once16#pragma once
17 17 
18#include "kernel_utils/common_utils.h"18#include "kernel_utils/common_utils.h"
19-#include "kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../policy/dispatch_policy.h"20#include "../policy/dispatch_policy.h"
22#include "../utils/constant.h"21#include "../utils/constant.h"
@@ -81,15 +80,15 @@ public:
81 __aicore__ inline BlockMmad(80 __aicore__ inline BlockMmad(
82 const TupleShape& problemShape, const TupleShape& tileL1Shape, const TupleShape& tileL0Shape)81 const TupleShape& problemShape, const TupleShape& tileL1Shape, const TupleShape& tileL0Shape)
83 {82 {
84- m_ = Get<IDX_M_IDX>(problemShape);83+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
85- n_ = Get<IDX_N_IDX>(problemShape);84+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
86- k_ = Get<IDX_K_IDX>(problemShape);85+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
87- mL1_ = Get<IDX_M_IDX>(tileL1Shape);86+ mL1_ = AscendC::Te::Get<IDX_M_IDX>(tileL1Shape);
88- nL1_ = Get<IDX_N_IDX>(tileL1Shape);87+ nL1_ = AscendC::Te::Get<IDX_N_IDX>(tileL1Shape);
89- kL1_ = Get<IDX_K_IDX>(tileL1Shape);88+ kL1_ = AscendC::Te::Get<IDX_K_IDX>(tileL1Shape);
90- baseM_ = Get<IDX_M_IDX>(tileL0Shape);89+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(tileL0Shape);
91- baseN_ = Get<IDX_N_IDX>(tileL0Shape);90+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(tileL0Shape);
92- baseK_ = Get<IDX_K_IDX>(tileL0Shape);91+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(tileL0Shape);
93 aL1OneBuffer_ = mL1_ * kL1_;92 aL1OneBuffer_ = mL1_ * kL1_;
94 bL1Init_ = aL1OneBuffer_ * L1_BUFFER_NUM;93 bL1Init_ = aL1OneBuffer_ * L1_BUFFER_NUM;
95 bL1OneBuffer_ = nL1_ * kL1_;94 bL1OneBuffer_ = nL1_ * kL1_;
@@ -119,9 +118,9 @@ public:
119 TensorC gmC, TensorA gmA, TensorB gmB, TensorWorkSpace gmWorkSpace, const BlockShape& tileShape,118 TensorC gmC, TensorA gmA, TensorB gmB, TensorWorkSpace gmWorkSpace, const BlockShape& tileShape,
120 int64_t kCntIndex, bool checkIsSkScene)119 int64_t kCntIndex, bool checkIsSkScene)
121 {120 {
122- uint64_t curML1 = Get<MNK_M>(tileShape);121+ uint64_t curML1 = AscendC::Te::Get<MNK_M>(tileShape);
123- uint64_t curNL1 = Get<MNK_N>(tileShape);122+ uint64_t curNL1 = AscendC::Te::Get<MNK_N>(tileShape);
124- uint64_t curSingleCoreK = Get<MNK_K>(tileShape);123+ uint64_t curSingleCoreK = AscendC::Te::Get<MNK_K>(tileShape);
125 uint64_t curKL1Iter = (curSingleCoreK + kL1_ - 1) / kL1_;124 uint64_t curKL1Iter = (curSingleCoreK + kL1_ - 1) / kL1_;
126 125 
127 // LoC move out126 // LoC move out
@@ -16,7 +16,6 @@
16#pragma once16#pragma once
17 17 
18#include "kernel_utils/common_utils.h"18#include "kernel_utils/common_utils.h"
19-#include "kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../policy/dispatch_policy.h"20#include "../policy/dispatch_policy.h"
22#include "../utils/constant.h"21#include "../utils/constant.h"
@@ -84,15 +83,15 @@ public:
84 83 
85 __aicore__ inline BlockMmad(const TupleShape& problemShape, const TupleShape& tileL1Shape, const TupleShape& tileL0Shape, bool l0cDB)84 __aicore__ inline BlockMmad(const TupleShape& problemShape, const TupleShape& tileL1Shape, const TupleShape& tileL0Shape, bool l0cDB)
86 {85 {
87- m_ = Get<IDX_M_IDX>(problemShape);86+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
88- n_ = Get<IDX_N_IDX>(problemShape);87+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
89- k_ = Get<IDX_K_IDX>(problemShape);88+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
90- mL1_ = Get<IDX_M_IDX>(tileL1Shape);89+ mL1_ = AscendC::Te::Get<IDX_M_IDX>(tileL1Shape);
91- nL1_ = Get<IDX_N_IDX>(tileL1Shape);90+ nL1_ = AscendC::Te::Get<IDX_N_IDX>(tileL1Shape);
92- kL1_ = Get<IDX_K_IDX>(tileL1Shape);91+ kL1_ = AscendC::Te::Get<IDX_K_IDX>(tileL1Shape);
93- baseM_ = Get<IDX_M_IDX>(tileL0Shape);92+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(tileL0Shape);
94- baseN_ = Get<IDX_N_IDX>(tileL0Shape);93+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(tileL0Shape);
95- baseK_ = Get<IDX_K_IDX>(tileL0Shape);94+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(tileL0Shape);
96 kAlign_ = Align(k_, AscendC::BLOCK_CUBE);95 kAlign_ = Align(k_, AscendC::BLOCK_CUBE);
97 enableL0cPingPong_ = l0cDB;96 enableL0cPingPong_ = l0cDB;
98 // Non-full load97 // Non-full load
@@ -126,8 +125,8 @@ public:
126 template <typename TensorC, typename TensorA, typename TensorB>125 template <typename TensorC, typename TensorA, typename TensorB>
127 __aicore__ inline void operator()(TensorC gmC, TensorA gmA, TensorB gmB, const BlockShape& tileShape)126 __aicore__ inline void operator()(TensorC gmC, TensorA gmA, TensorB gmB, const BlockShape& tileShape)
128 {127 {
129- uint64_t curM = Get<MNK_M>(tileShape);128+ uint64_t curM = AscendC::Te::Get<MNK_M>(tileShape);
130- uint64_t curN = Get<MNK_N>(tileShape);129+ uint64_t curN = AscendC::Te::Get<MNK_N>(tileShape);
131 uint64_t ml1Align = Align(curM, AscendC::BLOCK_CUBE);130 uint64_t ml1Align = Align(curM, AscendC::BLOCK_CUBE);
132 uint64_t l0cOffset = (l0cPingPong_ & 0x1) * HALF_L0C_SIZE;131 uint64_t l0cOffset = (l0cPingPong_ & 0x1) * HALF_L0C_SIZE;
133 if (enableL0cPingPong_) {132 if (enableL0cPingPong_) {
@@ -16,7 +16,6 @@
16#pragma once16#pragma once
17 17 
18#include "kernel_utils/common_utils.h"18#include "kernel_utils/common_utils.h"
19-#include "kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../policy/dispatch_policy.h"20#include "../policy/dispatch_policy.h"
22#include "../utils/constant.h"21#include "../utils/constant.h"
@@ -160,14 +159,14 @@ public:
160 // In the A-full-load path, the A tile and its scale stay resident in159 // In the A-full-load path, the A tile and its scale stay resident in
161 // L1. The offset plan therefore reserves a dedicated resident region160 // L1. The offset plan therefore reserves a dedicated resident region
162 // and packs the rolling B/scaleB buffers around it.161 // and packs the rolling B/scaleB buffers around it.
163- m_ = Get<IDX_M_IDX>(problemShape);162+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
164- n_ = Get<IDX_N_IDX>(problemShape);163+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
165- k_ = Get<IDX_K_IDX>(problemShape);164+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
166 kL1_ = l1Params.kL1;165 kL1_ = l1Params.kL1;
167 scaleKL1_ = l1Params.scaleKL1;166 scaleKL1_ = l1Params.scaleKL1;
168- baseM_ = Get<IDX_M_IDX>(l0TileShape);167+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
169- baseN_ = Get<IDX_N_IDX>(l0TileShape);168+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
170- baseK_ = Get<IDX_K_IDX>(l0TileShape);169+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
171 enableL0cPingPong_ = enableL0cPingPong;170 enableL0cPingPong_ = enableL0cPingPong;
172 171 
173 constexpr uint64_t sizeShift = isDTypeFp4 ? 1UL : 0UL;172 constexpr uint64_t sizeShift = isDTypeFp4 ? 1UL : 0UL;
@@ -208,8 +207,8 @@ public:
208 // This path keeps A-side data resident across the N tiles handled by207 // This path keeps A-side data resident across the N tiles handled by
209 // the same block. The first tile populates the resident A buffers and208 // the same block. The first tile populates the resident A buffers and
210 // loads scaleA once; later tiles mainly stream the B side through K.209 // loads scaleA once; later tiles mainly stream the B side through K.
211- auto curM = Get<IDX_M_TILEIDX>(singleShape);210+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
212- auto curN = Get<IDX_N_TILEIDX>(singleShape);211+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
213 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;212 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
214 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);213 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
215 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);214 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -16,7 +16,6 @@
16#pragma once16#pragma once
17 17 
18#include "kernel_utils/common_utils.h"18#include "kernel_utils/common_utils.h"
19-#include "kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../policy/dispatch_policy.h"20#include "../policy/dispatch_policy.h"
22#include "../utils/constant.h"21#include "../utils/constant.h"
@@ -159,14 +158,14 @@ public:
159 {158 {
160 // Pre-compute all persistent buffer sizes and L1 offsets once per block159 // Pre-compute all persistent buffer sizes and L1 offsets once per block
161 // so the hot path only needs to switch between ping-pong slots.160 // so the hot path only needs to switch between ping-pong slots.
162- m_ = Get<IDX_M_IDX>(problemShape);161+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
163- n_ = Get<IDX_N_IDX>(problemShape);162+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
164- k_ = Get<IDX_K_IDX>(problemShape);163+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
165 kL1_ = l1Params.kL1;164 kL1_ = l1Params.kL1;
166 scaleKL1_ = l1Params.scaleKL1;165 scaleKL1_ = l1Params.scaleKL1;
167- baseM_ = Get<IDX_M_IDX>(l0TileShape);166+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
168- baseN_ = Get<IDX_N_IDX>(l0TileShape);167+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
169- baseK_ = Get<IDX_K_IDX>(l0TileShape);168+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
170 enableL0cPingPong_ = enableL0cPingPong;169 enableL0cPingPong_ = enableL0cPingPong;
171 constexpr uint64_t sizeShift = isDTypeFp4 ? 1UL : 0UL;170 constexpr uint64_t sizeShift = isDTypeFp4 ? 1UL : 0UL;
172 bL1OneBuffer_ = (baseN_ * kL1_) >> sizeShift;171 bL1OneBuffer_ = (baseN_ * kL1_) >> sizeShift;
@@ -202,8 +201,8 @@ public:
202 {201 {
203 // Non-full-load streams both A and B through L1/L0 in chunks. Scale202 // Non-full-load streams both A and B through L1/L0 in chunks. Scale
204 // tensors advance in a coarser cadence that matches `scaleKL1_`.203 // tensors advance in a coarser cadence that matches `scaleKL1_`.
205- auto curM = Get<IDX_M_TILEIDX>(singleShape);204+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
206- auto curN = Get<IDX_N_TILEIDX>(singleShape);205+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
207 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;206 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
208 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);207 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
209 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);208 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -16,7 +16,6 @@
16#pragma once16#pragma once
17 17 
18#include "kernel_utils/common_utils.h"18#include "kernel_utils/common_utils.h"
19-#include "kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../policy/dispatch_policy.h"20#include "../policy/dispatch_policy.h"
22#include "../utils/constant.h"21#include "../utils/constant.h"
@@ -159,14 +158,14 @@ public:
159 {158 {
160 // Pre-compute all persistent buffer sizes and L1 offsets once per block159 // Pre-compute all persistent buffer sizes and L1 offsets once per block
161 // so the hot path only needs to switch between ping-pong slots.160 // so the hot path only needs to switch between ping-pong slots.
162- m_ = Get<IDX_M_IDX>(problemShape);161+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
163- n_ = Get<IDX_N_IDX>(problemShape);162+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
164- k_ = Get<IDX_K_IDX>(problemShape);163+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
165 kL1_ = l1Params.kL1;164 kL1_ = l1Params.kL1;
166 scaleKL1_ = l1Params.scaleKL1;165 scaleKL1_ = l1Params.scaleKL1;
167- baseM_ = Get<IDX_M_IDX>(l0TileShape);166+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
168- baseN_ = Get<IDX_N_IDX>(l0TileShape);167+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
169- baseK_ = Get<IDX_K_IDX>(l0TileShape);168+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
170 enableL0cPingPong_ = enableL0cPingPong;169 enableL0cPingPong_ = enableL0cPingPong;
171 constexpr uint64_t sizeShift = isDTypeFp4 ? 1UL : 0UL;170 constexpr uint64_t sizeShift = isDTypeFp4 ? 1UL : 0UL;
172 bL1OneBuffer_ = (baseN_ * kL1_) >> sizeShift;171 bL1OneBuffer_ = (baseN_ * kL1_) >> sizeShift;
@@ -202,8 +201,8 @@ public:
202 {201 {
203 // Non-full-load streams both A and B through L1/L0 in chunks. Scale202 // Non-full-load streams both A and B through L1/L0 in chunks. Scale
204 // tensors advance in a coarser cadence that matches `scaleKL1_`.203 // tensors advance in a coarser cadence that matches `scaleKL1_`.
205- auto curM = Get<IDX_M_TILEIDX>(singleShape);204+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
206- auto curN = Get<IDX_N_TILEIDX>(singleShape);205+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
207 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;206 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
208 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);207 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
209 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);208 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -127,8 +127,8 @@ public:
127 __aicore__ inline void CalSingleCoreShapeByCoord(127 __aicore__ inline void CalSingleCoreShapeByCoord(
128 int64_t& singleCoreM, int64_t& singleCoreN, const BlockCoord& blockCoord)128 int64_t& singleCoreM, int64_t& singleCoreN, const BlockCoord& blockCoord)
129 {129 {
130- int64_t mTileIdx = Get<MNK_K>(blockCoord);130+ int64_t mTileIdx = AscendC::Te::Get<MNK_K>(blockCoord);
131- int64_t nTileIdx = Get<MNK_B>(blockCoord);131+ int64_t nTileIdx = AscendC::Te::Get<MNK_B>(blockCoord);
132 if constexpr (!TransA_) {132 if constexpr (!TransA_) {
133 if (mTileIdx >= mBaseNormCnt_) {133 if (mTileIdx >= mBaseNormCnt_) {
134 singleCoreM = mTileIdx < mCnt_ - 1 ? mBaseTailMain_ : mBaseTailLast_;134 singleCoreM = mTileIdx < mCnt_ - 1 ? mBaseTailMain_ : mBaseTailLast_;
@@ -204,8 +204,8 @@ public:
204 int64_t nTileIdx = curRoundIdx * blockNum_ / mCnt_ % nCnt_ + blockIdx_ / mCnt_ / curNTailTile;204 int64_t nTileIdx = curRoundIdx * blockNum_ / mCnt_ % nCnt_ + blockIdx_ / mCnt_ / curNTailTile;
205 205 
206 BlockCoord shapeCoord{};206 BlockCoord shapeCoord{};
207- Get<MNK_K>(shapeCoord) = mTileIdx;207+ AscendC::Std::get<MNK_K>(shapeCoord) = mTileIdx;
208- Get<MNK_B>(shapeCoord) = nTileIdx;208+ AscendC::Std::get<MNK_B>(shapeCoord) = nTileIdx;
209 int64_t singleCoreM = baseM_;209 int64_t singleCoreM = baseM_;
210 int64_t singleCoreN = baseN_;210 int64_t singleCoreN = baseN_;
211 CalSingleCoreShapeByCoord(singleCoreM, singleCoreN, shapeCoord);211 CalSingleCoreShapeByCoord(singleCoreM, singleCoreN, shapeCoord);
@@ -243,10 +243,10 @@ public:
243 // Pack one scheduler result into `blockCoord`:243 // Pack one scheduler result into `blockCoord`:
244 // M/N hold GM origin, while K/B preserve logical tile indices for the244 // M/N hold GM origin, while K/B preserve logical tile indices for the
245 // later `GetBlockShape` call.245 // later `GetBlockShape` call.
246- Get<MNK_M>(blockCoord) = mPos;246+ AscendC::Std::get<MNK_M>(blockCoord) = mPos;
247- Get<MNK_N>(blockCoord) = nPos;247+ AscendC::Std::get<MNK_N>(blockCoord) = nPos;
248- Get<MNK_K>(blockCoord) = mTileIdx;248+ AscendC::Std::get<MNK_K>(blockCoord) = mTileIdx;
249- Get<MNK_B>(blockCoord) = nTileIdx;249+ AscendC::Std::get<MNK_B>(blockCoord) = nTileIdx;
250 roundIdx_++;250 roundIdx_++;
251 return true;251 return true;
252 }252 }
@@ -138,8 +138,8 @@ public:
138 {138 {
139 // `blockCoord` carries GM coordinates in M/N and keeps the logical139 // `blockCoord` carries GM coordinates in M/N and keeps the logical
140 // tile indices in K/B. Shape reconstruction must therefore read K/B.140 // tile indices in K/B. Shape reconstruction must therefore read K/B.
141- int64_t mTileIdx = Get<MNK_K>(blockCoord);141+ int64_t mTileIdx = AscendC::Te::Get<MNK_K>(blockCoord);
142- int64_t nTileIdx = Get<MNK_B>(blockCoord);142+ int64_t nTileIdx = AscendC::Te::Get<MNK_B>(blockCoord);
143 if constexpr (!TransA_) {143 if constexpr (!TransA_) {
144 if (mTileIdx >= mBaseNormCnt_) {144 if (mTileIdx >= mBaseNormCnt_) {
145 singleCoreM = mTileIdx < mCnt_ - 1 ? mBaseTailMain_ : mBaseTailLast_;145 singleCoreM = mTileIdx < mCnt_ - 1 ? mBaseTailMain_ : mBaseTailLast_;
@@ -238,8 +238,8 @@ public:
238 }238 }
239 239 
240 BlockCoord shapeCoord{};240 BlockCoord shapeCoord{};
241- Get<MNK_K>(shapeCoord) = mTileIdx;241+ AscendC::Std::get<MNK_K>(shapeCoord) = mTileIdx;
242- Get<MNK_B>(shapeCoord) = nTileIdx;242+ AscendC::Std::get<MNK_B>(shapeCoord) = nTileIdx;
243 int64_t singleCoreM = baseM_;243 int64_t singleCoreM = baseM_;
244 int64_t singleCoreN = baseN_;244 int64_t singleCoreN = baseN_;
245 CalSingleCoreShapeByCoord(singleCoreM, singleCoreN, shapeCoord);245 CalSingleCoreShapeByCoord(singleCoreM, singleCoreN, shapeCoord);
@@ -279,10 +279,10 @@ public:
279 // Pack one scheduler result into `blockCoord`:279 // Pack one scheduler result into `blockCoord`:
280 // M/N hold GM origin, while K/B preserve logical tile indices for the280 // M/N hold GM origin, while K/B preserve logical tile indices for the
281 // later `GetBlockShape` call.281 // later `GetBlockShape` call.
282- Get<MNK_M>(blockCoord) = mPos;282+ AscendC::Std::get<MNK_M>(blockCoord) = mPos;
283- Get<MNK_N>(blockCoord) = nPos;283+ AscendC::Std::get<MNK_N>(blockCoord) = nPos;
284- Get<MNK_K>(blockCoord) = mTileIdx;284+ AscendC::Std::get<MNK_K>(blockCoord) = mTileIdx;
285- Get<MNK_B>(blockCoord) = nTileIdx;285+ AscendC::Std::get<MNK_B>(blockCoord) = nTileIdx;
286 roundIdx_++;286 roundIdx_++;
287 return true;287 return true;
288 }288 }
@@ -139,8 +139,8 @@ public:
139 {139 {
140 // `blockCoord` carries GM coordinates in M/N and keeps the logical140 // `blockCoord` carries GM coordinates in M/N and keeps the logical
141 // tile indices in K/B. Shape reconstruction must therefore read K/B.141 // tile indices in K/B. Shape reconstruction must therefore read K/B.
142- int64_t mTileIdx = Get<MNK_K>(blockCoord);142+ int64_t mTileIdx = AscendC::Te::Get<MNK_K>(blockCoord);
143- int64_t nTileIdx = Get<MNK_B>(blockCoord);143+ int64_t nTileIdx = AscendC::Te::Get<MNK_B>(blockCoord);
144 if constexpr (!TransA_) {144 if constexpr (!TransA_) {
145 if (mTileIdx >= mBaseNormCnt_) {145 if (mTileIdx >= mBaseNormCnt_) {
146 singleCoreM = mTileIdx < mCnt_ - 1 ? mBaseTailMain_ : mBaseTailLast_;146 singleCoreM = mTileIdx < mCnt_ - 1 ? mBaseTailMain_ : mBaseTailLast_;
@@ -239,8 +239,8 @@ public:
239 }239 }
240 240 
241 BlockCoord shapeCoord{};241 BlockCoord shapeCoord{};
242- Get<MNK_K>(shapeCoord) = mTileIdx;242+ AscendC::Std::get<MNK_K>(shapeCoord) = mTileIdx;
243- Get<MNK_B>(shapeCoord) = nTileIdx;243+ AscendC::Std::get<MNK_B>(shapeCoord) = nTileIdx;
244 int64_t singleCoreM = baseM_;244 int64_t singleCoreM = baseM_;
245 int64_t singleCoreN = baseN_;245 int64_t singleCoreN = baseN_;
246 CalSingleCoreShapeByCoord(singleCoreM, singleCoreN, shapeCoord);246 CalSingleCoreShapeByCoord(singleCoreM, singleCoreN, shapeCoord);
@@ -280,10 +280,10 @@ public:
280 // Pack one scheduler result into `blockCoord`:280 // Pack one scheduler result into `blockCoord`:
281 // M/N hold GM origin, while K/B preserve logical tile indices for the281 // M/N hold GM origin, while K/B preserve logical tile indices for the
282 // later `GetBlockShape` call.282 // later `GetBlockShape` call.
283- Get<MNK_M>(blockCoord) = mPos;283+ AscendC::Std::get<MNK_M>(blockCoord) = mPos;
284- Get<MNK_N>(blockCoord) = nPos;284+ AscendC::Std::get<MNK_N>(blockCoord) = nPos;
285- Get<MNK_K>(blockCoord) = mTileIdx;285+ AscendC::Std::get<MNK_K>(blockCoord) = mTileIdx;
286- Get<MNK_B>(blockCoord) = nTileIdx;286+ AscendC::Std::get<MNK_B>(blockCoord) = nTileIdx;
287 roundIdx_++;287 roundIdx_++;
288 return true;288 return true;
289 }289 }
@@ -90,13 +90,13 @@ public:
90 __aicore__ inline void Init(Params const& params, TupleShape blockShapeInAiv, TupleShape tileL1ShapeInAiv,90 __aicore__ inline void Init(Params const& params, TupleShape blockShapeInAiv, TupleShape tileL1ShapeInAiv,
91 BlockCoord coordInAiv, uint64_t usedCoreNum, bool checkIsSkScene)91 BlockCoord coordInAiv, uint64_t usedCoreNum, bool checkIsSkScene)
92 {92 {
93- m_ = Get<MNK_M>(blockShapeInAiv);93+ m_ = AscendC::Te::Get<MNK_M>(blockShapeInAiv);
94- n_ = Get<MNK_N>(blockShapeInAiv);94+ n_ = AscendC::Te::Get<MNK_N>(blockShapeInAiv);
95- mL1_ = Get<MNK_M>(tileL1ShapeInAiv);95+ mL1_ = AscendC::Te::Get<MNK_M>(tileL1ShapeInAiv);
96- nL1_ = Get<MNK_N>(tileL1ShapeInAiv);96+ nL1_ = AscendC::Te::Get<MNK_N>(tileL1ShapeInAiv);
97- mCnt_ = Get<MNK_M>(coordInAiv);97+ mCnt_ = AscendC::Te::Get<MNK_M>(coordInAiv);
98- nCnt_ = Get<MNK_N>(coordInAiv);98+ nCnt_ = AscendC::Te::Get<MNK_N>(coordInAiv);
99- kCnt_ = Get<MNK_K>(coordInAiv);99+ kCnt_ = AscendC::Te::Get<MNK_K>(coordInAiv);
100 usedCoreNum_ = usedCoreNum;100 usedCoreNum_ = usedCoreNum;
101 // Decrease tile size of per vector core to prevent data race of cube and vector101 // Decrease tile size of per vector core to prevent data race of cube and vector
102 aivMte2Num_ = checkIsSkScene ? AscendC::GetTaskRation() : AscendC::BLOCK_CUBE;102 aivMte2Num_ = checkIsSkScene ? AscendC::GetTaskRation() : AscendC::BLOCK_CUBE;
@@ -23,7 +23,6 @@
23#endif23#endif
24 24 
25#include "kernel_utils/common_utils.h"25#include "kernel_utils/common_utils.h"
26-#include "kernel_utils/tuple_utils.h"
27#include "include/tensor_api/tensor.h"26#include "include/tensor_api/tensor.h"
28 27 
29#include "../block/matmul_a16w16_block_mmad_streamk.h"28#include "../block/matmul_a16w16_block_mmad_streamk.h"
@@ -110,12 +109,12 @@ __aicore__ inline void MatmulA16W16KernelStreamK<ProblemShape, BlockMmad, BlockS
110 workspaceGmAddr_ = reinterpret_cast<__gm__ float*>(blockMmadParams_.workspaceGmAddr);109 workspaceGmAddr_ = reinterpret_cast<__gm__ float*>(blockMmadParams_.workspaceGmAddr);
111 BlockSchedulerOp bs(params.problemShape, params.schParams);110 BlockSchedulerOp bs(params.problemShape, params.schParams);
112 TupleShape tileL1 = {params.kernelParams.mL1, params.kernelParams.nL1, params.kernelParams.kL1};111 TupleShape tileL1 = {params.kernelParams.mL1, params.kernelParams.nL1, params.kernelParams.kL1};
113- int64_t mL1 = Get<MNK_M>(tileL1);112+ int64_t mL1 = AscendC::Te::Get<MNK_M>(tileL1);
114- int64_t nL1 = Get<MNK_N>(tileL1);113+ int64_t nL1 = AscendC::Te::Get<MNK_N>(tileL1);
115- int64_t kL1 = Get<MNK_K>(tileL1);114+ int64_t kL1 = AscendC::Te::Get<MNK_K>(tileL1);
116- int64_t mTileNum = Get<MNK_M>(bs.GetMNKTileNum());115+ int64_t mTileNum = AscendC::Te::Get<MNK_M>(bs.GetMNKTileNum());
117- int64_t nTileNum = Get<MNK_N>(bs.GetMNKTileNum());116+ int64_t nTileNum = AscendC::Te::Get<MNK_N>(bs.GetMNKTileNum());
118- int64_t skKTileNum = Get<MNK_K>(bs.GetMNKTileNum()); // it only used in sk117+ int64_t skKTileNum = AscendC::Te::Get<MNK_K>(bs.GetMNKTileNum()); // it only used in sk
119 int64_t tileNum = bs.GetTotalTileNum();118 int64_t tileNum = bs.GetTotalTileNum();
120 119 
121 if ASCEND_IS_AIC {120 if ASCEND_IS_AIC {
@@ -129,9 +128,9 @@ __aicore__ inline void MatmulA16W16KernelStreamK<ProblemShape, BlockMmad, BlockS
129 AscendC::SetMMLayoutTransform(true);128 AscendC::SetMMLayoutTransform(true);
130 BlockMmad blockMmadOp(problemShape_, tileL1, tileL0);129 BlockMmad blockMmadOp(problemShape_, tileL1, tileL0);
131 int64_t tailSKTotalTileNum = static_cast<int64_t>(((mTileNum * nTileNum) % usedCoreNum_) * skKTileNum);130 int64_t tailSKTotalTileNum = static_cast<int64_t>(((mTileNum * nTileNum) % usedCoreNum_) * skKTileNum);
132- int64_t m = Get<MNK_M>(problemShape_);131+ int64_t m = AscendC::Te::Get<MNK_M>(problemShape_);
133- int64_t n = Get<MNK_N>(problemShape_);132+ int64_t n = AscendC::Te::Get<MNK_N>(problemShape_);
134- int64_t k = Get<MNK_K>(problemShape_);133+ int64_t k = AscendC::Te::Get<MNK_K>(problemShape_);
135 134 
136 auto layoutA = MakeLayoutA{}(m, k);135 auto layoutA = MakeLayoutA{}(m, k);
137 auto layoutB = MakeLayoutB{}(k, n);136 auto layoutB = MakeLayoutB{}(k, n);
@@ -160,21 +159,21 @@ __aicore__ inline void MatmulA16W16KernelStreamK<ProblemShape, BlockMmad, BlockS
160 auto singleCoreCoord = bs.GetSingleCoreCoord(tmpTileIdx);159 auto singleCoreCoord = bs.GetSingleCoreCoord(tmpTileIdx);
161 int64_t kSingleCore = bs.GetCurKSingleCore(tmpTileIdx);160 int64_t kSingleCore = bs.GetCurKSingleCore(tmpTileIdx);
162 int64_t offsetWorkspace =161 int64_t offsetWorkspace =
163- (((tmpTileIdx % usedCoreNum_) / skKTileNum) * skKTileNum + Get<MNK_K>(singleCoreCoord)) * BLOCK_BASE_M *162+ (((tmpTileIdx % usedCoreNum_) / skKTileNum) * skKTileNum + AscendC::Te::Get<MNK_K>(singleCoreCoord)) * BLOCK_BASE_M *
164 BLOCK_BASE_N;163 BLOCK_BASE_N;
165 auto layoutWorkspace = AscendC::Te::MakeFrameLayout<AscendC::Te::NDExtLayoutPtn>(164 auto layoutWorkspace = AscendC::Te::MakeFrameLayout<AscendC::Te::NDExtLayoutPtn>(
166- Get<MNK_M>(singleCoreShape), Get<MNK_N>(singleCoreShape));165+ AscendC::Te::Get<MNK_M>(singleCoreShape), AscendC::Te::Get<MNK_N>(singleCoreShape));
167 auto gmWorkSpace =166 auto gmWorkSpace =
168 AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::GM>(workspaceGmAddr_ + offsetWorkspace), layoutWorkspace);167 AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::GM>(workspaceGmAddr_ + offsetWorkspace), layoutWorkspace);
169- auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(Get<MNK_M>(singleCoreCoord) * mL1, Get<MNK_K>(singleCoreCoord) * kSingleCore),168+ auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(AscendC::Te::Get<MNK_M>(singleCoreCoord) * mL1, AscendC::Te::Get<MNK_K>(singleCoreCoord) * kSingleCore),
170- AscendC::Te::MakeShape(Get<MNK_M>(singleCoreShape), Get<MNK_K>(singleCoreShape)));169+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleCoreShape), AscendC::Te::Get<MNK_K>(singleCoreShape)));
171- auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(Get<MNK_K>(singleCoreCoord) * kSingleCore, Get<MNK_N>(singleCoreCoord) * nL1),170+ auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(AscendC::Te::Get<MNK_K>(singleCoreCoord) * kSingleCore, AscendC::Te::Get<MNK_N>(singleCoreCoord) * nL1),
172- AscendC::Te::MakeShape(Get<MNK_K>(singleCoreShape), Get<MNK_N>(singleCoreShape)));171+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_K>(singleCoreShape), AscendC::Te::Get<MNK_N>(singleCoreShape)));
173 auto gmBlockC =172 auto gmBlockC =
174- gmC.Slice(AscendC::Te::MakeCoord(Get<MNK_M>(singleCoreCoord) * mL1, Get<MNK_N>(singleCoreCoord) * nL1),173+ gmC.Slice(AscendC::Te::MakeCoord(AscendC::Te::Get<MNK_M>(singleCoreCoord) * mL1, AscendC::Te::Get<MNK_N>(singleCoreCoord) * nL1),
175- AscendC::Te::MakeShape(Get<MNK_M>(singleCoreShape), Get<MNK_N>(singleCoreShape)));174+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleCoreShape), AscendC::Te::Get<MNK_N>(singleCoreShape)));
176 blockMmadOp(175 blockMmadOp(
177- gmBlockC, gmBlockA, gmBlockB, gmWorkSpace, singleCoreShape, Get<MNK_K>(singleCoreCoord),176+ gmBlockC, gmBlockA, gmBlockB, gmWorkSpace, singleCoreShape, AscendC::Te::Get<MNK_K>(singleCoreCoord),
178 bs.CheckIsSkScene(tmpTileIdx));177 bs.CheckIsSkScene(tmpTileIdx));
179 if (tmpTileIdx + usedCoreNum_ >= tileNum) {178 if (tmpTileIdx + usedCoreNum_ >= tileNum) {
180 AscendC::CrossCoreSetFlag<AIC_SYNC_AIV_MODE_4, PIPE_FIX>(AIC_SYNC_AIV_FLAG);179 AscendC::CrossCoreSetFlag<AIC_SYNC_AIV_MODE_4, PIPE_FIX>(AIC_SYNC_AIV_FLAG);
@@ -23,7 +23,6 @@
23#endif23#endif
24 24 
25#include "kernel_utils/common_utils.h"25#include "kernel_utils/common_utils.h"
26-#include "kernel_utils/tuple_utils.h"
27#include "include/tensor_api/tensor.h"26#include "include/tensor_api/tensor.h"
28 27 
29#include "../block/matmul_a16w16_block_mmad_swat.h"28#include "../block/matmul_a16w16_block_mmad_swat.h"
@@ -115,9 +114,9 @@ __aicore__ inline void MatmulA16W16KernelSwat<ProblemShape, BlockMmad, BlockSche
115 // Instantiate mmadOp114 // Instantiate mmadOp
116 BlockMmad blockMmadOp(problemShape_, tileL1, tileL0, l0cDB);115 BlockMmad blockMmadOp(problemShape_, tileL1, tileL0, l0cDB);
117 116 
118- int64_t m = Get<MNK_M>(problemShape_);117+ int64_t m = AscendC::Te::Get<MNK_M>(problemShape_);
119- int64_t n = Get<MNK_N>(problemShape_);118+ int64_t n = AscendC::Te::Get<MNK_N>(problemShape_);
120- int64_t k = Get<MNK_K>(problemShape_);119+ int64_t k = AscendC::Te::Get<MNK_K>(problemShape_);
121 120 
122 auto layoutA = MakeLayoutA{}(m, k); // ND layout for A121 auto layoutA = MakeLayoutA{}(m, k); // ND layout for A
123 auto layoutB = MakeLayoutB{}(k, n); // ND layout for B122 auto layoutB = MakeLayoutB{}(k, n); // ND layout for B
@@ -136,12 +135,12 @@ __aicore__ inline void MatmulA16W16KernelSwat<ProblemShape, BlockMmad, BlockSche
136 auto tileShape = bs.GetBlockShape(tileIdx); // (m, n, k, b)135 auto tileShape = bs.GetBlockShape(tileIdx); // (m, n, k, b)
137 auto tileCoord = bs.GetBlockCoord(tileIdx); // (m, n, k, b)136 auto tileCoord = bs.GetBlockCoord(tileIdx); // (m, n, k, b)
138 auto gmBlockA =137 auto gmBlockA =
139- gmA.Slice(AscendC::MakeCoord(Get<0>(tileCoord), 0), AscendC::MakeShape(Get<0>(tileShape), Get<2>(tileShape)));138+ gmA.Slice(AscendC::MakeCoord(AscendC::Te::Get<0>(tileCoord), 0), AscendC::MakeShape(AscendC::Te::Get<0>(tileShape), AscendC::Te::Get<2>(tileShape)));
140 auto gmBlockB =139 auto gmBlockB =
141- gmB.Slice(AscendC::MakeCoord(0, Get<1>(tileCoord)), AscendC::MakeShape(Get<2>(tileShape), Get<1>(tileShape)));140+ gmB.Slice(AscendC::MakeCoord(0, AscendC::Te::Get<1>(tileCoord)), AscendC::MakeShape(AscendC::Te::Get<2>(tileShape), AscendC::Te::Get<1>(tileShape)));
142 auto gmBlockC =141 auto gmBlockC =
143- gmC.Slice(AscendC::MakeCoord(Get<0>(tileCoord), Get<1>(tileCoord)),142+ gmC.Slice(AscendC::MakeCoord(AscendC::Te::Get<0>(tileCoord), AscendC::Te::Get<1>(tileCoord)),
144- AscendC::MakeShape(Get<0>(tileShape), Get<1>(tileShape)));143+ AscendC::MakeShape(AscendC::Te::Get<0>(tileShape), AscendC::Te::Get<1>(tileShape)));
145 blockMmadOp(gmBlockC, gmBlockA, gmBlockB, tileShape);144 blockMmadOp(gmBlockC, gmBlockA, gmBlockB, tileShape);
146 }145 }
147 146 
@@ -23,7 +23,6 @@
23#endif23#endif
24 24 
25#include "kernel_utils/common_utils.h"25#include "kernel_utils/common_utils.h"
26-#include "kernel_utils/tuple_utils.h"
27#include "include/tensor_api/tensor.h"26#include "include/tensor_api/tensor.h"
28 27 
29#include "../block/quant_matmul_mx_block_mmad_a_full_load.h"28#include "../block/quant_matmul_mx_block_mmad_a_full_load.h"
@@ -218,10 +217,10 @@ __aicore__ inline void QuantMatmulMxKernelAFullLoad<QBMM_MX_KERNEL_A_FULL_LOAD_F
218 while (bs.template GetTileIdx<weightNz>(blockIdx)) {217 while (bs.template GetTileIdx<weightNz>(blockIdx)) {
219 // The scheduler packs GM origin into M/N and retains logical tile218 // The scheduler packs GM origin into M/N and retains logical tile
220 // indices in K/B so shape reconstruction still works.219 // indices in K/B so shape reconstruction still works.
221- int64_t mPos = Get<MNK_M>(blockIdx);220+ int64_t mPos = AscendC::Te::Get<MNK_M>(blockIdx);
222- int64_t nPos = Get<MNK_N>(blockIdx);221+ int64_t nPos = AscendC::Te::Get<MNK_N>(blockIdx);
223 BlockShape singleShape = bs.template GetBlockShape<weightNz>(blockIdx);222 BlockShape singleShape = bs.template GetBlockShape<weightNz>(blockIdx);
224- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {223+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
225 // Tail splitting can create empty logical slices; ignore them and224 // Tail splitting can create empty logical slices; ignore them and
226 // stop the current block once no useful work remains.225 // stop the current block once no useful work remains.
227 return;226 return;
@@ -229,16 +228,16 @@ __aicore__ inline void QuantMatmulMxKernelAFullLoad<QBMM_MX_KERNEL_A_FULL_LOAD_F
229 228 
230 // `blockIdx` now carries both GM origin and logical tile metadata.229 // `blockIdx` now carries both GM origin and logical tile metadata.
231 auto gmBlockA =230 auto gmBlockA =
232- gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), params.problemShape.k));231+ gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), params.problemShape.k));
233 auto gmBlockScaleA =232 auto gmBlockScaleA =
234- gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), kScaleSize));233+ gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), kScaleSize));
235 auto gmBlockB =234 auto gmBlockB =
236- gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, Get<MNK_N>(singleShape)));235+ gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, AscendC::Te::Get<MNK_N>(singleShape)));
237 auto gmBlockScaleB =236 auto gmBlockScaleB =
238- gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(kScaleSize, Get<MNK_N>(singleShape)));237+ gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(kScaleSize, AscendC::Te::Get<MNK_N>(singleShape)));
239 auto gmBlockC =238 auto gmBlockC =
240 gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),239 gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),
241- AscendC::Te::MakeShape(Get<MNK_M>(singleShape), Get<MNK_N>(singleShape)));240+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), AscendC::Te::Get<MNK_N>(singleShape)));
242 241 
243 // The block MMAD layer owns all data movement below GM granularity and242 // The block MMAD layer owns all data movement below GM granularity and
244 // performs the actual accumulation for this scheduled tile.243 // performs the actual accumulation for this scheduled tile.
@@ -23,7 +23,6 @@
23#endif23#endif
24 24 
25#include "kernel_utils/common_utils.h"25#include "kernel_utils/common_utils.h"
26-#include "kernel_utils/tuple_utils.h"
27#include "include/tensor_api/tensor.h"26#include "include/tensor_api/tensor.h"
28 27 
29#include "../block/quant_matmul_mx_block_mmad_swat.h"28#include "../block/quant_matmul_mx_block_mmad_swat.h"
@@ -219,10 +218,10 @@ __aicore__ inline void QuantMatmulMxKernelSwat<QBMM_MX_KERNEL_NO_FULL_LOAD_FUN_T
219 while (bs.template GetTileIdx<weightNz>(blockIdx)) {218 while (bs.template GetTileIdx<weightNz>(blockIdx)) {
220 // The scheduler packs GM origin into M/N and retains logical tile219 // The scheduler packs GM origin into M/N and retains logical tile
221 // indices in K/B so shape reconstruction still works.220 // indices in K/B so shape reconstruction still works.
222- int64_t mPos = Get<MNK_M>(blockIdx);221+ int64_t mPos = AscendC::Te::Get<MNK_M>(blockIdx);
223- int64_t nPos = Get<MNK_N>(blockIdx);222+ int64_t nPos = AscendC::Te::Get<MNK_N>(blockIdx);
224 BlockShape singleShape = bs.template GetBlockShape<weightNz>(blockIdx);223 BlockShape singleShape = bs.template GetBlockShape<weightNz>(blockIdx);
225- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {224+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
226 // Tail splitting can create empty logical slices; ignore them and225 // Tail splitting can create empty logical slices; ignore them and
227 // stop the current block once no useful work remains.226 // stop the current block once no useful work remains.
228 return;227 return;
@@ -230,16 +229,16 @@ __aicore__ inline void QuantMatmulMxKernelSwat<QBMM_MX_KERNEL_NO_FULL_LOAD_FUN_T
230 229 
231 // `blockIdx` now carries both GM origin and logical tile metadata.230 // `blockIdx` now carries both GM origin and logical tile metadata.
232 auto gmBlockA =231 auto gmBlockA =
233- gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), params.problemShape.k));232+ gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), params.problemShape.k));
234 auto gmBlockScaleA =233 auto gmBlockScaleA =
235- gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), kScaleSize));234+ gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), kScaleSize));
236 auto gmBlockB =235 auto gmBlockB =
237- gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, Get<MNK_N>(singleShape)));236+ gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, AscendC::Te::Get<MNK_N>(singleShape)));
238 auto gmBlockScaleB =237 auto gmBlockScaleB =
239- gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(kScaleSize, Get<MNK_N>(singleShape)));238+ gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(kScaleSize, AscendC::Te::Get<MNK_N>(singleShape)));
240 auto gmBlockC =239 auto gmBlockC =
241 gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),240 gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),
242- AscendC::Te::MakeShape(Get<MNK_M>(singleShape), Get<MNK_N>(singleShape)));241+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), AscendC::Te::Get<MNK_N>(singleShape)));
243 242 
244 // The block MMAD layer owns all data movement below GM granularity and243 // The block MMAD layer owns all data movement below GM granularity and
245 // performs the actual accumulation for this scheduled tile.244 // performs the actual accumulation for this scheduled tile.
@@ -23,7 +23,6 @@
23#endif23#endif
24 24 
25#include "kernel_utils/common_utils.h"25#include "kernel_utils/common_utils.h"
26-#include "kernel_utils/tuple_utils.h"
27#include "include/tensor_api/tensor.h"26#include "include/tensor_api/tensor.h"
28 27 
29#include "../block/block_mmad.h"28#include "../block/block_mmad.h"
@@ -219,10 +218,10 @@ __aicore__ inline void QuantMatmulMxKernelSwat4Buffer<QBMM_MX_KERNEL_SWAT_4BUF_F
219 while (bs.template GetTileIdx<weightNz>(blockIdx)) {218 while (bs.template GetTileIdx<weightNz>(blockIdx)) {
220 // The scheduler packs GM origin into M/N and retains logical tile219 // The scheduler packs GM origin into M/N and retains logical tile
221 // indices in K/B so shape reconstruction still works.220 // indices in K/B so shape reconstruction still works.
222- int64_t mPos = Get<MNK_M>(blockIdx);221+ int64_t mPos = AscendC::Te::Get<MNK_M>(blockIdx);
223- int64_t nPos = Get<MNK_N>(blockIdx);222+ int64_t nPos = AscendC::Te::Get<MNK_N>(blockIdx);
224 BlockShape singleShape = bs.template GetBlockShape<weightNz>(blockIdx);223 BlockShape singleShape = bs.template GetBlockShape<weightNz>(blockIdx);
225- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {224+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
226 // Tail splitting can create empty logical slices; ignore them and225 // Tail splitting can create empty logical slices; ignore them and
227 // stop the current block once no useful work remains.226 // stop the current block once no useful work remains.
228 return;227 return;
@@ -230,16 +229,16 @@ __aicore__ inline void QuantMatmulMxKernelSwat4Buffer<QBMM_MX_KERNEL_SWAT_4BUF_F
230 229 
231 // `blockIdx` now carries both GM origin and logical tile metadata.230 // `blockIdx` now carries both GM origin and logical tile metadata.
232 auto gmBlockA =231 auto gmBlockA =
233- gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), params.problemShape.k));232+ gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), params.problemShape.k));
234 auto gmBlockScaleA =233 auto gmBlockScaleA =
235- gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), kScaleSize));234+ gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), kScaleSize));
236 auto gmBlockB =235 auto gmBlockB =
237- gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, Get<MNK_N>(singleShape)));236+ gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, AscendC::Te::Get<MNK_N>(singleShape)));
238 auto gmBlockScaleB =237 auto gmBlockScaleB =
239- gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(kScaleSize, Get<MNK_N>(singleShape)));238+ gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(kScaleSize, AscendC::Te::Get<MNK_N>(singleShape)));
240 auto gmBlockC =239 auto gmBlockC =
241 gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),240 gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),
242- AscendC::Te::MakeShape(Get<MNK_M>(singleShape), Get<MNK_N>(singleShape)));241+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), AscendC::Te::Get<MNK_N>(singleShape)));
243 242 
244 // The block MMAD layer owns all data movement below GM granularity and243 // The block MMAD layer owns all data movement below GM granularity and
245 // performs the actual accumulation for this scheduled tile.244 // performs the actual accumulation for this scheduled tile.
@@ -15,8 +15,7 @@
15 15 
16#pragma once16#pragma once
17 17 
18-#include "kernel_utils/integral_constant.h"18+#include "kernel_utils/common_utils.h"
19-#include "include/tensor_api/tensor.h"
20 19 
21namespace MatmulRecipe {20namespace MatmulRecipe {
22 21 
@@ -16,7 +16,6 @@
16#include "kernel_operator.h"16#include "kernel_operator.h"
17#endif17#endif
18#include "../../../common/kernel_utils/common_utils.h"18#include "../../../common/kernel_utils/common_utils.h"
19-#include "../../../common/kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../utils/quant_matmul_constant.h"20#include "../utils/quant_matmul_constant.h"
22#include "../tile/tile_mmad_mx.h"21#include "../tile/tile_mmad_mx.h"
@@ -63,12 +62,12 @@ public:
63 __aicore__ inline void Init(const TupleShape& problemShape, const BlockShape& l0TileShape,62 __aicore__ inline void Init(const TupleShape& problemShape, const BlockShape& l0TileShape,
64 const L1Params& l1Params)63 const L1Params& l1Params)
65 {64 {
66- m_ = static_cast<uint64_t>(Get<IDX_M_IDX>(problemShape));65+ m_ = static_cast<uint64_t>(AscendC::Te::Get<IDX_M_IDX>(problemShape));
67- n_ = static_cast<uint64_t>(Get<IDX_N_IDX>(problemShape));66+ n_ = static_cast<uint64_t>(AscendC::Te::Get<IDX_N_IDX>(problemShape));
68- k_ = static_cast<uint64_t>(Get<IDX_K_IDX>(problemShape));67+ k_ = static_cast<uint64_t>(AscendC::Te::Get<IDX_K_IDX>(problemShape));
69- baseM_ = static_cast<uint64_t>(Get<IDX_M_IDX>(l0TileShape));68+ baseM_ = static_cast<uint64_t>(AscendC::Te::Get<IDX_M_IDX>(l0TileShape));
70- baseN_ = static_cast<uint64_t>(Get<IDX_N_IDX>(l0TileShape));69+ baseN_ = static_cast<uint64_t>(AscendC::Te::Get<IDX_N_IDX>(l0TileShape));
71- baseK_ = static_cast<uint64_t>(Get<IDX_K_IDX>(l0TileShape));70+ baseK_ = static_cast<uint64_t>(AscendC::Te::Get<IDX_K_IDX>(l0TileShape));
72 if (baseK_ == 0) {71 if (baseK_ == 0) {
73 baseK_ = 128 / sizeof(fp4x2_e2m1_t);72 baseK_ = 128 / sizeof(fp4x2_e2m1_t);
74 }73 }
@@ -86,8 +85,8 @@ public:
86 TensorC cGlobal,85 TensorC cGlobal,
87 const BlockShape& singleShape)86 const BlockShape& singleShape)
88 {87 {
89- uint64_t curM = static_cast<uint64_t>(Get<IDX_M_TILEIDX>(singleShape));88+ uint64_t curM = static_cast<uint64_t>(AscendC::Te::Get<IDX_M_TILEIDX>(singleShape));
90- uint64_t curN = static_cast<uint64_t>(Get<IDX_N_TILEIDX>(singleShape));89+ uint64_t curN = static_cast<uint64_t>(AscendC::Te::Get<IDX_N_TILEIDX>(singleShape));
91 90 
92 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);91 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
93 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(0), layoutL0C);92 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(0), layoutL0C);
@@ -16,7 +16,6 @@
16#include "kernel_operator.h"16#include "kernel_operator.h"
17#endif17#endif
18#include "../../../common/kernel_utils/common_utils.h"18#include "../../../common/kernel_utils/common_utils.h"
19-#include "../../../common/kernel_utils/tuple_utils.h"
20#include "block_scheduler_utils.h"19#include "block_scheduler_utils.h"
21 20 
22namespace Block {21namespace Block {
@@ -80,8 +79,8 @@ public:
80 79 
81 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)80 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)
82 {81 {
83- int64_t mTileIdx = Get<MNK_K>(blockCoord);82+ int64_t mTileIdx = AscendC::Te::Get<MNK_K>(blockCoord);
84- int64_t nTileIdx = Get<MNK_B>(blockCoord);83+ int64_t nTileIdx = AscendC::Te::Get<MNK_B>(blockCoord);
85 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;84 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;
86 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;85 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;
87 return {singleCoreM, singleCoreN, 0, 0};86 return {singleCoreM, singleCoreN, 0, 0};
@@ -98,10 +97,10 @@ public:
98 }97 }
99 int64_t mTileIdx = tileIdx % mCnt_;98 int64_t mTileIdx = tileIdx % mCnt_;
100 int64_t nTileIdx = tileIdx / mCnt_;99 int64_t nTileIdx = tileIdx / mCnt_;
101- Get<MNK_M>(blockCoord) = mTileIdx * baseM_;100+ AscendC::Std::get<MNK_M>(blockCoord) = mTileIdx * baseM_;
102- Get<MNK_N>(blockCoord) = nTileIdx * baseN_;101+ AscendC::Std::get<MNK_N>(blockCoord) = nTileIdx * baseN_;
103- Get<MNK_K>(blockCoord) = mTileIdx;102+ AscendC::Std::get<MNK_K>(blockCoord) = mTileIdx;
104- Get<MNK_B>(blockCoord) = nTileIdx;103+ AscendC::Std::get<MNK_B>(blockCoord) = nTileIdx;
105 roundIdx_++;104 roundIdx_++;
106 return true;105 return true;
107 }106 }
@@ -16,7 +16,6 @@
16#include "kernel_operator_intf.h"16#include "kernel_operator_intf.h"
17#endif17#endif
18#include "../../../common/kernel_utils/common_utils.h"18#include "../../../common/kernel_utils/common_utils.h"
19-#include "../../../common/kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../block/block_scheduler_mx_base.h"20#include "../block/block_scheduler_mx_base.h"
22#include "../block/block_mmad_mx_base.h"21#include "../block/block_mmad_mx_base.h"
@@ -135,23 +134,23 @@ __aicore__ inline void QuantMatmulMxKernelBaseImpl<QBMM_MX_KERNEL_FUN_TEM_PARAMS
135 BlockCoord blockCoord;134 BlockCoord blockCoord;
136 constexpr int64_t kPos = 0L;135 constexpr int64_t kPos = 0L;
137 while (bs.GetTileIdx(blockCoord)) {136 while (bs.GetTileIdx(blockCoord)) {
138- int64_t mPos = Get<MNK_M>(blockCoord);137+ int64_t mPos = AscendC::Te::Get<MNK_M>(blockCoord);
139- int64_t nPos = Get<MNK_N>(blockCoord);138+ int64_t nPos = AscendC::Te::Get<MNK_N>(blockCoord);
140 BlockShape singleShape = bs.GetBlockShape(blockCoord);139 BlockShape singleShape = bs.GetBlockShape(blockCoord);
141- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {140+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
142 return;141 return;
143 }142 }
144 143 
145- auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), params.problemShape.k));144+ auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), params.problemShape.k));
146 auto gmBlockScaleA = gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos),145 auto gmBlockScaleA = gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos),
147 AscendC::Te::MakeShape(146 AscendC::Te::MakeShape(
148- Get<MNK_M>(singleShape), CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE));147+ AscendC::Te::Get<MNK_M>(singleShape), CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE));
149- auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, Get<MNK_N>(singleShape)));148+ auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, AscendC::Te::Get<MNK_N>(singleShape)));
150 auto gmBlockScaleB = gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos),149 auto gmBlockScaleB = gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos),
151 AscendC::Te::MakeShape(150 AscendC::Te::MakeShape(
152- CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE, Get<MNK_N>(singleShape)));151+ CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE, AscendC::Te::Get<MNK_N>(singleShape)));
153 auto gmBlockC = gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),152 auto gmBlockC = gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),
154- AscendC::Te::MakeShape(Get<MNK_M>(singleShape), Get<MNK_N>(singleShape)));153+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), AscendC::Te::Get<MNK_N>(singleShape)));
155 mmadOp_(gmBlockA, gmBlockB, gmBlockScaleA, gmBlockScaleB, gmBlockC, singleShape);154 mmadOp_(gmBlockA, gmBlockB, gmBlockScaleA, gmBlockScaleB, gmBlockC, singleShape);
156 }155 }
157}156}
@@ -40,40 +40,40 @@ public:
40 int64_t nOffset = nTileIdx * l1N + nSplitOffset;40 int64_t nOffset = nTileIdx * l1N + nSplitOffset;
41 if constexpr (enableLoadBalance) {41 if constexpr (enableLoadBalance) {
42 if constexpr (!isTransA) {42 if constexpr (!isTransA) {
43- if (mTileIdx > Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {43+ if (mTileIdx > AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {
44- mOffset -= (mTileIdx - Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *44+ mOffset -= (mTileIdx - AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *
45- (l1M - Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));45+ (l1M - AscendC::Te::Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));
46 }46 }
47 }47 }
48 if constexpr (isTransB) {48 if constexpr (isTransB) {
49- if (nTileIdx > Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {49+ if (nTileIdx > AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {
50- nOffset -= (nTileIdx - Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *50+ nOffset -= (nTileIdx - AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *
51- (l1N - Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));51+ (l1N - AscendC::Te::Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));
52 }52 }
53 }53 }
54 }54 }
55 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};55 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};
56 if constexpr (isTransA) {56 if constexpr (isTransA) {
57- Get<IDX_A_OFFSET>(offset) = mOffset;57+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset;
58 } else {58 } else {
59- Get<IDX_A_OFFSET>(offset) = mOffset * k;59+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset * k;
60 }60 }
61 if constexpr (isTransB) {61 if constexpr (isTransB) {
62- Get<IDX_B_OFFSET>(offset) = nOffset * k;62+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset * k;
63 } else {63 } else {
64- Get<IDX_B_OFFSET>(offset) = nOffset;64+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset;
65 }65 }
66 66 
67- Get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset;67+ AscendC::Std::get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset;
68 if constexpr (isTransA) {68 if constexpr (isTransA) {
69- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE;69+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE;
70 } else {70 } else {
71- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;71+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;
72 }72 }
73 if constexpr (isTransB) {73 if constexpr (isTransB) {
74- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;74+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;
75 } else {75 } else {
76- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE;76+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE;
77 }77 }
78 return offset;78 return offset;
79 }79 }
@@ -17,7 +17,6 @@
17#endif17#endif
18 18 
19#include "kernel_utils/common_utils.h"19#include "kernel_utils/common_utils.h"
20-#include "kernel_utils/tuple_utils.h"
21#include "include/tensor_api/tensor.h"20#include "include/tensor_api/tensor.h"
22#include "../utils/quant_matmul_constant.h"21#include "../utils/quant_matmul_constant.h"
23#include "../tile/tile_mmad_mx.h"22#include "../tile/tile_mmad_mx.h"
@@ -91,14 +90,14 @@ public:
91 __aicore__ inline void Init(90 __aicore__ inline void Init(
92 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)91 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)
93 {92 {
94- m_ = Get<IDX_M_IDX>(problemShape);93+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
95- n_ = Get<IDX_N_IDX>(problemShape);94+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
96- k_ = Get<IDX_K_IDX>(problemShape);95+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
97 kL1_ = l1Params.kL1;96 kL1_ = l1Params.kL1;
98 scaleKL1_ = l1Params.scaleKL1;97 scaleKL1_ = l1Params.scaleKL1;
99- baseM_ = Get<IDX_M_IDX>(l0TileShape);98+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
100- baseN_ = Get<IDX_N_IDX>(l0TileShape);99+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
101- baseK_ = Get<IDX_K_IDX>(l0TileShape);100+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
102 l1BufNum_ = l1Params.l1BufNum;101 l1BufNum_ = l1Params.l1BufNum;
103 102 
104 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;103 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;
@@ -126,8 +125,8 @@ public:
126 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,125 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,
127 BlockShape singleShape)126 BlockShape singleShape)
128 {127 {
129- auto curM = Get<IDX_M_TILEIDX>(singleShape);128+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
130- auto curN = Get<IDX_N_TILEIDX>(singleShape);129+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
131 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;130 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
132 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);131 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
133 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);132 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -16,7 +16,6 @@
16#include "kernel_operator.h"16#include "kernel_operator.h"
17#endif17#endif
18#include "../../../common/kernel_utils/common_utils.h"18#include "../../../common/kernel_utils/common_utils.h"
19-#include "../../../common/kernel_utils/tuple_utils.h"
20#include "block_scheduler_utils.h"19#include "block_scheduler_utils.h"
21 20 
22namespace Block {21namespace Block {
@@ -80,8 +79,8 @@ public:
80 79 
81 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)80 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)
82 {81 {
83- int64_t mTileIdx = Get<MNK_K>(blockCoord);82+ int64_t mTileIdx = AscendC::Te::Get<MNK_K>(blockCoord);
84- int64_t nTileIdx = Get<MNK_B>(blockCoord);83+ int64_t nTileIdx = AscendC::Te::Get<MNK_B>(blockCoord);
85 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;84 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;
86 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;85 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;
87 return {singleCoreM, singleCoreN, 0, 0};86 return {singleCoreM, singleCoreN, 0, 0};
@@ -98,10 +97,10 @@ public:
98 }97 }
99 int64_t mTileIdx = tileIdx % mCnt_;98 int64_t mTileIdx = tileIdx % mCnt_;
100 int64_t nTileIdx = tileIdx / mCnt_;99 int64_t nTileIdx = tileIdx / mCnt_;
101- Get<MNK_M>(blockCoord) = mTileIdx * baseM_;100+ AscendC::Std::get<MNK_M>(blockCoord) = mTileIdx * baseM_;
102- Get<MNK_N>(blockCoord) = nTileIdx * baseN_;101+ AscendC::Std::get<MNK_N>(blockCoord) = nTileIdx * baseN_;
103- Get<MNK_K>(blockCoord) = mTileIdx;102+ AscendC::Std::get<MNK_K>(blockCoord) = mTileIdx;
104- Get<MNK_B>(blockCoord) = nTileIdx;103+ AscendC::Std::get<MNK_B>(blockCoord) = nTileIdx;
105 roundIdx_++;104 roundIdx_++;
106 return true;105 return true;
107 }106 }
@@ -21,7 +21,6 @@
21#include "kernel_operator_intf.h"21#include "kernel_operator_intf.h"
22#endif22#endif
23#include "kernel_utils/common_utils.h"23#include "kernel_utils/common_utils.h"
24-#include "kernel_utils/tuple_utils.h"
25#include "include/tensor_api/tensor.h"24#include "include/tensor_api/tensor.h"
26#include "../block/block_scheduler_mx_base.h"25#include "../block/block_scheduler_mx_base.h"
27#include "../block/block_mmad_mx_base.h"26#include "../block/block_mmad_mx_base.h"
@@ -146,14 +145,14 @@ __aicore__ inline void QuantMatmulMxKernelBaseImpl<QBMM_MX_KERNEL_FUN_TEM_PARAMS
146 BlockCoord blockCoord;145 BlockCoord blockCoord;
147 constexpr int64_t kPos = 0L;146 constexpr int64_t kPos = 0L;
148 while (bs.GetTileIdx(blockCoord)) {147 while (bs.GetTileIdx(blockCoord)) {
149- int64_t mPos = Get<MNK_M>(blockCoord);148+ int64_t mPos = AscendC::Te::Get<MNK_M>(blockCoord);
150- int64_t nPos = Get<MNK_N>(blockCoord);149+ int64_t nPos = AscendC::Te::Get<MNK_N>(blockCoord);
151 BlockShape singleShape = bs.GetBlockShape(blockCoord);150 BlockShape singleShape = bs.GetBlockShape(blockCoord);
152- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {151+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
153 return;152 return;
154 }153 }
155- auto curM = Get<IDX_M_TILEIDX>(singleShape);154+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
156- auto curN = Get<IDX_N_TILEIDX>(singleShape);155+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
157 156 
158 auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos),157 auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos),
159 AscendC::Te::MakeShape(curM, params.problemShape.k));158 AscendC::Te::MakeShape(curM, params.problemShape.k));
@@ -45,40 +45,40 @@ public:
45 int64_t nOffset = nTileIdx * l1N + nSplitOffset;45 int64_t nOffset = nTileIdx * l1N + nSplitOffset;
46 if constexpr (enableLoadBalance) {46 if constexpr (enableLoadBalance) {
47 if constexpr (!isTransA) {47 if constexpr (!isTransA) {
48- if (mTileIdx > Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {48+ if (mTileIdx > AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {
49- mOffset -= (mTileIdx - Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *49+ mOffset -= (mTileIdx - AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *
50- (l1M - Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));50+ (l1M - AscendC::Te::Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));
51 }51 }
52 }52 }
53 if constexpr (isTransB) {53 if constexpr (isTransB) {
54- if (nTileIdx > Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {54+ if (nTileIdx > AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {
55- nOffset -= (nTileIdx - Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *55+ nOffset -= (nTileIdx - AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *
56- (l1N - Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));56+ (l1N - AscendC::Te::Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));
57 }57 }
58 }58 }
59 }59 }
60 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};60 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};
61 if constexpr (isTransA) {61 if constexpr (isTransA) {
62- Get<IDX_A_OFFSET>(offset) = mOffset;62+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset;
63 } else {63 } else {
64- Get<IDX_A_OFFSET>(offset) = mOffset * k;64+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset * k;
65 }65 }
66 if constexpr (isTransB) {66 if constexpr (isTransB) {
67- Get<IDX_B_OFFSET>(offset) = nOffset * k;67+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset * k;
68 } else {68 } else {
69- Get<IDX_B_OFFSET>(offset) = nOffset;69+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset;
70 }70 }
71 71 
72- Get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset; // 4: idx of y72+ AscendC::Std::get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset; // 4: idx of y
73 if constexpr (isTransA) {73 if constexpr (isTransA) {
74- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale74+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale
75 } else {75 } else {
76- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale76+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale
77 }77 }
78 if constexpr (isTransB) {78 if constexpr (isTransB) {
79- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale79+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale
80 } else {80 } else {
81- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale81+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale
82 }82 }
83 return offset;83 return offset;
84 }84 }
@@ -17,7 +17,6 @@
17#endif17#endif
18 18 
19#include "kernel_utils/common_utils.h"19#include "kernel_utils/common_utils.h"
20-#include "kernel_utils/tuple_utils.h"
21#include "include/tensor_api/tensor.h"20#include "include/tensor_api/tensor.h"
22#include "../utils/quant_matmul_constant.h"21#include "../utils/quant_matmul_constant.h"
23#include "../tile/tile_mmad_mx.h"22#include "../tile/tile_mmad_mx.h"
@@ -91,14 +90,14 @@ public:
91 __aicore__ inline void Init(90 __aicore__ inline void Init(
92 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)91 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)
93 {92 {
94- m_ = Get<IDX_M_IDX>(problemShape);93+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
95- n_ = Get<IDX_N_IDX>(problemShape);94+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
96- k_ = Get<IDX_K_IDX>(problemShape);95+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
97 kL1_ = l1Params.kL1;96 kL1_ = l1Params.kL1;
98 scaleKL1_ = l1Params.scaleKL1;97 scaleKL1_ = l1Params.scaleKL1;
99- baseM_ = Get<IDX_M_IDX>(l0TileShape);98+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
100- baseN_ = Get<IDX_N_IDX>(l0TileShape);99+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
101- baseK_ = Get<IDX_K_IDX>(l0TileShape);100+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
102 l1BufNum_ = l1Params.l1BufNum;101 l1BufNum_ = l1Params.l1BufNum;
103 102 
104 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;103 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;
@@ -126,8 +125,8 @@ public:
126 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,125 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,
127 BlockShape singleShape)126 BlockShape singleShape)
128 {127 {
129- auto curM = Get<IDX_M_TILEIDX>(singleShape);128+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
130- auto curN = Get<IDX_N_TILEIDX>(singleShape);129+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
131 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;130 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
132 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);131 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
133 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);132 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -19,7 +19,6 @@
19#include "kernel_operator.h"19#include "kernel_operator.h"
20#endif20#endif
21#include "../../../common/kernel_utils/common_utils.h"21#include "../../../common/kernel_utils/common_utils.h"
22-#include "../../../common/kernel_utils/tuple_utils.h"
23#include "block_scheduler_utils.h"22#include "block_scheduler_utils.h"
24 23 
25namespace Block {24namespace Block {
@@ -88,8 +87,8 @@ public:
88 87 
89 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)88 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)
90 {89 {
91- int64_t mTileIdx = Get<MNK_K>(blockCoord);90+ int64_t mTileIdx = AscendC::Te::Get<MNK_K>(blockCoord);
92- int64_t nTileIdx = Get<MNK_B>(blockCoord);91+ int64_t nTileIdx = AscendC::Te::Get<MNK_B>(blockCoord);
93 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;92 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;
94 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;93 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;
95 return {singleCoreM, singleCoreN, 0, 0};94 return {singleCoreM, singleCoreN, 0, 0};
@@ -108,19 +107,19 @@ public:
108 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;107 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;
109 if (rowIdx < mainRow_) {108 if (rowIdx < mainRow_) {
110 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;109 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;
111- Get<MNK_K>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;110+ AscendC::Std::get<MNK_K>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;
112- Get<MNK_B>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;111+ AscendC::Std::get<MNK_B>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;
113 } else {112 } else {
114 rowIdx = mainRow_;113 rowIdx = mainRow_;
115 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;114 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;
116- Get<MNK_K>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;115+ AscendC::Std::get<MNK_K>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;
117- Get<MNK_B>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;116+ AscendC::Std::get<MNK_B>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;
118 }117 }
119 if (rowIdx & 1) {118 if (rowIdx & 1) {
120- Get<MNK_B>(blockCoord) = nCnt_ - 1 - Get<MNK_B>(blockCoord);119+ AscendC::Std::get<MNK_B>(blockCoord) = nCnt_ - 1 - AscendC::Te::Get<MNK_B>(blockCoord);
121 }120 }
122- Get<MNK_M>(blockCoord) = Get<MNK_K>(blockCoord) * baseM_;121+ AscendC::Std::get<MNK_M>(blockCoord) = AscendC::Te::Get<MNK_K>(blockCoord) * baseM_;
123- Get<MNK_N>(blockCoord) = Get<MNK_B>(blockCoord) * baseN_;122+ AscendC::Std::get<MNK_N>(blockCoord) = AscendC::Te::Get<MNK_B>(blockCoord) * baseN_;
124 123 
125 roundIdx_++;124 roundIdx_++;
126 return true;125 return true;
@@ -16,7 +16,6 @@
16#include "kernel_operator_intf.h"16#include "kernel_operator_intf.h"
17#endif17#endif
18#include "../../../common/kernel_utils/common_utils.h"18#include "../../../common/kernel_utils/common_utils.h"
19-#include "../../../common/kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../block/block_scheduler_mx_swat.h"20#include "../block/block_scheduler_mx_swat.h"
22#include "../block/block_mmad_mx_swat.h"21#include "../block/block_mmad_mx_swat.h"
@@ -138,22 +137,22 @@ __aicore__ inline void QuantMatmulMxKernelSwatImpl<QBMM_MX_KERNEL_FUN_TEM_PARAMS
138 BlockCoord blockCoord;137 BlockCoord blockCoord;
139 constexpr int64_t kPos = 0L;138 constexpr int64_t kPos = 0L;
140 while (bs.GetTileIdx(blockCoord)) {139 while (bs.GetTileIdx(blockCoord)) {
141- int64_t mPos = Get<MNK_M>(blockCoord);140+ int64_t mPos = AscendC::Te::Get<MNK_M>(blockCoord);
142- int64_t nPos = Get<MNK_N>(blockCoord);141+ int64_t nPos = AscendC::Te::Get<MNK_N>(blockCoord);
143 BlockShape singleShape = bs.GetBlockShape(blockCoord);142 BlockShape singleShape = bs.GetBlockShape(blockCoord);
144- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {143+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
145 return;144 return;
146 }145 }
147- auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), params.problemShape.k));146+ auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), params.problemShape.k));
148 auto gmBlockScaleA = gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos),147 auto gmBlockScaleA = gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos),
149 AscendC::Te::MakeShape(148 AscendC::Te::MakeShape(
150- Get<MNK_M>(singleShape), CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE));149+ AscendC::Te::Get<MNK_M>(singleShape), CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE));
151- auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, Get<MNK_N>(singleShape)));150+ auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, AscendC::Te::Get<MNK_N>(singleShape)));
152 auto gmBlockScaleB = gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos),151 auto gmBlockScaleB = gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos),
153 AscendC::Te::MakeShape(152 AscendC::Te::MakeShape(
154- CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE, Get<MNK_N>(singleShape)));153+ CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE, AscendC::Te::Get<MNK_N>(singleShape)));
155 auto gmBlockC = gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),154 auto gmBlockC = gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),
156- AscendC::Te::MakeShape(Get<MNK_M>(singleShape), Get<MNK_N>(singleShape)));155+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), AscendC::Te::Get<MNK_N>(singleShape)));
157 mmadOp_(gmBlockA, gmBlockB, gmBlockScaleA, gmBlockScaleB, gmBlockC, singleShape);156 mmadOp_(gmBlockA, gmBlockB, gmBlockScaleA, gmBlockScaleB, gmBlockC, singleShape);
158 }157 }
159}158}
@@ -40,40 +40,40 @@ public:
40 int64_t nOffset = nTileIdx * l1N + nSplitOffset;40 int64_t nOffset = nTileIdx * l1N + nSplitOffset;
41 if constexpr (enableLoadBalance) {41 if constexpr (enableLoadBalance) {
42 if constexpr (!isTransA) {42 if constexpr (!isTransA) {
43- if (mTileIdx > Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {43+ if (mTileIdx > AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {
44- mOffset -= (mTileIdx - Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *44+ mOffset -= (mTileIdx - AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *
45- (l1M - Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));45+ (l1M - AscendC::Te::Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));
46 }46 }
47 }47 }
48 if constexpr (isTransB) {48 if constexpr (isTransB) {
49- if (nTileIdx > Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {49+ if (nTileIdx > AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {
50- nOffset -= (nTileIdx - Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *50+ nOffset -= (nTileIdx - AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *
51- (l1N - Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));51+ (l1N - AscendC::Te::Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));
52 }52 }
53 }53 }
54 }54 }
55 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};55 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};
56 if constexpr (isTransA) {56 if constexpr (isTransA) {
57- Get<IDX_A_OFFSET>(offset) = mOffset;57+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset;
58 } else {58 } else {
59- Get<IDX_A_OFFSET>(offset) = mOffset * k;59+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset * k;
60 }60 }
61 if constexpr (isTransB) {61 if constexpr (isTransB) {
62- Get<IDX_B_OFFSET>(offset) = nOffset * k;62+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset * k;
63 } else {63 } else {
64- Get<IDX_B_OFFSET>(offset) = nOffset;64+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset;
65 }65 }
66 66 
67- Get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset;67+ AscendC::Std::get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset;
68 if constexpr (isTransA) {68 if constexpr (isTransA) {
69- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE;69+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE;
70 } else {70 } else {
71- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;71+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;
72 }72 }
73 if constexpr (isTransB) {73 if constexpr (isTransB) {
74- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;74+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;
75 } else {75 } else {
76- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE;76+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE;
77 }77 }
78 return offset;78 return offset;
79 }79 }
@@ -17,7 +17,6 @@
17#endif17#endif
18 18 
19#include "kernel_utils/common_utils.h"19#include "kernel_utils/common_utils.h"
20-#include "kernel_utils/tuple_utils.h"
21#include "include/tensor_api/tensor.h"20#include "include/tensor_api/tensor.h"
22#include "../utils/quant_matmul_constant.h"21#include "../utils/quant_matmul_constant.h"
23#include "../tile/tile_mmad_mx.h"22#include "../tile/tile_mmad_mx.h"
@@ -91,14 +90,14 @@ public:
91 __aicore__ inline void Init(90 __aicore__ inline void Init(
92 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)91 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)
93 {92 {
94- m_ = Get<IDX_M_IDX>(problemShape);93+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
95- n_ = Get<IDX_N_IDX>(problemShape);94+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
96- k_ = Get<IDX_K_IDX>(problemShape);95+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
97 kL1_ = l1Params.kL1;96 kL1_ = l1Params.kL1;
98 scaleKL1_ = l1Params.scaleKL1;97 scaleKL1_ = l1Params.scaleKL1;
99- baseM_ = Get<IDX_M_IDX>(l0TileShape);98+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
100- baseN_ = Get<IDX_N_IDX>(l0TileShape);99+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
101- baseK_ = Get<IDX_K_IDX>(l0TileShape);100+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
102 l1BufNum_ = l1Params.l1BufNum;101 l1BufNum_ = l1Params.l1BufNum;
103 102 
104 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;103 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;
@@ -126,8 +125,8 @@ public:
126 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,125 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,
127 BlockShape singleShape)126 BlockShape singleShape)
128 {127 {
129- auto curM = Get<IDX_M_TILEIDX>(singleShape);128+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
130- auto curN = Get<IDX_N_TILEIDX>(singleShape);129+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
131 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;130 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
132 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);131 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
133 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);132 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -19,7 +19,6 @@
19#include "kernel_operator.h"19#include "kernel_operator.h"
20#endif20#endif
21#include "../../../common/kernel_utils/common_utils.h"21#include "../../../common/kernel_utils/common_utils.h"
22-#include "../../../common/kernel_utils/tuple_utils.h"
23#include "block_scheduler_utils.h"22#include "block_scheduler_utils.h"
24 23 
25namespace Block {24namespace Block {
@@ -124,8 +123,8 @@ public:
124 123 
125 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)124 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)
126 {125 {
127- int64_t mTileIdx = Get<MNK_K>(blockCoord);126+ int64_t mTileIdx = AscendC::Te::Get<MNK_K>(blockCoord);
128- int64_t nTileIdx = Get<MNK_B>(blockCoord);127+ int64_t nTileIdx = AscendC::Te::Get<MNK_B>(blockCoord);
129 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;128 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;
130 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;129 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;
131 130 
@@ -164,19 +163,19 @@ public:
164 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;163 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;
165 if (rowIdx < mainRow_) {164 if (rowIdx < mainRow_) {
166 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;165 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;
167- Get<MNK_K>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;166+ AscendC::Std::get<MNK_K>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;
168- Get<MNK_B>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;167+ AscendC::Std::get<MNK_B>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;
169 } else {168 } else {
170 rowIdx = mainRow_;169 rowIdx = mainRow_;
171 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;170 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;
172- Get<MNK_K>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;171+ AscendC::Std::get<MNK_K>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;
173- Get<MNK_B>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;172+ AscendC::Std::get<MNK_B>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;
174 }173 }
175 if (rowIdx & 1) {174 if (rowIdx & 1) {
176- Get<MNK_B>(blockCoord) = nCnt_ - 1 - Get<MNK_B>(blockCoord);175+ AscendC::Std::get<MNK_B>(blockCoord) = nCnt_ - 1 - AscendC::Te::Get<MNK_B>(blockCoord);
177 }176 }
178- Get<MNK_M>(blockCoord) = Get<MNK_K>(blockCoord) * baseM_;177+ AscendC::Std::get<MNK_M>(blockCoord) = AscendC::Te::Get<MNK_K>(blockCoord) * baseM_;
179- Get<MNK_N>(blockCoord) = Get<MNK_B>(blockCoord) * baseN_;178+ AscendC::Std::get<MNK_N>(blockCoord) = AscendC::Te::Get<MNK_B>(blockCoord) * baseN_;
180 179 
181 roundIdx_++;180 roundIdx_++;
182 return true;181 return true;
@@ -16,7 +16,6 @@
16#include "kernel_operator_intf.h"16#include "kernel_operator_intf.h"
17#endif17#endif
18#include "../../../common/kernel_utils/common_utils.h"18#include "../../../common/kernel_utils/common_utils.h"
19-#include "../../../common/kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../utils/quant_matmul_constant.h"20#include "../utils/quant_matmul_constant.h"
22#include "../block/block_scheduler_mx_swat.h"21#include "../block/block_scheduler_mx_swat.h"
@@ -142,22 +141,22 @@ __aicore__ inline void QuantMatmulMxKernelLastRoundTileBalanceImpl<QBMM_MX_KERNE
142 constexpr int64_t kPos = 0L;141 constexpr int64_t kPos = 0L;
143 while (bs.GetTileIdx(blockCoord)) {142 while (bs.GetTileIdx(blockCoord)) {
144 BlockShape singleShape = bs.GetBlockShape(blockCoord);143 BlockShape singleShape = bs.GetBlockShape(blockCoord);
145- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {144+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
146 return;145 return;
147 }146 }
148- int64_t mPos = Get<MNK_M>(blockCoord) + Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);147+ int64_t mPos = AscendC::Te::Get<MNK_M>(blockCoord) + AscendC::Te::Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);
149- int64_t nPos = Get<MNK_N>(blockCoord) + Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);148+ int64_t nPos = AscendC::Te::Get<MNK_N>(blockCoord) + AscendC::Te::Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);
150 149 
151- auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), params.problemShape.k));150+ auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), params.problemShape.k));
152 auto gmBlockScaleA = gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos),151 auto gmBlockScaleA = gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos),
153 AscendC::Te::MakeShape(152 AscendC::Te::MakeShape(
154- Get<MNK_M>(singleShape), CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE));153+ AscendC::Te::Get<MNK_M>(singleShape), CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE));
155- auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, Get<MNK_N>(singleShape)));154+ auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, AscendC::Te::Get<MNK_N>(singleShape)));
156 auto gmBlockScaleB = gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos),155 auto gmBlockScaleB = gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos),
157 AscendC::Te::MakeShape(156 AscendC::Te::MakeShape(
158- CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE, Get<MNK_N>(singleShape)));157+ CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE, AscendC::Te::Get<MNK_N>(singleShape)));
159 auto gmBlockC = gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),158 auto gmBlockC = gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),
160- AscendC::Te::MakeShape(Get<MNK_M>(singleShape), Get<MNK_N>(singleShape)));159+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), AscendC::Te::Get<MNK_N>(singleShape)));
161 mmadOp_(gmBlockA, gmBlockB, gmBlockScaleA, gmBlockScaleB, gmBlockC, singleShape);160 mmadOp_(gmBlockA, gmBlockB, gmBlockScaleA, gmBlockScaleB, gmBlockC, singleShape);
162 }161 }
163}162}
@@ -40,40 +40,40 @@ public:
40 int64_t nOffset = nTileIdx * l1N + nSplitOffset;40 int64_t nOffset = nTileIdx * l1N + nSplitOffset;
41 if constexpr (enableLoadBalance) {41 if constexpr (enableLoadBalance) {
42 if constexpr (!isTransA) {42 if constexpr (!isTransA) {
43- if (mTileIdx > Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {43+ if (mTileIdx > AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {
44- mOffset -= (mTileIdx - Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *44+ mOffset -= (mTileIdx - AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *
45- (l1M - Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));45+ (l1M - AscendC::Te::Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));
46 }46 }
47 }47 }
48 if constexpr (isTransB) {48 if constexpr (isTransB) {
49- if (nTileIdx > Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {49+ if (nTileIdx > AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {
50- nOffset -= (nTileIdx - Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *50+ nOffset -= (nTileIdx - AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *
51- (l1N - Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));51+ (l1N - AscendC::Te::Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));
52 }52 }
53 }53 }
54 }54 }
55 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};55 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};
56 if constexpr (isTransA) {56 if constexpr (isTransA) {
57- Get<IDX_A_OFFSET>(offset) = mOffset;57+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset;
58 } else {58 } else {
59- Get<IDX_A_OFFSET>(offset) = mOffset * k;59+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset * k;
60 }60 }
61 if constexpr (isTransB) {61 if constexpr (isTransB) {
62- Get<IDX_B_OFFSET>(offset) = nOffset * k;62+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset * k;
63 } else {63 } else {
64- Get<IDX_B_OFFSET>(offset) = nOffset;64+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset;
65 }65 }
66 66 
67- Get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset;67+ AscendC::Std::get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset;
68 if constexpr (isTransA) {68 if constexpr (isTransA) {
69- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE;69+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE;
70 } else {70 } else {
71- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;71+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;
72 }72 }
73 if constexpr (isTransB) {73 if constexpr (isTransB) {
74- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;74+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;
75 } else {75 } else {
76- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE;76+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE;
77 }77 }
78 return offset;78 return offset;
79 }79 }
@@ -17,7 +17,6 @@
17#endif17#endif
18 18 
19#include "kernel_utils/common_utils.h"19#include "kernel_utils/common_utils.h"
20-#include "kernel_utils/tuple_utils.h"
21#include "include/tensor_api/tensor.h"20#include "include/tensor_api/tensor.h"
22#include "../utils/quant_matmul_constant.h"21#include "../utils/quant_matmul_constant.h"
23#include "../tile/tile_mmad_mx.h"22#include "../tile/tile_mmad_mx.h"
@@ -91,14 +90,14 @@ public:
91 __aicore__ inline void Init(90 __aicore__ inline void Init(
92 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)91 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)
93 {92 {
94- m_ = Get<IDX_M_IDX>(problemShape);93+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
95- n_ = Get<IDX_N_IDX>(problemShape);94+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
96- k_ = Get<IDX_K_IDX>(problemShape);95+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
97 kL1_ = l1Params.kL1;96 kL1_ = l1Params.kL1;
98 scaleKL1_ = l1Params.scaleKL1;97 scaleKL1_ = l1Params.scaleKL1;
99- baseM_ = Get<IDX_M_IDX>(l0TileShape);98+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
100- baseN_ = Get<IDX_N_IDX>(l0TileShape);99+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
101- baseK_ = Get<IDX_K_IDX>(l0TileShape);100+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
102 l1BufNum_ = l1Params.l1BufNum;101 l1BufNum_ = l1Params.l1BufNum;
103 102 
104 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;103 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;
@@ -126,8 +125,8 @@ public:
126 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,125 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,
127 BlockShape singleShape)126 BlockShape singleShape)
128 {127 {
129- auto curM = Get<IDX_M_TILEIDX>(singleShape);128+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
130- auto curN = Get<IDX_N_TILEIDX>(singleShape);129+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
131 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;130 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
132 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);131 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
133 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);132 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -19,7 +19,6 @@
19#include "kernel_operator.h"19#include "kernel_operator.h"
20#endif20#endif
21#include "../../../common/kernel_utils/common_utils.h"21#include "../../../common/kernel_utils/common_utils.h"
22-#include "../../../common/kernel_utils/tuple_utils.h"
23#include "block_scheduler_utils.h"22#include "block_scheduler_utils.h"
24 23 
25namespace Block {24namespace Block {
@@ -124,8 +123,8 @@ public:
124 123 
125 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)124 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)
126 {125 {
127- int64_t mTileIdx = Get<MNK_K>(blockCoord);126+ int64_t mTileIdx = AscendC::Te::Get<MNK_K>(blockCoord);
128- int64_t nTileIdx = Get<MNK_B>(blockCoord);127+ int64_t nTileIdx = AscendC::Te::Get<MNK_B>(blockCoord);
129 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;128 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;
130 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;129 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;
131 130 
@@ -164,19 +163,19 @@ public:
164 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;163 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;
165 if (rowIdx < mainRow_) {164 if (rowIdx < mainRow_) {
166 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;165 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;
167- Get<MNK_K>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;166+ AscendC::Std::get<MNK_K>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;
168- Get<MNK_B>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;167+ AscendC::Std::get<MNK_B>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;
169 } else {168 } else {
170 rowIdx = mainRow_;169 rowIdx = mainRow_;
171 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;170 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;
172- Get<MNK_K>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;171+ AscendC::Std::get<MNK_K>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;
173- Get<MNK_B>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;172+ AscendC::Std::get<MNK_B>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;
174 }173 }
175 if (rowIdx & 1) {174 if (rowIdx & 1) {
176- Get<MNK_B>(blockCoord) = nCnt_ - 1 - Get<MNK_B>(blockCoord);175+ AscendC::Std::get<MNK_B>(blockCoord) = nCnt_ - 1 - AscendC::Te::Get<MNK_B>(blockCoord);
177 }176 }
178- Get<MNK_M>(blockCoord) = Get<MNK_K>(blockCoord) * baseM_;177+ AscendC::Std::get<MNK_M>(blockCoord) = AscendC::Te::Get<MNK_K>(blockCoord) * baseM_;
179- Get<MNK_N>(blockCoord) = Get<MNK_B>(blockCoord) * baseN_;178+ AscendC::Std::get<MNK_N>(blockCoord) = AscendC::Te::Get<MNK_B>(blockCoord) * baseN_;
180 179 
181 roundIdx_++;180 roundIdx_++;
182 return true;181 return true;
@@ -16,7 +16,6 @@
16#include "kernel_operator_intf.h"16#include "kernel_operator_intf.h"
17#endif17#endif
18#include "../../../common/kernel_utils/common_utils.h"18#include "../../../common/kernel_utils/common_utils.h"
19-#include "../../../common/kernel_utils/tuple_utils.h"
20#include "include/tensor_api/tensor.h"19#include "include/tensor_api/tensor.h"
21#include "../utils/quant_matmul_constant.h"20#include "../utils/quant_matmul_constant.h"
22#include "../block/block_scheduler_mx_swat.h"21#include "../block/block_scheduler_mx_swat.h"
@@ -140,22 +139,22 @@ __aicore__ inline void QuantMatmulMxKernelUnitFlagImpl<QBMM_MX_KERNEL_FUN_TEM_PA
140 constexpr int64_t kPos = 0L;139 constexpr int64_t kPos = 0L;
141 while (bs.GetTileIdx(blockCoord)) {140 while (bs.GetTileIdx(blockCoord)) {
142 BlockShape singleShape = bs.GetBlockShape(blockCoord);141 BlockShape singleShape = bs.GetBlockShape(blockCoord);
143- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {142+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
144 return;143 return;
145 }144 }
146- int64_t mPos = Get<MNK_M>(blockCoord) + Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);145+ int64_t mPos = AscendC::Te::Get<MNK_M>(blockCoord) + AscendC::Te::Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);
147- int64_t nPos = Get<MNK_N>(blockCoord) + Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);146+ int64_t nPos = AscendC::Te::Get<MNK_N>(blockCoord) + AscendC::Te::Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);
148 147 
149- auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(Get<MNK_M>(singleShape), params.problemShape.k));148+ auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos), AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), params.problemShape.k));
150 auto gmBlockScaleA = gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos),149 auto gmBlockScaleA = gmScaleA.Slice(AscendC::Te::MakeCoord(mPos, kPos),
151 AscendC::Te::MakeShape(150 AscendC::Te::MakeShape(
152- Get<MNK_M>(singleShape), CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE));151+ AscendC::Te::Get<MNK_M>(singleShape), CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE));
153- auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, Get<MNK_N>(singleShape)));152+ auto gmBlockB = gmB.Slice(AscendC::Te::MakeCoord(kPos, nPos), AscendC::Te::MakeShape(params.problemShape.k, AscendC::Te::Get<MNK_N>(singleShape)));
154 auto gmBlockScaleB = gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos),153 auto gmBlockScaleB = gmScaleB.Slice(AscendC::Te::MakeCoord(kPos, nPos),
155 AscendC::Te::MakeShape(154 AscendC::Te::MakeShape(
156- CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE, Get<MNK_N>(singleShape)));155+ CeilDiv(params.problemShape.k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE, AscendC::Te::Get<MNK_N>(singleShape)));
157 auto gmBlockC = gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),156 auto gmBlockC = gmC.Slice(AscendC::Te::MakeCoord(mPos, nPos),
158- AscendC::Te::MakeShape(Get<MNK_M>(singleShape), Get<MNK_N>(singleShape)));157+ AscendC::Te::MakeShape(AscendC::Te::Get<MNK_M>(singleShape), AscendC::Te::Get<MNK_N>(singleShape)));
159 mmadOp_(gmBlockA, gmBlockB, gmBlockScaleA, gmBlockScaleB, gmBlockC, singleShape);158 mmadOp_(gmBlockA, gmBlockB, gmBlockScaleA, gmBlockScaleB, gmBlockC, singleShape);
160 }159 }
161}160}
@@ -40,40 +40,40 @@ public:
40 int64_t nOffset = nTileIdx * l1N + nSplitOffset;40 int64_t nOffset = nTileIdx * l1N + nSplitOffset;
41 if constexpr (enableLoadBalance) {41 if constexpr (enableLoadBalance) {
42 if constexpr (!isTransA) {42 if constexpr (!isTransA) {
43- if (mTileIdx > Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {43+ if (mTileIdx > AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {
44- mOffset -= (mTileIdx - Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *44+ mOffset -= (mTileIdx - AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *
45- (l1M - Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));45+ (l1M - AscendC::Te::Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));
46 }46 }
47 }47 }
48 if constexpr (isTransB) {48 if constexpr (isTransB) {
49- if (nTileIdx > Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {49+ if (nTileIdx > AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {
50- nOffset -= (nTileIdx - Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *50+ nOffset -= (nTileIdx - AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *
51- (l1N - Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));51+ (l1N - AscendC::Te::Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));
52 }52 }
53 }53 }
54 }54 }
55 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};55 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};
56 if constexpr (isTransA) {56 if constexpr (isTransA) {
57- Get<IDX_A_OFFSET>(offset) = mOffset;57+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset;
58 } else {58 } else {
59- Get<IDX_A_OFFSET>(offset) = mOffset * k;59+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset * k;
60 }60 }
61 if constexpr (isTransB) {61 if constexpr (isTransB) {
62- Get<IDX_B_OFFSET>(offset) = nOffset * k;62+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset * k;
63 } else {63 } else {
64- Get<IDX_B_OFFSET>(offset) = nOffset;64+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset;
65 }65 }
66 66 
67- Get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset;67+ AscendC::Std::get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset;
68 if constexpr (isTransA) {68 if constexpr (isTransA) {
69- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE;69+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE;
70 } else {70 } else {
71- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;71+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;
72 }72 }
73 if constexpr (isTransB) {73 if constexpr (isTransB) {
74- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;74+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE;
75 } else {75 } else {
76- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE;76+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE;
77 }77 }
78 return offset;78 return offset;
79 }79 }
@@ -17,7 +17,6 @@
17#endif17#endif
18 18 
19#include "kernel_utils/common_utils.h"19#include "kernel_utils/common_utils.h"
20-#include "kernel_utils/tuple_utils.h"
21#include "include/tensor_api/tensor.h"20#include "include/tensor_api/tensor.h"
22#include "../utils/quant_matmul_constant.h"21#include "../utils/quant_matmul_constant.h"
23#include "../tile/tile_mmad_mx.h"22#include "../tile/tile_mmad_mx.h"
@@ -91,14 +90,14 @@ public:
91 __aicore__ inline void Init(90 __aicore__ inline void Init(
92 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)91 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)
93 {92 {
94- m_ = Get<IDX_M_IDX>(problemShape);93+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
95- n_ = Get<IDX_N_IDX>(problemShape);94+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
96- k_ = Get<IDX_K_IDX>(problemShape);95+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
97 kL1_ = l1Params.kL1;96 kL1_ = l1Params.kL1;
98 scaleKL1_ = l1Params.scaleKL1;97 scaleKL1_ = l1Params.scaleKL1;
99- baseM_ = Get<IDX_M_IDX>(l0TileShape);98+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
100- baseN_ = Get<IDX_N_IDX>(l0TileShape);99+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
101- baseK_ = Get<IDX_K_IDX>(l0TileShape);100+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
102 l1BufNum_ = l1Params.l1BufNum;101 l1BufNum_ = l1Params.l1BufNum;
103 102 
104 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;103 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;
@@ -131,8 +130,8 @@ public:
131 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,130 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,
132 BlockShape singleShape)131 BlockShape singleShape)
133 {132 {
134- auto curM = Get<IDX_M_TILEIDX>(singleShape);133+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
135- auto curN = Get<IDX_N_TILEIDX>(singleShape);134+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
136 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;135 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
137 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);136 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
138 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);137 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -22,7 +22,6 @@
22#include "kernel_operator.h"22#include "kernel_operator.h"
23#endif23#endif
24#include "kernel_utils/common_utils.h"24#include "kernel_utils/common_utils.h"
25-#include "kernel_utils/tuple_utils.h"
26#include "block_scheduler_utils.h"25#include "block_scheduler_utils.h"
27 26 
28namespace Block {27namespace Block {
@@ -127,8 +126,8 @@ public:
127 126 
128 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)127 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)
129 {128 {
130- int64_t mTileIdx = Get<MNK_M>(blockCoord);129+ int64_t mTileIdx = AscendC::Te::Get<MNK_M>(blockCoord);
131- int64_t nTileIdx = Get<MNK_N>(blockCoord);130+ int64_t nTileIdx = AscendC::Te::Get<MNK_N>(blockCoord);
132 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;131 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;
133 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;132 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;
134 133 
@@ -167,16 +166,16 @@ public:
167 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;166 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;
168 if (rowIdx < mainRow_) {167 if (rowIdx < mainRow_) {
169 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;168 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;
170- Get<MNK_M>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;169+ AscendC::Std::get<MNK_M>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;
171- Get<MNK_N>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;170+ AscendC::Std::get<MNK_N>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;
172 } else {171 } else {
173 rowIdx = mainRow_;172 rowIdx = mainRow_;
174 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;173 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;
175- Get<MNK_M>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;174+ AscendC::Std::get<MNK_M>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;
176- Get<MNK_N>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;175+ AscendC::Std::get<MNK_N>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;
177 }176 }
178 if (rowIdx & 1) {177 if (rowIdx & 1) {
179- Get<MNK_N>(blockCoord) = nCnt_ - 1 - Get<MNK_N>(blockCoord);178+ AscendC::Std::get<MNK_N>(blockCoord) = nCnt_ - 1 - AscendC::Te::Get<MNK_N>(blockCoord);
180 }179 }
181 180 
182 roundIdx_++;181 roundIdx_++;
@@ -21,7 +21,6 @@
21#include "kernel_operator_intf.h"21#include "kernel_operator_intf.h"
22#endif22#endif
23#include "kernel_utils/common_utils.h"23#include "kernel_utils/common_utils.h"
24-#include "kernel_utils/tuple_utils.h"
25#include "include/tensor_api/tensor.h"24#include "include/tensor_api/tensor.h"
26#include "../block/block_scheduler_mx_base.h"25#include "../block/block_scheduler_mx_base.h"
27#include "../block/block_mmad_mx_base.h"26#include "../block/block_mmad_mx_base.h"
@@ -147,18 +146,18 @@ __aicore__ inline void QuantMatmulMxKernelBaseImpl<QBMM_MX_KERNEL_FUN_TEM_PARAMS
147 constexpr int64_t kPos = 0L;146 constexpr int64_t kPos = 0L;
148 while (bs.GetTileIdx(blockIdx)) {147 while (bs.GetTileIdx(blockIdx)) {
149 BlockShape singleShape = bs.GetBlockShape(blockIdx);148 BlockShape singleShape = bs.GetBlockShape(blockIdx);
150- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {149+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
151 return;150 return;
152 }151 }
153 152 
154- int64_t mTileIdx = Get<MNK_M>(blockIdx);153+ int64_t mTileIdx = AscendC::Te::Get<MNK_M>(blockIdx);
155- int64_t nTileIdx = Get<MNK_N>(blockIdx);154+ int64_t nTileIdx = AscendC::Te::Get<MNK_N>(blockIdx);
156- int64_t mSplitOffset = Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);155+ int64_t mSplitOffset = AscendC::Te::Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);
157- int64_t nSplitOffset = Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);156+ int64_t nSplitOffset = AscendC::Te::Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);
158 int64_t mPos = mTileIdx * params.qbmmParams.baseM + mSplitOffset;157 int64_t mPos = mTileIdx * params.qbmmParams.baseM + mSplitOffset;
159 int64_t nPos = nTileIdx * params.qbmmParams.baseN + nSplitOffset;158 int64_t nPos = nTileIdx * params.qbmmParams.baseN + nSplitOffset;
160- auto curM = Get<IDX_M_TILEIDX>(singleShape);159+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
161- auto curN = Get<IDX_N_TILEIDX>(singleShape);160+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
162 161 
163 auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos),162 auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos),
164 AscendC::Te::MakeShape(curM, params.problemShape.k));163 AscendC::Te::MakeShape(curM, params.problemShape.k));
@@ -45,40 +45,40 @@ public:
45 int64_t nOffset = nTileIdx * l1N + nSplitOffset;45 int64_t nOffset = nTileIdx * l1N + nSplitOffset;
46 if constexpr (enableLoadBalance) {46 if constexpr (enableLoadBalance) {
47 if constexpr (!isTransA) {47 if constexpr (!isTransA) {
48- if (mTileIdx > Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {48+ if (mTileIdx > AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {
49- mOffset -= (mTileIdx - Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *49+ mOffset -= (mTileIdx - AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *
50- (l1M - Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));50+ (l1M - AscendC::Te::Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));
51 }51 }
52 }52 }
53 if constexpr (isTransB) {53 if constexpr (isTransB) {
54- if (nTileIdx > Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {54+ if (nTileIdx > AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {
55- nOffset -= (nTileIdx - Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *55+ nOffset -= (nTileIdx - AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *
56- (l1N - Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));56+ (l1N - AscendC::Te::Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));
57 }57 }
58 }58 }
59 }59 }
60 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};60 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};
61 if constexpr (isTransA) {61 if constexpr (isTransA) {
62- Get<IDX_A_OFFSET>(offset) = mOffset;62+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset;
63 } else {63 } else {
64- Get<IDX_A_OFFSET>(offset) = mOffset * k;64+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset * k;
65 }65 }
66 if constexpr (isTransB) {66 if constexpr (isTransB) {
67- Get<IDX_B_OFFSET>(offset) = nOffset * k;67+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset * k;
68 } else {68 } else {
69- Get<IDX_B_OFFSET>(offset) = nOffset;69+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset;
70 }70 }
71 71 
72- Get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset; // 4: idx of y72+ AscendC::Std::get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset; // 4: idx of y
73 if constexpr (isTransA) {73 if constexpr (isTransA) {
74- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale74+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale
75 } else {75 } else {
76- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale76+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale
77 }77 }
78 if constexpr (isTransB) {78 if constexpr (isTransB) {
79- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale79+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale
80 } else {80 } else {
81- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale81+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale
82 }82 }
83 return offset;83 return offset;
84 }84 }
@@ -17,7 +17,6 @@
17#endif17#endif
18 18 
19#include "kernel_utils/common_utils.h"19#include "kernel_utils/common_utils.h"
20-#include "kernel_utils/tuple_utils.h"
21#include "include/tensor_api/tensor.h"20#include "include/tensor_api/tensor.h"
22#include "../utils/quant_matmul_constant.h"21#include "../utils/quant_matmul_constant.h"
23#include "../tile/tile_mmad_mx.h"22#include "../tile/tile_mmad_mx.h"
@@ -91,14 +90,14 @@ public:
91 __aicore__ inline void Init(90 __aicore__ inline void Init(
92 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)91 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)
93 {92 {
94- m_ = Get<IDX_M_IDX>(problemShape);93+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
95- n_ = Get<IDX_N_IDX>(problemShape);94+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
96- k_ = Get<IDX_K_IDX>(problemShape);95+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
97 kL1_ = l1Params.kL1;96 kL1_ = l1Params.kL1;
98 scaleKL1_ = l1Params.scaleKL1;97 scaleKL1_ = l1Params.scaleKL1;
99- baseM_ = Get<IDX_M_IDX>(l0TileShape);98+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
100- baseN_ = Get<IDX_N_IDX>(l0TileShape);99+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
101- baseK_ = Get<IDX_K_IDX>(l0TileShape);100+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
102 l1BufNum_ = l1Params.l1BufNum;101 l1BufNum_ = l1Params.l1BufNum;
103 scaleKL1Ratio_ = scaleKL1_ / kL1_;102 scaleKL1Ratio_ = scaleKL1_ / kL1_;
104 103 
@@ -200,8 +199,8 @@ AscendC::Te::Mmad(
200 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,199 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,
201 BlockShape singleShape)200 BlockShape singleShape)
202 {201 {
203- auto curM = Get<IDX_M_TILEIDX>(singleShape);202+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
204- auto curN = Get<IDX_N_TILEIDX>(singleShape);203+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
205 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;204 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
206 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);205 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
207 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);206 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -22,7 +22,6 @@
22#include "kernel_operator.h"22#include "kernel_operator.h"
23#endif23#endif
24#include "kernel_utils/common_utils.h"24#include "kernel_utils/common_utils.h"
25-#include "kernel_utils/tuple_utils.h"
26#include "block_scheduler_utils.h"25#include "block_scheduler_utils.h"
27 26 
28namespace Block {27namespace Block {
@@ -127,8 +126,8 @@ public:
127 126 
128 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)127 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)
129 {128 {
130- int64_t mTileIdx = Get<MNK_M>(blockCoord);129+ int64_t mTileIdx = AscendC::Te::Get<MNK_M>(blockCoord);
131- int64_t nTileIdx = Get<MNK_N>(blockCoord);130+ int64_t nTileIdx = AscendC::Te::Get<MNK_N>(blockCoord);
132 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;131 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;
133 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;132 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;
134 133 
@@ -167,16 +166,16 @@ public:
167 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;166 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;
168 if (rowIdx < mainRow_) {167 if (rowIdx < mainRow_) {
169 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;168 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;
170- Get<MNK_M>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;169+ AscendC::Std::get<MNK_M>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;
171- Get<MNK_N>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;170+ AscendC::Std::get<MNK_N>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;
172 } else {171 } else {
173 rowIdx = mainRow_;172 rowIdx = mainRow_;
174 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;173 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;
175- Get<MNK_M>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;174+ AscendC::Std::get<MNK_M>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;
176- Get<MNK_N>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;175+ AscendC::Std::get<MNK_N>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;
177 }176 }
178 if (rowIdx & 1) {177 if (rowIdx & 1) {
179- Get<MNK_N>(blockCoord) = nCnt_ - 1 - Get<MNK_N>(blockCoord);178+ AscendC::Std::get<MNK_N>(blockCoord) = nCnt_ - 1 - AscendC::Te::Get<MNK_N>(blockCoord);
180 }179 }
181 180 
182 roundIdx_++;181 roundIdx_++;
@@ -21,7 +21,6 @@
21#include "kernel_operator_intf.h"21#include "kernel_operator_intf.h"
22#endif22#endif
23#include "kernel_utils/common_utils.h"23#include "kernel_utils/common_utils.h"
24-#include "kernel_utils/tuple_utils.h"
25#include "include/tensor_api/tensor.h"24#include "include/tensor_api/tensor.h"
26#include "../block/block_scheduler_mx_base.h"25#include "../block/block_scheduler_mx_base.h"
27#include "../block/block_mmad_mx_base.h"26#include "../block/block_mmad_mx_base.h"
@@ -147,18 +146,18 @@ __aicore__ inline void QuantMatmulMxKernelBaseImpl<QBMM_MX_KERNEL_FUN_TEM_PARAMS
147 constexpr int64_t kPos = 0L;146 constexpr int64_t kPos = 0L;
148 while (bs.GetTileIdx(blockIdx)) {147 while (bs.GetTileIdx(blockIdx)) {
149 BlockShape singleShape = bs.GetBlockShape(blockIdx);148 BlockShape singleShape = bs.GetBlockShape(blockIdx);
150- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {149+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
151 return;150 return;
152 }151 }
153 152 
154- int64_t mTileIdx = Get<MNK_M>(blockIdx);153+ int64_t mTileIdx = AscendC::Te::Get<MNK_M>(blockIdx);
155- int64_t nTileIdx = Get<MNK_N>(blockIdx);154+ int64_t nTileIdx = AscendC::Te::Get<MNK_N>(blockIdx);
156- int64_t mSplitOffset = Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);155+ int64_t mSplitOffset = AscendC::Te::Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);
157- int64_t nSplitOffset = Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);156+ int64_t nSplitOffset = AscendC::Te::Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);
158 int64_t mPos = mTileIdx * params.qbmmParams.baseM + mSplitOffset;157 int64_t mPos = mTileIdx * params.qbmmParams.baseM + mSplitOffset;
159 int64_t nPos = nTileIdx * params.qbmmParams.baseN + nSplitOffset;158 int64_t nPos = nTileIdx * params.qbmmParams.baseN + nSplitOffset;
160- auto curM = Get<IDX_M_TILEIDX>(singleShape);159+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
161- auto curN = Get<IDX_N_TILEIDX>(singleShape);160+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
162 161 
163 auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos),162 auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos),
164 AscendC::Te::MakeShape(curM, params.problemShape.k));163 AscendC::Te::MakeShape(curM, params.problemShape.k));
@@ -45,40 +45,40 @@ public:
45 int64_t nOffset = nTileIdx * l1N + nSplitOffset;45 int64_t nOffset = nTileIdx * l1N + nSplitOffset;
46 if constexpr (enableLoadBalance) {46 if constexpr (enableLoadBalance) {
47 if constexpr (!isTransA) {47 if constexpr (!isTransA) {
48- if (mTileIdx > Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {48+ if (mTileIdx > AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {
49- mOffset -= (mTileIdx - Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *49+ mOffset -= (mTileIdx - AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *
50- (l1M - Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));50+ (l1M - AscendC::Te::Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));
51 }51 }
52 }52 }
53 if constexpr (isTransB) {53 if constexpr (isTransB) {
54- if (nTileIdx > Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {54+ if (nTileIdx > AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {
55- nOffset -= (nTileIdx - Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *55+ nOffset -= (nTileIdx - AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *
56- (l1N - Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));56+ (l1N - AscendC::Te::Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));
57 }57 }
58 }58 }
59 }59 }
60 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};60 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};
61 if constexpr (isTransA) {61 if constexpr (isTransA) {
62- Get<IDX_A_OFFSET>(offset) = mOffset;62+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset;
63 } else {63 } else {
64- Get<IDX_A_OFFSET>(offset) = mOffset * k;64+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset * k;
65 }65 }
66 if constexpr (isTransB) {66 if constexpr (isTransB) {
67- Get<IDX_B_OFFSET>(offset) = nOffset * k;67+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset * k;
68 } else {68 } else {
69- Get<IDX_B_OFFSET>(offset) = nOffset;69+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset;
70 }70 }
71 71 
72- Get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset; // 4: idx of y72+ AscendC::Std::get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset; // 4: idx of y
73 if constexpr (isTransA) {73 if constexpr (isTransA) {
74- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale74+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale
75 } else {75 } else {
76- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale76+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale
77 }77 }
78 if constexpr (isTransB) {78 if constexpr (isTransB) {
79- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale79+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale
80 } else {80 } else {
81- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale81+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale
82 }82 }
83 return offset;83 return offset;
84 }84 }
@@ -22,7 +22,6 @@
22#include "kernel_operator.h"22#include "kernel_operator.h"
23#endif23#endif
24#include "kernel_utils/common_utils.h"24#include "kernel_utils/common_utils.h"
25-#include "kernel_utils/tuple_utils.h"
26#include "block_scheduler_utils.h"25#include "block_scheduler_utils.h"
27 26 
28namespace Block {27namespace Block {
@@ -127,8 +126,8 @@ public:
127 126 
128 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)127 __aicore__ inline BlockShape GetBlockShape(BlockCoord blockCoord)
129 {128 {
130- int64_t mTileIdx = Get<MNK_M>(blockCoord);129+ int64_t mTileIdx = AscendC::Te::Get<MNK_M>(blockCoord);
131- int64_t nTileIdx = Get<MNK_N>(blockCoord);130+ int64_t nTileIdx = AscendC::Te::Get<MNK_N>(blockCoord);
132 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;131 int64_t singleCoreM = (mTileIdx == mCnt_ - 1) ? tailM_ : baseM_;
133 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;132 int64_t singleCoreN = (nTileIdx == nCnt_ - 1) ? tailN_ : baseN_;
134 133 
@@ -167,16 +166,16 @@ public:
167 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;166 int64_t rowIdx = (mCoreNum_ > 0) ? (tileIdx / (mCoreNum_ * nCnt_)) : 0;
168 if (rowIdx < mainRow_) {167 if (rowIdx < mainRow_) {
169 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;168 int64_t localTileIdx = tileIdx - rowIdx * mCoreNum_ * nCnt_;
170- Get<MNK_M>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;169+ AscendC::Std::get<MNK_M>(blockCoord) = rowIdx * mCoreNum_ + localTileIdx % mCoreNum_;
171- Get<MNK_N>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;170+ AscendC::Std::get<MNK_N>(blockCoord) = (localTileIdx / mCoreNum_) % nCnt_;
172 } else {171 } else {
173 rowIdx = mainRow_;172 rowIdx = mainRow_;
174 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;173 int64_t tailIdx = tileIdx - mainRow_ * mCoreNum_ * nCnt_;
175- Get<MNK_M>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;174+ AscendC::Std::get<MNK_M>(blockCoord) = mainRow_ * mCoreNum_ + tailIdx % mTailCoreNum_;
176- Get<MNK_N>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;175+ AscendC::Std::get<MNK_N>(blockCoord) = (tailIdx / mTailCoreNum_) % nCnt_;
177 }176 }
178 if (rowIdx & 1) {177 if (rowIdx & 1) {
179- Get<MNK_N>(blockCoord) = nCnt_ - 1 - Get<MNK_N>(blockCoord);178+ AscendC::Std::get<MNK_N>(blockCoord) = nCnt_ - 1 - AscendC::Te::Get<MNK_N>(blockCoord);
180 }179 }
181 180 
182 roundIdx_++;181 roundIdx_++;
@@ -17,7 +17,6 @@
17#endif17#endif
18 18 
19#include "kernel_utils/common_utils.h"19#include "kernel_utils/common_utils.h"
20-#include "kernel_utils/tuple_utils.h"
21#include "include/tensor_api/tensor.h"20#include "include/tensor_api/tensor.h"
22#include "../utils/quant_matmul_constant.h"21#include "../utils/quant_matmul_constant.h"
23#include "../tile/tile_mmad_mx.h"22#include "../tile/tile_mmad_mx.h"
@@ -91,14 +90,14 @@ public:
91 __aicore__ inline void Init(90 __aicore__ inline void Init(
92 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)91 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)
93 {92 {
94- m_ = Get<IDX_M_IDX>(problemShape);93+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
95- n_ = Get<IDX_N_IDX>(problemShape);94+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
96- k_ = Get<IDX_K_IDX>(problemShape);95+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
97 kL1_ = l1Params.kL1;96 kL1_ = l1Params.kL1;
98 scaleKL1_ = l1Params.scaleKL1;97 scaleKL1_ = l1Params.scaleKL1;
99- baseM_ = Get<IDX_M_IDX>(l0TileShape);98+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
100- baseN_ = Get<IDX_N_IDX>(l0TileShape);99+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
101- baseK_ = Get<IDX_K_IDX>(l0TileShape);100+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
102 l1BufNum_ = l1Params.l1BufNum;101 l1BufNum_ = l1Params.l1BufNum;
103 102 
104 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;103 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;
@@ -199,8 +198,8 @@ AscendC::Te::Mmad(
199 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,198 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,
200 BlockShape singleShape)199 BlockShape singleShape)
201 {200 {
202- auto curM = Get<IDX_M_TILEIDX>(singleShape);201+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
203- auto curN = Get<IDX_N_TILEIDX>(singleShape);202+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
204 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;203 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
205 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);204 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
206 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);205 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -17,7 +17,6 @@
17#endif17#endif
18 18 
19#include "kernel_utils/common_utils.h"19#include "kernel_utils/common_utils.h"
20-#include "kernel_utils/tuple_utils.h"
21#include "include/tensor_api/tensor.h"20#include "include/tensor_api/tensor.h"
22#include "../utils/quant_matmul_constant.h"21#include "../utils/quant_matmul_constant.h"
23#include "../tile/tile_mmad_mx.h"22#include "../tile/tile_mmad_mx.h"
@@ -91,14 +90,14 @@ public:
91 __aicore__ inline void Init(90 __aicore__ inline void Init(
92 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)91 const TupleShape& problemShape, const BlockShape& l0TileShape, const L1Params& l1Params)
93 {92 {
94- m_ = Get<IDX_M_IDX>(problemShape);93+ m_ = AscendC::Te::Get<IDX_M_IDX>(problemShape);
95- n_ = Get<IDX_N_IDX>(problemShape);94+ n_ = AscendC::Te::Get<IDX_N_IDX>(problemShape);
96- k_ = Get<IDX_K_IDX>(problemShape);95+ k_ = AscendC::Te::Get<IDX_K_IDX>(problemShape);
97 kL1_ = l1Params.kL1;96 kL1_ = l1Params.kL1;
98 scaleKL1_ = l1Params.scaleKL1;97 scaleKL1_ = l1Params.scaleKL1;
99- baseM_ = Get<IDX_M_IDX>(l0TileShape);98+ baseM_ = AscendC::Te::Get<IDX_M_IDX>(l0TileShape);
100- baseN_ = Get<IDX_N_IDX>(l0TileShape);99+ baseN_ = AscendC::Te::Get<IDX_N_IDX>(l0TileShape);
101- baseK_ = Get<IDX_K_IDX>(l0TileShape);100+ baseK_ = AscendC::Te::Get<IDX_K_IDX>(l0TileShape);
102 l1BufNum_ = l1Params.l1BufNum;101 l1BufNum_ = l1Params.l1BufNum;
103 102 
104 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;103 bL1OneBuffer_ = (baseN_ * kL1_) >> 1;
@@ -198,8 +197,8 @@ AscendC::Te::Mmad(
198 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,197 TensorA gmA, TensorB gmB, TensorScaleA gmScaleA, TensorScaleB gmScaleB, TensorC gmC,
199 BlockShape singleShape)198 BlockShape singleShape)
200 {199 {
201- auto curM = Get<IDX_M_TILEIDX>(singleShape);200+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
202- auto curN = Get<IDX_N_TILEIDX>(singleShape);201+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
203 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;202 uint64_t l0cOffset = (l0cPingPong_ & 1) * HALF_L0C_SIZE;
204 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);203 auto layoutL0C = AscendC::Te::MakeFrameLayout<AscendC::Te::NZLayoutPtn, AscendC::Std::Int<L0C_C0>>(curM, curN);
205 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);204 auto tensorL0C = AscendC::Te::MakeTensor(AscendC::Te::MakeMemPtr<AscendC::Te::Location::L0C, float>(l0cOffset), layoutL0C);
@@ -21,7 +21,6 @@
21#include "kernel_operator_intf.h"21#include "kernel_operator_intf.h"
22#endif22#endif
23#include "kernel_utils/common_utils.h"23#include "kernel_utils/common_utils.h"
24-#include "kernel_utils/tuple_utils.h"
25#include "include/tensor_api/tensor.h"24#include "include/tensor_api/tensor.h"
26#include "../block/block_scheduler_mx_base.h"25#include "../block/block_scheduler_mx_base.h"
27#include "../block/quant_matmul_mxfp4_block_mmad_a_full_load.h"26#include "../block/quant_matmul_mxfp4_block_mmad_a_full_load.h"
@@ -148,18 +147,18 @@ __aicore__ inline void QuantMatmulMxKernelBaseImpl<QBMM_MX_KERNEL_FUN_TEM_PARAMS
148 constexpr int64_t kPos = 0L;147 constexpr int64_t kPos = 0L;
149 while (bs.GetTileIdx(blockIdx)) {148 while (bs.GetTileIdx(blockIdx)) {
150 BlockShape singleShape = bs.GetBlockShape(blockIdx);149 BlockShape singleShape = bs.GetBlockShape(blockIdx);
151- if (Get<MNK_M>(singleShape) <= 0 || Get<MNK_N>(singleShape) <= 0) {150+ if (AscendC::Te::Get<MNK_M>(singleShape) <= 0 || AscendC::Te::Get<MNK_N>(singleShape) <= 0) {
152 return;151 return;
153 }152 }
154 153 
155- int64_t mTileIdx = Get<MNK_M>(blockIdx);154+ int64_t mTileIdx = AscendC::Te::Get<MNK_M>(blockIdx);
156- int64_t nTileIdx = Get<MNK_N>(blockIdx);155+ int64_t nTileIdx = AscendC::Te::Get<MNK_N>(blockIdx);
157- int64_t mSplitOffset = Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);156+ int64_t mSplitOffset = AscendC::Te::Get<IDX_M_TAIL_SPLIT_TILEIDX>(singleShape);
158- int64_t nSplitOffset = Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);157+ int64_t nSplitOffset = AscendC::Te::Get<IDX_N_TAIL_SPLIT_TILEIDX>(singleShape);
159 int64_t mPos = mTileIdx * params.qbmmParams.baseM + mSplitOffset;158 int64_t mPos = mTileIdx * params.qbmmParams.baseM + mSplitOffset;
160 int64_t nPos = nTileIdx * params.qbmmParams.baseN + nSplitOffset;159 int64_t nPos = nTileIdx * params.qbmmParams.baseN + nSplitOffset;
161- auto curM = Get<IDX_M_TILEIDX>(singleShape);160+ auto curM = AscendC::Te::Get<IDX_M_TILEIDX>(singleShape);
162- auto curN = Get<IDX_N_TILEIDX>(singleShape);161+ auto curN = AscendC::Te::Get<IDX_N_TILEIDX>(singleShape);
163 162 
164 auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos),163 auto gmBlockA = gmA.Slice(AscendC::Te::MakeCoord(mPos, kPos),
165 AscendC::Te::MakeShape(curM, params.problemShape.k));164 AscendC::Te::MakeShape(curM, params.problemShape.k));
@@ -45,40 +45,40 @@ public:
45 int64_t nOffset = nTileIdx * l1N + nSplitOffset;45 int64_t nOffset = nTileIdx * l1N + nSplitOffset;
46 if constexpr (enableLoadBalance) {46 if constexpr (enableLoadBalance) {
47 if constexpr (!isTransA) {47 if constexpr (!isTransA) {
48- if (mTileIdx > Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {48+ if (mTileIdx > AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) {
49- mOffset -= (mTileIdx - Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *49+ mOffset -= (mTileIdx - AscendC::Te::Get<IDX_M_BASE_NORM_CNT>(loadBalanceParam)) *
50- (l1M - Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));50+ (l1M - AscendC::Te::Get<IDX_M_BASE_TAIL_MAIN>(loadBalanceParam));
51 }51 }
52 }52 }
53 if constexpr (isTransB) {53 if constexpr (isTransB) {
54- if (nTileIdx > Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {54+ if (nTileIdx > AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) {
55- nOffset -= (nTileIdx - Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *55+ nOffset -= (nTileIdx - AscendC::Te::Get<IDX_N_BASE_NORM_CNT>(loadBalanceParam)) *
56- (l1N - Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));56+ (l1N - AscendC::Te::Get<IDX_N_BASE_TAIL_MAIN>(loadBalanceParam));
57 }57 }
58 }58 }
59 }59 }
60 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};60 AscendC::Std::tuple<int64_t, int64_t, int64_t, int64_t, int64_t> offset{0, 0, 0, 0, 0};
61 if constexpr (isTransA) {61 if constexpr (isTransA) {
62- Get<IDX_A_OFFSET>(offset) = mOffset;62+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset;
63 } else {63 } else {
64- Get<IDX_A_OFFSET>(offset) = mOffset * k;64+ AscendC::Std::get<IDX_A_OFFSET>(offset) = mOffset * k;
65 }65 }
66 if constexpr (isTransB) {66 if constexpr (isTransB) {
67- Get<IDX_B_OFFSET>(offset) = nOffset * k;67+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset * k;
68 } else {68 } else {
69- Get<IDX_B_OFFSET>(offset) = nOffset;69+ AscendC::Std::get<IDX_B_OFFSET>(offset) = nOffset;
70 }70 }
71 71 
72- Get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset; // 4: idx of y72+ AscendC::Std::get<IDX_C_OFFSET>(offset) = mOffset * n + nOffset; // 4: idx of y
73 if constexpr (isTransA) {73 if constexpr (isTransA) {
74- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale74+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale
75 } else {75 } else {
76- Get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale76+ AscendC::Std::get<IDX_X1SCALE_OFFSET>(offset) = mOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 2: idx of x1Scale
77 }77 }
78 if constexpr (isTransB) {78 if constexpr (isTransB) {
79- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale79+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * CeilDiv(k, MXFP_DIVISOR_SIZE) * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale
80 } else {80 } else {
81- Get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale81+ AscendC::Std::get<IDX_X2SCALE_OFFSET>(offset) = nOffset * MXFP_MULTI_BASE_SIZE; // 3: idx of x2Scale
82 }82 }
83 return offset;83 return offset;
84 }84 }
@@ -22,8 +22,7 @@
22#include "kernel_operator.h"22#include "kernel_operator.h"
23#endif23#endif
24#include "lib/matmul_intf.h"24#include "lib/matmul_intf.h"
25- 25+#include "include/tensor_api/tensor.h"
26-#include "integral_constant.h"
27 26 
28// On-chip buffer capacities used by the kernel helper code.27// On-chip buffer capacities used by the kernel helper code.
29static constexpr int64_t L0A_SIZE = 64 * 1024;28static constexpr int64_t L0A_SIZE = 64 * 1024;
@@ -1,36 +0,0 @@
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 integral_constant.h
13- * \brief
14- */
15-#pragma once
16-#if ASC_DEVKIT_MAJOR >= 9
17-#include "kernel_basic_intf.h"
18-#else
19-#include "kernel_operator.h"
20-#endif
21- 
22-namespace AscendC {
23-namespace Std {
24-template <typename...>
25-struct always_false : public false_type {};
26- 
27-template <typename... Tp>
28-constexpr bool always_false_v = always_false<Tp...>::value;
29-} // namespace Std
30-} // namespace AscendC
31- 
32-template <int32_t t>
33-using Int = AscendC::Std::integral_constant<int32_t, t>;
34- 
35-using _0 = Int<0>;
36- 
@@ -15,46 +15,43 @@
15 15 
16#pragma once16#pragma once
17 17 
18-// Cube format definitions.18+#include "include/tensor_api/tensor.h"
19-#include "matmul/matmul_config.h"
20-#include "./integral_constant.h"
21 19 
22-namespace layout {20+template <typename LayoutPattern>
23-struct RowMajor {};21+constexpr bool GetTransValue()
24-struct ColumnMajor {};22+{
25-} // namespace layout23+ constexpr bool isNonTrans =
24+ AscendC::Std::is_one_of_v<LayoutPattern, AscendC::Te::NDExtLayoutPtn, AscendC::Te::NZLayoutPtn>;
25+ constexpr bool isTrans =
26+ AscendC::Std::is_one_of_v<LayoutPattern, AscendC::Te::DNExtLayoutPtn, AscendC::Te::ZNLayoutPtn>;
26 27 
27-// Map layout tags to CubeFormat values.28+ constexpr bool isKnown = isNonTrans || isTrans;
28-template <typename T>29+ static_assert(isKnown, "IsTrans is not implemented for this layout pattern");
29-struct TagToFormat {30+ 
30- static_assert(AscendC::Std::always_false_v<T>, "TagToFormat is not implemented for this layout");31+ return !isNonTrans && isTrans;
32+}
33+ 
34+template <typename LayoutPattern>
35+struct IsTrans {
36+ static constexpr bool value = GetTransValue<LayoutPattern>();
31};37};
32 38 
33-template <>39+template <typename LayoutPattern>
34-struct TagToFormat<layout::RowMajor> {40+constexpr bool GetWeightNzValue()
35- using tag = layout::RowMajor;41+{
36- static constexpr CubeFormat format = CubeFormat::ND;42+ constexpr bool isNonWeightNz =
37-};43+ AscendC::Std::is_one_of_v<LayoutPattern, AscendC::Te::NDExtLayoutPtn, AscendC::Te::DNExtLayoutPtn>;
38- 44+ constexpr bool isWeightNz =
39-template <>45+ AscendC::Std::is_one_of_v<LayoutPattern, AscendC::Te::NZLayoutPtn, AscendC::Te::ZNLayoutPtn>;
40-struct TagToFormat<layout::ColumnMajor> {46+ 
41- using tag = layout::ColumnMajor;47+ constexpr bool isKnown = isNonWeightNz || isWeightNz;
42- static constexpr CubeFormat format = CubeFormat::ND;48+ static_assert(isKnown, "IsWeightNz is not implemented for this layout");
43-};49+ 
44- 50+ return !isNonWeightNz && isWeightNz;
45-// Map layout tags to transpose flags.51+}
46-template <typename T>52+ 
47-struct TagToTrans {53+template <typename LayoutPattern>
48- static_assert(AscendC::Std::always_false_v<T>, "TagToTrans is not implemented for this layout");54+struct IsWeightNz {
49-};55+ static constexpr bool value = GetWeightNzValue<LayoutPattern>();
50- 
51-template <>
52-struct TagToTrans<layout::RowMajor> {
53- static constexpr bool value = false;
54-};
55- 
56-template <>
57-struct TagToTrans<layout::ColumnMajor> {
58- static constexpr bool value = true;
59};56};
60 57 
@@ -1,34 +0,0 @@
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 tuple_utils.h
13- * \brief
14- */
15- 
16-#pragma once
17- 
18-#include "lib/std/tuple.h"
19-#include "./integral_constant.h"
20- 
21-// Base template: handles single-index case
22-template <size_t I, typename T>
23-__aicore__ constexpr inline decltype(auto) Get(T&& t)
24-{
25- return AscendC::Std::get<I>(AscendC::Std::forward<T>(t));
26-}
27- 
28-// Recursive template: handles multiple index cases
29-template <size_t First, size_t Second, size_t... Rest, typename T>
30-__aicore__ constexpr inline decltype(auto) Get(T&& t)
31-{
32- return Get<Second, Rest...>(AscendC::Std::get<First>(AscendC::Std::forward<T>(t)));
33-}
34- 
@@ -1 +1 @@
1-Subproject commit 6dc6a7cd0f05ccf042c86bb0837ec27c3144d0831+Subproject commit 66186294b92970f9f1a044619b15637d65edf8cb