ops-tune-workbench-plugin 0.0.0-stage → 0.0.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/NOTICE.md +14 -0
  2. package/README.md +39 -2
  3. package/cordis.patch.yml +20 -0
  4. package/lib/client.js +4253 -0
  5. package/lib/host.js +2518 -0
  6. package/package.json +53 -4
  7. package/skills/tool-ops-tune/INSTALL.md +52 -0
  8. package/skills/tool-ops-tune/README.md +167 -0
  9. package/skills/tool-ops-tune/SKILL.md +93 -0
  10. package/skills/tool-ops-tune/agent/AGENTS.md +195 -0
  11. package/skills/tool-ops-tune/agent/agents/perf-implementer.md +68 -0
  12. package/skills/tool-ops-tune/agent/agents/perf-reviewer.md +86 -0
  13. package/skills/tool-ops-tune/agent/workflows/task-prompts.md +362 -0
  14. package/skills/tool-ops-tune/agent/workflows/troubleshooting.md +43 -0
  15. package/skills/tool-ops-tune/docs/figures/opstune-architecture.png +0 -0
  16. package/skills/tool-ops-tune/docs/figures/opstune-architecture.svg +253 -0
  17. package/skills/tool-ops-tune/docs/ops-tune-design.md +404 -0
  18. package/skills/tool-ops-tune/docs//347/224/250/344/276/213/346/236/204/345/273/272.md +714 -0
  19. package/skills/tool-ops-tune/docs//347/237/245/350/257/206/345/272/223/350/247/204/350/214/203.md +103 -0
  20. package/skills/tool-ops-tune/evals/evals.json +242 -0
  21. package/skills/tool-ops-tune/ops-collect/SKILL.md +146 -0
  22. package/skills/tool-ops-tune/ops-collect/references/tool-routing.md +86 -0
  23. package/skills/tool-ops-tune/ops-collect/scripts/collect_board.sh +444 -0
  24. package/skills/tool-ops-tune/ops-collect/scripts/collect_cases.py +368 -0
  25. package/skills/tool-ops-tune/ops-collect/scripts/collect_sim.sh +134 -0
  26. package/skills/tool-ops-tune/ops-collect/scripts/csv_to_db.py +314 -0
  27. package/skills/tool-ops-tune/ops-collect/scripts/db_bench.py +545 -0
  28. package/skills/tool-ops-tune/ops-collect/scripts/facts_bridge.py +1063 -0
  29. package/skills/tool-ops-tune/ops-collect/scripts/isolation_test.py +454 -0
  30. package/skills/tool-ops-tune/ops-collect/scripts/jsonl_to_cases.py +163 -0
  31. package/skills/tool-ops-tune/ops-family/SKILL.md +76 -0
  32. package/skills/tool-ops-tune/ops-family/references/broadcast/advanced_tiling.md +92 -0
  33. package/skills/tool-ops-tune/ops-family/references/broadcast/broadcast_design.md +160 -0
  34. package/skills/tool-ops-tune/ops-family/references/broadcast/code/broadcast_add_kernel.cpp +126 -0
  35. package/skills/tool-ops-tune/ops-family/references/broadcast/code/broadcast_add_tiling.cpp +144 -0
  36. package/skills/tool-ops-tune/ops-family/references/broadcast/code/broadcast_tiling_common.h +401 -0
  37. package/skills/tool-ops-tune/ops-family/references/broadcast/code/onedim_add_kernel.cpp +107 -0
  38. package/skills/tool-ops-tune/ops-family/references/broadcast/code/onedim_add_tiling.cpp +64 -0
  39. package/skills/tool-ops-tune/ops-family/references/broadcast/datacopypad_design.md +46 -0
  40. package/skills/tool-ops-tune/ops-family/references/broadcast/guide.md +14 -0
  41. package/skills/tool-ops-tune/ops-family/references/broadcast/nddma_design.md +53 -0
  42. package/skills/tool-ops-tune/ops-family/references/broadcast/onedim_design.md +114 -0
  43. package/skills/tool-ops-tune/ops-family/references/broadcast/ub_broadcast_design.md +67 -0
  44. package/skills/tool-ops-tune/ops-family/references/common/datacopy_optimization_design.md +351 -0
  45. package/skills/tool-ops-tune/ops-family/references/common/index.md +9 -0
  46. package/skills/tool-ops-tune/ops-family/references/common/tail_block_design.md +268 -0
  47. package/skills/tool-ops-tune/ops-family/references/common/timing_harness/index.md +38 -0
  48. package/skills/tool-ops-tune/ops-family/references/common/timing_harness/timing_harness_aclrt_event.cpp +199 -0
  49. package/skills/tool-ops-tune/ops-family/references/common/timing_harness/timing_harness_torch_event.py +130 -0
  50. package/skills/tool-ops-tune/ops-family/references/common/ub_resident_design.md +342 -0
  51. package/skills/tool-ops-tune/ops-family/references/conversion/guide.md +69 -0
  52. package/skills/tool-ops-tune/ops-family/references/conversion/index.md +4 -0
  53. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_base.template +81 -0
  54. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_big_dim.template +217 -0
  55. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_cut_one_axis.template +336 -0
  56. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_cut_two_axis.template +781 -0
  57. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_n_last.template +340 -0
  58. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_small_shape.template +321 -0
  59. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_tensor_move.template +102 -0
  60. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_transdata_5hd.template +480 -0
  61. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_transdata_5hd_021axis.template +533 -0
  62. package/skills/tool-ops-tune/ops-family/references/conversion/templates/dav3510/transpose_with_gather.template +688 -0
  63. package/skills/tool-ops-tune/ops-family/references/conversion/templates/transpose_tiling_data.template +192 -0
  64. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_big_dim.md +220 -0
  65. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_cut_one_axis.md +175 -0
  66. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_cut_two_axis.md +177 -0
  67. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_fusion_design.md +398 -0
  68. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_gather.md +191 -0
  69. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_n_last.md +276 -0
  70. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_small_shape.md +315 -0
  71. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_tensor_move.md +203 -0
  72. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_tiling_data.md +176 -0
  73. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_vconv_021.md +206 -0
  74. package/skills/tool-ops-tune/ops-family/references/conversion/transpose_vconv_5hd.md +179 -0
  75. package/skills/tool-ops-tune/ops-family/references/elementwise/double_buffer_design.md +288 -0
  76. package/skills/tool-ops-tune/ops-family/references/elementwise/guide.md +46 -0
  77. package/skills/tool-ops-tune/ops-family/references/elementwise/index.md +10 -0
  78. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/CMakeLists.txt +131 -0
  79. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/README.md +55 -0
  80. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/op_extension/add_custom_torch.cpp +80 -0
  81. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/op_extension/ops.h +23 -0
  82. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/op_extension/register.cpp +30 -0
  83. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/op_host/add_custom.asc +149 -0
  84. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/op_host/data_utils.h +97 -0
  85. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/op_kernel/add_custom_kernel.asc +136 -0
  86. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/op_kernel/add_custom_tiling.h +31 -0
  87. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/run.sh +86 -0
  88. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/scripts/gen_data.py +70 -0
  89. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/scripts/golden.py +34 -0
  90. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/scripts/test_torch.py +99 -0
  91. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/add_custom/scripts/verify_result.py +56 -0
  92. package/skills/tool-ops-tune/ops-family/references/elementwise/templates/usage_guide.md +61 -0
  93. package/skills/tool-ops-tune/ops-family/references/elementwise/vector_efficiency_design.md +203 -0
  94. package/skills/tool-ops-tune/ops-family/references/fa/fa_mixed_kernel_design.md +174 -0
  95. package/skills/tool-ops-tune/ops-family/references/fa/fa_roofline_design.md +141 -0
  96. package/skills/tool-ops-tune/ops-family/references/fa/guide.md +87 -0
  97. package/skills/tool-ops-tune/ops-family/references/knowledge_gaps.json +56 -0
  98. package/skills/tool-ops-tune/ops-family/references/matmul/best-practices-guide.md +14 -0
  99. package/skills/tool-ops-tune/ops-family/references/matmul/fullload_design.md +344 -0
  100. package/skills/tool-ops-tune/ops-family/references/matmul/guide.md +52 -0
  101. package/skills/tool-ops-tune/ops-family/references/matmul/mte2_preload_design.md +320 -0
  102. package/skills/tool-ops-tune/ops-family/references/matmul/pingpong_design.md +254 -0
  103. package/skills/tool-ops-tune/ops-family/references/matmul/scale_coalescing_design.md +282 -0
  104. package/skills/tool-ops-tune/ops-family/references/matmul/streamk_design.md +374 -0
  105. package/skills/tool-ops-tune/ops-family/references/matmul/swat_design.md +423 -0
  106. package/skills/tool-ops-tune/ops-family/references/matmul/templates/matmul_basic_blaze.template +165 -0
  107. package/skills/tool-ops-tune/ops-family/references/matmul/templates/usage_guide.md +29 -0
  108. package/skills/tool-ops-tune/ops-family/references/mc2/best-practices-guide.md +43 -0
  109. package/skills/tool-ops-tune/ops-family/references/mc2/guide.md +42 -0
  110. package/skills/tool-ops-tune/ops-family/references/mc2/local_matmul_design.md +130 -0
  111. package/skills/tool-ops-tune/ops-family/references/mc2/pipeline_balancing_design.md +502 -0
  112. package/skills/tool-ops-tune/ops-family/references/reduce/guide.md +178 -0
  113. package/skills/tool-ops-tune/ops-family/references/reduce/templates/dav310/kernel_utils.template +75 -0
  114. package/skills/tool-ops-tune/ops-family/references/reduce/templates/dav310/softmax_v2_ar_full_load.template +429 -0
  115. package/skills/tool-ops-tune/ops-family/references/reduce/templates/dav310/softmax_v2_ar_recompute.template +485 -0
  116. package/skills/tool-ops-tune/ops-family/references/reduce/templates/dav310/softmax_v2_ar_small_r.template +348 -0
  117. package/skills/tool-ops-tune/ops-family/references/reduce/templates/dav310/softmax_v2_ara_full_load.template +574 -0
  118. package/skills/tool-ops-tune/ops-family/references/reduce/templates/dav310/softmax_v2_ara_online.template +324 -0
  119. package/skills/tool-ops-tune/ops-family/references/reduce/templates/dav310/softmax_v2_ara_recompute.template +436 -0
  120. package/skills/tool-ops-tune/ops-family/references/reduce/templates/dav310/softmax_v2_base.template +950 -0
  121. package/skills/tool-ops-tune/ops-family/references/reduce/templates/fused_attention_online_softmax_design.md +428 -0
  122. package/skills/tool-ops-tune/ops-family/references/reduce/templates/softmax_v2_ar_full_load.md +137 -0
  123. package/skills/tool-ops-tune/ops-family/references/reduce/templates/softmax_v2_ar_recompute.md +135 -0
  124. package/skills/tool-ops-tune/ops-family/references/reduce/templates/softmax_v2_ar_small_r.md +122 -0
  125. package/skills/tool-ops-tune/ops-family/references/reduce/templates/softmax_v2_ara_full_load.md +144 -0
  126. package/skills/tool-ops-tune/ops-family/references/reduce/templates/softmax_v2_ara_online.md +185 -0
  127. package/skills/tool-ops-tune/ops-family/references/reduce/templates/softmax_v2_ara_recompute.md +163 -0
  128. package/skills/tool-ops-tune/ops-family/references/reduce/templates/softmax_v2_tiling.template +460 -0
  129. package/skills/tool-ops-tune/ops-family/references/reduce/templates/softmax_v2_tiling_data.template +278 -0
  130. package/skills/tool-ops-tune/ops-family/references/reduce/templates/state_resident_design.md +337 -0
  131. package/skills/tool-ops-tune/ops-family/references/reduce/templates/usage_guide.md +253 -0
  132. package/skills/tool-ops-tune/ops-family/references/scalar/coding_principles.md +476 -0
  133. package/skills/tool-ops-tune/ops-family/references/scalar/conv_scalar.md +163 -0
  134. package/skills/tool-ops-tune/ops-family/references/scalar/guide.md +30 -0
  135. package/skills/tool-ops-tune/ops-family/references/simt/guide.md +91 -0
  136. package/skills/tool-ops-tune/ops-family/references/simt/optimization-guide.md +110 -0
  137. package/skills/tool-ops-tune/ops-family/references/sort/guide.md +83 -0
  138. package/skills/tool-ops-tune/ops-family/references/sort/radix_sort.md +354 -0
  139. package/skills/tool-ops-tune/ops-family/scripts/family_asset_audit.py +68 -0
  140. package/skills/tool-ops-tune/ops-family/scripts/tiling_candidates.py +419 -0
  141. package/skills/tool-ops-tune/ops-mechanism/SKILL.md +23 -0
  142. package/skills/tool-ops-tune/ops-mechanism/cases/ascendc/case_groupedmatmul_pipeline.md +23 -0
  143. package/skills/tool-ops-tune/ops-mechanism/cases/ascendc/case_triton_atomic_revert.md +19 -0
  144. package/skills/tool-ops-tune/ops-mechanism/cases/mc2/case_mc2_fusion.md +19 -0
  145. package/skills/tool-ops-tune/ops-mechanism/references/optimize/api-usage.md +70 -0
  146. package/skills/tool-ops-tune/ops-mechanism/references/optimize/ascendc-regbase-vf.md +45 -0
  147. package/skills/tool-ops-tune/ops-mechanism/references/optimize/ascendc-tiling.md +51 -0
  148. package/skills/tool-ops-tune/ops-mechanism/references/optimize/data-copy.md +67 -0
  149. package/skills/tool-ops-tune/ops-mechanism/references/optimize/index.md +45 -0
  150. package/skills/tool-ops-tune/ops-mechanism/references/optimize/mc2-balancing.md +77 -0
  151. package/skills/tool-ops-tune/ops-mechanism/references/optimize/mc2.md +103 -0
  152. package/skills/tool-ops-tune/ops-mechanism/references/optimize/memory-hierarchy.md +40 -0
  153. package/skills/tool-ops-tune/ops-mechanism/references/optimize/pipeline.md +95 -0
  154. package/skills/tool-ops-tune/ops-mechanism/scripts/case_backfill.py +170 -0
  155. package/skills/tool-ops-tune/ops-mechanism/scripts/log_gap.py +145 -0
  156. package/skills/tool-ops-tune/ops-mechanism/scripts/mc2_search.py +367 -0
  157. package/skills/tool-ops-tune/ops-report/SKILL.md +77 -0
  158. package/skills/tool-ops-tune/ops-verdict/evals/run_evals.py +837 -0
  159. package/skills/tool-ops-tune/ops-verdict/evals/smoke/install-hooks.sh +65 -0
  160. package/skills/tool-ops-tune/ops-verdict/evals/smoke/run_smoke.sh +405 -0
  161. package/skills/tool-ops-tune/ops-verdict/fixtures/core_tail_a5.csv +25 -0
  162. package/skills/tool-ops-tune/ops-verdict/fixtures/few_cores_a5.csv +5 -0
  163. package/skills/tool-ops-tune/ops-verdict/fixtures/mte2_bound_a2.csv +17 -0
  164. package/skills/tool-ops-tune/ops-verdict/fixtures/multi_kernel_mix_a5.csv +7 -0
  165. package/skills/tool-ops-tune/ops-verdict/fixtures/no_bound_a5.csv +9 -0
  166. package/skills/tool-ops-tune/ops-verdict/fixtures/serial_no_overlap_a2.csv +9 -0
  167. package/skills/tool-ops-tune/ops-verdict/fixtures/vec_bound_a5.csv +9 -0
  168. package/skills/tool-ops-tune/ops-verdict/references/io-contracts.md +94 -0
  169. package/skills/tool-ops-tune/ops-verdict/references/rule-schema.md +130 -0
  170. package/skills/tool-ops-tune/ops-verdict/references/scope-schema.md +61 -0
  171. package/skills/tool-ops-tune/ops-verdict/references/soc-spec.yaml +140 -0
  172. package/skills/tool-ops-tune/ops-verdict/rules/L0-instruction.yaml +67 -0
  173. package/skills/tool-ops-tune/ops-verdict/rules/L1-single-core.yaml +316 -0
  174. package/skills/tool-ops-tune/ops-verdict/rules/L2-inter-core.yaml +173 -0
  175. package/skills/tool-ops-tune/ops-verdict/rules/L3-inter-card.yaml +156 -0
  176. package/skills/tool-ops-tune/ops-verdict/scripts/batch_pipeline.py +444 -0
  177. package/skills/tool-ops-tune/ops-verdict/scripts/calibrate.py +249 -0
  178. package/skills/tool-ops-tune/ops-verdict/scripts/delta_compare.py +244 -0
  179. package/skills/tool-ops-tune/ops-verdict/scripts/render_html.py +274 -0
  180. package/skills/tool-ops-tune/ops-verdict/scripts/snapshot.py +200 -0
  181. package/skills/tool-ops-tune/ops-verdict/scripts/trace_bubble.py +331 -0
  182. package/skills/tool-ops-tune/ops-verdict/scripts/verdict.py +1072 -0
  183. package/skills/tool-ops-tune/scripts/diff_audit.py +281 -0
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3
+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4
+ * CANN Open Software License Agreement Version 2.0 (the "License").
5
+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6
+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7
+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8
+ * See LICENSE in the root of the software repository for the full text of the License.
9
+ */
10
+
11
+ /*!
12
+ * \file transpose_tensor_move.h
13
+ * \brief transpose_tensor_move
14
+ */
15
+ #ifndef TRANSPOSE_TENSOR_MOVE_H
16
+ #define TRANSPOSE_TENSOR_MOVE_H
17
+
18
+ #include "transpose_base.h"
19
+
20
+ namespace Transpose {
21
+ using namespace AscendC;
22
+
23
+ template <typename T>
24
+ class TransposeTensorMove : public TransposeBase<T> {
25
+ public:
26
+ __aicore__ inline TransposeTensorMove(){};
27
+ __aicore__ inline void Init(GM_ADDR x, GM_ADDR y, const TransposeOpTilingData* tilingData, TPipe* pipe);
28
+ __aicore__ inline void Process();
29
+
30
+ private:
31
+ __aicore__ inline void ProcessPerCore();
32
+
33
+ private:
34
+ int64_t blockIdx_;
35
+
36
+ // buffer
37
+ TQueBind<QuePosition::VECIN, QuePosition::VECOUT, 1> vecQue_;
38
+ GlobalTensor<T> inputGM_;
39
+ GlobalTensor<T> outputGM_;
40
+
41
+ // tiling params
42
+ const TransposeOpTilingData* tiling_;
43
+ int64_t inputTailFactor_ = 0;
44
+ int64_t blockLoopNum_ = 0;
45
+ int64_t inLoopNum_ = 0;
46
+ int64_t srcOffset_ = 0;
47
+
48
+ // Datacopy params
49
+ DataCopyPadExtParams<T> padParams_{false, 0, 0, 0};
50
+ DataCopyExtParams copyOutParamsMain_{1, 0, 0, 0, 0};
51
+ };
52
+
53
+ template <typename T>
54
+ __aicore__ inline void TransposeTensorMove<T>::Init(GM_ADDR x, GM_ADDR y, const TransposeOpTilingData* tilingData,
55
+ TPipe* pipe)
56
+ {
57
+ blockIdx_ = GetBlockIdx();
58
+ tiling_ = tilingData;
59
+ inputGM_.SetGlobalBuffer((__gm__ T*)x);
60
+ outputGM_.SetGlobalBuffer((__gm__ T*)y);
61
+ pipe->InitBuffer(vecQue_, BUFFER_NUM, tiling_->ubSize / BUFFER_NUM);
62
+ }
63
+
64
+ template <typename T>
65
+ __aicore__ inline void TransposeTensorMove<T>::Process()
66
+ {
67
+ if (blockIdx_ >= tiling_->realCoreNum) {
68
+ return;
69
+ }
70
+ blockLoopNum_ = tiling_->blkFactor;
71
+ srcOffset_ = blockIdx_ * tiling_->blkFactor;
72
+ if (blockIdx_ < tiling_->blkTailFactor) {
73
+ blockLoopNum_ += 1;
74
+ srcOffset_ += blockIdx_;
75
+ } else {
76
+ srcOffset_ += tiling_->blkTailFactor;
77
+ }
78
+ inLoopNum_ = Ops::Base::CeilDiv(blockLoopNum_, tiling_->inUbFactor);
79
+ inputTailFactor_ = blockLoopNum_ % tiling_->inUbFactor;
80
+ ProcessPerCore();
81
+ }
82
+
83
+ template <typename T>
84
+ __aicore__ inline void TransposeTensorMove<T>::ProcessPerCore()
85
+ {
86
+ int64_t copyNum = tiling_->inUbFactor;
87
+ for (int64_t loopIdx = 0; loopIdx < inLoopNum_; loopIdx++) {
88
+ if (loopIdx == inLoopNum_ - 1 && inputTailFactor_ != 0) {
89
+ copyNum = inputTailFactor_;
90
+ }
91
+ copyOutParamsMain_.blockLen = copyNum * sizeof(T);
92
+ LocalTensor<T> bindLocalIn = vecQue_.AllocTensor<T>();
93
+ DataCopyPad(bindLocalIn, inputGM_[srcOffset_ + loopIdx * tiling_->inUbFactor], copyOutParamsMain_, padParams_);
94
+ vecQue_.EnQue(bindLocalIn);
95
+ LocalTensor<T> bindLocalOut = vecQue_.DeQue<T>();
96
+ DataCopyPad(outputGM_[srcOffset_ + loopIdx * tiling_->inUbFactor], bindLocalOut, copyOutParamsMain_);
97
+ vecQue_.FreeTensor(bindLocalOut);
98
+ }
99
+ }
100
+ } // namespace Transpose
101
+
102
+ #endif // TRANSPOSE_TENSOR_MOVE_H
@@ -0,0 +1,480 @@
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 transpose_transdata_5hd.h
13
+ * \brief transpose_transdata_5hd
14
+ */
15
+
16
+ #ifndef KERNEL_TRANSPOSE_TRANSDATA_5HD_H_
17
+ #define KERNEL_TRANSPOSE_TRANSDATA_5HD_H_
18
+
19
+ #include <type_traits>
20
+ #include "op_kernel/platform_util.h"
21
+ #include "transpose_base.h"
22
+
23
+ namespace Transpose {
24
+ using namespace AscendC;
25
+ static constexpr int64_t TRANSELEM = 16;
26
+
27
+ template <typename T>
28
+ class KernelTransDataTo5HD {
29
+ public:
30
+ __aicore__ inline KernelTransDataTo5HD(){};
31
+ __aicore__ inline void Init(GM_ADDR x, GM_ADDR y, const TransposeVCONVTilingData* tilingData, TPipe* pipe);
32
+ __aicore__ inline void Process();
33
+
34
+ private:
35
+ __aicore__ inline void SetCopyInParams(uint32_t process);
36
+ __aicore__ inline void SetRCSplitCopyInParams(uint32_t process);
37
+ __aicore__ inline void SetRSplitCopyInParams(uint32_t process);
38
+ __aicore__ inline void SetCSplitCopyInParams(uint32_t process);
39
+ __aicore__ inline void BaseCopyIn(uint32_t process);
40
+ __aicore__ inline void SetBasePocessData(uint32_t process, bool rSplit, bool rcSplit);
41
+ __aicore__ inline void BaseProcess(uint32_t process, uint32_t r, uint32_t c, uint32_t rAlign, uint32_t cAlign);
42
+ __aicore__ inline void BaseCompute(uint32_t r, uint32_t c, uint32_t rAlign, uint32_t cAlign);
43
+ __aicore__ inline void ComputeRConv(int r, int c, int cAlign);
44
+ __aicore__ inline void ComputeCConv(int r, int c, int rAlign);
45
+ __aicore__ inline void SetCopyOutParams(uint32_t process);
46
+ __aicore__ inline void SetRCSplitCopyOutParams(uint32_t process);
47
+ __aicore__ inline void SetRSplitCopyOutParams(uint32_t process);
48
+ __aicore__ inline void SetCSplitCopyOutParams(uint32_t process);
49
+ __aicore__ inline void BaseCopyOut(uint32_t process);
50
+
51
+ private:
52
+ const TransposeVCONVTilingData* tiling_ = nullptr;
53
+ TQue<TPosition::VECIN, 1> inQueueSrc;
54
+ TQue<TPosition::VECOUT, 1> outQueueDst;
55
+ GlobalTensor<T> srcGlobal, dstGlobal;
56
+ int64_t fullCoreNum = 0;
57
+ int64_t blockIdx_ = 0;
58
+ uint64_t loopCount = 0;
59
+ int64_t copyInCoreOffset = 0;
60
+ int64_t copyOutCoreOffset = 0;
61
+ int64_t gmOffset = 0;
62
+ int64_t ubOffset = 0;
63
+ bool isRsplit = false;
64
+ bool isRCSplit = false;
65
+ DataCopyPadExtParams<T> padParams{false, 0, 0, 0};
66
+ DataCopyExtParams Params;
67
+ };
68
+
69
+ template <typename T>
70
+ __aicore__ inline void KernelTransDataTo5HD<T>::Init(GM_ADDR x, GM_ADDR y, const TransposeVCONVTilingData* tilingData,
71
+ TPipe* pipe)
72
+ {
73
+ tiling_ = tilingData;
74
+ blockIdx_ = GetBlockIdx();
75
+ srcGlobal.SetGlobalBuffer((__gm__ T*)x);
76
+ dstGlobal.SetGlobalBuffer((__gm__ T*)y);
77
+ fullCoreNum = tiling_->UsedCoreNum - 1;
78
+ loopCount = (blockIdx_ <= fullCoreNum - 1) ? tiling_->MainCoreLoopCount : tiling_->TailCoreLoopCount;
79
+ isRsplit = tiling_->IsRSplit;
80
+ isRCSplit = tiling_->IsRCSplit;
81
+ pipe->InitBuffer(inQueueSrc, BUFFER_NUM, tiling_->AvailableUbSize);
82
+ pipe->InitBuffer(outQueueDst, BUFFER_NUM, tiling_->AvailableUbSize);
83
+ }
84
+
85
+ template <typename T>
86
+ __aicore__ inline void KernelTransDataTo5HD<T>::ComputeRConv(int r, int c, int cAlign)
87
+ {
88
+ LocalTensor<T> srcLocal = inQueueSrc.DeQue<T>();
89
+ LocalTensor<T> dstLocal = outQueueDst.AllocTensor<T>();
90
+
91
+ TransDataTo5HDParams transDataParams;
92
+ transDataParams.dstHighHalf = false;
93
+ transDataParams.srcHighHalf = false;
94
+ transDataParams.repeatTimes = r / TRANSELEM;
95
+ transDataParams.dstRepStride = transDataParams.repeatTimes == 1 ? 0 : 1;
96
+ transDataParams.srcRepStride = transDataParams.repeatTimes == 1 ? 0 : cAlign * TRANSELEM;
97
+
98
+ // TransDataTo5HD times
99
+ for (int j = 0; j < cAlign; j++) {
100
+ LocalTensor<T> srcLocalList[16];
101
+ for (int i = 0; i < 16; i++) {
102
+ srcLocalList[i] = srcLocal[i * c + j * TRANSELEM];
103
+ }
104
+
105
+ LocalTensor<T> dstLocalList[16];
106
+ for (int i = 0; i < 16; i++) {
107
+ dstLocalList[i] = dstLocal[i * r + j * TRANSELEM * r];
108
+ }
109
+ TransDataTo5HD(dstLocalList, srcLocalList, transDataParams);
110
+ }
111
+ outQueueDst.EnQue<T>(dstLocal);
112
+ inQueueSrc.FreeTensor(srcLocal);
113
+ }
114
+
115
+ template <typename T>
116
+ __aicore__ inline void KernelTransDataTo5HD<T>::ComputeCConv(int r, int c, int rAlign)
117
+ {
118
+ LocalTensor<T> srcLocal = inQueueSrc.DeQue<T>();
119
+ LocalTensor<T> dstLocal = outQueueDst.AllocTensor<T>();
120
+
121
+ TransDataTo5HDParams transDataParams;
122
+ transDataParams.dstHighHalf = false;
123
+ transDataParams.srcHighHalf = false;
124
+ transDataParams.repeatTimes = c / TRANSELEM;
125
+ transDataParams.dstRepStride = transDataParams.repeatTimes == 1 ? 0 : rAlign * TRANSELEM;
126
+ transDataParams.srcRepStride = transDataParams.repeatTimes == 1 ? 0 : 1;
127
+
128
+ // TransDataTo5HD times
129
+ for (int j = 0; j < rAlign; j++) {
130
+ LocalTensor<T> srcLocalList[16];
131
+ for (int i = 0; i < 16; i++) {
132
+ srcLocalList[i] = srcLocal[i * c + j * TRANSELEM * c];
133
+ }
134
+
135
+ LocalTensor<T> dstLocalList[16];
136
+ for (int i = 0; i < 16; i++) {
137
+ dstLocalList[i] = dstLocal[i * r + j * TRANSELEM];
138
+ }
139
+ TransDataTo5HD(dstLocalList, srcLocalList, transDataParams);
140
+ }
141
+ outQueueDst.EnQue<T>(dstLocal);
142
+ inQueueSrc.FreeTensor(srcLocal);
143
+ }
144
+
145
+ template <typename T>
146
+ __aicore__ inline void KernelTransDataTo5HD<T>::Process()
147
+ {
148
+ if (blockIdx_ >= tiling_->UsedCoreNum) {
149
+ return;
150
+ }
151
+ if (blockIdx_ < fullCoreNum) {
152
+ for (int i = 0; i < loopCount; i++) {
153
+ if (i < loopCount - 1) {
154
+ SetBasePocessData(i, isRsplit, isRCSplit);
155
+ BaseProcess(i, tiling_->rUbSplitPara.MainCoreUbFactor, tiling_->cUbSplitPara.MainCoreUbFactor,
156
+ tiling_->rUbSplitPara.MainCoreUbAlignFactor, tiling_->cUbSplitPara.MainCoreUbAlignFactor);
157
+ } else {
158
+ SetBasePocessData(i, isRsplit, isRCSplit);
159
+ BaseProcess(i, tiling_->rUbSplitPara.MainCoreTailUbFactor, tiling_->cUbSplitPara.MainCoreTailUbFactor,
160
+ tiling_->rUbSplitPara.MainCoreTailUbAlignFactor,
161
+ tiling_->cUbSplitPara.MainCoreTailUbAlignFactor);
162
+ }
163
+ }
164
+ } else {
165
+ for (int i = 0; i < loopCount; i++) {
166
+ if (i < loopCount - 1) {
167
+ SetBasePocessData(i, isRsplit, isRCSplit);
168
+ BaseProcess(i, tiling_->rUbSplitPara.TailCoreUbFactor, tiling_->cUbSplitPara.TailCoreUbFactor,
169
+ tiling_->rUbSplitPara.TailCoreUbAlignFactor, tiling_->cUbSplitPara.TailCoreUbAlignFactor);
170
+ } else {
171
+ SetBasePocessData(i, isRsplit, isRCSplit);
172
+ BaseProcess(i, tiling_->rUbSplitPara.TailCoreTailUbFactor, tiling_->cUbSplitPara.TailCoreTailUbFactor,
173
+ tiling_->rUbSplitPara.TailCoreTailUbAlignFactor,
174
+ tiling_->cUbSplitPara.TailCoreTailUbAlignFactor);
175
+ }
176
+ }
177
+ }
178
+ }
179
+
180
+ template <typename T>
181
+ __aicore__ inline void KernelTransDataTo5HD<T>::SetBasePocessData(uint32_t process, bool rSplit, bool rcSplit)
182
+ {
183
+ if (rSplit) {
184
+ if (rcSplit) {
185
+ copyInCoreOffset = blockIdx_ * tiling_->CblkLen * tiling_->rSplitPara.BlockFactor;
186
+ gmOffset = process * tiling_->cUbSplitPara.MainCoreUbFactor;
187
+ copyOutCoreOffset = blockIdx_ * tiling_->rUbSplitPara.MainCoreUbFactor;
188
+ ubOffset = process * tiling_->RLen * tiling_->cUbSplitPara.MainCoreUbFactor;
189
+ } else {
190
+ copyInCoreOffset = blockIdx_ * tiling_->CblkLen * tiling_->rSplitPara.BlockFactor;
191
+ gmOffset = process * tiling_->rUbSplitPara.MainCoreUbFactor * tiling_->CblkLen;
192
+ copyOutCoreOffset = blockIdx_ * tiling_->rSplitPara.BlockFactor;
193
+ ubOffset = process * tiling_->rUbSplitPara.MainCoreUbFactor;
194
+ }
195
+ } else {
196
+ copyInCoreOffset = blockIdx_ * tiling_->cSplitPara.BlockFactor;
197
+ gmOffset = process * tiling_->cUbSplitPara.MainCoreUbFactor;
198
+ copyOutCoreOffset = blockIdx_ * tiling_->RLen * tiling_->cSplitPara.BlockFactor;
199
+ ubOffset = process * tiling_->RLen * tiling_->cUbSplitPara.MainCoreUbFactor;
200
+ }
201
+ }
202
+
203
+ template <typename T>
204
+ __aicore__ inline void KernelTransDataTo5HD<T>::BaseProcess(uint32_t process, uint32_t r, uint32_t c, uint32_t rAlign,
205
+ uint32_t cAlign)
206
+ {
207
+ BaseCopyIn(process);
208
+ BaseCompute(r, c, rAlign, cAlign);
209
+ BaseCopyOut(process);
210
+ }
211
+
212
+ template <typename T>
213
+ __aicore__ inline void KernelTransDataTo5HD<T>::BaseCopyIn(uint32_t process)
214
+ {
215
+ LocalTensor<T> srcLocal = inQueueSrc.AllocTensor<T>();
216
+ SetCopyInParams(process);
217
+ DataCopyPad(srcLocal, srcGlobal[gmOffset + copyInCoreOffset], Params, padParams);
218
+ inQueueSrc.EnQue(srcLocal);
219
+ }
220
+
221
+ template <typename T>
222
+ __aicore__ inline void KernelTransDataTo5HD<T>::BaseCompute(uint32_t r, uint32_t c, uint32_t rAlign, uint32_t cAlign)
223
+ {
224
+ if (r >= c) {
225
+ ComputeRConv(r, c, cAlign);
226
+ } else {
227
+ ComputeCConv(r, c, rAlign);
228
+ }
229
+ }
230
+
231
+ template <typename T>
232
+ __aicore__ inline void KernelTransDataTo5HD<T>::BaseCopyOut(uint32_t process)
233
+ {
234
+ LocalTensor<T> dstLocal = outQueueDst.DeQue<T>();
235
+ SetCopyOutParams(process);
236
+ DataCopyPad(dstGlobal[copyOutCoreOffset + ubOffset], dstLocal, Params);
237
+ outQueueDst.FreeTensor(dstLocal);
238
+ }
239
+
240
+ template <typename T>
241
+ __aicore__ inline void KernelTransDataTo5HD<T>::SetCopyInParams(uint32_t process)
242
+ {
243
+ if (isRCSplit) {
244
+ SetRCSplitCopyInParams(process);
245
+ } else if (isRsplit) {
246
+ SetRSplitCopyInParams(process);
247
+ } else {
248
+ SetCSplitCopyInParams(process);
249
+ }
250
+ }
251
+
252
+ template <typename T>
253
+ __aicore__ inline void KernelTransDataTo5HD<T>::SetRCSplitCopyInParams(uint32_t process)
254
+ {
255
+ if (blockIdx_ < fullCoreNum) {
256
+ if (process < loopCount - 1) {
257
+ Params.blockCount = tiling_->rUbSplitPara.MainCoreUbFactor;
258
+ Params.blockLen = tiling_->cUbSplitPara.MainCoreUbFactor * sizeof(T);
259
+ Params.srcStride = (tiling_->CblkLen - tiling_->cUbSplitPara.MainCoreUbFactor) * sizeof(T);
260
+ } else {
261
+ Params.blockCount = tiling_->rUbSplitPara.MainCoreTailUbFactor;
262
+ Params.blockLen = (tiling_->CblkLen - process * tiling_->cUbSplitPara.MainCoreUbFactor) * sizeof(T);
263
+ Params.srcStride = (process * tiling_->cUbSplitPara.MainCoreUbFactor) * sizeof(T);
264
+ }
265
+ } else {
266
+ if (process < loopCount - 1) {
267
+ Params.blockCount = tiling_->RLen - blockIdx_ * tiling_->rSplitPara.BlockFactor;
268
+ Params.blockLen = tiling_->cUbSplitPara.TailCoreUbFactor * sizeof(T);
269
+ Params.srcStride = (tiling_->CblkLen - tiling_->cUbSplitPara.TailCoreUbFactor) * sizeof(T);
270
+ } else {
271
+ Params.blockCount = tiling_->RLen - blockIdx_ * tiling_->rSplitPara.BlockFactor;
272
+ Params.blockLen = (tiling_->CblkLen - process * tiling_->cUbSplitPara.TailCoreUbFactor) * sizeof(T);
273
+ Params.srcStride = (process * tiling_->cUbSplitPara.TailCoreUbFactor) * sizeof(T);
274
+ }
275
+ }
276
+ Params.dstStride = 0;
277
+ }
278
+
279
+ template <typename T>
280
+ __aicore__ inline void KernelTransDataTo5HD<T>::SetRSplitCopyInParams(uint32_t process)
281
+ {
282
+ if (tiling_->CblkLen % TRANSELEM == 0) {
283
+ Params.blockCount = 1;
284
+ Params.srcStride = 0;
285
+ Params.dstStride = 0;
286
+ if (blockIdx_ < fullCoreNum) {
287
+ if (process < loopCount - 1) {
288
+ Params.blockLen = tiling_->rUbSplitPara.MainCoreUbFactor * tiling_->cUbSplitPara.MainCoreUbFactor *
289
+ sizeof(T);
290
+ } else {
291
+ Params.blockLen = tiling_->rUbSplitPara.MainCoreTailUbFactor *
292
+ tiling_->cUbSplitPara.MainCoreTailUbFactor * sizeof(T);
293
+ }
294
+ } else {
295
+ if (process < loopCount - 1) {
296
+ Params.blockLen = tiling_->rUbSplitPara.TailCoreUbFactor * tiling_->cUbSplitPara.TailCoreUbFactor *
297
+ sizeof(T);
298
+ } else {
299
+ Params.blockLen = (tiling_->RLen - (blockIdx_ * tiling_->rSplitPara.BlockFactor +
300
+ process * tiling_->rUbSplitPara.TailCoreUbFactor)) *
301
+ tiling_->cUbSplitPara.TailCoreTailUbFactor * sizeof(T);
302
+ }
303
+ }
304
+ } else {
305
+ if (blockIdx_ < fullCoreNum) {
306
+ if (process < loopCount - 1) {
307
+ Params.blockCount = tiling_->rUbSplitPara.MainCoreUbFactor;
308
+ } else {
309
+ Params.blockCount = tiling_->rUbSplitPara.MainCoreTailUbFactor;
310
+ }
311
+ } else {
312
+ if (process < loopCount - 1) {
313
+ Params.blockCount = tiling_->rUbSplitPara.TailCoreUbFactor;
314
+ } else {
315
+ Params.blockCount = tiling_->RLen - (blockIdx_ * tiling_->rSplitPara.BlockFactor +
316
+ process * tiling_->rUbSplitPara.TailCoreUbFactor);
317
+ }
318
+ }
319
+ Params.blockLen = tiling_->CblkLen * sizeof(T);
320
+ Params.srcStride = 0;
321
+ Params.dstStride = 0;
322
+ }
323
+ }
324
+
325
+ template <typename T>
326
+ __aicore__ inline void KernelTransDataTo5HD<T>::SetCSplitCopyInParams(uint32_t process)
327
+ {
328
+ if (blockIdx_ < fullCoreNum) {
329
+ if (process < loopCount - 1) {
330
+ Params.blockCount = tiling_->RLen;
331
+ Params.blockLen = tiling_->cUbSplitPara.MainCoreUbFactor * sizeof(T);
332
+ Params.srcStride = (tiling_->CblkLen - tiling_->cUbSplitPara.MainCoreUbFactor) * sizeof(T);
333
+ } else {
334
+ Params.blockCount = tiling_->RLen;
335
+ Params.blockLen = tiling_->cUbSplitPara.MainCoreTailUbFactor * sizeof(T);
336
+ Params.srcStride = (tiling_->CblkLen - tiling_->cUbSplitPara.MainCoreTailUbFactor) * sizeof(T);
337
+ }
338
+ } else {
339
+ if (process < loopCount - 1) {
340
+ Params.blockCount = tiling_->RLen;
341
+ Params.blockLen = tiling_->cUbSplitPara.TailCoreUbFactor * sizeof(T);
342
+ Params.srcStride = (tiling_->CblkLen - tiling_->cUbSplitPara.TailCoreUbFactor) * sizeof(T);
343
+ } else {
344
+ Params.blockCount = tiling_->RLen;
345
+ Params.blockLen = (tiling_->CblkLen - blockIdx_ * tiling_->cSplitPara.BlockFactor -
346
+ process * tiling_->cUbSplitPara.TailCoreUbFactor) *
347
+ sizeof(T);
348
+ Params.srcStride = (blockIdx_ * tiling_->cSplitPara.BlockFactor +
349
+ process * tiling_->cUbSplitPara.TailCoreUbFactor) *
350
+ sizeof(T);
351
+ }
352
+ }
353
+ Params.dstStride = 0;
354
+ }
355
+
356
+ template <typename T>
357
+ __aicore__ inline void KernelTransDataTo5HD<T>::SetCopyOutParams(uint32_t process)
358
+ {
359
+ if (isRCSplit) {
360
+ SetRCSplitCopyOutParams(process);
361
+ } else if (isRsplit) {
362
+ SetRSplitCopyOutParams(process);
363
+ } else {
364
+ SetCSplitCopyOutParams(process);
365
+ }
366
+ }
367
+
368
+ template <typename T>
369
+ __aicore__ inline void KernelTransDataTo5HD<T>::SetRCSplitCopyOutParams(uint32_t process)
370
+ {
371
+ if (blockIdx_ < fullCoreNum) {
372
+ if (process < loopCount - 1) {
373
+ Params.blockCount = tiling_->cUbSplitPara.MainCoreUbFactor;
374
+ Params.blockLen = tiling_->rUbSplitPara.MainCoreUbFactor * sizeof(T);
375
+ Params.srcStride = 0;
376
+ Params.dstStride = (tiling_->RLen - tiling_->rUbSplitPara.MainCoreUbFactor) * sizeof(T);
377
+ } else {
378
+ Params.blockCount = (tiling_->CblkLen - process * tiling_->cUbSplitPara.MainCoreUbFactor);
379
+ Params.blockLen = tiling_->rUbSplitPara.MainCoreTailUbFactor * sizeof(T);
380
+ Params.srcStride = 0;
381
+ Params.dstStride = (tiling_->RLen - tiling_->rUbSplitPara.MainCoreTailUbFactor) * sizeof(T);
382
+ }
383
+ } else {
384
+ if (process < loopCount - 1) {
385
+ Params.blockCount = tiling_->cUbSplitPara.TailCoreUbFactor;
386
+ Params.blockLen = (tiling_->RLen - blockIdx_ * tiling_->rSplitPara.BlockFactor) * sizeof(T);
387
+ Params.srcStride = 0;
388
+ Params.dstStride = (blockIdx_ * tiling_->rSplitPara.BlockFactor) * sizeof(T);
389
+ } else {
390
+ Params.blockCount = (tiling_->CblkLen - process * tiling_->cUbSplitPara.TailCoreUbFactor);
391
+ Params.blockLen = (tiling_->RLen - blockIdx_ * tiling_->rSplitPara.BlockFactor) * sizeof(T);
392
+ Params.srcStride = 0;
393
+ Params.dstStride = (blockIdx_ * tiling_->rSplitPara.BlockFactor) * sizeof(T);
394
+ }
395
+ }
396
+ }
397
+
398
+ template <typename T>
399
+ __aicore__ inline void KernelTransDataTo5HD<T>::SetRSplitCopyOutParams(uint32_t process)
400
+ {
401
+ if (blockIdx_ < fullCoreNum) {
402
+ if (process < loopCount - 1) {
403
+ Params.blockCount = tiling_->CblkLen;
404
+ Params.blockLen = tiling_->rUbSplitPara.MainCoreUbFactor * sizeof(T);
405
+ Params.srcStride = 0;
406
+ Params.dstStride = (tiling_->RLen - tiling_->rUbSplitPara.MainCoreUbFactor) * sizeof(T);
407
+ } else {
408
+ Params.blockCount = tiling_->CblkLen;
409
+ Params.blockLen = tiling_->rUbSplitPara.MainCoreTailUbFactor * sizeof(T);
410
+ Params.srcStride = 0;
411
+ Params.dstStride = (tiling_->RLen - tiling_->rUbSplitPara.MainCoreTailUbFactor) * sizeof(T);
412
+ }
413
+ } else {
414
+ if (process < loopCount - 1) {
415
+ Params.blockCount = tiling_->CblkLen;
416
+ Params.blockLen = tiling_->rUbSplitPara.TailCoreUbFactor * sizeof(T);
417
+ Params.srcStride = 0;
418
+ Params.dstStride = (tiling_->RLen - tiling_->rUbSplitPara.TailCoreUbFactor) * sizeof(T);
419
+ } else {
420
+ Params.blockCount = tiling_->CblkLen;
421
+ Params.blockLen = (tiling_->RLen - blockIdx_ * tiling_->rSplitPara.BlockFactor -
422
+ process * tiling_->rUbSplitPara.TailCoreUbFactor) *
423
+ sizeof(T);
424
+ Params.srcStride = 0;
425
+ Params.dstStride = (blockIdx_ * tiling_->rSplitPara.BlockFactor +
426
+ process * tiling_->rUbSplitPara.TailCoreUbFactor) *
427
+ sizeof(T);
428
+ }
429
+ }
430
+ }
431
+
432
+ template <typename T>
433
+ __aicore__ inline void KernelTransDataTo5HD<T>::SetCSplitCopyOutParams(uint32_t process)
434
+ {
435
+ if (blockIdx_ < fullCoreNum) {
436
+ if (process < loopCount - 1) {
437
+ Params.blockCount = (tiling_->RLen % TRANSELEM == 0) ? 1 : tiling_->cUbSplitPara.MainCoreUbFactor;
438
+ Params.blockLen = (tiling_->RLen % TRANSELEM == 0) ?
439
+ tiling_->rUbSplitPara.MainCoreUbFactor * tiling_->cUbSplitPara.MainCoreUbFactor *
440
+ sizeof(T) :
441
+ tiling_->RLen * sizeof(T);
442
+ Params.srcStride = 0;
443
+ Params.dstStride = 0;
444
+ } else {
445
+ Params.blockCount = (tiling_->RLen % TRANSELEM == 0) ? 1 : tiling_->cUbSplitPara.MainCoreTailUbFactor;
446
+ Params.blockLen = (tiling_->RLen % TRANSELEM == 0) ?
447
+ tiling_->rUbSplitPara.MainCoreTailUbFactor *
448
+ tiling_->cUbSplitPara.MainCoreTailUbFactor * sizeof(T) :
449
+ tiling_->RLen * sizeof(T);
450
+ Params.srcStride = 0;
451
+ Params.dstStride = 0;
452
+ }
453
+ } else {
454
+ if (process < loopCount - 1) {
455
+ Params.blockCount = (tiling_->RLen % TRANSELEM == 0) ? 1 : tiling_->cUbSplitPara.TailCoreUbFactor;
456
+ Params.blockLen = (tiling_->RLen % TRANSELEM == 0) ?
457
+ tiling_->rUbSplitPara.TailCoreUbFactor * tiling_->cUbSplitPara.TailCoreUbFactor *
458
+ sizeof(T) :
459
+ tiling_->RLen * sizeof(T);
460
+ Params.srcStride = 0;
461
+ Params.dstStride = 0;
462
+ } else {
463
+ Params.blockCount = (tiling_->RLen % TRANSELEM == 0) ?
464
+ 1 :
465
+ (tiling_->CblkLen - blockIdx_ * tiling_->cSplitPara.BlockFactor -
466
+ process * tiling_->cUbSplitPara.TailCoreUbFactor);
467
+ Params.blockLen = (tiling_->RLen % TRANSELEM == 0) ?
468
+ tiling_->rUbSplitPara.TailCoreTailUbFactor *
469
+ (tiling_->CblkLen - blockIdx_ * tiling_->cSplitPara.BlockFactor -
470
+ process * tiling_->cUbSplitPara.TailCoreUbFactor) *
471
+ sizeof(T) :
472
+ tiling_->RLen * sizeof(T);
473
+ Params.srcStride = 0;
474
+ Params.dstStride = 0;
475
+ }
476
+ }
477
+ }
478
+
479
+ } // namespace Transpose
480
+ #endif