已合并
update: 更新文件 08.05_chapter_practice.ipynb #363
update: 更新文件 08.05_chapter_practice.ipynb #363
已合并
ink_polymer创建于 7月20日
39 个文件变更+172-122
@@ -389,7 +389,7 @@
389 "source": [389 "source": [
390 "### 3.6 编程语言 Ascend C —— 自定义算子的开发利器\n",390 "### 3.6 编程语言 Ascend C —— 自定义算子的开发利器\n",
391 "\n",391 "\n",
392- "<img src=\"./images/ascend_c.jpg\" alt=\"Ascend C\" />\n",392+ "<img src=\"./images/ascend_c.png\" alt=\"Ascend C\" />\n",
393 "\n",393 "\n",
394 "当 CANN 内置算子不满足需求时(比如遇到了不支持的算子,或者想自己写一个更快的版本),就需要用 **Ascend C**开发自定义算子。\n",394 "当 CANN 内置算子不满足需求时(比如遇到了不支持的算子,或者想自己写一个更快的版本),就需要用 **Ascend C**开发自定义算子。\n",
395 "\n",395 "\n",
@@ -160,7 +160,8 @@
160 "source": [160 "source": [
161 "%%writefile -a Sources/02.04/add_custom.asc\n",161 "%%writefile -a Sources/02.04/add_custom.asc\n",
162 "\n",162 "\n",
163- "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue"163+ "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue",
164+ "constexpr uint32_t QUEUE_DEPTH = 2;"
atomgit-bot
atomgit-botatomgit-bot7月20日

🟡 Medium Priority

该 diff 在 add_custom.ascsub_custom.asc 两个代码块中新增了 constexpr uint32_t QUEUE_DEPTH = 2;,并将 TQue 的第二个模板参数从 BUFFER_NUM 改为 QUEUE_DEPTH(第 300-301 行)。但是以下位置仍使用 BUFFER_NUM

  1. 第 406 行:this->tileLength = this->blockLength / tileNum / BUFFER_NUM;
  2. 第 412-414 行:pipe.InitBuffer(inQueueX, BUFFER_NUM, ...) 等三处
  3. 第 443-444 行:int32_t loopCount = this->tileNum * BUFFER_NUM;

在 AscendC 中,TQue 的 depth 参数与 InitBuffer 的 buffer 数量参数必须一致,tileLengthloopCount 的计算也依赖同一数值。当前两者值相同(均为 2),不会触发运行时错误;但如果未来只修改其中一个常量而忘记另一个,会导致队列深度与分配的 buffer 数量不匹配,引发内存越界或流水线死锁。

作为教程代码,这种不一致会误导学习者认为 QUEUE_DEPTHBUFFER_NUM 是两个独立的概念,实际上它们必须一致。建议将 InitBuffertileLengthloopCount 中的 BUFFER_NUM 也统一改为 QUEUE_DEPTH,或反之在 TQue 中保持使用 BUFFER_NUM 以确保语义统一。

建议:统一使用 QUEUE_DEPTH 替换所有 BUFFER_NUM(或反之保持原样),确保 TQue 模板参数、InitBuffer 调用、tileLength 计算、loopCount 计算使用同一常量。具体需修改的 02.04 文件内行:406(tileLength)、412-414(InitBuffer 三处)、443(loopCount)。如果保留 BUFFER_NUM 作为唯一常量,则应将 TQue 模板参数改回 BUFFER_NUM。

likedislike
164 ]165 ]
165 },166 },
166 {167 {
@@ -296,8 +297,8 @@
296 "private:\n",297 "private:\n",
297 " // 核心数据成员\n",298 " // 核心数据成员\n",
298 " AscendC::TPipe pipe; // TPipe内存管理对象\n",299 " AscendC::TPipe pipe; // TPipe内存管理对象\n",
299- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY; // 输入数据Queue队列管理对象,TPosition为VECIN\n",300+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY; // 输入数据Queue队列管理对象,TPosition为VECIN\n",
300- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ; // 输出数据Queue队列管理对象,TPosition为VECOUT\n",301+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ; // 输出数据Queue队列管理对象,TPosition为VECOUT\n",
301 " AscendC::GlobalTensor<float> xGm; // 管理输入输出Global Memory内存地址的对象,其中xGm, yGm为输入,zGm为输出\n",302 " AscendC::GlobalTensor<float> xGm; // 管理输入输出Global Memory内存地址的对象,其中xGm, yGm为输入,zGm为输出\n",
302 " AscendC::GlobalTensor<float> yGm;\n",303 " AscendC::GlobalTensor<float> yGm;\n",
303 " AscendC::GlobalTensor<float> zGm;\n",304 " AscendC::GlobalTensor<float> zGm;\n",
@@ -994,6 +995,7 @@
994 "#include \"kernel_operator.h\"\n",995 "#include \"kernel_operator.h\"\n",
995 "\n",996 "\n",
996 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",997 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
998+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
997 "\n",999 "\n",
998 "struct SubCustomTilingData\n",1000 "struct SubCustomTilingData\n",
999 "{\n",1001 "{\n",
@@ -1178,4 +1180,4 @@
1178 },1180 },
1179 "nbformat": 4,1181 "nbformat": 4,
1180 "nbformat_minor": 51182 "nbformat_minor": 5
1181-}1183+}
@@ -78,6 +78,7 @@
78 "#include \"kernel_operator.h\"\n",78 "#include \"kernel_operator.h\"\n",
79 "\n",79 "\n",
80 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",80 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
81+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
81 "\n",82 "\n",
82 "struct SigmoidCustomTilingData\n",83 "struct SigmoidCustomTilingData\n",
83 "{\n",84 "{\n",
@@ -7,6 +7,7 @@
7#include "kernel_operator.h"7#include "kernel_operator.h"
8 8 
9constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue9constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue
10+constexpr uint32_t QUEUE_DEPTH = 2;
10 11 
11struct SubCustomTilingData12struct SubCustomTilingData
12{13{
@@ -68,8 +69,8 @@ private:
68 69 
69private:70private:
70 AscendC::TPipe pipe;71 AscendC::TPipe pipe;
71- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;72+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;
72- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;73+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
73 AscendC::GlobalTensor<float> xGm;74 AscendC::GlobalTensor<float> xGm;
74 AscendC::GlobalTensor<float> yGm;75 AscendC::GlobalTensor<float> yGm;
75 AscendC::GlobalTensor<float> zGm;76 AscendC::GlobalTensor<float> zGm;
@@ -8,6 +8,7 @@
8#include "kernel_operator.h"8#include "kernel_operator.h"
9 9 
10constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue10constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue
11+constexpr uint32_t QUEUE_DEPTH = 2;
11 12 
12struct SigmoidCustomTilingData13struct SigmoidCustomTilingData
13{14{
@@ -69,8 +70,8 @@ private:
69 70 
70private:71private:
71 AscendC::TPipe pipe;72 AscendC::TPipe pipe;
72- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;73+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
73- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueY;74+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueY;
74 AscendC::GlobalTensor<float> xGm;75 AscendC::GlobalTensor<float> xGm;
75 AscendC::GlobalTensor<float> yGm;76 AscendC::GlobalTensor<float> yGm;
76 uint32_t blockLength;77 uint32_t blockLength;
@@ -7,6 +7,7 @@
7#include "kernel_operator.h"7#include "kernel_operator.h"
8 8 
9constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue9constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue
10+constexpr uint32_t QUEUE_DEPTH = 2;
10 11 
11struct AddCustomTilingData12struct AddCustomTilingData
12{13{
@@ -68,8 +69,8 @@ private:
68 69 
69private:70private:
70 AscendC::TPipe pipe;71 AscendC::TPipe pipe;
71- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;72+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;
72- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;73+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
73 AscendC::GlobalTensor<float> xGm;74 AscendC::GlobalTensor<float> xGm;
74 AscendC::GlobalTensor<float> yGm;75 AscendC::GlobalTensor<float> yGm;
75 AscendC::GlobalTensor<float> zGm;76 AscendC::GlobalTensor<float> zGm;
@@ -650,6 +650,7 @@
650 "#include \"add_custom_template_tiling.h\"\n",650 "#include \"add_custom_template_tiling.h\"\n",
651 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",651 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",
652 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",652 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",
653+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
653 "\n",654 "\n",
654 "template <class dtypeX, class dtypeY, class dtypeZ>\n",655 "template <class dtypeX, class dtypeY, class dtypeZ>\n",
655 "class KernelAdd {\n",656 "class KernelAdd {\n",
@@ -708,9 +709,9 @@
708 "\n",709 "\n",
709 "private:\n",710 "private:\n",
710 " AscendC::TPipe pipe;\n",711 " AscendC::TPipe pipe;\n",
711- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",712+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
712- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;\n",713+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;\n",
713- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",714+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
714 " AscendC::GlobalTensor<dtypeX> xGm;\n",715 " AscendC::GlobalTensor<dtypeX> xGm;\n",
715 " AscendC::GlobalTensor<dtypeY> yGm;\n",716 " AscendC::GlobalTensor<dtypeY> yGm;\n",
716 " AscendC::GlobalTensor<dtypeZ> zGm;\n",717 " AscendC::GlobalTensor<dtypeZ> zGm;\n",
@@ -1136,4 +1137,4 @@
1136 },1137 },
1137 "nbformat": 4,1138 "nbformat": 4,
1138 "nbformat_minor": 41139 "nbformat_minor": 4
1139-}1140+}
@@ -643,7 +643,8 @@
643 "#include \"kernel_operator.h\"\n",643 "#include \"kernel_operator.h\"\n",
644 "#include \"add_custom_template_tiling.h\"\n",644 "#include \"add_custom_template_tiling.h\"\n",
645 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",645 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",
646- "constexpr int32_t BUFFER_NUM = 1;"646+"constexpr int32_t BUFFER_NUM = 1;\n",
647+ "constexpr int32_t QUEUE_DEPTH = 1;"
647 ]648 ]
648 },649 },
649 {650 {
@@ -837,8 +838,8 @@
837 "%%writefile -a Sources/03.04/custom_op/op_kernel/add_custom_template.cpp\n",838 "%%writefile -a Sources/03.04/custom_op/op_kernel/add_custom_template.cpp\n",
838 "private:\n",839 "private:\n",
839 " AscendC::TPipe pipe;\n",840 " AscendC::TPipe pipe;\n",
840- " AscendC::TQue<AscendC::QuePosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",841+ " AscendC::TQue<AscendC::QuePosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
841- " AscendC::TQue<AscendC::QuePosition::VECOUT, BUFFER_NUM> outQueueZ;\n",842+ " AscendC::TQue<AscendC::QuePosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
842 " AscendC::GlobalTensor<TYPE_X> xGm;\n",843 " AscendC::GlobalTensor<TYPE_X> xGm;\n",
843 " AscendC::GlobalTensor<TYPE_Y> yGm;\n",844 " AscendC::GlobalTensor<TYPE_Y> yGm;\n",
844 " AscendC::GlobalTensor<TYPE_Z> zGm;\n",845 " AscendC::GlobalTensor<TYPE_Z> zGm;\n",
@@ -1150,6 +1151,7 @@
1150 "#include \"sub_custom_template_tiling.h\"\n",1151 "#include \"sub_custom_template_tiling.h\"\n",
1151 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",1152 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",
1152 "constexpr int32_t BUFFER_NUM = 2;\n",1153 "constexpr int32_t BUFFER_NUM = 2;\n",
1154+ "constexpr int32_t QUEUE_DEPTH = 2;\n",
1153 "\n",1155 "\n",
1154 "class KernelSub {\n",1156 "class KernelSub {\n",
1155 "public:\n",1157 "public:\n",
@@ -859,6 +859,7 @@
859 "#include \"tiling_key_clamp.h\"\n",859 "#include \"tiling_key_clamp.h\"\n",
860 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",860 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",
861 "constexpr int32_t BUFFER_NUM = 1;\n",861 "constexpr int32_t BUFFER_NUM = 1;\n",
862+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
862 "\n",863 "\n",
863 "template <class dtypeX, class dtypeY>\n",864 "template <class dtypeX, class dtypeY>\n",
864 "class KernelClamp {\n",865 "class KernelClamp {\n",
@@ -948,9 +949,9 @@
948 "\n",949 "\n",
949 "private:\n",950 "private:\n",
950 " AscendC::TPipe pipe;\n",951 " AscendC::TPipe pipe;\n",
951- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",952+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
952- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueY;\n",953+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueY;\n",
953- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueTmp;\n",954+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueTmp;\n",
954 " AscendC::GlobalTensor<dtypeX> xGm;\n",955 " AscendC::GlobalTensor<dtypeX> xGm;\n",
955 " AscendC::GlobalTensor<dtypeY> yGm;\n",956 " AscendC::GlobalTensor<dtypeY> yGm;\n",
956 " AscendC::GlobalTensor<float> tmpGm;\n",957 " AscendC::GlobalTensor<float> tmpGm;\n",
@@ -1372,8 +1373,8 @@
1372 "outputs": [],1373 "outputs": [],
1373 "source": [1374 "source": [
1374 "# 清除已有的custom_op目录\n",1375 "# 清除已有的custom_op目录\n",
1375- "!rm -rf Sources/03.05/custom_op\n",1376+ "!rm -rf Sources/03.05/custom_op\n",
1376- "!msopgen gen -i Sources/03.05/add_custom_template.json -c ai_core-ascend910b1 -lan cpp -out Sources/03.05/custom_op\n"1377+ "!msopgen gen -i Sources/03.05/add_custom_template.json -c ai_core-ascend910b1 -lan cpp -out Sources/03.05/custom_op\n"
1377 ]1378 ]
1378 },1379 },
1379 {1380 {
@@ -1878,4 +1879,4 @@
1878 },1879 },
1879 "nbformat": 4,1880 "nbformat": 4,
1880 "nbformat_minor": 21881 "nbformat_minor": 2
1881-}1882+}
@@ -2,6 +2,7 @@
2#include "sub_custom_template_tiling.h"2#include "sub_custom_template_tiling.h"
3#include "kernel_operator_dump_tensor_intf_impl.h"3#include "kernel_operator_dump_tensor_intf_impl.h"
4constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue4constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue
5+constexpr int32_t QUEUE_DEPTH = 1;
5 6 
6template <class dtypeX, class dtypeY, class dtypeZ>7template <class dtypeX, class dtypeY, class dtypeZ>
7class KernelSub {8class KernelSub {
@@ -60,9 +61,9 @@ private:
60 61 
61private:62private:
62 AscendC::TPipe pipe;63 AscendC::TPipe pipe;
63- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;64+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
64- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;65+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;
65- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;66+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
66 AscendC::GlobalTensor<dtypeX> xGm;67 AscendC::GlobalTensor<dtypeX> xGm;
67 AscendC::GlobalTensor<dtypeY> yGm;68 AscendC::GlobalTensor<dtypeY> yGm;
68 AscendC::GlobalTensor<dtypeZ> zGm;69 AscendC::GlobalTensor<dtypeZ> zGm;
@@ -13,6 +13,7 @@
13#include "sub_custom_template_tiling.h"13#include "sub_custom_template_tiling.h"
14#include "kernel_operator_dump_tensor_intf_impl.h"14#include "kernel_operator_dump_tensor_intf_impl.h"
15constexpr int32_t BUFFER_NUM = 2;15constexpr int32_t BUFFER_NUM = 2;
16+constexpr int32_t QUEUE_DEPTH = 2;
16 17 
17template<typename TYPE_X, typename TYPE_Y, typename TYPE_Z> class KernelSub {18template<typename TYPE_X, typename TYPE_Y, typename TYPE_Z> class KernelSub {
18public:19public:
@@ -87,8 +88,8 @@ private:
87 88 
88private:89private:
89 AscendC::TPipe pipe;90 AscendC::TPipe pipe;
90- AscendC::TQue<AscendC::QuePosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;91+ AscendC::TQue<AscendC::QuePosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;
91- AscendC::TQue<AscendC::QuePosition::VECOUT, BUFFER_NUM> outQueueZ;92+ AscendC::TQue<AscendC::QuePosition::VECOUT, QUEUE_DEPTH> outQueueZ;
92 AscendC::GlobalTensor<TYPE_X> xGm;93 AscendC::GlobalTensor<TYPE_X> xGm;
93 AscendC::GlobalTensor<TYPE_Y> yGm;94 AscendC::GlobalTensor<TYPE_Y> yGm;
94 AscendC::GlobalTensor<TYPE_Z> zGm;95 AscendC::GlobalTensor<TYPE_Z> zGm;
@@ -2,6 +2,7 @@
2#include "add_custom_template_tiling.h"2#include "add_custom_template_tiling.h"
3#include "tiling_key_add_custom_template.h"3#include "tiling_key_add_custom_template.h"
4constexpr int32_t BUFFER_NUM = 1;4constexpr int32_t BUFFER_NUM = 1;
5+constexpr int32_t QUEUE_DEPTH = 1;
5 6 
6template <class dtypeX>7template <class dtypeX>
7class KernelAdd {8class KernelAdd {
@@ -97,9 +98,9 @@ private:
97 98 
98private:99private:
99 AscendC::TPipe pipe;100 AscendC::TPipe pipe;
100- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;101+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
101- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;102+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;
102- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;103+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
103 AscendC::TBuf<AscendC::QuePosition::VECCALC> tmp1, tmp2;104 AscendC::TBuf<AscendC::QuePosition::VECCALC> tmp1, tmp2;
104 AscendC::GlobalTensor<dtypeX> xGm;105 AscendC::GlobalTensor<dtypeX> xGm;
105 AscendC::GlobalTensor<dtypeX> yGm;106 AscendC::GlobalTensor<dtypeX> yGm;
@@ -1,6 +1,7 @@
1#include "kernel_operator.h"1#include "kernel_operator.h"
2#include "sigmoid_custom_tiling.h"2#include "sigmoid_custom_tiling.h"
3constexpr int32_t BUFFER_NUM = 2;3constexpr int32_t BUFFER_NUM = 2;
4+constexpr int32_t QUEUE_DEPTH = 2;
4 5 
5template<typename TYPE_X, typename TYPE_Y>6template<typename TYPE_X, typename TYPE_Y>
6class KernelSigmoid {7class KernelSigmoid {
@@ -76,8 +77,8 @@ private:
76 77 
77private:78private:
78 AscendC::TPipe pipe;79 AscendC::TPipe pipe;
79- AscendC::TQue<AscendC::QuePosition::VECIN, BUFFER_NUM> inQueueX; // 单输入队列80+ AscendC::TQue<AscendC::QuePosition::VECIN, QUEUE_DEPTH> inQueueX; // 单输入队列
80- AscendC::TQue<AscendC::QuePosition::VECOUT, BUFFER_NUM> outQueueZ; // 单输出队列81+ AscendC::TQue<AscendC::QuePosition::VECOUT, QUEUE_DEPTH> outQueueZ; // 单输出队列
81 AscendC::GlobalTensor<TYPE_X> xGm; // 输入全局Tensor82 AscendC::GlobalTensor<TYPE_X> xGm; // 输入全局Tensor
82 AscendC::GlobalTensor<TYPE_Y> zGm; // 输出全局Tensor83 AscendC::GlobalTensor<TYPE_Y> zGm; // 输出全局Tensor
83 uint32_t coreDataNum;84 uint32_t coreDataNum;
@@ -13,6 +13,7 @@
13#include "add_custom_template_tiling.h"13#include "add_custom_template_tiling.h"
14#include "kernel_operator_dump_tensor_intf_impl.h"14#include "kernel_operator_dump_tensor_intf_impl.h"
15constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue15constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue
16+constexpr int32_t QUEUE_DEPTH = 1;
16 17 
17template <class dtypeX, class dtypeY, class dtypeZ>18template <class dtypeX, class dtypeY, class dtypeZ>
18class KernelAdd {19class KernelAdd {
@@ -71,9 +72,9 @@ private:
71 72 
72private:73private:
73 AscendC::TPipe pipe;74 AscendC::TPipe pipe;
74- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;75+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
75- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;76+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;
76- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;77+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
77 AscendC::GlobalTensor<dtypeX> xGm;78 AscendC::GlobalTensor<dtypeX> xGm;
78 AscendC::GlobalTensor<dtypeY> yGm;79 AscendC::GlobalTensor<dtypeY> yGm;
79 AscendC::GlobalTensor<dtypeZ> zGm;80 AscendC::GlobalTensor<dtypeZ> zGm;
@@ -13,6 +13,7 @@
13#include "add_custom_template_tiling.h"13#include "add_custom_template_tiling.h"
14#include "kernel_operator_dump_tensor_intf_impl.h"14#include "kernel_operator_dump_tensor_intf_impl.h"
15constexpr int32_t BUFFER_NUM = 2;15constexpr int32_t BUFFER_NUM = 2;
16+constexpr int32_t QUEUE_DEPTH = 2;
16 17 
17template<typename TYPE_X, typename TYPE_Y, typename TYPE_Z> class KernelAdd {18template<typename TYPE_X, typename TYPE_Y, typename TYPE_Z> class KernelAdd {
18public:19public:
@@ -87,8 +88,8 @@ private:
87 88 
88private:89private:
89 AscendC::TPipe pipe;90 AscendC::TPipe pipe;
90- AscendC::TQue<AscendC::QuePosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;91+ AscendC::TQue<AscendC::QuePosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;
91- AscendC::TQue<AscendC::QuePosition::VECOUT, BUFFER_NUM> outQueueZ;92+ AscendC::TQue<AscendC::QuePosition::VECOUT, QUEUE_DEPTH> outQueueZ;
92 AscendC::GlobalTensor<TYPE_X> xGm;93 AscendC::GlobalTensor<TYPE_X> xGm;
93 AscendC::GlobalTensor<TYPE_Y> yGm;94 AscendC::GlobalTensor<TYPE_Y> yGm;
94 AscendC::GlobalTensor<TYPE_Z> zGm;95 AscendC::GlobalTensor<TYPE_Z> zGm;
@@ -395,6 +395,7 @@
395 "#include \"kernel_operator.h\"\n",395 "#include \"kernel_operator.h\"\n",
396 "#include \"square_diff_tiling.h\"\n",396 "#include \"square_diff_tiling.h\"\n",
397 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",397 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",
398+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
398 "\n",399 "\n",
399 "class KernelSquareDiff {\n",400 "class KernelSquareDiff {\n",
400 "public:\n",401 "public:\n",
@@ -453,8 +454,8 @@
453 "\n",454 "\n",
454 "private:\n",455 "private:\n",
455 " AscendC::TPipe pipe;\n",456 " AscendC::TPipe pipe;\n",
456- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",457+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
457- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",458+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
458 " AscendC::GlobalTensor<DTYPE_X> xGm;\n",459 " AscendC::GlobalTensor<DTYPE_X> xGm;\n",
459 " AscendC::GlobalTensor<DTYPE_Y> yGm;\n",460 " AscendC::GlobalTensor<DTYPE_Y> yGm;\n",
460 " AscendC::GlobalTensor<DTYPE_Z> zGm;\n",461 " AscendC::GlobalTensor<DTYPE_Z> zGm;\n",
@@ -776,6 +777,7 @@
776 "#include \"kernel_operator.h\"\n",777 "#include \"kernel_operator.h\"\n",
777 "#include \"square_diff_tiling.h\"\n",778 "#include \"square_diff_tiling.h\"\n",
778 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",779 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",
780+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
779 "\n",781 "\n",
780 "class KernelSquareDiff {\n",782 "class KernelSquareDiff {\n",
781 "public:\n",783 "public:\n",
@@ -833,8 +835,8 @@
833 "\n",835 "\n",
834 "private:\n",836 "private:\n",
835 " AscendC::TPipe pipe;\n",837 " AscendC::TPipe pipe;\n",
836- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",838+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
837- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",839+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
838 " AscendC::GlobalTensor<DTYPE_X> xGm;\n",840 " AscendC::GlobalTensor<DTYPE_X> xGm;\n",
839 " AscendC::GlobalTensor<DTYPE_Y> yGm;\n",841 " AscendC::GlobalTensor<DTYPE_Y> yGm;\n",
840 " AscendC::GlobalTensor<DTYPE_Z> zGm;\n",842 " AscendC::GlobalTensor<DTYPE_Z> zGm;\n",
@@ -1070,4 +1072,4 @@
1070 },1072 },
1071 "nbformat": 4,1073 "nbformat": 4,
1072 "nbformat_minor": 41074 "nbformat_minor": 4
1073-}1075+}
@@ -1,6 +1,7 @@
1#include "kernel_operator.h"1#include "kernel_operator.h"
2#include "square_diff_tiling.h"2#include "square_diff_tiling.h"
3constexpr int32_t BUFFER_NUM = 2;3constexpr int32_t BUFFER_NUM = 2;
4+constexpr int32_t QUEUE_DEPTH = 2;
4 5 
5template<typename TYPE_X, typename TYPE_Y, typename TYPE_Z> class KernelSquareDiff {6template<typename TYPE_X, typename TYPE_Y, typename TYPE_Z> class KernelSquareDiff {
6public:7public:
@@ -78,8 +79,8 @@ private:
78 79 
79private:80private:
80 AscendC::TPipe pipe;81 AscendC::TPipe pipe;
81- AscendC::TQue<AscendC::QuePosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;82+ AscendC::TQue<AscendC::QuePosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;
82- AscendC::TQue<AscendC::QuePosition::VECOUT, BUFFER_NUM> outQueueZ;83+ AscendC::TQue<AscendC::QuePosition::VECOUT, QUEUE_DEPTH> outQueueZ;
83 AscendC::GlobalTensor<TYPE_X> xGm;84 AscendC::GlobalTensor<TYPE_X> xGm;
84 AscendC::GlobalTensor<TYPE_Y> yGm;85 AscendC::GlobalTensor<TYPE_Y> yGm;
85 AscendC::GlobalTensor<TYPE_Z> zGm;86 AscendC::GlobalTensor<TYPE_Z> zGm;
@@ -815,6 +815,7 @@
815 "#include \"add_custom_tiling_key.h\"\n",815 "#include \"add_custom_tiling_key.h\"\n",
816 "\n",816 "\n",
817 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",817 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",
818+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
818 "\n",819 "\n",
819 "template <class dtypeX, class dtypeY, class dtypeZ>\n",820 "template <class dtypeX, class dtypeY, class dtypeZ>\n",
820 "class KernelAdd {\n",821 "class KernelAdd {\n",
@@ -873,9 +874,9 @@
873 "\n",874 "\n",
874 "private:\n",875 "private:\n",
875 " AscendC::TPipe pipe;\n",876 " AscendC::TPipe pipe;\n",
876- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",877+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
877- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;\n",878+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;\n",
878- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",879+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
879 " AscendC::GlobalTensor<dtypeX> xGm;\n",880 " AscendC::GlobalTensor<dtypeX> xGm;\n",
880 " AscendC::GlobalTensor<dtypeY> yGm;\n",881 " AscendC::GlobalTensor<dtypeY> yGm;\n",
881 " AscendC::GlobalTensor<dtypeZ> zGm;\n",882 " AscendC::GlobalTensor<dtypeZ> zGm;\n",
@@ -2171,6 +2172,7 @@
2171 "using namespace AscendC;\n",2172 "using namespace AscendC;\n",
2172 "\n",2173 "\n",
2173 "constexpr int32_t BUFFER_NUM = 2;\n",2174 "constexpr int32_t BUFFER_NUM = 2;\n",
2175+ "constexpr int32_t QUEUE_DEPTH = 2;\n",
2174 "\n",2176 "\n",
2175 "template <typename T>\n",2177 "template <typename T>\n",
2176 "class Sub {\n",2178 "class Sub {\n",
@@ -2187,8 +2189,8 @@
2187 "\n",2189 "\n",
2188 "private:\n",2190 "private:\n",
2189 " TPipe pipe;\n",2191 " TPipe pipe;\n",
2190- " TQue<QuePosition::VECIN, BUFFER_NUM> XXX;\n",2192+ " TQue<QuePosition::VECIN, QUEUE_DEPTH> XXX;\n",
2191- " TQue<QuePosition::VECOUT, BUFFER_NUM> YYY;\n",2193+ " TQue<QuePosition::VECOUT, QUEUE_DEPTH> YYY;\n",
2192 "};\n",2194 "};\n",
2193 "\n",2195 "\n",
2194 "template <typename T>\n",2196 "template <typename T>\n",
@@ -449,6 +449,7 @@
449 "using namespace AscendC;\n",449 "using namespace AscendC;\n",
450 "\n",450 "\n",
451 "constexpr int32_t BUFFER_NUM = 2;\n",451 "constexpr int32_t BUFFER_NUM = 2;\n",
452+ "constexpr int32_t QUEUE_DEPTH = 2;\n",
452 "\n",453 "\n",
453 "template <typename T>\n",454 "template <typename T>\n",
454 "class Sigmoid {\n",455 "class Sigmoid {\n",
@@ -465,8 +466,8 @@
465 "\n",466 "\n",
466 "private:\n",467 "private:\n",
467 " TPipe pipe;\n",468 " TPipe pipe;\n",
468- " TQue<QuePosition::VECIN, BUFFER_NUM> XXX;\n",469+ " TQue<QuePosition::VECIN, QUEUE_DEPTH> XXX;\n",
469- " TQue<QuePosition::VECOUT, BUFFER_NUM> YYY;\n",470+ " TQue<QuePosition::VECOUT, QUEUE_DEPTH> YYY;\n",
470 "};\n",471 "};\n",
471 "\n",472 "\n",
472 "template <typename T>\n",473 "template <typename T>\n",
@@ -12,6 +12,7 @@ namespace NsSub {
12using namespace AscendC;12using namespace AscendC;
13 13 
14constexpr int32_t BUFFER_NUM = 1;14constexpr int32_t BUFFER_NUM = 1;
15+constexpr int32_t QUEUE_DEPTH = 1;
15 16 
16template <typename T>17template <typename T>
17class Sub {18class Sub {
@@ -28,9 +29,9 @@ private:
28 29 
29private:30private:
30 AscendC::TPipe pipe;31 AscendC::TPipe pipe;
31- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;32+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
32- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX2;33+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX2;
33- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueY;34+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueY;
34 AscendC::GlobalTensor<T> xGm;35 AscendC::GlobalTensor<T> xGm;
35 AscendC::GlobalTensor<T> x2Gm;36 AscendC::GlobalTensor<T> x2Gm;
36 AscendC::GlobalTensor<T> yGm;37 AscendC::GlobalTensor<T> yGm;
@@ -11,6 +11,7 @@ namespace NsSigmoid {
11using namespace AscendC;11using namespace AscendC;
12 12 
13constexpr int32_t BUFFER_NUM = 1;13constexpr int32_t BUFFER_NUM = 1;
14+constexpr int32_t QUEUE_DEPTH = 1;
14 15 
15template <typename T>16template <typename T>
16class Sigmoid {17class Sigmoid {
@@ -29,8 +30,8 @@ private:
29 30 
30private:31private:
31 TPipe pipe;32 TPipe pipe;
32- TQue<QuePosition::VECIN, BUFFER_NUM> XXX;33+ TQue<QuePosition::VECIN, QUEUE_DEPTH> XXX;
33- TQue<QuePosition::VECOUT, BUFFER_NUM> YYY;34+ TQue<QuePosition::VECOUT, QUEUE_DEPTH> YYY;
34 AscendC::TBuf<AscendC::QuePosition::VECCALC> tmp1, tmp2;35 AscendC::TBuf<AscendC::QuePosition::VECCALC> tmp1, tmp2;
35 AscendC::GlobalTensor<T> xGm;36 AscendC::GlobalTensor<T> xGm;
36 AscendC::GlobalTensor<T> yGm;37 AscendC::GlobalTensor<T> yGm;
@@ -4,6 +4,7 @@
4#include "add_custom_tiling_key.h"4#include "add_custom_tiling_key.h"
5 5 
6constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue6constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue
7+constexpr int32_t QUEUE_DEPTH = 1;
7 8 
8template <class dtypeX, class dtypeY, class dtypeZ>9template <class dtypeX, class dtypeY, class dtypeZ>
9class KernelAdd {10class KernelAdd {
@@ -62,9 +63,9 @@ private:
62 63 
63private:64private:
64 AscendC::TPipe pipe;65 AscendC::TPipe pipe;
65- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;66+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
66- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;67+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;
67- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;68+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
68 AscendC::GlobalTensor<dtypeX> xGm;69 AscendC::GlobalTensor<dtypeX> xGm;
69 AscendC::GlobalTensor<dtypeY> yGm;70 AscendC::GlobalTensor<dtypeY> yGm;
70 AscendC::GlobalTensor<dtypeZ> zGm;71 AscendC::GlobalTensor<dtypeZ> zGm;
@@ -152,6 +152,7 @@
152 "constexpr int32_t BLOCK_LENGTH = TOTAL_LENGTH / USE_CORE_NUM; // length computed of each core\n",152 "constexpr int32_t BLOCK_LENGTH = TOTAL_LENGTH / USE_CORE_NUM; // length computed of each core\n",
153 "constexpr int32_t TILE_NUM = 8; // split data into 1 tiles for each core\n",153 "constexpr int32_t TILE_NUM = 8; // split data into 1 tiles for each core\n",
154 "constexpr int32_t BUFFER_NUM = 2; // tensor num for each queue\n",154 "constexpr int32_t BUFFER_NUM = 2; // tensor num for each queue\n",
155+ "constexpr int32_t QUEUE_DEPTH = 2;\n",
155 "constexpr int32_t TILE_LENGTH = BLOCK_LENGTH / TILE_NUM / BUFFER_NUM; // separate to 2 parts, due to double buffer"156 "constexpr int32_t TILE_LENGTH = BLOCK_LENGTH / TILE_NUM / BUFFER_NUM; // separate to 2 parts, due to double buffer"
156 ]157 ]
157 },158 },
@@ -225,8 +226,8 @@
225 "\n",226 "\n",
226 "private:\n",227 "private:\n",
227 " AscendC::TPipe pipe;\n",228 " AscendC::TPipe pipe;\n",
228- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",229+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
229- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",230+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
230 " AscendC::GlobalTensor<half> xGm;\n",231 " AscendC::GlobalTensor<half> xGm;\n",
231 " AscendC::GlobalTensor<half> yGm;\n",232 " AscendC::GlobalTensor<half> yGm;\n",
232 " AscendC::GlobalTensor<half> zGm;\n",233 " AscendC::GlobalTensor<half> zGm;\n",
@@ -748,6 +749,7 @@
748 "constexpr int32_t BLOCK_LENGTH = TOTAL_LENGTH / USE_CORE_NUM; // length computed of each core\n",749 "constexpr int32_t BLOCK_LENGTH = TOTAL_LENGTH / USE_CORE_NUM; // length computed of each core\n",
749 "constexpr int32_t TILE_NUM = 8; // split data into 1 tiles for each core\n",750 "constexpr int32_t TILE_NUM = 8; // split data into 1 tiles for each core\n",
750 "constexpr int32_t BUFFER_NUM = 2; // tensor num for each queue\n",751 "constexpr int32_t BUFFER_NUM = 2; // tensor num for each queue\n",
752+ "constexpr int32_t QUEUE_DEPTH = 2;\n",
751 "constexpr int32_t TILE_LENGTH = BLOCK_LENGTH / TILE_NUM / BUFFER_NUM; // separate to 2 parts, due to double buffer\n",753 "constexpr int32_t TILE_LENGTH = BLOCK_LENGTH / TILE_NUM / BUFFER_NUM; // separate to 2 parts, due to double buffer\n",
752 "constexpr int32_t OFFSET_LENGTH = 32; // offset length for DumpAccChkPoint\n",754 "constexpr int32_t OFFSET_LENGTH = 32; // offset length for DumpAccChkPoint\n",
753 "constexpr int32_t DUMP_LENGTH = 32; // dump length\n",755 "constexpr int32_t DUMP_LENGTH = 32; // dump length\n",
@@ -805,8 +807,8 @@
805 "\n",807 "\n",
806 "private:\n",808 "private:\n",
807 " AscendC::TPipe pipe;\n",809 " AscendC::TPipe pipe;\n",
808- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",810+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
809- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",811+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
810 " AscendC::GlobalTensor<half> xGm;\n",812 " AscendC::GlobalTensor<half> xGm;\n",
811 " AscendC::GlobalTensor<half> yGm;\n",813 " AscendC::GlobalTensor<half> yGm;\n",
812 " AscendC::GlobalTensor<half> zGm;\n",814 " AscendC::GlobalTensor<half> zGm;\n",
@@ -906,6 +908,7 @@
906 "constexpr int32_t BLOCK_LENGTH = TOTAL_LENGTH / USE_CORE_NUM; // length computed of each core\n",908 "constexpr int32_t BLOCK_LENGTH = TOTAL_LENGTH / USE_CORE_NUM; // length computed of each core\n",
907 "constexpr int32_t TILE_NUM = 8; // split data into 1 tiles for each core\n",909 "constexpr int32_t TILE_NUM = 8; // split data into 1 tiles for each core\n",
908 "constexpr int32_t BUFFER_NUM = 2; // tensor num for each queue\n",910 "constexpr int32_t BUFFER_NUM = 2; // tensor num for each queue\n",
911+ "constexpr int32_t QUEUE_DEPTH = 2;\n",
909 "constexpr int32_t TILE_LENGTH = BLOCK_LENGTH / TILE_NUM / BUFFER_NUM; // separate to 2 parts, due to double buffer\n",912 "constexpr int32_t TILE_LENGTH = BLOCK_LENGTH / TILE_NUM / BUFFER_NUM; // separate to 2 parts, due to double buffer\n",
910 "constexpr int32_t OFFSET_LENGTH = 32; // offset length for DumpAccChkPoint\n",913 "constexpr int32_t OFFSET_LENGTH = 32; // offset length for DumpAccChkPoint\n",
911 "constexpr int32_t DUMP_LENGTH = 32; // dump length\n",914 "constexpr int32_t DUMP_LENGTH = 32; // dump length\n",
@@ -963,8 +966,8 @@
963 "\n",966 "\n",
964 "private:\n",967 "private:\n",
965 " AscendC::TPipe pipe;\n",968 " AscendC::TPipe pipe;\n",
966- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",969+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
967- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",970+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
968 " AscendC::GlobalTensor<half> xGm;\n",971 " AscendC::GlobalTensor<half> xGm;\n",
969 " AscendC::GlobalTensor<half> yGm;\n",972 " AscendC::GlobalTensor<half> yGm;\n",
970 " AscendC::GlobalTensor<half> zGm;\n",973 " AscendC::GlobalTensor<half> zGm;\n",
@@ -315,6 +315,7 @@
315 "#include \"kernel_operator.h\"\n",315 "#include \"kernel_operator.h\"\n",
316 "\n",316 "\n",
317 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",317 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
318+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
318 "\n",319 "\n",
319 "struct AddCustomTilingData\n",320 "struct AddCustomTilingData\n",
320 "{\n",321 "{\n",
@@ -389,8 +390,8 @@
389 "\n",390 "\n",
390 "private:\n",391 "private:\n",
391 " AscendC::TPipe pipe;\n",392 " AscendC::TPipe pipe;\n",
392- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",393+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
393- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",394+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
394 " AscendC::GlobalTensor<float> xGm;\n",395 " AscendC::GlobalTensor<float> xGm;\n",
395 " AscendC::GlobalTensor<float> yGm;\n",396 " AscendC::GlobalTensor<float> yGm;\n",
396 " AscendC::GlobalTensor<float> zGm;\n",397 " AscendC::GlobalTensor<float> zGm;\n",
@@ -588,6 +589,7 @@
588 "#include \"kernel_operator.h\"\n",589 "#include \"kernel_operator.h\"\n",
589 "\n",590 "\n",
590 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",591 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
592+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
591 "\n",593 "\n",
592 "struct AddCustomTilingData\n",594 "struct AddCustomTilingData\n",
593 "{\n",595 "{\n",
@@ -651,8 +653,8 @@
651 "\n",653 "\n",
652 "private:\n",654 "private:\n",
653 " AscendC::TPipe pipe;\n",655 " AscendC::TPipe pipe;\n",
654- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",656+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
655- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",657+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
656 " AscendC::GlobalTensor<float> xGm;\n",658 " AscendC::GlobalTensor<float> xGm;\n",
657 " AscendC::GlobalTensor<float> yGm;\n",659 " AscendC::GlobalTensor<float> yGm;\n",
658 " AscendC::GlobalTensor<float> zGm;\n",660 " AscendC::GlobalTensor<float> zGm;\n",
@@ -293,6 +293,7 @@
293 "#include \"kernel_operator.h\"\n",293 "#include \"kernel_operator.h\"\n",
294 "\n",294 "\n",
295 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",295 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
296+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
atomgit-bot
atomgit-botatomgit-bot7月20日

🟡 Medium Priority

该文件中有 6 个独立的算子代码示例(AddCustom × 5 + SinhCustom × 1),每个都新增了 QUEUE_DEPTH = 2 常量并将 TQue 模板参数从 BUFFER_NUM 改为 QUEUE_DEPTH。但每个代码块中以下位置仍然使用 BUFFER_NUM

具体受影响的代码块(按 cell 出现的行范围):

  1. 第 285-366 行(AddCustom,含 printf 调试)
  2. 第 525-604 行(AddCustom,含 printf 调试)
  3. 第 745-824 行(AddCustom,含 printf 调试)
  4. 第 990-1069 行(AddCustom,CopyOut 中 zLocal 越界场景)
  5. 第 1255-1334 行(AddCustom,正确示例)
  6. 第 1485-1564 行(SinhCustom)

当前 BUFFER_NUMQUEUE_DEPTH 值相同(均为 2),不会触发运行时错误。但这是教程代码,不一致的命名会误导学习者;且未来若只修改其中一个常量会导致队列深度与 buffer 分配数量不匹配,引发内存错误或流水线死锁。

建议:统一使用 QUEUE_DEPTH(或统一使用 BUFFER_NUM)作为唯一常量名,并将上述 6 个代码块中所有 InitBuffertileLength 计算、loopCount 计算中的 BUFFER_NUM 替换为与 TQue 模板参数一致的常量。两个常量只应保留一个,另一个应删除。

likedislike
296 "\n",297 "\n",
297 "struct AddCustomTilingData\n",298 "struct AddCustomTilingData\n",
298 "{\n",299 "{\n",
@@ -354,8 +355,8 @@
354 "\n",355 "\n",
355 "private:\n",356 "private:\n",
356 " AscendC::TPipe pipe;\n",357 " AscendC::TPipe pipe;\n",
357- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",358+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
358- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",359+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
359 " AscendC::GlobalTensor<float> xGm;\n",360 " AscendC::GlobalTensor<float> xGm;\n",
360 " AscendC::GlobalTensor<float> yGm;\n",361 " AscendC::GlobalTensor<float> yGm;\n",
361 " AscendC::GlobalTensor<float> zGm;\n",362 " AscendC::GlobalTensor<float> zGm;\n",
@@ -531,6 +532,7 @@
531 "#include \"kernel_operator.h\"\n",532 "#include \"kernel_operator.h\"\n",
532 "\n",533 "\n",
533 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",534 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
535+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
534 "\n",536 "\n",
535 "struct AddCustomTilingData\n",537 "struct AddCustomTilingData\n",
536 "{\n",538 "{\n",
@@ -596,8 +598,8 @@
596 "\n",598 "\n",
597 "private:\n",599 "private:\n",
598 " AscendC::TPipe pipe;\n",600 " AscendC::TPipe pipe;\n",
599- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",601+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
600- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",602+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
601 " AscendC::GlobalTensor<float> xGm;\n",603 " AscendC::GlobalTensor<float> xGm;\n",
602 " AscendC::GlobalTensor<float> yGm;\n",604 " AscendC::GlobalTensor<float> yGm;\n",
603 " AscendC::GlobalTensor<float> zGm;\n",605 " AscendC::GlobalTensor<float> zGm;\n",
@@ -750,6 +752,7 @@
750 "#include \"kernel_operator.h\"\n",752 "#include \"kernel_operator.h\"\n",
751 "\n",753 "\n",
752 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",754 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
755+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
753 "\n",756 "\n",
754 "struct AddCustomTilingData\n",757 "struct AddCustomTilingData\n",
755 "{\n",758 "{\n",
@@ -815,8 +818,8 @@
815 "\n",818 "\n",
816 "private:\n",819 "private:\n",
817 " AscendC::TPipe pipe;\n",820 " AscendC::TPipe pipe;\n",
818- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",821+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
819- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",822+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
820 " AscendC::GlobalTensor<float> xGm;\n",823 " AscendC::GlobalTensor<float> xGm;\n",
821 " AscendC::GlobalTensor<float> yGm;\n",824 " AscendC::GlobalTensor<float> yGm;\n",
822 " AscendC::GlobalTensor<float> zGm;\n",825 " AscendC::GlobalTensor<float> zGm;\n",
@@ -998,6 +1001,7 @@
998 "#include \"kernel_operator.h\"\n",1001 "#include \"kernel_operator.h\"\n",
999 "\n",1002 "\n",
1000 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",1003 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
1004+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
1001 "\n",1005 "\n",
1002 "struct AddCustomTilingData\n",1006 "struct AddCustomTilingData\n",
1003 "{\n",1007 "{\n",
@@ -1059,8 +1063,8 @@
1059 "\n",1063 "\n",
1060 "private:\n",1064 "private:\n",
1061 " AscendC::TPipe pipe;\n",1065 " AscendC::TPipe pipe;\n",
1062- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",1066+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
1063- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",1067+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
1064 " AscendC::GlobalTensor<float> xGm;\n",1068 " AscendC::GlobalTensor<float> xGm;\n",
1065 " AscendC::GlobalTensor<float> yGm;\n",1069 " AscendC::GlobalTensor<float> yGm;\n",
1066 " AscendC::GlobalTensor<float> zGm;\n",1070 " AscendC::GlobalTensor<float> zGm;\n",
@@ -1262,6 +1266,7 @@
1262 "#include \"kernel_operator.h\"\n",1266 "#include \"kernel_operator.h\"\n",
1263 "\n",1267 "\n",
1264 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",1268 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
1269+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
1265 "\n",1270 "\n",
1266 "struct AddCustomTilingData\n",1271 "struct AddCustomTilingData\n",
1267 "{\n",1272 "{\n",
@@ -1323,8 +1328,8 @@
1323 "\n",1328 "\n",
1324 "private:\n",1329 "private:\n",
1325 " AscendC::TPipe pipe;\n",1330 " AscendC::TPipe pipe;\n",
1326- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX, inQueueY;\n",1331+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX, inQueueY;\n",
1327- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",1332+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
1328 " AscendC::GlobalTensor<float> xGm;\n",1333 " AscendC::GlobalTensor<float> xGm;\n",
1329 " AscendC::GlobalTensor<float> yGm;\n",1334 " AscendC::GlobalTensor<float> yGm;\n",
1330 " AscendC::GlobalTensor<float> zGm;\n",1335 " AscendC::GlobalTensor<float> zGm;\n",
@@ -1492,6 +1497,7 @@
1492 "#include \"kernel_operator.h\"\n",1497 "#include \"kernel_operator.h\"\n",
1493 "\n",1498 "\n",
1494 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",1499 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
1500+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
1495 "\n",1501 "\n",
1496 "struct SinhCustomTilingData\n",1502 "struct SinhCustomTilingData\n",
1497 "{\n",1503 "{\n",
@@ -1551,8 +1557,8 @@
1551 "\n",1557 "\n",
1552 "private:\n",1558 "private:\n",
1553 " AscendC::TPipe pipe;\n",1559 " AscendC::TPipe pipe;\n",
1554- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",1560+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
1555- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",1561+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
1556 " AscendC::GlobalTensor<float> xGm;\n",1562 " AscendC::GlobalTensor<float> xGm;\n",
1557 " AscendC::GlobalTensor<float> zGm;\n",1563 " AscendC::GlobalTensor<float> zGm;\n",
1558 " uint32_t blockLength;\n",1564 " uint32_t blockLength;\n",
@@ -81,6 +81,7 @@
81 " } while (0)\n",81 " } while (0)\n",
82 " \n",82 " \n",
83 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",83 "constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue\n",
84+ "constexpr uint32_t QUEUE_DEPTH = 2;\n",
84 "\n",85 "\n",
85 "struct SinhCustomTilingData\n",86 "struct SinhCustomTilingData\n",
86 "{\n",87 "{\n",
@@ -138,8 +139,8 @@
138 "\n",139 "\n",
139 "private:\n",140 "private:\n",
140 " AscendC::TPipe pipe;\n",141 " AscendC::TPipe pipe;\n",
141- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",142+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
142- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",143+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
143 " AscendC::GlobalTensor<float> xGm;\n",144 " AscendC::GlobalTensor<float> xGm;\n",
144 " AscendC::GlobalTensor<float> zGm;\n",145 " AscendC::GlobalTensor<float> zGm;\n",
145 " uint32_t blockLength;\n",146 " uint32_t blockLength;\n",
@@ -12,6 +12,7 @@
12#include "kernel_operator.h"12#include "kernel_operator.h"
13 13 
14constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue14constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue
15+constexpr uint32_t QUEUE_DEPTH = 2;
15 16 
16struct SinhCustomTilingData17struct SinhCustomTilingData
17{18{
@@ -70,8 +71,8 @@ private:
70 71 
71private:72private:
72 AscendC::TPipe pipe;73 AscendC::TPipe pipe;
73- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;74+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
74- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;75+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
75 AscendC::GlobalTensor<float> xGm;76 AscendC::GlobalTensor<float> xGm;
76 AscendC::GlobalTensor<float> zGm;77 AscendC::GlobalTensor<float> zGm;
77 uint32_t blockLength;78 uint32_t blockLength;
@@ -12,6 +12,7 @@
12#include "kernel_operator.h"12#include "kernel_operator.h"
13 13 
14constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue14constexpr uint32_t BUFFER_NUM = 2; // tensor num for each queue
15+constexpr uint32_t QUEUE_DEPTH = 2;
15 16 
16struct SinhCustomTilingData17struct SinhCustomTilingData
17{18{
@@ -70,8 +71,8 @@ private:
70 71 
71private:72private:
72 AscendC::TPipe pipe;73 AscendC::TPipe pipe;
73- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;74+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
74- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;75+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
75 AscendC::GlobalTensor<float> xGm;76 AscendC::GlobalTensor<float> xGm;
76 AscendC::GlobalTensor<float> zGm;77 AscendC::GlobalTensor<float> zGm;
77 uint32_t blockLength;78 uint32_t blockLength;
@@ -430,6 +430,7 @@
430 "#include \"add_custom_template_tiling.h\"\n",430 "#include \"add_custom_template_tiling.h\"\n",
431 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",431 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",
432 "constexpr int32_t BUFFER_NUM = 1;\n",432 "constexpr int32_t BUFFER_NUM = 1;\n",
433+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
433 "\n",434 "\n",
434 "template <class dtypeX, class dtypeY, class dtypeZ>\n",435 "template <class dtypeX, class dtypeY, class dtypeZ>\n",
435 "class KernelAdd {\n",436 "class KernelAdd {\n",
@@ -488,9 +489,9 @@
488 "\n",489 "\n",
489 "private:\n",490 "private:\n",
490 " AscendC::TPipe pipe;\n",491 " AscendC::TPipe pipe;\n",
491- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",492+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
492- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;\n",493+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;\n",
493- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",494+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
494 " AscendC::GlobalTensor<dtypeX> xGm;\n",495 " AscendC::GlobalTensor<dtypeX> xGm;\n",
495 " AscendC::GlobalTensor<dtypeY> yGm;\n",496 " AscendC::GlobalTensor<dtypeY> yGm;\n",
496 " AscendC::GlobalTensor<dtypeZ> zGm;\n",497 " AscendC::GlobalTensor<dtypeZ> zGm;\n",
@@ -347,6 +347,7 @@
347 "#include \"add_custom_template_tiling.h\"\n",347 "#include \"add_custom_template_tiling.h\"\n",
348 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",348 "#include \"kernel_operator_dump_tensor_intf_impl.h\"\n",
349 "constexpr int32_t BUFFER_NUM = 1;\n",349 "constexpr int32_t BUFFER_NUM = 1;\n",
350+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
350 "\n",351 "\n",
351 "template <class dtypeX, class dtypeY, class dtypeZ>\n",352 "template <class dtypeX, class dtypeY, class dtypeZ>\n",
352 "class KernelAdd {\n",353 "class KernelAdd {\n",
@@ -405,9 +406,9 @@
405 "\n",406 "\n",
406 "private:\n",407 "private:\n",
407 " AscendC::TPipe pipe;\n",408 " AscendC::TPipe pipe;\n",
408- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",409+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
409- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;\n",410+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;\n",
410- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",411+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
411 " AscendC::GlobalTensor<dtypeX> xGm;\n",412 " AscendC::GlobalTensor<dtypeX> xGm;\n",
412 " AscendC::GlobalTensor<dtypeY> yGm;\n",413 " AscendC::GlobalTensor<dtypeY> yGm;\n",
413 " AscendC::GlobalTensor<dtypeZ> zGm;\n",414 " AscendC::GlobalTensor<dtypeZ> zGm;\n",
@@ -273,6 +273,7 @@
273 "#include \"kernel_operator.h\"\n",273 "#include \"kernel_operator.h\"\n",
274 "#include \"add_custom_template_tiling.h\"\n",274 "#include \"add_custom_template_tiling.h\"\n",
275 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",275 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",
276+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
276 "\n",277 "\n",
277 "template <class dtypeX, class dtypeY, class dtypeZ>\n",278 "template <class dtypeX, class dtypeY, class dtypeZ>\n",
278 "class KernelAdd {\n",279 "class KernelAdd {\n",
@@ -331,9 +332,9 @@
331 "\n",332 "\n",
332 "private:\n",333 "private:\n",
333 " AscendC::TPipe pipe;\n",334 " AscendC::TPipe pipe;\n",
334- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",335+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
335- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;\n",336+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;\n",
336- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",337+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
337 " AscendC::GlobalTensor<dtypeX> xGm;\n",338 " AscendC::GlobalTensor<dtypeX> xGm;\n",
338 " AscendC::GlobalTensor<dtypeY> yGm;\n",339 " AscendC::GlobalTensor<dtypeY> yGm;\n",
339 " AscendC::GlobalTensor<dtypeZ> zGm;\n",340 " AscendC::GlobalTensor<dtypeZ> zGm;\n",
@@ -645,6 +646,7 @@
645 "#include \"kernel_operator.h\"\n",646 "#include \"kernel_operator.h\"\n",
646 "#include \"add_custom_template_tiling.h\"\n",647 "#include \"add_custom_template_tiling.h\"\n",
647 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",648 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",
649+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
648 "\n",650 "\n",
649 "template <class dtypeX, class dtypeY, class dtypeZ>\n",651 "template <class dtypeX, class dtypeY, class dtypeZ>\n",
650 "class KernelAdd {\n",652 "class KernelAdd {\n",
@@ -704,9 +706,9 @@
704 "\n",706 "\n",
705 "private:\n",707 "private:\n",
706 " AscendC::TPipe pipe;\n",708 " AscendC::TPipe pipe;\n",
707- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",709+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
708- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;\n",710+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;\n",
709- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",711+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
710 " AscendC::GlobalTensor<dtypeX> xGm;\n",712 " AscendC::GlobalTensor<dtypeX> xGm;\n",
711 " AscendC::GlobalTensor<dtypeY> yGm;\n",713 " AscendC::GlobalTensor<dtypeY> yGm;\n",
712 " AscendC::GlobalTensor<dtypeZ> zGm;\n",714 " AscendC::GlobalTensor<dtypeZ> zGm;\n",
@@ -1009,6 +1011,7 @@
1009 "#include \"kernel_operator.h\"\n",1011 "#include \"kernel_operator.h\"\n",
1010 "#include \"add_custom_template_tiling.h\"\n",1012 "#include \"add_custom_template_tiling.h\"\n",
1011 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",1013 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",
1014+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
1012 "\n",1015 "\n",
1013 "template <class dtypeX, class dtypeY, class dtypeZ>\n",1016 "template <class dtypeX, class dtypeY, class dtypeZ>\n",
1014 "class KernelAdd {\n",1017 "class KernelAdd {\n",
@@ -1066,9 +1069,9 @@
1066 "\n",1069 "\n",
1067 "private:\n",1070 "private:\n",
1068 " AscendC::TPipe pipe;\n",1071 " AscendC::TPipe pipe;\n",
1069- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",1072+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
1070- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;\n",1073+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;\n",
1071- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",1074+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
1072 " AscendC::GlobalTensor<dtypeX> xGm;\n",1075 " AscendC::GlobalTensor<dtypeX> xGm;\n",
1073 " AscendC::GlobalTensor<dtypeY> yGm;\n",1076 " AscendC::GlobalTensor<dtypeY> yGm;\n",
1074 " AscendC::GlobalTensor<dtypeZ> zGm;\n",1077 " AscendC::GlobalTensor<dtypeZ> zGm;\n",
@@ -206,6 +206,7 @@
206 "#include \"kernel_operator.h\"\n",206 "#include \"kernel_operator.h\"\n",
207 "#include \"add_custom_template_tiling.h\"\n",207 "#include \"add_custom_template_tiling.h\"\n",
208 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",208 "constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue\n",
209+ "constexpr int32_t QUEUE_DEPTH = 1;\n",
209 "\n",210 "\n",
210 "template <class dtypeX, class dtypeY, class dtypeZ>\n",211 "template <class dtypeX, class dtypeY, class dtypeZ>\n",
211 "class KernelAdd {\n",212 "class KernelAdd {\n",
@@ -263,9 +264,9 @@
263 "\n",264 "\n",
264 "private:\n",265 "private:\n",
265 " AscendC::TPipe pipe;\n",266 " AscendC::TPipe pipe;\n",
266- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;\n",267+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;\n",
267- " AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;\n",268+ " AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;\n",
268- " AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;\n",269+ " AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;\n",
269 " AscendC::GlobalTensor<dtypeX> xGm;\n",270 " AscendC::GlobalTensor<dtypeX> xGm;\n",
270 " AscendC::GlobalTensor<dtypeY> yGm;\n",271 " AscendC::GlobalTensor<dtypeY> yGm;\n",
271 " AscendC::GlobalTensor<dtypeZ> zGm;\n",272 " AscendC::GlobalTensor<dtypeZ> zGm;\n",
@@ -13,6 +13,7 @@
13#include "add_custom_template_tiling.h"13#include "add_custom_template_tiling.h"
14#include "kernel_operator_dump_tensor_intf_impl.h"14#include "kernel_operator_dump_tensor_intf_impl.h"
15constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue15constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue
16+constexpr int32_t QUEUE_DEPTH = 1;
16 17 
17template <class dtypeX, class dtypeY, class dtypeZ>18template <class dtypeX, class dtypeY, class dtypeZ>
18class KernelAdd {19class KernelAdd {
@@ -71,9 +72,9 @@ private:
71 72 
72private:73private:
73 AscendC::TPipe pipe;74 AscendC::TPipe pipe;
74- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;75+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
75- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;76+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;
76- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;77+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
77 AscendC::GlobalTensor<dtypeX> xGm;78 AscendC::GlobalTensor<dtypeX> xGm;
78 AscendC::GlobalTensor<dtypeY> yGm;79 AscendC::GlobalTensor<dtypeY> yGm;
79 AscendC::GlobalTensor<dtypeZ> zGm;80 AscendC::GlobalTensor<dtypeZ> zGm;
@@ -12,6 +12,7 @@
12#include "kernel_operator.h"12#include "kernel_operator.h"
13#include "add_custom_template_tiling.h"13#include "add_custom_template_tiling.h"
14constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue14constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue
15+constexpr int32_t QUEUE_DEPTH = 1;
15 16 
16template <class dtypeX, class dtypeY, class dtypeZ>17template <class dtypeX, class dtypeY, class dtypeZ>
17class KernelAdd {18class KernelAdd {
@@ -70,9 +71,9 @@ private:
70 71 
71private:72private:
72 AscendC::TPipe pipe;73 AscendC::TPipe pipe;
73- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;74+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
74- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;75+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;
75- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;76+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
76 AscendC::GlobalTensor<dtypeX> xGm;77 AscendC::GlobalTensor<dtypeX> xGm;
77 AscendC::GlobalTensor<dtypeY> yGm;78 AscendC::GlobalTensor<dtypeY> yGm;
78 AscendC::GlobalTensor<dtypeZ> zGm;79 AscendC::GlobalTensor<dtypeZ> zGm;
@@ -12,6 +12,7 @@
12#include "kernel_operator.h"12#include "kernel_operator.h"
13#include "add_custom_template_tiling.h"13#include "add_custom_template_tiling.h"
14constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue14constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue
15+constexpr int32_t QUEUE_DEPTH = 1;
15 16 
16template <class dtypeX, class dtypeY, class dtypeZ>17template <class dtypeX, class dtypeY, class dtypeZ>
17class KernelAdd {18class KernelAdd {
@@ -71,9 +72,9 @@ private:
71 72 
72private:73private:
73 AscendC::TPipe pipe;74 AscendC::TPipe pipe;
74- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;75+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
75- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;76+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;
76- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;77+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
77 AscendC::GlobalTensor<dtypeX> xGm;78 AscendC::GlobalTensor<dtypeX> xGm;
78 AscendC::GlobalTensor<dtypeY> yGm;79 AscendC::GlobalTensor<dtypeY> yGm;
79 AscendC::GlobalTensor<dtypeZ> zGm;80 AscendC::GlobalTensor<dtypeZ> zGm;
@@ -12,6 +12,7 @@
12#include "kernel_operator.h"12#include "kernel_operator.h"
13#include "add_custom_template_tiling.h"13#include "add_custom_template_tiling.h"
14constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue14constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue
15+constexpr int32_t QUEUE_DEPTH = 1;
15 16 
16template <class dtypeX, class dtypeY, class dtypeZ>17template <class dtypeX, class dtypeY, class dtypeZ>
17class KernelAdd {18class KernelAdd {
@@ -69,9 +70,9 @@ private:
69 70 
70private:71private:
71 AscendC::TPipe pipe;72 AscendC::TPipe pipe;
72- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;73+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
73- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;74+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;
74- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;75+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
75 AscendC::GlobalTensor<dtypeX> xGm;76 AscendC::GlobalTensor<dtypeX> xGm;
76 AscendC::GlobalTensor<dtypeY> yGm;77 AscendC::GlobalTensor<dtypeY> yGm;
77 AscendC::GlobalTensor<dtypeZ> zGm;78 AscendC::GlobalTensor<dtypeZ> zGm;
@@ -12,6 +12,7 @@
12#include "kernel_operator.h"12#include "kernel_operator.h"
13#include "add_custom_template_tiling.h"13#include "add_custom_template_tiling.h"
14constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue14constexpr int32_t BUFFER_NUM = 1; // tensor num for each queue
15+constexpr int32_t QUEUE_DEPTH = 1;
15 16 
16template <class dtypeX, class dtypeY, class dtypeZ>17template <class dtypeX, class dtypeY, class dtypeZ>
17class KernelAdd {18class KernelAdd {
@@ -69,9 +70,9 @@ private:
69 70 
70private:71private:
71 AscendC::TPipe pipe;72 AscendC::TPipe pipe;
72- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueX;73+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueX;
73- AscendC::TQue<AscendC::TPosition::VECIN, BUFFER_NUM> inQueueY;74+ AscendC::TQue<AscendC::TPosition::VECIN, QUEUE_DEPTH> inQueueY;
74- AscendC::TQue<AscendC::TPosition::VECOUT, BUFFER_NUM> outQueueZ;75+ AscendC::TQue<AscendC::TPosition::VECOUT, QUEUE_DEPTH> outQueueZ;
75 AscendC::GlobalTensor<dtypeX> xGm;76 AscendC::GlobalTensor<dtypeX> xGm;
76 AscendC::GlobalTensor<dtypeY> yGm;77 AscendC::GlobalTensor<dtypeY> yGm;
77 AscendC::GlobalTensor<dtypeZ> zGm;78 AscendC::GlobalTensor<dtypeZ> zGm;