@cannbot-plugin/cannbot-harness 0.0.0-stage → 0.1.5

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 (1291) hide show
  1. package/README.md +105 -3
  2. package/THIRD_PARTY_NOTICES.md +11 -0
  3. package/assets/ops-direct-invoke/.cannbot-bundle +1 -0
  4. package/assets/ops-direct-invoke/.claude-plugin/plugin.json +21 -0
  5. package/assets/ops-direct-invoke/.codex-plugin/plugin.json +30 -0
  6. package/assets/ops-direct-invoke/AGENTS.md +93 -0
  7. package/assets/ops-direct-invoke/LICENSE +38 -0
  8. package/assets/ops-direct-invoke/QUICKSTART.md +44 -0
  9. package/assets/ops-direct-invoke/README.md +219 -0
  10. package/assets/ops-direct-invoke/SKILLS_LICENSE +38 -0
  11. package/assets/ops-direct-invoke/agents/ops-direct-invoke-architect.md +39 -0
  12. package/assets/ops-direct-invoke/agents/ops-direct-invoke-developer.md +39 -0
  13. package/assets/ops-direct-invoke/agents/ops-direct-invoke-verifier.md +38 -0
  14. package/assets/ops-direct-invoke/init.sh +8 -0
  15. package/assets/ops-direct-invoke/plugin-install.json +24 -0
  16. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/SKILL.md +88 -0
  17. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/evals/evals.json +207 -0
  18. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-arithmetic.md +399 -0
  19. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-atomic.md +192 -0
  20. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-buffer.md +364 -0
  21. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-cross-gen-fixpipe.md +28 -0
  22. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-cross-gen-migration.md +91 -0
  23. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-crosscore-sync.md +259 -0
  24. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-datacopy.md +405 -0
  25. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-gathermask.md +243 -0
  26. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-gmm.md +260 -0
  27. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-hccl-host.md +187 -0
  28. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-hcomm.md +229 -0
  29. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-host-runtime.md +129 -0
  30. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-loaddata.md +196 -0
  31. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-matmul.md +364 -0
  32. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-mrgsort.md +636 -0
  33. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-pipeline.md +206 -0
  34. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-precision.md +146 -0
  35. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-quickref.md +192 -0
  36. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-reduce-pattern.md +132 -0
  37. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-reduce.md +282 -0
  38. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-repeat-limits.md +144 -0
  39. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-restrictions.md +200 -0
  40. package/assets/ops-direct-invoke/skills/ascendc-api-best-practices/references/api-transpose.md +234 -0
  41. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/SKILL.md +245 -0
  42. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/block/block_mmad_glu.h +238 -0
  43. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/block/block_scheduler_group_matmul.h +106 -0
  44. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/block/weight_quant_matmul_block_mmad.h +362 -0
  45. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/block_epilogue_dequant_swiglu.h +265 -0
  46. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/block_epilogue_pertoken_quant_single_pass.h +252 -0
  47. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/block_epilogue_pertoken_quant_two_pass_chunked.h +313 -0
  48. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/block_epilogue_swiglu.h +171 -0
  49. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/cv_sync_constants.h +32 -0
  50. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/epilogue_fusion_membase.h +212 -0
  51. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/epilogue_fusion_regbase.h +324 -0
  52. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/online_softmax_cross_core_epilogue.h +396 -0
  53. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/epilogue/online_softmax_per_tile_epilogue.h +421 -0
  54. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/kernel/group_matmul_kernel_cv1_v2.h +150 -0
  55. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/kernel/group_matmul_kernel_glu_fused.h +345 -0
  56. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/kernel/weight_quant_matmul_kernel.h +611 -0
  57. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/policy/dispatch_policy.h +63 -0
  58. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/utils/common_utils.h +101 -0
  59. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/blaze_custom/utils/integral_constant.h +38 -0
  60. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/matmul/blaze_group_matmul_pertoken_quant_selector.h +119 -0
  61. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/matmul/blaze_group_matmul_tiling_data.h +38 -0
  62. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/matmul/blaze_matmul_tiling.h +457 -0
  63. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/matmul/blaze_matmul_tiling_data.h +50 -0
  64. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/mx/quant_matmul_mx_tiling.h +549 -0
  65. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/mx/quant_matmul_mx_tiling_data.h +47 -0
  66. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/weight_quant/weight_quant_tiling.h +428 -0
  67. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/assets/op_tiling/weight_quant/weight_quant_tiling_data.h +59 -0
  68. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/evals/evals.json +234 -0
  69. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/assembly-recovery-method.md +106 -0
  70. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/dependency-trace-method.md +140 -0
  71. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/design-contract-method.md +78 -0
  72. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/investigation-report-template.md +249 -0
  73. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/blaze-investigation/source-investigation-method.md +131 -0
  74. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/blaze-cmake-build-guide.md +184 -0
  75. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/blaze-framework-overview.md +403 -0
  76. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/blaze-matmul-layout.md +322 -0
  77. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/blaze-sync-patterns.md +814 -0
  78. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/fundamentals/tensor-api-reference.md +589 -0
  79. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/blaze-design-template.md +593 -0
  80. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/blaze-plan-template.md +391 -0
  81. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/glu-development.md +755 -0
  82. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/glu-precision-diagnosis.md +113 -0
  83. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/group-matmul-delta.md +299 -0
  84. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/per-token-quant-development.md +450 -0
  85. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/kernel-design/tiling-selection.md +114 -0
  86. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/launcher/launcher-development.md +346 -0
  87. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-elementwise-then-vector-pertoken-quant/cube-matmul-then-vector-elementwise-then-vector-pertoken-quant-design.md +196 -0
  88. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-elementwise-then-vector-pertoken-quant/cube-matmul-then-vector-elementwise-then-vector-pertoken-quant-development.md +104 -0
  89. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-glu/cube-matmul-then-vector-glu-design.md +150 -0
  90. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-glu/cube-matmul-then-vector-glu-development.md +54 -0
  91. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-glu-then-vector-pertoken-quant/cube-matmul-then-vector-glu-then-vector-pertoken-quant-design.md +189 -0
  92. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-glu-then-vector-pertoken-quant/cube-matmul-then-vector-glu-then-vector-pertoken-quant-development.md +52 -0
  93. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-pertoken-quant/cube-matmul-then-vector-pertoken-quant-design.md +138 -0
  94. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-pertoken-quant/cube-matmul-then-vector-pertoken-quant-development.md +45 -0
  95. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/cube-matmul-then-vector-softmax-reduce-design.md +205 -0
  96. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/cube-matmul-then-vector-softmax-reduce-development.md +99 -0
  97. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/cv-sync-and-two-phase-entry.md +156 -0
  98. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/cv1-v2-adaptation-for-softmax-reduce.md +331 -0
  99. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/online-softmax-reduce-epilogue-design.md +174 -0
  100. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/cube-matmul-then-vector-softmax-reduce/reduce-adaptation-guide.md +204 -0
  101. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/block-l0c2ub-extension.md +75 -0
  102. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/elementwise-broadcast-epilogue-fusion-design.md +280 -0
  103. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/elementwise-broadcast-epilogue-fusion-development.md +202 -0
  104. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/epilogue-membase-design.md +82 -0
  105. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/epilogue-regbase-design.md +95 -0
  106. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/fused-kernel-development.md +71 -0
  107. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/precision-diagnosis.md +86 -0
  108. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/elementwise-broadcast-epilogue-fusion/splitm-contract-and-debugging.md +86 -0
  109. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/index.md +14 -0
  110. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/scenario-extension-guide.md +84 -0
  111. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/layout-variant-boundary.md +76 -0
  112. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/pitfalls-and-diagnosis.md +124 -0
  113. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/prologue-ub-layout-design.md +135 -0
  114. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/prologue-vf-dequant-design.md +213 -0
  115. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/vc-sync-and-l1-layout-design.md +103 -0
  116. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/weight-dequant-prologue-fusion-design.md +289 -0
  117. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/weight-dequant-prologue-fusion-development.md +232 -0
  118. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/scenarios/weight-dequant-prologue-fusion/weight-quant-tiling-contract.md +83 -0
  119. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/troubleshooting/compile-troubleshooting.md +231 -0
  120. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/troubleshooting/optimized-runtime-hang.md +102 -0
  121. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/workflow/step1-project-setup.md +170 -0
  122. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/workflow/step2-blaze-investigation.md +192 -0
  123. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/workflow/step3-kernel-design.md +246 -0
  124. package/assets/ops-direct-invoke/skills/ascendc-blaze-best-practice/references/workflow/step4-operator-development.md +166 -0
  125. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/SKILL.md +67 -0
  126. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/evals/evals.json +123 -0
  127. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/references/crash_workflow.md +193 -0
  128. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/references/memcheck/README.md +137 -0
  129. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/references/memcheck/automated_workflow.md +418 -0
  130. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/references/memcheck/mssanitizer_guide.md +181 -0
  131. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/scripts/memcheck_input.json.template +44 -0
  132. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/scripts/parse_plog.py +191 -0
  133. package/assets/ops-direct-invoke/skills/ascendc-crash-debug/scripts/run_memcheck_pre.sh +696 -0
  134. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/SKILL.md +105 -0
  135. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/evals/evals.json +128 -0
  136. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/CMakeLists.txt +131 -0
  137. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/README.md +55 -0
  138. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_extension/add_custom_torch.cpp +82 -0
  139. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_extension/ops.h +23 -0
  140. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_extension/register.cpp +42 -0
  141. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_host/add_custom.asc +149 -0
  142. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_host/data_utils.h +98 -0
  143. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_kernel/add_custom_kernel.asc +136 -0
  144. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/op_kernel/add_custom_tiling.h +31 -0
  145. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/run.sh +86 -0
  146. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/scripts/gen_data.py +49 -0
  147. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/scripts/golden.py +36 -0
  148. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/scripts/test_torch.py +90 -0
  149. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/add_custom/scripts/verify_result.py +54 -0
  150. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kernel_launch_details.md +116 -0
  151. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/CMakeLists.txt +19 -0
  152. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/README.md +214 -0
  153. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/UPSTREAM.md +35 -0
  154. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/add_custom.cpp +99 -0
  155. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/add_custom_tiling.h +25 -0
  156. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/Modules/CMakeCCECompiler.cmake.in +15 -0
  157. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/Modules/CMakeCCEInformation.cmake +51 -0
  158. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/Modules/CMakeDetermineCCECompiler.cmake +119 -0
  159. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/Modules/CMakeTestCCECompiler.cmake +11 -0
  160. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/cmake/npu/CMakeLists.txt +36 -0
  161. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/data_utils.h +132 -0
  162. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/ext_lib/.gitattributes +1 -0
  163. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/input/.keep +0 -0
  164. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/main.cpp +108 -0
  165. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/output/.keep +0 -0
  166. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/run.sh +141 -0
  167. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/scripts/acl.json +1 -0
  168. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/scripts/gen_data.py +26 -0
  169. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_add_template/scripts/verify_result.py +54 -0
  170. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/kirin_vector_guide.md +172 -0
  171. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_guide.md +348 -0
  172. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/CMakeLists.txt +157 -0
  173. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/common/acl_utils.h +70 -0
  174. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/common/common_utils.h +84 -0
  175. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/common/io_utils.h +163 -0
  176. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_extension/matmul_blaze_torch.cpp +55 -0
  177. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_extension/ops.h +22 -0
  178. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_extension/register.cpp +22 -0
  179. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_kernel/include/blaze_custom/.gitkeep +0 -0
  180. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_kernel/matmul_blaze_kernel.cpp +33 -0
  181. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_kernel/matmul_blaze_kernel.h +99 -0
  182. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_tiling/matmul_constant.h +31 -0
  183. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_tiling/matmul_tiling_data.h +45 -0
  184. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/op_tiling/matmul_tiling_stub.h +77 -0
  185. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/run.sh +94 -0
  186. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/scripts/gen_data_mxfp4.py +152 -0
  187. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/scripts/gen_data_mxfp8.py +114 -0
  188. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/scripts/verify_result.py +132 -0
  189. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/test_matmul_blaze.cpp +145 -0
  190. package/assets/ops-direct-invoke/skills/ascendc-direct-invoke-template/references/matmul_blaze_template/test_matmul_blaze_torch.py +141 -0
  191. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/SKILL.md +56 -0
  192. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/evals/evals.json +191 -0
  193. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/aclnn-api-doc-template.md +368 -0
  194. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/detailed-design-template.md +388 -0
  195. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/iteration-plan-template.md +45 -0
  196. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/operator-readme-template.md +234 -0
  197. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/operator-readme-template_bak.md +165 -0
  198. package/assets/ops-direct-invoke/skills/ascendc-docs-gen/references/requirement-analysis-template.md +131 -0
  199. package/assets/ops-direct-invoke/skills/ascendc-docs-search/SKILL.md +163 -0
  200. package/assets/ops-direct-invoke/skills/ascendc-docs-search/evals/evals.json +197 -0
  201. package/assets/ops-direct-invoke/skills/ascendc-docs-search/references/api-index.md +207 -0
  202. package/assets/ops-direct-invoke/skills/ascendc-docs-search/references/compatibility.md +141 -0
  203. package/assets/ops-direct-invoke/skills/ascendc-docs-search/references/example-catalog.md +197 -0
  204. package/assets/ops-direct-invoke/skills/ascendc-docs-search/requirements.txt +2 -0
  205. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/__init__.py +6 -0
  206. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/ascend_content_fetcher.py +479 -0
  207. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/ascend_search_client.py +201 -0
  208. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/ascend_search_skill.py +163 -0
  209. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/clean_markdown.py +489 -0
  210. package/assets/ops-direct-invoke/skills/ascendc-docs-search/scripts/find_api_doc.sh +54 -0
  211. package/assets/ops-direct-invoke/skills/ascendc-env-check/SKILL.md +123 -0
  212. package/assets/ops-direct-invoke/skills/ascendc-env-check/evals/evals.json +211 -0
  213. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/asys_commands.md +64 -0
  214. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/env_config_guide.md +96 -0
  215. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/kirin_platform_guide.md +11 -0
  216. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/npu_commands.md +114 -0
  217. package/assets/ops-direct-invoke/skills/ascendc-env-check/references/troubleshooting.md +177 -0
  218. package/assets/ops-direct-invoke/skills/ascendc-env-check/scripts/_npu_info.py +763 -0
  219. package/assets/ops-direct-invoke/skills/ascendc-env-check/scripts/check_env.sh +320 -0
  220. package/assets/ops-direct-invoke/skills/ascendc-env-check/scripts/get_npu_arch.py +488 -0
  221. package/assets/ops-direct-invoke/skills/ascendc-env-check/scripts/npu_info.sh +228 -0
  222. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/SKILL.md +370 -0
  223. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/docs/CONTEXT.md +85 -0
  224. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/docs/MC2-CAPABILITY-PLAN.md +111 -0
  225. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/docs/adr/0001-mc2-skill-not-plugin.md +31 -0
  226. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/docs/adr/0002-decision-stack-path-registry.md +33 -0
  227. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/evals/evals.json +315 -0
  228. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/capability-declaration.md +97 -0
  229. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/codebase-analysis.md +34 -0
  230. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/fundamentals/architecture.md +444 -0
  231. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/fundamentals/communication.md +669 -0
  232. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/fundamentals/compute.md +587 -0
  233. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/fundamentals/fusion.md +550 -0
  234. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/design-template.md +313 -0
  235. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/dev-methodology.md +111 -0
  236. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/development-guide.md +445 -0
  237. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/host-and-testing.md +285 -0
  238. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/operator-anatomy.md +739 -0
  239. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/paradigm-mapping.md +93 -0
  240. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/operator-design/plan-template.md +235 -0
  241. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/review-checklist.md +96 -0
  242. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/compute-first-reduce-scatter/design.md +107 -0
  243. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/compute-first-reduce-scatter/development.md +272 -0
  244. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/get-all-gather-quant-matmul/design.md +93 -0
  245. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/get-all-gather-quant-matmul/development.md +70 -0
  246. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/index.md +47 -0
  247. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/put-all-gather-quant-matmul/design.md +83 -0
  248. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/put-all-gather-quant-matmul/development.md +62 -0
  249. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/put-all-to-all-quant-matmul/design.md +106 -0
  250. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/scenarios/put-all-to-all-quant-matmul/development.md +74 -0
  251. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/troubleshooting/failure-navigation.md +47 -0
  252. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/troubleshooting/optimization-playbook.md +143 -0
  253. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow/step1-project-setup.md +52 -0
  254. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow/step2-investigation.md +89 -0
  255. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow/step3-design.md +69 -0
  256. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow/step4-implementation.md +29 -0
  257. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/apace/workflow_integration.md +122 -0
  258. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/api-rules/dispatch-combine-contracts.md +60 -0
  259. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/api-rules/index.md +71 -0
  260. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/api-rules/mte-address-access.md +374 -0
  261. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/api-rules/sync-and-visibility.md +105 -0
  262. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/combine-reading-guide.md +102 -0
  263. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/common-reading-method.md +226 -0
  264. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/design-overview.md +558 -0
  265. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/dispatch-reading-guide.md +81 -0
  266. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/kernel-execution-units.md +189 -0
  267. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/reading/mega-moe-reading-guide.md +123 -0
  268. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/build-framework.md +177 -0
  269. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/change-routing.md +18 -0
  270. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/combine-dataflow.md +144 -0
  271. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/dispatch-dataflow.md +128 -0
  272. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/index.md +98 -0
  273. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/CMakeLists.txt +51 -0
  274. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/README.md +131 -0
  275. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/build.sh +56 -0
  276. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/include/moe_dispatch_base_compat.h +113 -0
  277. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/include/tiling_data.h +100 -0
  278. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/include/utils.h +57 -0
  279. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/kernel/moe_dispatch.h +524 -0
  280. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/kernel/mte_dispatch_comm.h +324 -0
  281. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/moe_dispatch.cpp +67 -0
  282. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/run.sh +61 -0
  283. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/run_multi_data_test.sh +80 -0
  284. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/scripts/verify_dispatch.py +248 -0
  285. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/moe_dispatch_direct_invoke_sample/test/test_moe_dispatch.cpp +679 -0
  286. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/sample-helper-map.md +47 -0
  287. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/samples/spec-template.md +78 -0
  288. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/double-buffer-protocol.md +69 -0
  289. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/index.md +111 -0
  290. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/multi-core-formulas.md +126 -0
  291. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/split-core-design.md +100 -0
  292. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/ascendc-api/moe-dispatch-combine/tiling-scheme/window-memory-layout.md +199 -0
  293. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/CMakeLists.txt +95 -0
  294. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/cmake/ascend.cmake +59 -0
  295. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/cmake/shmem.cmake +75 -0
  296. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/cmake/tensor_api.cmake +48 -0
  297. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/host_utils/acl_utils.h +73 -0
  298. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/host_utils/common_utils.h +181 -0
  299. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/host_utils/io_utils.h +175 -0
  300. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/kernel_utils/common_utils.h +99 -0
  301. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/kernel_utils/integral_constant.h +36 -0
  302. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/common/kernel_utils/tuple_utils.h +34 -0
  303. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/block_mmad.h +27 -0
  304. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/block_scheduler_policy.h +35 -0
  305. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/block_scheduler_utils.h +27 -0
  306. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/quant_matmul_mx_block_mmad_swat.h +392 -0
  307. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/block/quant_matmul_mx_block_scheduler_swat.h +290 -0
  308. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/kernel/all_to_all_comm_udma.h +255 -0
  309. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/kernel/all_to_all_matmul_impl.h +370 -0
  310. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/kernel/heavy_kernels.h +128 -0
  311. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/kernel/qbmm_mx_kernel.h +395 -0
  312. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/policy/dispatch_policy.h +47 -0
  313. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tile/copy_scale_l1_to_l0a.h +61 -0
  314. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tile/copy_scale_l1_to_l0b.h +54 -0
  315. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tile/pad_mx_kl1.h +138 -0
  316. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tile/tile_mmad_mx.h +34 -0
  317. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/all_to_all_matmul_tiling_data.h +29 -0
  318. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/quant_matmul_mx_tiling_swat.h +410 -0
  319. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/quant_matmul_tiling_base.h +116 -0
  320. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/quant_matmul_tiling_common.h +101 -0
  321. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/tiling/quant_matmul_tiling_data.h +61 -0
  322. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/include/utils/constant.h +106 -0
  323. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/run.sh +65 -0
  324. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/scripts/extract_perf.py +57 -0
  325. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/scripts/gen_data.py +139 -0
  326. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/scripts/verify_result.py +152 -0
  327. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/src/all_to_all_matmul.cpp +396 -0
  328. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/all_to_all_matmul/src/utils.h +168 -0
  329. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/codebase_map.md +342 -0
  330. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/comm_shmem.md +280 -0
  331. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/matmul_blaze.md +259 -0
  332. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/mc2_architecture.md +199 -0
  333. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/review-checklist.md +29 -0
  334. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/blaze-shmem/workflow_integration.md +215 -0
  335. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/CMakeLists.txt +559 -0
  336. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/build.sh +319 -0
  337. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/config.cmake +232 -0
  338. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/func.cmake +478 -0
  339. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/intf.cmake +4 -0
  340. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/intf_pub.cmake +67 -0
  341. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/modules/Findalog.cmake +105 -0
  342. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/scripts/check_version_compatible.py +94 -0
  343. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/cmake/scripts/prepare.sh +129 -0
  344. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/golden.py +27 -0
  345. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/run_test.sh +33 -0
  346. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/single_server_check_result.py +71 -0
  347. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/single_server_config.ini +17 -0
  348. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/single_server_gen_data.py +91 -0
  349. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/single_server_run.py +116 -0
  350. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/examples/test_golden_cpu.py +63 -0
  351. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/CMakeLists.txt +202 -0
  352. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/mc2_common_infershape.cpp +163 -0
  353. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/mc2_common_infershape.h +49 -0
  354. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/formulaic_tiling_datatype.h +161 -0
  355. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hccl_formulaic_tiling.cpp +373 -0
  356. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hccl_formulaic_tiling.h +150 -0
  357. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hccl_performance.cpp +206 -0
  358. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hccl_performance.h +118 -0
  359. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/hcom_topo_info.h +81 -0
  360. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/matmul_formulaic_tiling.cpp +338 -0
  361. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/matmul_formulaic_tiling.h +340 -0
  362. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/matmul_performance.cpp +272 -0
  363. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/matmul_performance.h +152 -0
  364. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/mc2_tiling_struct.h +46 -0
  365. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/mc2_tiling_utils.cpp +296 -0
  366. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_host/op_tiling/mc2_tiling_utils.h +269 -0
  367. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_matmul_block.h +235 -0
  368. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_matmul_block_l2cache.h +165 -0
  369. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_matmul_compute.h +218 -0
  370. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_nd_to_nz.h +579 -0
  371. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/op_kernel/mc2_tiling_struct.h +164 -0
  372. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/utils/mc2_hcom_topo_info.cpp +390 -0
  373. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/utils/mc2_hcom_topo_info.h +81 -0
  374. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/mc2_common/utils/ops_utils.h +77 -0
  375. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_api/aclnn_x_all_gather_matmul.cpp +65 -0
  376. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_api/aclnn_x_all_gather_matmul.h +57 -0
  377. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/arch22/x_all_gather_formulaic_tiling_a2a3.cpp +50 -0
  378. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/arch22/x_all_gather_formulaic_tiling_a2a3.h +47 -0
  379. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/arch22/x_all_gather_matmul_tiling_a2a3.cpp +72 -0
  380. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/arch22/x_all_gather_matmul_tiling_a2a3.h +31 -0
  381. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/x_all_gather_formulaic_tiling.cpp +82 -0
  382. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/x_all_gather_formulaic_tiling.h +55 -0
  383. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/x_all_gather_matmul_tiling_base.cpp +508 -0
  384. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/op_tiling/x_all_gather_matmul_tiling_base.h +54 -0
  385. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/x_all_gather_matmul_def.cpp +79 -0
  386. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_host/x_all_gather_matmul_proto.cpp +39 -0
  387. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul.cpp +96 -0
  388. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul_base.h +152 -0
  389. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul_full_mesh.h +230 -0
  390. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul_tiling.h +45 -0
  391. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/all_gather_matmul/x_all_gather_matmul/op_kernel/x_all_gather_matmul_tiling_key.h +47 -0
  392. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/codebase_map.md +281 -0
  393. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/comm_hccl.md +201 -0
  394. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/matmul_fusion.md +50 -0
  395. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/mc2_architecture.md +142 -0
  396. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/op_architecture.md +167 -0
  397. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/pipeline_tuning.md +47 -0
  398. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/review-checklist.md +39 -0
  399. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/foundations/hccl-matmul/workflow_integration.md +152 -0
  400. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/operators/collective-comm.md +145 -0
  401. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/classification.md +27 -0
  402. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/comm-path-decision.md +51 -0
  403. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/grill-protocol.md +202 -0
  404. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/quality-checklist.md +57 -0
  405. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/requirement-analysis/template.md +208 -0
  406. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/shared/pipeline_tuning.md +232 -0
  407. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/references/shared/profiling_mc2.md +278 -0
  408. package/assets/ops-direct-invoke/skills/ascendc-mc2-best-practice/scripts/fetch_apace.sh +96 -0
  409. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/SKILL.md +121 -0
  410. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/evals/evals.json +138 -0
  411. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/advanced_tiling.md +92 -0
  412. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/broadcast_design.md +160 -0
  413. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/broadcast_add_kernel.cpp +118 -0
  414. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/broadcast_add_tiling.cpp +126 -0
  415. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/broadcast_common.h +344 -0
  416. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/onedim_add_kernel.cpp +97 -0
  417. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/code/onedim_add_tiling.cpp +57 -0
  418. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/datacopypad_design.md +46 -0
  419. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/nddma_design.md +53 -0
  420. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/onedim_design.md +114 -0
  421. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/broadcast/ub_broadcast_design.md +67 -0
  422. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/common/core_shrink_design.md +126 -0
  423. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/common/datacopy_optimization_design.md +351 -0
  424. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/common/tail_block_design.md +268 -0
  425. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/common/ub_resident_design.md +342 -0
  426. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/guide.md +69 -0
  427. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_base.template +81 -0
  428. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_big_dim.template +217 -0
  429. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_cut_one_axis.template +336 -0
  430. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_cut_two_axis.template +781 -0
  431. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_n_last.template +340 -0
  432. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_small_shape.template +321 -0
  433. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_tensor_move.template +102 -0
  434. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_transdata_5hd.template +480 -0
  435. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_transdata_5hd_021axis.template +533 -0
  436. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/dav3510/transpose_with_gather.template +688 -0
  437. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/templates/transpose_tiling_data.template +192 -0
  438. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_big_dim.md +220 -0
  439. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_cut_one_axis.md +175 -0
  440. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_cut_two_axis.md +177 -0
  441. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_fusion_design.md +398 -0
  442. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_gather.md +191 -0
  443. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_n_last.md +276 -0
  444. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_small_shape.md +315 -0
  445. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_tensor_move.md +203 -0
  446. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_tiling_data.md +176 -0
  447. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_vconv_021.md +206 -0
  448. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/conversion/transpose_vconv_5hd.md +179 -0
  449. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/elementwise/double_buffer_design.md +288 -0
  450. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/elementwise/vector_efficiency_design.md +203 -0
  451. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/constant_folding_design.md +466 -0
  452. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/fullload_design.md +344 -0
  453. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/guide.md +16 -0
  454. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/mte2_preload_design.md +320 -0
  455. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/pingpong_design.md +254 -0
  456. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/scale_coalescing_design.md +282 -0
  457. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/small_m_wide_n_pipeline_design.md +137 -0
  458. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/streamk_design.md +374 -0
  459. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/matmul/swat_design.md +423 -0
  460. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/mc2/guide.md +45 -0
  461. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/mc2/local_matmul_design.md +130 -0
  462. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/mc2/pipeline_balancing_design.md +502 -0
  463. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/guide.md +178 -0
  464. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/kernel_utils.template +75 -0
  465. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ar_full_load.template +429 -0
  466. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ar_recompute.template +485 -0
  467. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ar_small_r.template +348 -0
  468. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ara_full_load.template +574 -0
  469. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ara_online.template +324 -0
  470. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_ara_recompute.template +436 -0
  471. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/dav310/softmax_v2_base.template +950 -0
  472. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/fused_attention_online_softmax_design.md +428 -0
  473. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ar_full_load.md +137 -0
  474. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ar_recompute.md +135 -0
  475. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ar_small_r.md +122 -0
  476. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ara_full_load.md +144 -0
  477. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ara_online.md +185 -0
  478. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_ara_recompute.md +163 -0
  479. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_tiling.template +460 -0
  480. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/softmax_v2_tiling_data.template +278 -0
  481. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/state_resident_design.md +337 -0
  482. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/reduce/templates/usage_guide.md +253 -0
  483. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/scalar/coding_principles.md +476 -0
  484. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/scalar/conv_scalar.md +165 -0
  485. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/scalar/guide.md +31 -0
  486. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/simt/optimization-guide.md +110 -0
  487. package/assets/ops-direct-invoke/skills/ascendc-performance-best-practices/references/sort/radix_sort.md +354 -0
  488. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/SKILL.md +361 -0
  489. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/evals/evals.json +161 -0
  490. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/ascendc-dumptensor-refs/api-reference.md +92 -0
  491. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/ascendc-dumptensor-refs/error-patterns.md +40 -0
  492. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/ascendc-dumptensor.md +205 -0
  493. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/best-practices.md +317 -0
  494. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/binary-search-debug.md +275 -0
  495. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/case-studies.md +459 -0
  496. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/common-traps.md +492 -0
  497. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/data-comparison.md +308 -0
  498. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/debug-summary-template.md +198 -0
  499. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/diagnosis-workflow.md +180 -0
  500. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/printf-debug.md +296 -0
  501. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/simt-precision-debug.md +76 -0
  502. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/references/tools-reference.md +364 -0
  503. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/scripts/error_analysis.py +148 -0
  504. package/assets/ops-direct-invoke/skills/ascendc-precision-debug/scripts/gen_boundary_test.py +169 -0
  505. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/SKILL.md +47 -0
  506. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/evals/evals.json +115 -0
  507. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/arithmetic_and_reduce.md +228 -0
  508. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/compute_api_membase_vs_regbase.md +107 -0
  509. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/datacopy_best_practices.md +139 -0
  510. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/index.md +38 -0
  511. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/pipeline_and_buffer.md +105 -0
  512. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/regbase_api_reference.md +303 -0
  513. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/regbase_api_sync.md +173 -0
  514. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/api/regbase_api_whitelist.md +142 -0
  515. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/index.md +24 -0
  516. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/regbase_build_notes.md +49 -0
  517. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/regbase_performance_practices.md +52 -0
  518. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/regbase_programming_notes.md +120 -0
  519. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/tiling_review_notes.md +86 -0
  520. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/dev-experience/working_vs_failed_dav_3510_cases.md +49 -0
  521. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/README.md +190 -0
  522. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_host/adam_apply_one_assign_def.cpp +102 -0
  523. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_host/arch35/adam_apply_one_assign_tiling_arch35.cpp +597 -0
  524. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_host/arch35/adam_apply_one_assign_tiling_arch35.h +82 -0
  525. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_kernel/adam_apply_one_assign.cpp +44 -0
  526. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_kernel.h +361 -0
  527. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_struct.h +27 -0
  528. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_tiling_struct.h +53 -0
  529. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-design/adam_apply_one_assign_analysis.md +143 -0
  530. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/examples-adam-design/adam_apply_one_assign_design.md +2865 -0
  531. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/CMakeLists.txt +328 -0
  532. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/README.md +163 -0
  533. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_graph/xdivy_graph_infer.cpp +38 -0
  534. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_graph/xdivy_proto.h +42 -0
  535. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_host/arch35/xdivy_tiling_arch35.cpp +601 -0
  536. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_host/arch35/xdivy_tiling_arch35.h +89 -0
  537. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_host/xdivy_def.cpp +60 -0
  538. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_host/xdivy_infershape.cpp +58 -0
  539. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_kernel/arch35/xdivy_kernel.h +331 -0
  540. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_kernel/arch35/xdivy_struct.h +28 -0
  541. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_kernel/arch35/xdivy_tiling_struct.h +57 -0
  542. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/op_kernel/xdivy.cpp +42 -0
  543. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/aclnn/CMakeLists.txt +67 -0
  544. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/aclnn/run.sh +56 -0
  545. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/aclnn/test_aclnn.cpp +354 -0
  546. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/geir/CMakeLists.txt +69 -0
  547. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/geir/run.sh +58 -0
  548. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/geir/test_geir.cpp +407 -0
  549. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/tiling/CMakeLists.txt +185 -0
  550. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/tiling/run.sh +61 -0
  551. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/example/xdivy_custom_package/tests/tiling/test_tiling.cpp +386 -0
  552. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/patterns.md +324 -0
  553. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-kernel-entrance.md +95 -0
  554. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-overview.md +252 -0
  555. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-compute-flow.md +214 -0
  556. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-dag-buffers.md +285 -0
  557. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-kernel-helpers.md +209 -0
  558. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-kernel-template.md +611 -0
  559. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-tiling-preprocess.md +545 -0
  560. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/broadcast/references/broadcast-template-standard/broadcast-standard-tiling.md +471 -0
  561. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/broadcast-rules.md +126 -0
  562. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/cast-rules.md +414 -0
  563. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/datacopypad-rules.md +185 -0
  564. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/nddma-rules.md +255 -0
  565. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/sync-and-consistency.md +314 -0
  566. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/value-depend-process.md +40 -0
  567. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/common/vf-programming-rules.md +150 -0
  568. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/dynamic_shape/knowledge.md +382 -0
  569. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/dynamic_shape/patterns.md +260 -0
  570. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/elewise/patterns.md +46 -0
  571. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/elewise/tiling.md +215 -0
  572. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/example-routes.yaml +17 -0
  573. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/general-methodology.md +94 -0
  574. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/mask_predicate/patterns.md +99 -0
  575. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/numerical_stable/knowledge.md +233 -0
  576. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/numerical_stable/patterns.md +390 -0
  577. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/CMakeLists.txt +289 -0
  578. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/README.md +148 -0
  579. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_graph/euclidean_norm_graph_infer.cpp +39 -0
  580. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_graph/euclidean_norm_proto.h +54 -0
  581. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_host/arch35/euclidean_norm_tiling_arch35.cpp +1040 -0
  582. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_host/arch35/euclidean_norm_tiling_arch35.h +28 -0
  583. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_host/euclidean_norm_def.cpp +86 -0
  584. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_host/euclidean_norm_infershape.cpp +205 -0
  585. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm.cpp +46 -0
  586. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_base.h +965 -0
  587. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_empty.h +153 -0
  588. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_group.h +396 -0
  589. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_tiling_data.h +74 -0
  590. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_tiling_key.h +32 -0
  591. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/aclnn/CMakeLists.txt +59 -0
  592. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/aclnn/run.sh +36 -0
  593. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/aclnn/test_aclnn.cpp +227 -0
  594. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/geir/CMakeLists.txt +84 -0
  595. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/geir/run.sh +48 -0
  596. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/geir/test_geir.cpp +297 -0
  597. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/tiling/CMakeLists.txt +143 -0
  598. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/tiling/run.sh +40 -0
  599. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/example/euclidean_norm_package/tests/tiling/test_tiling.cpp +318 -0
  600. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/patterns.md +527 -0
  601. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-binary-sum.md +260 -0
  602. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-highlevel-api.md +146 -0
  603. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-kernel-entrance.md +96 -0
  604. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-survival-node.md +74 -0
  605. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-base/reduction-binary-base-dag-buffers.md +612 -0
  606. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-base/reduction-binary-base-kernel-template.md +1261 -0
  607. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-base/reduction-binary-base-tiling.md +531 -0
  608. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-group/reduction-binary-group-dag-buffers.md +209 -0
  609. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-group/reduction-binary-group-kernel-template.md +588 -0
  610. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-binary-group/reduction-binary-group-tiling.md +203 -0
  611. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-empty/reduction-empty-dag-buffers.md +292 -0
  612. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-empty/reduction-empty-kernel-template.md +360 -0
  613. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-empty/reduction-empty-tiling.md +234 -0
  614. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-template-overview.md +238 -0
  615. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-tiling-preprocess.md +218 -0
  616. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-tuple-reduce.md +72 -0
  617. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/references/reduction-vf-fusion-rules.md +95 -0
  618. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/reduction/validate_gates.py +194 -0
  619. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/resolve_example.py +106 -0
  620. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/routes.yaml +39 -0
  621. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/stateful/patterns.md +146 -0
  622. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/variable_output/knowledge.md +366 -0
  623. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/paradigms/variable_output/patterns.md +203 -0
  624. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/api_misuse.md +50 -0
  625. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/common_traps.md +67 -0
  626. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/index.md +25 -0
  627. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/precision_failures.md +51 -0
  628. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/precision_guide.md +85 -0
  629. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/regbase_vs_membase_confusions.md +52 -0
  630. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/pitfalls/symptom_to_cause.md +38 -0
  631. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/reference-ops/open_source_operator_table.md +740 -0
  632. package/assets/ops-direct-invoke/skills/ascendc-regbase-best-practice/references/regbase_development_guide.md +334 -0
  633. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/SKILL.md +107 -0
  634. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/evals/evals.json +44 -0
  635. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/compute-operators.md +34 -0
  636. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/data-transfer.md +51 -0
  637. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/debug-api.md +530 -0
  638. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/index-calculation.md +49 -0
  639. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/intra-core-shared.md +70 -0
  640. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/macro-api.md +65 -0
  641. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/multi-core-sync.md +39 -0
  642. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/overview.md +128 -0
  643. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/tensorlist-handling.md +92 -0
  644. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/thread-stride-pattern.md +49 -0
  645. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/vf-call.md +51 -0
  646. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references/vf-declaration.md +39 -0
  647. package/assets/ops-direct-invoke/skills/ascendc-simt-best-practices/references//347/274/226/350/257/221/344/270/216/350/277/220/350/241/214.md +158 -0
  648. package/assets/ops-direct-invoke/skills/ascendc-simt-tiling-design/SKILL.md +42 -0
  649. package/assets/ops-direct-invoke/skills/ascendc-simt-tiling-design/evals/evals.json +44 -0
  650. package/assets/ops-direct-invoke/skills/ascendc-simt-tiling-design/references/guide.md +73 -0
  651. package/assets/ops-direct-invoke/skills/ascendc-st-design/SKILL.md +316 -0
  652. package/assets/ops-direct-invoke/skills/ascendc-st-design/evals/evals.json +44 -0
  653. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/constraint-examples.md +392 -0
  654. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/dependency-yaml-spec.md +625 -0
  655. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/empty-tensor-guide.md +236 -0
  656. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/parameter-definition.md +491 -0
  657. package/assets/ops-direct-invoke/skills/ascendc-st-design/references/standards.md +11 -0
  658. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_empty_tensor_cases_derive.py +815 -0
  659. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_factor_values.py +1287 -0
  660. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_implicit_constraints.py +511 -0
  661. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_solver_config.py +618 -0
  662. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_test_cases.py +2800 -0
  663. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/generate_test_factors.py +762 -0
  664. package/assets/ops-direct-invoke/skills/ascendc-st-design/scripts/utils.py +1931 -0
  665. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/SKILL.md +91 -0
  666. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/evals/evals.json +72 -0
  667. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/dynamic-ub-broadcast.md +87 -0
  668. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/nddma-broadcast.md +199 -0
  669. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/onedim.md +152 -0
  670. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/patterns.md +165 -0
  671. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/broadcast/ub-broadcast.md +331 -0
  672. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/conversion/patterns.md +261 -0
  673. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/elewise/patterns.md +46 -0
  674. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/elewise/tiling.md +215 -0
  675. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/design/_governance.md +132 -0
  676. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/design/execution.md +469 -0
  677. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/design/resources.md +339 -0
  678. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/design/shape.md +271 -0
  679. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/foundation/composition.md +138 -0
  680. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/foundation/extension_points.md +173 -0
  681. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/foundation/fundamentals.md +245 -0
  682. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/foundation/roofline.md +227 -0
  683. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/implementation_ref.md +201 -0
  684. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/patterns.md +239 -0
  685. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/specialization/feature_flags.md +216 -0
  686. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/specialization/sparse_design.md +198 -0
  687. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/subfamilies/base_design.md +395 -0
  688. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/flashattention/subfamilies/quantization_design.md +233 -0
  689. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/gather.md +273 -0
  690. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/index_add.md +434 -0
  691. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/index_select.md +185 -0
  692. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/patterns.md +199 -0
  693. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/repeat_interleave.md +251 -0
  694. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/index/scatter.md +341 -0
  695. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/matmul/ascendc-api-gmm-tiling.md +313 -0
  696. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/matmul/ascendc-api-matmul-tiling.md +408 -0
  697. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/matmul/patterns.md +32 -0
  698. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/alg-dichotomy.md +56 -0
  699. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/alg-group-reduce.md +101 -0
  700. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/alg-welford.md +74 -0
  701. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/algorithms.md +35 -0
  702. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/ar-colsplit.md +149 -0
  703. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/ar-fullload.md +151 -0
  704. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/ara-fullload.md +228 -0
  705. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/ara-rowsplit.md +219 -0
  706. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/multi-axis-transform.md +83 -0
  707. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/multi-output-buffer.md +115 -0
  708. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/patterns.md +212 -0
  709. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/tiling-fields.md +94 -0
  710. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/reduction/with-index.md +247 -0
  711. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/scatter/patterns.md +827 -0
  712. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/sort/alg-two-level-mrgsort.md +681 -0
  713. package/assets/ops-direct-invoke/skills/ascendc-tiling-design/references/sort/patterns.md +249 -0
  714. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/SKILL.md +109 -0
  715. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/coverage_files_question.json +24 -0
  716. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_cmake.txt +46 -0
  717. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_inferdtype.cpp +139 -0
  718. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_inferdtype.csv +5 -0
  719. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_infershape.cpp +122 -0
  720. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_infershape.csv +5 -0
  721. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_param.h +319 -0
  722. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_tiling.cpp +154 -0
  723. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/csv-refactor/template_tiling.csv +5 -0
  724. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/question.json +100 -0
  725. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/template_report.md +112 -0
  726. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/assets/todo.json +24 -0
  727. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/evals/evals.json +198 -0
  728. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/coverage-guide/coverage-extraction.md +78 -0
  729. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/coverage-guide/test-implementation.md +136 -0
  730. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/custom/custom.md +5 -0
  731. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ops-transformer/csv-format-spec.md +263 -0
  732. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ops-transformer/csv-refactor-workflow.md +494 -0
  733. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ops-transformer/legacy-code-extraction.md +325 -0
  734. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ops-transformer/ops-transformer.md +75 -0
  735. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ut-guide/build_ut.md +65 -0
  736. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ut-guide/op-api-ut-guide.md +237 -0
  737. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ut-guide/op-host-ut-guide.md +240 -0
  738. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/ut-guide/op-kernel-ut-guide.md +198 -0
  739. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step1.md +43 -0
  740. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step2.md +26 -0
  741. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step3.md +51 -0
  742. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step4.md +130 -0
  743. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/references/workflow/step5.md +5 -0
  744. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/scripts/extract_dtype_combinations.py +200 -0
  745. package/assets/ops-direct-invoke/skills/ascendc-ut-develop/scripts/generate_csv_template.py +270 -0
  746. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/SKILL.md +125 -0
  747. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/evals/evals.json +198 -0
  748. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/S1-input-collection.md +125 -0
  749. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/00-execution-order.md +58 -0
  750. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/01-variable-semantics.md +250 -0
  751. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/02-generate-mapper.md +218 -0
  752. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/S5_case_json_schema.md +373 -0
  753. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/S5_mapped_case_schema.md +131 -0
  754. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/case-mapper/s5_case_mapper_template.py +411 -0
  755. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/design-verifier/00-execution-order.md +114 -0
  756. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/00-execution-order.md +291 -0
  757. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/01-code-analyzer.md +121 -0
  758. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/02-interface-analyzer.md +417 -0
  759. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/03-param-derivation.md +45 -0
  760. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/04-test-design-template.md +231 -0
  761. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/source-analysis/05-network-search.md +154 -0
  762. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/00-overview.md +66 -0
  763. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/01-step1-tiling.md +114 -0
  764. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/02-step2-trace.md +81 -0
  765. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/03-step3-kernel.md +51 -0
  766. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-a/04-path-config-schema.md +342 -0
  767. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/00-execution-order.md +26 -0
  768. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/01-step1-merge.md +54 -0
  769. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/02-step2-group.md +44 -0
  770. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/03-step3-derive.md +416 -0
  771. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/04-step4-output.md +122 -0
  772. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/task-d/05-step5-gen-cases.md +156 -0
  773. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/ttk-converter/00-execution-order.md +108 -0
  774. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/ttk-converter/01-csv-common.md +33 -0
  775. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/ttk-converter/02-kernel-fields.md +64 -0
  776. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/ttk-converter/03-kernel-mode.md +142 -0
  777. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/references/workflow.md +193 -0
  778. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/_scout_common.py +53 -0
  779. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/assemble_dim_spec.py +232 -0
  780. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/build_param_def.py +134 -0
  781. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/build_path_list.py +520 -0
  782. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/format_json.py +135 -0
  783. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/gen_cases_template.py +196 -0
  784. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/generate_test_design.py +555 -0
  785. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/normalize_op_name.py +157 -0
  786. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/pick_dims.py +173 -0
  787. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/run_ttk_kernel_module.py +750 -0
  788. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s2p0_verify.py +302 -0
  789. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s3_task_d_gate.py +365 -0
  790. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s5_append_empty.py +180 -0
  791. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s5_check_mapper_outputs.py +292 -0
  792. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/s5_expand_high.py +208 -0
  793. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/scout_k.py +723 -0
  794. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/scout_t.py +983 -0
  795. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/ttk_generate_kernel_csv.py +346 -0
  796. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/ttk_precheck_env.py +248 -0
  797. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/ttk_validate_csv.py +315 -0
  798. package/assets/ops-direct-invoke/skills/ascendc-whitebox-design/scripts/update_path_list.py +143 -0
  799. package/assets/ops-direct-invoke/skills/cann-env-setup/SKILL.md +177 -0
  800. package/assets/ops-direct-invoke/skills/cann-env-setup/evals/evals.json +144 -0
  801. package/assets/ops-direct-invoke/skills/cann-env-setup/references/env_dependence.md +77 -0
  802. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/SKILL.md +51 -0
  803. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/overall-implementation.md +226 -0
  804. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/aclnn-adaptation.md +34 -0
  805. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/aicpu-load-balance-metadata.md +116 -0
  806. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/channel-buffer.md +36 -0
  807. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/compilation-launch.md +144 -0
  808. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/host-validation.md +34 -0
  809. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/layout-tail.md +53 -0
  810. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/synchronization.md +80 -0
  811. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/torch-registration.md +66 -0
  812. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/vf.md +144 -0
  813. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/patterns/workspace.md +67 -0
  814. package/assets/ops-direct-invoke/skills/cannbot-dsl-best-practice/references/production-code.md +120 -0
  815. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/SKILL.md +25 -0
  816. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/core/methodology.md +104 -0
  817. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/references/readability-rules.md +280 -0
  818. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/steps/clause-review.md +59 -0
  819. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/steps/report-write.md +60 -0
  820. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/workflows/file-review.md +49 -0
  821. package/assets/ops-direct-invoke/skills/cannbot-dsl-code-reviewer/workflows/pr-review.md +58 -0
  822. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/SKILL.md +97 -0
  823. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/references/checks-and-troubleshooting.md +96 -0
  824. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/references/env-selected-soc-schema.md +43 -0
  825. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/references/environment-schema.md +112 -0
  826. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/scripts/check_env.sh +34 -0
  827. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/scripts/env_check.py +946 -0
  828. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/scripts/probe_compile_stage.py +99 -0
  829. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/scripts/probe_kernel.py +33 -0
  830. package/assets/ops-direct-invoke/skills/cannbot-dsl-env-check/tests/test_env_report.py +90 -0
  831. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/SKILL.md +60 -0
  832. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/references/pipeline-design.md +84 -0
  833. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/references/stage-cost-model.md +77 -0
  834. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/DESIGN-BRANCH.md.templ +119 -0
  835. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/INDEX.md.templ +34 -0
  836. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/API.md.templ +67 -0
  837. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/DevView.md.templ +67 -0
  838. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/HostLaunch.md.templ +119 -0
  839. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/InferShapeDtype.md.templ +56 -0
  840. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/Interface.md.templ +61 -0
  841. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/Kernel.md.templ +183 -0
  842. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/LaunchData.md.templ +126 -0
  843. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/Overview.md.templ +57 -0
  844. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/TemplatePartition.md.templ +69 -0
  845. package/assets/ops-direct-invoke/skills/cannbot-dsl-op-design/templates/design/Validation.md.templ +80 -0
  846. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/SKILL.md +64 -0
  847. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/assets/case_contract.py +269 -0
  848. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/assets/test.py +571 -0
  849. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/references/cases.md +29 -0
  850. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/references/evidence.md +67 -0
  851. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/references/golden.md +12 -0
  852. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/build_blackbox_cases.py +536 -0
  853. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/build_tdd_cases.py +498 -0
  854. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/build_whitebox_cases.py +183 -0
  855. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/casebook.py +71 -0
  856. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/generator_support.py +95 -0
  857. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/prepare_golden.py +390 -0
  858. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/scripts/recipe_validation.py +144 -0
  859. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/tests/test_evidence_chain.py +339 -0
  860. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/tests/test_skills.py +547 -0
  861. package/assets/ops-direct-invoke/skills/cannbot-dsl-test-generator/tests/test_synthesize_dtype.py +85 -0
  862. package/assets/ops-direct-invoke/skills/cannbot-dsl-unit-planner/SKILL.md +35 -0
  863. package/assets/ops-direct-invoke/skills/cannbot-dsl-unit-planner/references/decomposition-checks.md +46 -0
  864. package/assets/ops-direct-invoke/skills/cannbot-dsl-unit-planner/references/unit-format.md +77 -0
  865. package/assets/ops-direct-invoke/skills/npu-arch/SKILL.md +87 -0
  866. package/assets/ops-direct-invoke/skills/npu-arch/evals/evals.json +356 -0
  867. package/assets/ops-direct-invoke/skills/npu-arch/references/npu-arch-guide-triton.md +312 -0
  868. package/assets/ops-direct-invoke/skills/npu-arch/references/npu-arch-guide.md +454 -0
  869. package/assets/ops-direct-invoke/skills/npu-arch/references/npu-hardware-params.md +248 -0
  870. package/assets/ops-direct-invoke/skills/npu-arch/references/simt-arch-guide.md +303 -0
  871. package/assets/ops-direct-invoke/skills/ops-design-paradigms/SKILL.md +41 -0
  872. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/index.md +32 -0
  873. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/arithmetic_and_reduce.md +96 -0
  874. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/datacopy_best_practices.md +87 -0
  875. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/index.md +37 -0
  876. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/pipeline_and_buffer.md +87 -0
  877. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/precision_and_runtime.md +98 -0
  878. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/regbase_api_reference.md +88 -0
  879. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/regbase_api_sync.md +112 -0
  880. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/api/regbase_api_whitelist.md +121 -0
  881. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/complexity_and_route_selection.md +113 -0
  882. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/index.md +55 -0
  883. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/process_memory_cards.md +54 -0
  884. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/regbase_build_notes.md +87 -0
  885. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/regbase_kernel_case_notes.md +103 -0
  886. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/regbase_performance_practices.md +92 -0
  887. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/regbase_programming_notes.md +108 -0
  888. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/requirements_analysis_patterns.md +97 -0
  889. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/small_channel_transpose_notes.md +78 -0
  890. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/tiling_review_notes.md +87 -0
  891. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/dev-experience/working_vs_failed_950_cases.md +85 -0
  892. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/index.md +30 -0
  893. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/broadcast_patterns.md +132 -0
  894. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/index.md +48 -0
  895. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/inplace_operator_patterns.md +182 -0
  896. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/kernel_design_patterns.md +117 -0
  897. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/reduction_patterns.md +152 -0
  898. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/regbase_buffer_partitioning.md +122 -0
  899. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/regbase_kernel_dataflow_patterns.md +164 -0
  900. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/regbase_operator_patterns.md +138 -0
  901. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/regbase_sync_patterns.md +113 -0
  902. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/tiling_input_validation.md +267 -0
  903. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/patterns/tiling_patterns.md +124 -0
  904. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/api_misuse.md +161 -0
  905. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/common_traps.md +199 -0
  906. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/index.md +41 -0
  907. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/precision_failures.md +176 -0
  908. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/precision_guide.md +190 -0
  909. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/regbase_vs_membase_confusions.md +89 -0
  910. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/pitfalls/symptom_to_cause.md +58 -0
  911. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/knowledge/regbase_development_guide.md +290 -0
  912. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/design_sample/flash_attn-arch35-best-practices.md +80 -0
  913. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/design_sample/quant_flash_attn-arch35-best-practices.md +67 -0
  914. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/design_sample/sparse_flash_attention-arch35-best-practices.md +66 -0
  915. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/design_sample/sparse_flash_mla-arch35-best-practices.md +69 -0
  916. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/patterns.md +65 -0
  917. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/advanced.md +37 -0
  918. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/buffer.md +241 -0
  919. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/compute-flow.md +111 -0
  920. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/load-balancing.md +42 -0
  921. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/pipeline-example.md +173 -0
  922. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/pipeline.md +60 -0
  923. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/pre-knowledge.md +197 -0
  924. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/roofline.md +220 -0
  925. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/selection.md +32 -0
  926. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/stage-cost.md +63 -0
  927. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/trait-mla.md +36 -0
  928. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/trait-quantization.md +51 -0
  929. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/FA/references/trait-sparse.md +35 -0
  930. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/README.md +20 -0
  931. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/capability-mapping.md +41 -0
  932. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/dag-buffers.md +285 -0
  933. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/design-spec.md +24 -0
  934. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_host/adam_apply_one_assign_def.cpp +104 -0
  935. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_host/arch35/adam_apply_one_assign_tiling_arch35.cpp +572 -0
  936. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_host/arch35/adam_apply_one_assign_tiling_arch35.h +86 -0
  937. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_kernel/adam_apply_one_assign.cpp +46 -0
  938. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_kernel.h +343 -0
  939. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_struct.h +29 -0
  940. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-code/op_kernel/arch35/adam_apply_one_assign_tiling_struct.h +53 -0
  941. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-design/adam_apply_one_assign_analysis.md +143 -0
  942. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/examples-adam-design/adam_apply_one_assign_design.md +2840 -0
  943. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/CMakeLists.txt +328 -0
  944. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/README.md +162 -0
  945. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_graph/xdivy_graph_infer.cpp +40 -0
  946. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_graph/xdivy_proto.h +44 -0
  947. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_host/arch35/xdivy_tiling_arch35.cpp +582 -0
  948. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_host/arch35/xdivy_tiling_arch35.h +94 -0
  949. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_host/xdivy_def.cpp +62 -0
  950. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_host/xdivy_infershape.cpp +60 -0
  951. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_kernel/arch35/xdivy_kernel.h +337 -0
  952. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_kernel/arch35/xdivy_struct.h +30 -0
  953. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_kernel/arch35/xdivy_tiling_struct.h +57 -0
  954. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/op_kernel/xdivy.cpp +44 -0
  955. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/aclnn/CMakeLists.txt +67 -0
  956. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/aclnn/run.sh +57 -0
  957. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/aclnn/test_aclnn.cpp +353 -0
  958. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/geir/CMakeLists.txt +69 -0
  959. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/geir/run.sh +59 -0
  960. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/geir/test_geir.cpp +409 -0
  961. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/tiling/CMakeLists.txt +185 -0
  962. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/tiling/run.sh +62 -0
  963. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/example/xdivy_custom_package/tests/tiling/test_tiling.cpp +355 -0
  964. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/index.md +48 -0
  965. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/kernel-entrance.md +95 -0
  966. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/kernel-helpers.md +208 -0
  967. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/kernel-template.md +617 -0
  968. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/overview.md +250 -0
  969. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/pitfalls.md +50 -0
  970. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/tiling-preprocess.md +487 -0
  971. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/ascendc/tiling.md +374 -0
  972. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/dsl/capability-mapping.md +50 -0
  973. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/dsl/implementation-guide.md +52 -0
  974. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/adapters/dsl/index.md +33 -0
  975. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/capability-contract.md +41 -0
  976. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/compute-flow.md +216 -0
  977. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/index.md +23 -0
  978. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/liveness-fusion.md +200 -0
  979. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/scene.md +68 -0
  980. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/shape-preprocessing.md +209 -0
  981. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/splitting.md +158 -0
  982. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/sync-model.md +79 -0
  983. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/generic/verification.md +131 -0
  984. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/broadcast/patterns.md +62 -0
  985. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/broadcast-rules.md +126 -0
  986. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/cast-rules.md +414 -0
  987. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/datacopypad-rules.md +186 -0
  988. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/nddma-rules.md +257 -0
  989. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/sync-and-consistency.md +315 -0
  990. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/value-depend-process.md +40 -0
  991. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/common/vf-programming-rules.md +150 -0
  992. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/example-routes.yaml +31 -0
  993. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/general-methodology-dsl.md +11 -0
  994. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/general-methodology.md +94 -0
  995. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/binary-tree.md +260 -0
  996. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/capability-mapping.md +49 -0
  997. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/design-spec.md +26 -0
  998. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/CMakeLists.txt +289 -0
  999. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/README.md +147 -0
  1000. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_graph/euclidean_norm_graph_infer.cpp +39 -0
  1001. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_graph/euclidean_norm_proto.h +54 -0
  1002. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_host/arch35/euclidean_norm_tiling_arch35.cpp +1027 -0
  1003. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_host/arch35/euclidean_norm_tiling_arch35.h +28 -0
  1004. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_host/euclidean_norm_def.cpp +85 -0
  1005. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_host/euclidean_norm_infershape.cpp +211 -0
  1006. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_apt.cpp +41 -0
  1007. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_base.h +911 -0
  1008. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_empty.h +141 -0
  1009. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_group.h +381 -0
  1010. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_tiling_data.h +65 -0
  1011. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/op_kernel/arch35/euclidean_norm_tiling_key.h +30 -0
  1012. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/aclnn/CMakeLists.txt +59 -0
  1013. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/aclnn/run.sh +37 -0
  1014. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/aclnn/test_aclnn.cpp +223 -0
  1015. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/geir/CMakeLists.txt +84 -0
  1016. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/geir/run.sh +49 -0
  1017. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/geir/test_geir.cpp +296 -0
  1018. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/tiling/CMakeLists.txt +143 -0
  1019. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/tiling/run.sh +41 -0
  1020. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/example/euclidean_norm_package/tests/tiling/test_tiling.cpp +320 -0
  1021. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/highlevel-api.md +146 -0
  1022. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/index.md +48 -0
  1023. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/kernel-entrance.md +97 -0
  1024. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/overview.md +237 -0
  1025. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/survival-node.md +74 -0
  1026. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-base/dag-buffers.md +612 -0
  1027. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-base/kernel-template.md +1213 -0
  1028. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-base/tiling.md +511 -0
  1029. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-group/dag-buffers.md +209 -0
  1030. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-group/kernel-template.md +577 -0
  1031. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/binary-group/tiling.md +199 -0
  1032. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/empty/dag-buffers.md +292 -0
  1033. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/empty/kernel-template.md +349 -0
  1034. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/templates/empty/tiling.md +230 -0
  1035. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/tiling-preprocess.md +218 -0
  1036. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/tuple-reduce.md +72 -0
  1037. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/adapters/ascendc/vf-fusion-rules.md +95 -0
  1038. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/axis-preprocessing.md +109 -0
  1039. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/capability-contract.md +48 -0
  1040. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/index.md +23 -0
  1041. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/liveness-fusion.md +111 -0
  1042. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/scene.md +92 -0
  1043. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/splitting.md +230 -0
  1044. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/sync-model.md +86 -0
  1045. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/tree-reduction.md +160 -0
  1046. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/generic/tuple-reduce.md +53 -0
  1047. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/patterns.md +62 -0
  1048. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/reduction/validate_gates.py +196 -0
  1049. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/resolve_example.py +170 -0
  1050. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/paradigms/routes.yaml +39 -0
  1051. package/assets/ops-direct-invoke/skills/ops-design-paradigms/references/reference-ops/open_source_operator_table.md +715 -0
  1052. package/assets/ops-direct-invoke/skills/ops-design-paradigms/tests/test_language_route.py +142 -0
  1053. package/assets/ops-direct-invoke/skills/ops-direct-invoke/SKILL.md +249 -0
  1054. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/assemble_cannbotdsl_design.py +156 -0
  1055. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/assemble_workflow.py +571 -0
  1056. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/build_implementation_subgraph.py +320 -0
  1057. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/generate_workflow_guide.py +94 -0
  1058. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/run_workflow.py +121 -0
  1059. package/assets/ops-direct-invoke/skills/ops-direct-invoke/scripts/validate_unit_contracts.py +228 -0
  1060. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//344/273/243/347/240/201/344/277/256/345/244/215.yaml +39 -0
  1061. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//346/212/200/346/234/257/347/251/277/345/210/272.yaml +40 -0
  1062. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//346/226/207/346/241/243/345/207/206/345/244/207.yaml +27 -0
  1063. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//346/265/213/350/257/225/345/267/245/347/250/213/345/274/200/345/217/221.yaml +33 -0
  1064. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//347/231/275/347/233/222/346/265/213/350/257/225/350/256/276/350/256/241.yaml +34 -0
  1065. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//347/237/245/350/257/206/346/220/234/351/233/206.yaml +36 -0
  1066. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//347/256/227/345/255/220/345/274/200/345/217/221.yaml +47 -0
  1067. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/ascendc//351/273/221/347/233/222/346/265/213/350/257/225/350/256/276/350/256/241.yaml +27 -0
  1068. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//344/272/244/344/273/230.yaml +15 -0
  1069. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//344/273/243/347/240/201/346/243/200/350/247/206.yaml +18 -0
  1070. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/210/233/345/273/272/345/267/245/344/275/234/345/214/272.yaml +17 -0
  1071. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/215/225/345/205/203/344/273/273/345/212/241/346/213/206/345/210/206.yaml +22 -0
  1072. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/215/225/345/205/203/345/256/236/347/216/260.yaml +27 -0
  1073. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/215/225/345/205/203/351/233/206/346/210/220/345/244/215/351/252/214.yaml +19 -0
  1074. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/256/236/347/216/260/344/277/256/345/244/215.yaml +21 -0
  1075. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/256/236/347/216/260/346/243/200/350/247/206.yaml +20 -0
  1076. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//345/256/236/347/216/260/351/227/250/347/246/201.yaml +17 -0
  1077. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//346/200/247/350/203/275/344/274/230/345/214/226.yaml +22 -0
  1078. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//346/226/207/346/241/243/347/224/237/346/210/220.yaml +15 -0
  1079. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//346/226/271/346/241/210/350/256/276/350/256/241.yaml +32 -0
  1080. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//346/265/213/350/257/225/347/224/237/346/210/220.yaml +29 -0
  1081. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//347/216/257/345/242/203/345/260/261/347/273/252.yaml +25 -0
  1082. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//347/262/276/345/272/246/351/252/214/350/257/201.yaml +25 -0
  1083. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//350/247/204/346/240/274/347/224/237/346/210/220.yaml +18 -0
  1084. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//351/234/200/346/261/202/345/210/206/346/236/220.yaml +16 -0
  1085. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/cannbot-dsl//351/273/221/347/233/222/347/224/250/344/276/213/350/256/276/350/256/241.yaml +19 -0
  1086. package/assets/ops-direct-invoke/skills/ops-direct-invoke/tasks/common/.gitkeep +0 -0
  1087. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//344/273/243/347/240/201/346/243/200/350/247/206/346/212/245/345/221/212.md +70 -0
  1088. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//345/212/237/350/203/275/351/252/214/346/224/266/346/212/245/345/221/212.md +80 -0
  1089. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//346/265/213/350/257/225/346/211/247/350/241/214/350/256/260/345/275/225.md +73 -0
  1090. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//347/231/275/347/233/222/346/265/213/350/257/225/350/256/276/350/256/241.md +37 -0
  1091. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//347/237/245/350/257/206/346/220/234/351/233/206.md +25 -0
  1092. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//351/252/214/346/224/266/346/212/245/345/221/212.md +39 -0
  1093. package/assets/ops-direct-invoke/skills/ops-direct-invoke/templates//351/273/221/347/233/222/346/265/213/350/257/225/350/256/276/350/256/241.md +130 -0
  1094. package/assets/ops-direct-invoke/skills/ops-direct-invoke/workflows/ascendc/basic.yaml +57 -0
  1095. package/assets/ops-direct-invoke/skills/ops-direct-invoke/workflows/ascendc/feasibility.yaml +13 -0
  1096. package/assets/ops-direct-invoke/skills/ops-direct-invoke/workflows/cannbot-dsl/op-dev.graph-preview.yaml +18 -0
  1097. package/assets/ops-direct-invoke/skills/ops-direct-invoke/workflows/cannbot-dsl/op-dev.yaml +142 -0
  1098. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/SKILL.md +115 -0
  1099. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/agents-entry.md +23 -0
  1100. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/documentation.md +52 -0
  1101. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/ops-direct-invoke.md +67 -0
  1102. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/repo-skills.md +85 -0
  1103. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/subagents.md +43 -0
  1104. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/task-authoring.md +83 -0
  1105. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/reference/tests.md +33 -0
  1106. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/dsl_generation/test.py +499 -0
  1107. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/support.py +122 -0
  1108. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/test_all.py +59 -0
  1109. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/variables/test.py +100 -0
  1110. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/workflow_execution/test.py +134 -0
  1111. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/workflow_generation/test.py +457 -0
  1112. package/assets/ops-direct-invoke/skills/ops-direct-invoke-maintain/test/ut/workflow_guide/test.py +91 -0
  1113. package/assets/ops-direct-invoke/skills/ops-precision-standard/SKILL.md +22 -0
  1114. package/assets/ops-direct-invoke/skills/ops-precision-standard/evals/evals.json +120 -0
  1115. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/benchmark_construction.md +77 -0
  1116. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/float_compute.md +126 -0
  1117. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/integer_compute.md +105 -0
  1118. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/non_compute.md +81 -0
  1119. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/quantization.md +49 -0
  1120. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/random_generation.md +198 -0
  1121. package/assets/ops-direct-invoke/skills/ops-precision-standard/references/test_case_generation.md +61 -0
  1122. package/assets/ops-direct-invoke/skills/ops-precision-standard/scripts/bitwise_match.py +103 -0
  1123. package/assets/ops-direct-invoke/skills/ops-precision-standard/scripts/integer_compute_check.py +157 -0
  1124. package/assets/ops-direct-invoke/skills/ops-precision-standard/scripts/mixed_tolerance_check.py +178 -0
  1125. package/assets/ops-direct-invoke/skills/ops-precision-standard/scripts/random_distribution_check.py +247 -0
  1126. package/assets/ops-direct-invoke/skills/ops-profiling/SKILL.md +185 -0
  1127. package/assets/ops-direct-invoke/skills/ops-profiling/evals/evals.json +196 -0
  1128. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/SKILL.md +259 -0
  1129. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/VERSION +10 -0
  1130. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/evals/evals.json +33 -0
  1131. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/collection-workflow.md +91 -0
  1132. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/data-contract.md +63 -0
  1133. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/environment-and-failure.md +82 -0
  1134. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/validation-and-performance.md +63 -0
  1135. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/references/visualization-contract.md +86 -0
  1136. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/collect.py +2209 -0
  1137. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/collect_discovery.py +987 -0
  1138. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/collect_validate.py +607 -0
  1139. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/environment_context.py +723 -0
  1140. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/estimate_runtime.py +131 -0
  1141. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/run_pipeline.py +339 -0
  1142. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/runtime_guard.py +589 -0
  1143. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/self_check.py +465 -0
  1144. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize.py +1004 -0
  1145. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_common.py +258 -0
  1146. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_parsers.py +1555 -0
  1147. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_render.py +286 -0
  1148. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_resolvers.py +1224 -0
  1149. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/scripts/visualize_source.py +1288 -0
  1150. package/assets/ops-direct-invoke/skills/ops-profiling/msopprof-visualization/templates/report_template.html +253 -0
  1151. package/assets/ops-direct-invoke/skills/ops-profiling/references/csv_fields_reference.md +260 -0
  1152. package/assets/ops-direct-invoke/skills/ops-profiling/references/msprof-guide.md +252 -0
  1153. package/assets/ops-direct-invoke/skills/ops-profiling/references/msprof-op-guide.md +241 -0
  1154. package/assets/ops-direct-invoke/skills/ops-profiling/references/optimization_quickref.md +265 -0
  1155. package/assets/ops-direct-invoke/skills/ops-profiling/scripts/msprof_perf_summary.py +2469 -0
  1156. package/assets/ops-direct-invoke/skills/ops-profiling/scripts/msprof_profile_run.sh +400 -0
  1157. package/assets/ops-direct-invoke/skills/ops-profiling/scripts/perf_summary.py +448 -0
  1158. package/assets/ops-direct-invoke/skills/ops-simulator/SKILL.md +233 -0
  1159. package/assets/ops-direct-invoke/skills/ops-simulator/evals/evals.json +128 -0
  1160. package/assets/ops-direct-invoke/skills/ops-simulator/references/pc-source-mapping.md +76 -0
  1161. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-issues-aic.md +557 -0
  1162. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-issues-aiv.md +674 -0
  1163. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-issues-general.md +199 -0
  1164. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-issues-template.md +143 -0
  1165. package/assets/ops-direct-invoke/skills/ops-simulator/references/performance-metrics-reference.md +350 -0
  1166. package/assets/ops-direct-invoke/skills/ops-simulator/references/pipeline-bubble-analysis.md +269 -0
  1167. package/assets/ops-direct-invoke/skills/ops-simulator/references/simulator-advanced.md +174 -0
  1168. package/assets/ops-direct-invoke/skills/ops-simulator/references/troubleshooting.md +105 -0
  1169. package/assets/ops-direct-invoke/skills/ops-simulator/scripts/map_pc_to_source.py +741 -0
  1170. package/assets/ops-direct-invoke/skills/ops-simulator/scripts/trace_bubble_analyzer.py +971 -0
  1171. package/assets/ops-direct-invoke/skills/ops-spec-gen/SKILL.md +350 -0
  1172. package/assets/ops-direct-invoke/skills/ops-spec-gen/evals/evals.json +114 -0
  1173. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/README.md +71 -0
  1174. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/add/spec.yaml +161 -0
  1175. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/complex/spec.yaml +154 -0
  1176. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/cumsum/spec.yaml +176 -0
  1177. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/dropout/spec.yaml +170 -0
  1178. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/fused_quant_matmul/spec.yaml +331 -0
  1179. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/matmul/spec.yaml +201 -0
  1180. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/nonzero/spec.yaml +174 -0
  1181. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/reduce_sum/spec.yaml +151 -0
  1182. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/reduce_sum_all/spec.yaml +135 -0
  1183. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/reduce_sum_fixed/spec.yaml +143 -0
  1184. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/softmax/spec.yaml +231 -0
  1185. package/assets/ops-direct-invoke/skills/ops-spec-gen/examples/split/spec.yaml +160 -0
  1186. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/accumulation_order.md +63 -0
  1187. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/error-codes.md +199 -0
  1188. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/spec-cheatsheet.md +358 -0
  1189. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/stage-rules.md +476 -0
  1190. package/assets/ops-direct-invoke/skills/ops-spec-gen/references/usage-scenarios.md +265 -0
  1191. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/anti_pattern_registry.yaml +51 -0
  1192. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/boundary_min_cases.yaml +215 -0
  1193. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/category_enum.yaml +37 -0
  1194. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/category_paradigm_map.yaml +145 -0
  1195. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/chip_registry.yaml +82 -0
  1196. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/error_code_enum.yaml +25 -0
  1197. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/framework_oracle_registry.yaml +22 -0
  1198. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/invariant_kind_registry.yaml +130 -0
  1199. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/machine_check_kind_registry.yaml +84 -0
  1200. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/paradigm_enum.yaml +48 -0
  1201. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/primitive_whitelist.yaml +67 -0
  1202. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/synthesize_pattern_registry.yaml +58 -0
  1203. package/assets/ops-direct-invoke/skills/ops-spec-gen/registries/tolerance_defaults.yaml +53 -0
  1204. package/assets/ops-direct-invoke/skills/ops-spec-gen/schemas/op-spec.json +762 -0
  1205. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/check_registry_schema_sync.py +167 -0
  1206. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/dump_rule_ids.py +168 -0
  1207. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/__init__.py +8 -0
  1208. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/_ast_sandbox.py +142 -0
  1209. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/broadcast.py +270 -0
  1210. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/dtype_eval.py +186 -0
  1211. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/extreme_inputs_check.py +355 -0
  1212. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/formula_eval.py +431 -0
  1213. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/formula_oracle_equiv.py +603 -0
  1214. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/invariant_exec.py +569 -0
  1215. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/oracle_check.py +465 -0
  1216. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/parser.py +71 -0
  1217. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/promote.py +254 -0
  1218. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/shape_eval.py +368 -0
  1219. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/stages.py +995 -0
  1220. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/evaluators/types.py +130 -0
  1221. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/generate_spec.py +1571 -0
  1222. package/assets/ops-direct-invoke/skills/ops-spec-gen/scripts/validate_spec.py +1848 -0
  1223. package/assets/ops-direct-invoke/skills/ops-spec-gen/templates/spec.yaml.tmpl +100 -0
  1224. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/conftest.py +21 -0
  1225. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_attr_resolve.py +72 -0
  1226. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_broadcast.py +85 -0
  1227. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_doc_drift.py +45 -0
  1228. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_dtype_eval.py +163 -0
  1229. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_examples.py +54 -0
  1230. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_extreme_inputs_check.py +181 -0
  1231. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_formula_eval.py +154 -0
  1232. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_formula_oracle_equiv.py +281 -0
  1233. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_generate_spec.py +98 -0
  1234. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_invariant_exec.py +235 -0
  1235. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_main_pipeline.py +419 -0
  1236. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_oracle.py +255 -0
  1237. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_promote.py +127 -0
  1238. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_registry_schema_sync.py +32 -0
  1239. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_sandbox_escape.py +90 -0
  1240. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_shape_eval.py +220 -0
  1241. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_shape_literal.py +82 -0
  1242. package/assets/ops-direct-invoke/skills/ops-spec-gen/tests/test_stage2_constraints.py +213 -0
  1243. package/assets/ops-direct-invoke/skills/repo-build-guide/SKILL.md +10 -0
  1244. package/assets/ops-direct-invoke/skills/repo-build-guide/references/build-guide.md +42 -0
  1245. package/assets/ops-direct-invoke/skills/repo-coding-rules/SKILL.md +10 -0
  1246. package/assets/ops-direct-invoke/skills/repo-coding-rules/references/red-lines.md +42 -0
  1247. package/assets/ops-direct-invoke/skills/repo-env-check/SKILL.md +44 -0
  1248. package/assets/ops-direct-invoke/skills/repo-env-check/references//347/216/257/345/242/203/344/277/241/346/201/257.md +42 -0
  1249. package/assets/ops-direct-invoke/skills/repo-knowledge/SKILL.md +12 -0
  1250. package/assets/ops-direct-invoke/skills/repo-knowledge/references/evaluation-contract.md +48 -0
  1251. package/assets/ops-direct-invoke/skills/repo-op-templates/SKILL.md +15 -0
  1252. package/assets/ops-direct-invoke/skills/repo-op-templates/references/operator-template.md +27 -0
  1253. package/assets/ops-direct-invoke/skills/repo-op-templates/references/project-skeleton.md +41 -0
  1254. package/assets/ops-direct-invoke/skills/repo-requirement/SKILL.md +39 -0
  1255. package/assets/ops-direct-invoke/skills/repo-requirement/references/requirement-checklist.md +70 -0
  1256. package/assets/ops-direct-invoke/skills/repo-test-develop/SKILL.md +17 -0
  1257. package/assets/ops-direct-invoke/skills/repo-test-develop/references/blackbox-design.md +30 -0
  1258. package/assets/ops-direct-invoke/skills/repo-test-develop/references/cannbench-integration.md +75 -0
  1259. package/assets/ops-direct-invoke/skills/repo-test-develop/references/precision-and-perf.md +36 -0
  1260. package/assets/ops-direct-invoke/skills/repo-test-develop/references/test-framework.md +75 -0
  1261. package/assets/ops-direct-invoke/skills/repo-test-develop/references/whitebox-design.md +19 -0
  1262. package/assets/ops-direct-invoke/skills/workflow-orchestrator/README.md +145 -0
  1263. package/assets/ops-direct-invoke/skills/workflow-orchestrator/SKILL.md +84 -0
  1264. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/approve_task.py +98 -0
  1265. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/get_task.py +1133 -0
  1266. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/init_status.py +131 -0
  1267. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/link_agent_config.py +89 -0
  1268. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/orchestrator.py +738 -0
  1269. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/poll_workflow.py +392 -0
  1270. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/task_graph.py +144 -0
  1271. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/update_status.py +149 -0
  1272. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/verdict_common.py +103 -0
  1273. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/verdict_fail.py +22 -0
  1274. package/assets/ops-direct-invoke/skills/workflow-orchestrator/scripts/verdict_pass.py +21 -0
  1275. package/assets/ops-direct-invoke/skills/workflow-orchestrator/templates/basic_workflow.yaml +113 -0
  1276. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_agent_exit.py +91 -0
  1277. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_approval.py +490 -0
  1278. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_link_agent_config.py +202 -0
  1279. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_nested_subgraphs.py +337 -0
  1280. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_orchestrator.py +1383 -0
  1281. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_poll_workflow.py +371 -0
  1282. package/assets/ops-direct-invoke/skills/workflow-orchestrator/tests/test_verdict.py +148 -0
  1283. package/cordis.patch.yml +3 -0
  1284. package/icon.svg +1 -0
  1285. package/lib/client.js +255 -0
  1286. package/lib/client.js.map +1 -0
  1287. package/lib/index.js +15 -0
  1288. package/locale/en.json +1 -0
  1289. package/locale/zh.json +1 -0
  1290. package/package.json +62 -3
  1291. package/upstream.json +10 -0
@@ -0,0 +1,2865 @@
1
+ # AdamApplyOneAssign 详细设计
2
+
3
+ ## 1. 逻辑存活节点
4
+
5
+ ### 1.1 核心原则
6
+
7
+ **存活节点** = 同一时刻 UB 中必须同时驻留的 tensor buffer 数量。
8
+
9
+ **逻辑存活节点** = 纯计算图结构决定的数学下界——不涉及硬件参数、不依赖 API 能力、不考虑实现策略。通过调度顺序优化后,计算图中不可避免的最小峰值存活节点数。P ≥ L 恒成立,物理不可能低于逻辑。
10
+
11
+ ### 1.2 物理意义
12
+
13
+ 逻辑存活节点是 Tiling 分析的起点。它回答一个问题:在不考虑任何硬件限制的前提下,这个算子的计算图拓扑结构本身,至少需要几个 buffer 同时在线?
14
+
15
+ 方法:
16
+ 1. 画出完整计算图(含 broadcast),来自接口分析
17
+ 2. 识别分叉结构——同一 tensor 被多处引用,产生需要跨步保留的中间量
18
+ 3. 按最优调度顺序(先集中消费分叉源,用完即放)逐步追踪
19
+ 4. 每步记录存活节点 = 上下文中间量 + 本轮输入 + 本轮输出
20
+ 5. 峰值即为最小逻辑存活节点
21
+
22
+ 意义:为后续物理存活节点分析提供不可突破的下界。`perBufferMax = UB / L`,这是任何实现策略都无法超越的内存上限。
23
+
24
+ ### 1.3 计算图
25
+
26
+ ```
27
+ Path 1 (→ output0):
28
+ S1: squareResult = vmul(dataInput0, dataInput0)
29
+ S2: mul3Result = vmul(squareResult, dataInputMul3) [broadcast]
30
+ S3: mul2Result = vmul(dataInput1, dataInputMul2) [broadcast]
31
+ S4: output0 = vadd(mul2Result, mul3Result) [broadcast]
32
+ S5: sqrtResult = vsqrt(output0)
33
+ S6: add2Result = vadd(sqrtResult, dataInputAdd2) [broadcast]
34
+
35
+ Path 2 (→ output1):
36
+ S7: mul0Result = vmul(dataInput2, dataInputMul) [broadcast]
37
+ S8: mul1Result = vmul(dataInput0, dataInputMul1) [broadcast]
38
+ S9: output1 = vadd(mul0Result, mul1Result) [broadcast]
39
+
40
+ Merge (→ output2):
41
+ S10a: output1 = vmuls(output1, 1) [恒等, in-place]
42
+ S10b: truedivResult = vdiv(output1, add2Result) [broadcast]
43
+ S11: mul4Result = vmul(truedivResult, input4) [broadcast]
44
+ S12: output2 = vsub(dataInput3, mul4Result) [broadcast]
45
+ ```
46
+
47
+ ### 1.4 分叉点
48
+
49
+ `dataInput0` 同时被 S1 (Path1) 和 S8 (Path2) 引用,是唯一的分叉源。
50
+
51
+ ### 1.5 最优调度
52
+
53
+ 策略:先集中消费分叉源 `dataInput0`(S1→S8 背靠背),S8 完成后立即释放。剩余操作按数据依赖排布,尽早释放不再需要的中间量。
54
+
55
+ ```
56
+ Step 1: 载 dataInput0
57
+ S1: squareResult = vmul(dataInput0, dataInput0)
58
+ 存活: [dataInput0, squareResult] = 2
59
+
60
+ Step 2: 载 dataInputMul1
61
+ S8: mul1Result = vmul(dataInput0, dataInputMul1)
62
+ 存活: [dataInput0, squareResult, dataInputMul1, mul1Result] = 4
63
+ 释放 dataInput0, dataInputMul1
64
+ 存活: [squareResult, mul1Result] = 2
65
+
66
+ Step 3: 载 dataInput2, dataInputMul
67
+ S7: mul0Result = vmul(dataInput2, dataInputMul)
68
+ 存活: [squareResult, mul1Result, dataInput2, dataInputMul, mul0Result] = 5 ← 峰值
69
+ 释放 dataInput2, dataInputMul
70
+ 存活: [squareResult, mul1Result, mul0Result] = 3
71
+
72
+ Step 4: S9: output1 = vadd(mul0Result, mul1Result)
73
+ 存活: [squareResult, mul0Result, mul1Result, output1] = 4
74
+ 释放 mul0Result, mul1Result
75
+ 存活: [squareResult, output1] = 2
76
+
77
+ Step 5: 载 dataInputMul3
78
+ S2: mul3Result = vmul(squareResult, dataInputMul3)
79
+ 存活: [squareResult, output1, dataInputMul3, mul3Result] = 4
80
+ 释放 squareResult, dataInputMul3
81
+ 存活: [output1, mul3Result] = 2
82
+
83
+ Step 6: 载 dataInput1, dataInputMul2
84
+ S3: mul2Result = vmul(dataInput1, dataInputMul2)
85
+ 存活: [output1, mul3Result, dataInput1, dataInputMul2, mul2Result] = 5 ← 峰值
86
+ 释放 dataInput1, dataInputMul2
87
+ 存活: [output1, mul3Result, mul2Result] = 3
88
+
89
+ Step 7: S4: output0 = vadd(mul2Result, mul3Result)
90
+ 存活: [output1, mul2Result, mul3Result, output0] = 4
91
+ 释放 mul2Result, mul3Result
92
+ 存活: [output1, output0] = 2
93
+
94
+ Step 8: S5: sqrtResult = vsqrt(output0)
95
+ 存活: [output1, output0, sqrtResult] = 3
96
+
97
+ Step 9: 载 dataInputAdd2
98
+ S6: add2Result = vadd(sqrtResult, dataInputAdd2)
99
+ 存活: [output1, output0, sqrtResult, dataInputAdd2, add2Result] = 5 ← 峰值
100
+ 释放 sqrtResult, dataInputAdd2
101
+ 存活: [output1, output0, add2Result] = 3
102
+
103
+ Step 10: S10a: output1 = vmuls(output1, 1) [in-place]
104
+ S10b: truedivResult = vdiv(output1, add2Result)
105
+ 存活: [output1, output0, add2Result, truedivResult] = 4
106
+ 释放 add2Result
107
+ 存活: [output1, output0, truedivResult] = 3
108
+
109
+ Step 11: 载 input4
110
+ S11: mul4Result = vmul(truedivResult, input4)
111
+ 存活: [output1, output0, truedivResult, input4, mul4Result] = 5 ← 峰值
112
+ 释放 truedivResult, input4
113
+ 存活: [output1, output0, mul4Result] = 3
114
+
115
+ Step 12: 载 dataInput3
116
+ S12: output2 = vsub(dataInput3, mul4Result)
117
+ 存活: [output1, output0, dataInput3, mul4Result, output2] = 5 ← 峰值
118
+ 释放 dataInput3, mul4Result
119
+ 存活: [output0, output1, output2] = 3
120
+ ```
121
+
122
+ ### 1.6 结论
123
+
124
+ | 指标 | 值 |
125
+ |------|-----|
126
+ | **逻辑存活节点 L** | **5** |
127
+ | 峰值出现步骤 | Step 3, 6, 9, 11, 12 |
128
+ | 瓶颈 | `dataInput0` 分叉产生 `squareResult` 和 `mul1Result` 两个跨步上下文量 |
129
+ | 下界不可降原因 | 2 上下文 + 2 输入 + 1 输出 = 5,分叉结构决定了上下文无法合并 |
130
+
131
+ ### 1.7 对本算子的意义
132
+
133
+ - perBuffer理论上限 = 256KB / 5 ≈ 51KB > 48KB,逻辑下界本身已可接受
134
+ - 该计算图上任何tiling方案的存活节点 **≥ 5**
135
+ - 不可降:继续划分任务时,每个step都最少需要 5 个节点
136
+ - 简化瓶颈:如果找到减少分叉的方法,可进一步降低逻辑存活节点
137
+
138
+ ---
139
+
140
+ ## 2. 物理存活节点
141
+
142
+ ### 2.1 核心原则
143
+
144
+ **物理存活节点 = f(计算流, API 能力, 算法实现)**。三要素缺一不可:
145
+
146
+ - **计算流**:规则 3 产出的完整计算图(含 broadcast),不可简化
147
+ - **API 能力**:芯片/框架能做什么——NDDMA 随路 broadcast、MulAddDst 融合、RegBase 寄存器域
148
+ - **算法实现**:你选择怎么做——broadcast 提前还是延迟、哪些操作融合、用不用 RegBase
149
+
150
+ 同一张计算图,不同实现策略 → 不同物理节点数。物理存活节点不由计算图唯一确定。
151
+
152
+ **计数域**:UB 上同时驻留的 buffer 数。寄存器不计入(UB→Reg→UB 过路中转)。
153
+
154
+ **P ≥ L 恒成立**。逻辑和物理在同一公平基线上——两端都不假设输入输出 buffer 复用。差异只能来自 API 硬件能力。
155
+
156
+ ### 2.2 物理意义
157
+
158
+ 逻辑存活节点回答"至少几个",物理存活节点回答"实际几个"。两者可能一致(P = L),也可能有差距(P > L)。
159
+
160
+ 三要素如何在每一步中起作用:
161
+ 1. 从完整计算图中取一步(broadcast + vXXX)
162
+ 2. 标每个 tensor 的物理数据通路:从哪来(GM 搬入 / UB 驻留 / 上一步产出),broadcast 放在哪步做(随 DataCopy 还是独立),是否有融合指令可用,到哪去(下游哪步用到 / 释放)
163
+ 3. 物理节点 = 此时刻 UB 需同时驻留的不同 buffer 数
164
+ 4. 穷尽算法选择(broadcast 时机、融合配对),取最小的物理节点
165
+
166
+ **公平基线**:逻辑分析不假设复用,物理分析同样不假设。只有硬件融合指令(MulAddDst)自带的复用计入 API 能力。
167
+
168
+ **RegBase 边界**:硬件不支持同一 buffer 同一循环内 in-place read-modify-write。RegBase 对单次二元操作仍需 src0 + src1 + dst 三块独立 UB buffer,价值在性能(减少 UB 读写次数),不在降峰值节点。
169
+
170
+ ### 2.3 可用 API 能力
171
+
172
+ | API | 能力 | 对物理节点的意义 | 来源 |
173
+ |-----|------|-----------------|------|
174
+ | **NDDMA 随路 broadcast** | DataCopy(GM→UB) 时一并 broadcast | 不另占 UB buffer,broadcast 被 DataCopy 消化 | ascendc.md |
175
+ | **MulAddDst** | `dst = src0×src1 + dst`,vmul+vadd 合为 1 条,dst 就地覆写 | 省 1 个 UB 中间 buffer | ascendc.md |
176
+ | **RegBase (Reg::Mul/Add/Sub)** | UB→Reg→UB,中间值留在寄存器 | 将部分 UB 临时 buffer 转移至寄存器,压低 UB 物理节点 | regbase.md |
177
+ | **Reg::Sqrt / Reg::Div** | 寄存器级 Sqrt/Div | **未确认**,需查 reg_vector.h | regbase.md |
178
+
179
+ ### 2.4 融合机会(MulAddDst)
180
+
181
+ ```
182
+ S7: mul0Result = vmul(dataInput2, dataInputMul)
183
+ S9: output1 = vadd(mul0Result, mul1Result)
184
+ → MulAddDst(mul1Result, dataInput2, dataInputMul) → output1
185
+
186
+ S3: mul2Result = vmul(dataInput1, dataInputMul2)
187
+ S4: output0 = vadd(mul2Result, mul3Result)
188
+ → MulAddDst(mul3Result, dataInput1, dataInputMul2) → output0
189
+ ```
190
+
191
+ 条件:中间 vmuls 结果无其他引用,dst(累加器) 被覆写后下游不再需要原值。
192
+
193
+ ### 2.5 物理节点分析
194
+
195
+ NDDMA broadcast + MulAddDst,逐步追踪:
196
+
197
+ ```
198
+ Step 1:
199
+ DC: dataInput0 (GM→UB, NDDMA broadcast) → dataInput0'
200
+ C: vmul(dataInput0', dataInput0') → squareResult
201
+ UB: [dataInput0', squareResult] = 2
202
+
203
+ Step 2:
204
+ DC: dataInputMul1 (GM→UB, NDDMA broadcast) → dataInputMul1'
205
+ C: vmul(dataInput0', dataInputMul1') → mul1Result
206
+ 峰值: [squareResult, dataInput0', dataInputMul1', mul1Result] = 4
207
+ 释放 dataInput0', dataInputMul1'
208
+ UB: [squareResult, mul1Result] = 2
209
+
210
+ Step 3: ← S7+S9 MulAddDst
211
+ DC: dataInput2 (GM→UB, NDDMA broadcast) → dataInput2'
212
+ DC: dataInputMul (GM→UB, NDDMA broadcast) → dataInputMul'
213
+ C: MulAddDst(mul1Result, dataInput2', dataInputMul') → output1
214
+ (硬件融合: dst=mul1Result 就地覆写为 output1)
215
+ 峰值: [squareResult, mul1Result, dataInput2', dataInputMul'] = 4
216
+ 释放 dataInput2', dataInputMul'
217
+ UB: [squareResult, output1] = 2
218
+
219
+ Step 4:
220
+ DC: dataInputMul3 (GM→UB, NDDMA broadcast) → dataInputMul3'
221
+ C: vmul(squareResult, dataInputMul3') → mul3Result
222
+ 峰值: [output1, squareResult, dataInputMul3', mul3Result] = 4
223
+ 释放 squareResult, dataInputMul3'
224
+ UB: [output1, mul3Result] = 2
225
+
226
+ Step 5: ← S3+S4 MulAddDst
227
+ DC: dataInput1 (GM→UB, NDDMA broadcast) → dataInput1'
228
+ DC: dataInputMul2 (GM→UB, NDDMA broadcast) → dataInputMul2'
229
+ C: MulAddDst(mul3Result, dataInput1', dataInputMul2') → output0
230
+ (硬件融合: dst=mul3Result 就地覆写为 output0)
231
+ 峰值: [output1, mul3Result, dataInput1', dataInputMul2'] = 4
232
+ 释放 dataInput1', dataInputMul2'
233
+ UB: [output1, output0] = 2
234
+
235
+ Step 6:
236
+ C: vsqrt(output0) → sqrtResult
237
+ UB: [output1, output0, sqrtResult] = 3
238
+
239
+ Step 7: ← 峰值 ★
240
+ DC: dataInputAdd2 (NDDMA broadcast) → dataInputAdd2'
241
+ C: vadd(sqrtResult, dataInputAdd2') → add2Result
242
+ src0: sqrtResult (读)
243
+ src1: dataInputAdd2' (读)
244
+ dst: add2Result (写, 独立 buffer)
245
+ 峰值: [output1, output0, sqrtResult, dataInputAdd2', add2Result]
246
+ = 2(持久输出) + 3(vadd src0+src1+dst) = 5
247
+ 释放 sqrtResult, dataInputAdd2'
248
+ UB: [output1, output0, add2Result] = 3
249
+
250
+ Step 8:
251
+ C: vdiv(output1, add2Result) → truedivResult
252
+ 峰值: [output1, output0, add2Result, truedivResult] = 4
253
+ 释放 add2Result
254
+ UB: [output1, output0, truedivResult] = 3
255
+
256
+ Step 9: ← 峰值 ★
257
+ DC: input4 (NDDMA broadcast) → input4'
258
+ C: vmul(truedivResult, input4') → mul4Result
259
+ src0: truedivResult (读)
260
+ src1: input4' (读)
261
+ dst: mul4Result (写, 独立 buffer)
262
+ 峰值: [output1, output0, truedivResult, input4', mul4Result]
263
+ = 2(持久输出) + 3(vmul src0+src1+dst) = 5
264
+ 释放 truedivResult, input4'
265
+ UB: [output1, output0, mul4Result] = 3
266
+
267
+ Step 10: ← 峰值 ★
268
+ DC: dataInput3 (NDDMA broadcast) → dataInput3'
269
+ C: vsub(dataInput3', mul4Result) → output2
270
+ src0: dataInput3' (读)
271
+ src1: mul4Result (读)
272
+ dst: output2 (写, 独立 buffer)
273
+ 峰值: [output1, output0, dataInput3', mul4Result, output2]
274
+ = 2(持久输出) + 3(vsub src0+src1+dst) = 5
275
+ 释放 dataInput3', mul4Result
276
+ UB: [output0, output1, output2] = 3 ← 三输出就位
277
+ ```
278
+
279
+ ### 2.6 结论
280
+
281
+ | 指标 | 值 |
282
+ |------|-----|
283
+ | 逻辑下界 L | 5 |
284
+ | **物理存活节点 P** | **5** |
285
+ | P vs L | P = L,打到下界 |
286
+ | 峰值步骤 | Step 7, 9, 10 |
287
+ | 依赖 API | NDDMA broadcast + MulAddDst — **全部已确认** |
288
+ | 瓶颈 | output0+output1 持久化 = 2 上下文,后续二元操作 src0+src1+dst = 3,合 5 |
289
+
290
+ 物理没有低于逻辑——逻辑数 tensor,物理数 UB buffer,两者都不假设输入输出复用。MulAddDst 的复用是硬件能力(不属于软件调度假设),RegBase 无法做到同等的 in-place 覆写。
291
+
292
+ ### 2.7 对本算子的意义
293
+
294
+ - P = 5,perBuffer = 256KB / 5 ≈ 51KB > 48KB ✓
295
+ - tile 长度上限 = 51KB / sizeof(dtype)
296
+ - FP16: ~26K elements/tile
297
+ - FP32: ~13K elements/tile
298
+ - 物理已打到逻辑下界,此算子 Tiling 分析完成
299
+
300
+ ---
301
+
302
+ ## 3. 计算流伪码
303
+
304
+ ### 3.1 核心原则
305
+
306
+ 计算流伪码是 §2 物理存活节点分析的序列化产物。§2 选定了三要素组合(NDDMA broadcast + MulAddDst),伪码就是把这把选择的每一步写成 `DataCopy → 计算 → 释放` 的完整序列。每步标注 UB 驻留数,验证全程 ≤ P。
307
+
308
+ 伪码不是实现——它是物理分析到 kernel 编码之间的桥梁。后续所有设计(计算流验证、输入预处理、UB 切分)都以这份伪码为唯一参照。
309
+
310
+ ### 3.2 物理意义
311
+
312
+ §2 的物理节点分析是"每一步 peak 多少"的抽象论证。伪码把它落实到每一行的具体操作:哪个 buffer 在哪个时刻被创建、被消费、被释放。它回答三个问题:
313
+
314
+ - §2 的 P=5 能否兑现为一个具体的步骤序列?
315
+ - 每步的 UB 驻留是否始终 ≤ P?
316
+ - 融合(MulAddDst)和 broadcast(NDDMA 随路)是否正确嵌入?
317
+
318
+ ### 3.3 计算流伪码
319
+
320
+ ```
321
+ 输入: dataInput0..4, dataInputMul, dataInputMul1..3, dataInputAdd2
322
+ 输出: output0, output1, output2
323
+ 约束: UB 最多同时驻留 5 块 buffer
324
+
325
+ // ─── Step 1: 载入 dataInput0,算 square ───
326
+ DataCopy(dataInput0, GM→UB, NDDMA_broadcast) → bufInput0
327
+ AscendC::Mul(bufSquare, bufInput0, bufInput0) → bufSquare
328
+ // UB: [bufInput0, bufSquare] = 2
329
+
330
+ // ─── Step 2: 载入 mul1_x,算 mul1 ───
331
+ DataCopy(dataInputMul1, GM→UB, NDDMA_broadcast) → bufMul1X
332
+ AscendC::Mul(bufMul1, bufInput0, bufMul1X) → bufMul1
333
+ // 释放 bufInput0, bufMul1X
334
+ // UB: [bufSquare, bufMul1] = 2
335
+
336
+ // ─── Step 3: 载入 dataM + mul0_x,MulAddDst 融合 S7+S9 → output1 ───
337
+ DataCopy(dataInput2, GM→UB, NDDMA_broadcast) → bufDataM
338
+ DataCopy(dataInputMul, GM→UB, NDDMA_broadcast) → bufMul0X
339
+ MulAddDst(bufMul1, bufDataM, bufMul0X) → output1
340
+ // dst=output1 就地覆写 bufMul1
341
+ // 释放 bufDataM, bufMul0X
342
+ // UB: [bufSquare, output1] = 2
343
+
344
+ // ─── Step 4: 载入 mul3_x,算 mul3 ───
345
+ DataCopy(dataInputMul3, GM→UB, NDDMA_broadcast) → bufMul3X
346
+ AscendC::Mul(bufMul3, bufSquare, bufMul3X) → bufMul3
347
+ // 释放 bufSquare, bufMul3X
348
+ // UB: [output1, bufMul3] = 2
349
+
350
+ // ─── Step 5: 载入 dataV + mul2_x,MulAddDst 融合 S3+S4 → output0 ───
351
+ DataCopy(dataInput1, GM→UB, NDDMA_broadcast) → bufDataV
352
+ DataCopy(dataInputMul2, GM→UB, NDDMA_broadcast) → bufMul2X
353
+ MulAddDst(bufMul3, bufDataV, bufMul2X) → output0
354
+ // dst=output0 就地覆写 bufMul3
355
+ // 释放 bufDataV, bufMul2X
356
+ // UB: [output1, output0] = 2
357
+
358
+ // ─── Step 6: sqrt ───
359
+ AscendC::Sqrt(bufSqrt, output0) → bufSqrt
360
+ // UB: [output1, output0, bufSqrt] = 3
361
+
362
+ // ─── Step 7: 载入 add2_y,算 add2 ─── ← 峰值 5
363
+ DataCopy(dataInputAdd2, GM→UB, NDDMA_broadcast) → bufAdd2Y
364
+ AscendC::Add(bufAdd2, bufSqrt, bufAdd2Y) → bufAdd2
365
+ // UB: [output1, output0, bufSqrt, bufAdd2Y, bufAdd2] = 5
366
+ // 释放 bufSqrt, bufAdd2Y
367
+ // UB: [output1, output0, bufAdd2] = 3
368
+
369
+ // ─── Step 8: truediv ───
370
+ AscendC::Div(bufTruediv, output1, bufAdd2) → bufTruediv
371
+ // 释放 bufAdd2
372
+ // UB: [output1, output0, bufTruediv] = 3
373
+
374
+ // ─── Step 9: 载入 input4,算 mul4 ─── ← 峰值 5
375
+ DataCopy(dataInput4, GM→UB, NDDMA_broadcast) → bufInput4
376
+ AscendC::Mul(bufMul4, bufTruediv, bufInput4) → bufMul4
377
+ // UB: [output1, output0, bufTruediv, bufInput4, bufMul4] = 5
378
+ // 释放 bufTruediv, bufInput4
379
+ // UB: [output1, output0, bufMul4] = 3
380
+
381
+ // ─── Step 10: 载入 dataVar,算 sub → output2 ─── ← 峰值 5
382
+ DataCopy(dataInput3, GM→UB, NDDMA_broadcast) → bufDataVar
383
+ Sub(output2, bufDataVar, bufMul4) → output2
384
+ // UB: [output1, output0, bufDataVar, bufMul4, output2] = 5
385
+ // 释放 bufDataVar, bufMul4
386
+ // UB: [output0, output1, output2] = 3
387
+
388
+ // ─── 搬出 ───
389
+ DataCopy(output0, UB→GM)
390
+ DataCopy(output1, UB→GM)
391
+ DataCopy(output2, UB→GM)
392
+ ```
393
+
394
+ ### 3.4 关键设计决策
395
+
396
+ | 决策 | 选择 | 理由 |
397
+ |------|------|------|
398
+ | broadcast 策略 | 全部 DataCopy 时随路 NDDMA broadcast | 不另占 UB buffer |
399
+ | 融合策略 | S7+S9 → MulAddDst, S3+S4 → MulAddDst | 各省 1 中间 buffer |
400
+ | S10a 恒等乘 vmuls(output1,1) | 省略 | x×1.0 数学恒等(IEEE754 下 NaN/±Inf/-0 均不变),原图中是 broadcast 物化的历史产物;kernel 直接以 Div 消费 output1,省每 tile 一次全量向量乘 |
401
+ | output0/output1 持久化 | 保留至搬出,不提前释放 | 下游 truediv 和最终搬出都需要 |
402
+ | RegBase | 不使用 | 该算子二元操作 src 本就在 UB,RegBase 不降节点 |
403
+
404
+ ### 3.5 结论
405
+
406
+ 10 步序列全程 UB 驻留 ≤ 5,P=5 可兑现。NDDMA broadcast 消化了所有独立 broadcast 操作,MulAddDst 消化了 S7+S9 和 S3+S4 的中间 buffer。
407
+
408
+ ### 3.6 对本算子的意义
409
+
410
+ 计算流伪码是后续所有设计阶段的唯一参照:§4 验证语义等价,§5.4 kernel 循环骨架中"执行计算流"段直接嵌入这 10 步的 DataCopy → 计算序列。
411
+
412
+ ---
413
+
414
+ ## 4. 物理计算流验证
415
+
416
+ ### 4.1 核心原则
417
+
418
+ 物理计算流含融合(MulAddDst)、重排等优化,可能与原始算子的计算语义产生偏差。必须在进入编码前,用 numpy 验证优化版和原始版等价。
419
+
420
+ 验证方法:**golden**(原始语义)+ **opt**(§3 优化伪码),全整数随机输入 100 次,`np.array_equal` 判等,不通过不进编码。
421
+
422
+ golden 的来源取决于算子类型:
423
+ - **有竞品(TF/Torch)**:以竞品公式为基准,直接形成 numpy golden 或直接跑竞品代码
424
+ - **无竞品、A2/A3 算子**:基于 A2/A3 源码的计算流,严格逐行翻译为 numpy golden
425
+
426
+ opt 始终按 §3 计算流伪码(含所有融合和重排)实现。
427
+
428
+ ### 4.2 物理意义
429
+
430
+ 融合和重排可能改变浮点累加顺序。全整数输入可规避累加顺序带来的数值差异,但仅对**单次二元操作**有效。
431
+
432
+ **Reduce 类操作的额外风险**:Reduce(如 sum、mean)对累加顺序敏感——不同的归约顺序在浮点下产生不同结果,即便整数验证通过也无法保证浮点等价。若算子含 Reduce,需单独提示用户评估累加顺序偏差是否可接受。
433
+
434
+ ### 4.3 验证文件
435
+
436
+ | 文件 | 内容 |
437
+ |------|------|
438
+ | `adam_apply_one_assign_golden.py` | 源码逐行翻译,标注行号,不掺解读 |
439
+ | `adam_apply_one_assign_opt.py` | 按 §3 计算流伪码实现 |
440
+ | `compare_golden_opt.py` | 对比脚本 |
441
+
442
+ 覆盖 6 种 shape 组合:同形 / 1D 广播 / 标量 / 混合 / 16×32 / 3D。
443
+
444
+ 例:S7+S9 MulAddDst 融合的验证
445
+
446
+ ```
447
+ golden (源码逐行):
448
+ S7: mul0Result = dataInput2 * dataInputMul // shape broadcast
449
+ S9: output1 = mul0Result + mul1Result // shape broadcast
450
+
451
+ opt (MulAddDst 融合):
452
+ MulAddDst(dst=mul1Result, src0=dataInput2, src1=dataInputMul) → output1
453
+ ```
454
+
455
+ 全整数下 `np.array_equal(goldenOutput1, optOutput1) → True`,融合不改变整数语义。
456
+
457
+ ### 4.4 结论
458
+
459
+ 100 次随机整数输入,`np.array_equal` 三输出全部 True。**优化计算流与原始源码语义等价。**
460
+
461
+ ### 4.5 对本算子的意义
462
+
463
+ MulAddDst 融合和调度重排已确认安全,§3 伪码可正式作为 kernel 实现的唯一参照,进入 §5 Tiling 详细设计。
464
+
465
+ ---
466
+
467
+ ## 5. Tiling 详细设计
468
+
469
+ ### 5.1 输入预处理
470
+
471
+ #### 5.1.1 核心原则
472
+
473
+ 输入预处理是几乎每个算子都要做的通用步骤。目标:将不同 shape 的入参和出参归一化,拉到同一个参照系 `maximumBroShape` 下。
474
+
475
+ 预处理产出三类 shape:
476
+ - `maximumBroShape` — 坐标系,所有输入/输出的 broadcast 上界
477
+ - `normalInputShapes` — 归一化后各输入 shape,与 maximumBroShape 同 rank
478
+ - `normalOutputShapes` — 归一化后各输出 shape,与 maximumBroShape 同 rank 且必须稠密(每维等于该维 broadcast 最大值)。广播输出(某维为 1)经 stride=0 映射后多核 tile 落到同一 GM 地址构成写-写数据竞争,且本算子为就地 assign 语义、广播输出无定义,Host 侧直接拒绝
479
+
480
+ 基本操作:
481
+ - **补 1**:低 rank 入参/输出在 shape 最前面补 1,拉齐 rank
482
+ - **去 1**:所有入参/输出都为 1 的轴 squeeze 掉,消除废维度
483
+ - **合轴**:将多个连续轴合并为一个轴,消除维度差异(如 (16,8) → (128,))
484
+
485
+ 预处理只操作 shape 元数据,不碰实际 tensor。在 host 侧一次性完成,device 侧只按统一坐标执行。
486
+
487
+ **参照系的确定**:由计算流伪码决定。不同算子类型推导参照系的方法不同——例如 broadcast 型算子取 broadcastMax(所有入参和输出)。
488
+
489
+ #### 5.1.2 物理意义
490
+
491
+ 不同入参 rank 不同、废维不同、broadcast 关系不同。输出必须稠密——所有输出 shape 均等于 maximumBroShape(广播输出会造成多核写-写数据竞争,Host 侧拒绝)。预处理的产物(maximumBroShape + normalInputShapes + normalOutputShapes)就是这张映射表,device 侧按统一坐标迭代,通过各自 shape 映射回实际数据。
492
+
493
+ #### 5.1.3 去 1 补 1
494
+
495
+ ##### 5.1.3.1 物理意义
496
+
497
+ 入参和出参 rank 可能不同,且对齐后可能出现所有参数都为 1 的废维度。
498
+
499
+ 补 1 约束:**只能在 shape 最前面补 1**——低 rank 入参/输出在 shape 最前面补 1 拉齐到 maxRank,不允许在中间或末尾维度补 1。
500
+
501
+ 归一化后需验证 broadcast 兼容性:对每个维度,若某入参在该维的大小不为 1 且与其他入参同维不为 1 的大小不同,则输出报错日志;同时校验输出稠密性——该维存在非 1 值时输出不允许为 1,否则报错日志。
502
+
503
+ ```
504
+ 补 1 — 低 rank 在 shape 最前面补 1,拉齐到 maxRank(含入参+出参)
505
+ 去 1 — 对齐后,所有入参+出参在某轴都是 1 → squeeze 掉
506
+ 归一 — 去 1 后若 maximumBroShape 为空(全部均为标量),填 (1,)
507
+ 校验 — 归一化后逐维检查:输入同维非 1 大小必须一致;输出必须稠密(该维存在非 1 值时输出不得为 1),违者输出报错日志
508
+
509
+ 产出三样:
510
+ maximumBroShape = broadcastMax(所有入参+出参),后续 UB/多核切分的坐标系
511
+ normalInputShapes = 每入参归一化后 shape,与坐标系同 rank
512
+ normalOutputShapes = 每出参归一化后 shape,与坐标系同 rank 且稠密(= maximumBroShape)
513
+ ```
514
+
515
+ 例 1(正常广播,补 1 个 1):
516
+
517
+ ```
518
+ 入参 A: shape = (4, 8)
519
+ 入参 B: shape = (1, 8)
520
+ 入参 C: shape = (8,) // 在最前面补一个 1 → (1,8)
521
+
522
+ 补 1 → A=(4,8), B=(1,8), C=(1,8) // C 最前面补 1
523
+ 去 1 → dim0: A=4, B=1, C=1 → 不全为 1,保留
524
+ dim1: A=8, B=8, C=8 → 全为 8≠1,保留
525
+ maximumBroShape = (4, 8)
526
+ normal_A = (4, 8) // 非 broadcast
527
+ normal_B = (1, 8) // 轴 0 broadcast
528
+ normal_C = (1, 8) // 轴 0 broadcast
529
+ 校验 → dim0: 4,1,1 → ref=4 ✓
530
+ dim1: 8,8,8 → ref=8 ✓
531
+ ```
532
+
533
+ 例 2(正常广播,补多个 1):
534
+
535
+ ```
536
+ 入参 A: shape = (2, 4, 8)
537
+ 入参 B: shape = (8,) // 在最前面补两个 1 → (1,1,8)
538
+
539
+ 补 1 → A=(2,4,8), B=(1,1,8) // B 最前面补 1,1
540
+ 去 1 → dim0: A=2, B=1 → 不全为 1,保留
541
+ dim1: A=4, B=1 → 不全为 1,保留
542
+ dim2: A=8, B=8 → 全为 8≠1,保留
543
+ maximumBroShape = (2, 4, 8)
544
+ normal_A = (2, 4, 8) // 非 broadcast
545
+ normal_B = (1, 1, 8) // 轴 0、轴 1 broadcast
546
+ 校验 → dim0: 2,1 → ref=2 ✓
547
+ dim1: 4,1 → ref=4 ✓
548
+ dim2: 8,8 → ref=8 ✓
549
+ ```
550
+
551
+ 例 3(broadcast 不兼容报错):
552
+
553
+ ```
554
+ 入参 A: shape = (4, 8)
555
+ 入参 B: shape = (4, 3) // 同 rank,无需补 1
556
+
557
+ 补 1 → A=(4,8), B=(4,3) // 同 rank,无需补 1
558
+ 去 1 → dim0: 4,4 → 不全为 1,保留
559
+ dim1: 8,3 → 不全为 1,保留
560
+ maximumBroShape = (4, 8)
561
+ normal_A = (4, 8)
562
+ normal_B = (4, 3)
563
+ 校验 → dim0: 4,4 → ref=4 ✓
564
+ dim1: 8,3 → 两者均非 1 且 8≠3 → 报错!
565
+ → OP_LOGE_FOR_INVALID_VALUES_WITH_REASON("CheckBroadcastShape", "input size and ref size", "dim 1 input[1] size 3 and 8", "broadcast incompatible: input sizes must be equal or 1")
566
+ → return false
567
+ ```
568
+
569
+ 例 4(标量):
570
+
571
+ ```
572
+ 入参 A: shape = () // 标量
573
+ 入参 B: shape = () // 标量
574
+
575
+ 补 1 → A=(), B=() // rank=0,无轴可补
576
+ 去 1 → maximumBroShape = ()
577
+ 归一 → maximumBroShape = (1,)
578
+ normal_A = (1,)
579
+ normal_B = (1,)
580
+ 校验 → dim0: 1,1 → 全为 1 ✓
581
+ ```
582
+
583
+ ##### 5.1.3.2 函数模块
584
+
585
+ ```
586
+ 函数名:PadAndSqueeze
587
+ 文件归属:Tiling
588
+ 作用:入参+出参归一化 — 最前面补 1 拉 rank、去 1 消废维、标量归一
589
+ in: inputShapes 所有入参原始 shape
590
+ in: outputShapes 所有出参原始 shape
591
+ out: maximumBroShape 坐标系 → TilingData
592
+ out: normalInputShapes 归一化后各入参 shape → TilingData
593
+ out: normalOutputShapes 归一化后各出参 shape → TilingData
594
+ ```
595
+
596
+ ```
597
+ 函数名:CheckBroadcastShape
598
+ 文件归属:Tiling
599
+ 作用:broadcast 兼容校验 — 归一化后逐维检查输入同维非 1 大小是否一致、输出是否稠密,违者报错
600
+ in: paddedIn 补 1 后各入参 shape
601
+ in: paddedOut 补 1 后各出参 shape
602
+ in: maxRank 最大 rank
603
+ ret: bool true=兼容,false=不兼容
604
+ 校验: 输入同维非 1 大小必须一致;输出必须稠密(该维存在非 1 值时输出不得为 1)。违者 OP_LOGE_FOR_INVALID_VALUES_WITH_REASON 报错并返回 false
605
+ ```
606
+
607
+ ```cpp
608
+ bool CheckBroadcastShape(
609
+ const std::vector<std::vector<int64_t>>& paddedIn,
610
+ const std::vector<std::vector<int64_t>>& paddedOut,
611
+ int64_t maxRank)
612
+ {
613
+ for (int64_t d = 0; d < maxRank; d++) {
614
+ int64_t ref = -1;
615
+ for (size_t i = 0; i < paddedIn.size(); i++) {
616
+ if (paddedIn[i][d] != 1) {
617
+ if (ref == -1) ref = paddedIn[i][d];
618
+ else if (paddedIn[i][d] != ref) {
619
+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON("CheckBroadcastShape", "input size and ref size",
620
+ (std::string("dim ") + std::to_string(d) + " input[" + std::to_string(i) +
621
+ "] size " + std::to_string(paddedIn[i][d]) + " and " + std::to_string(ref)).c_str(),
622
+ "broadcast incompatible: input sizes must be equal or 1");
623
+ return false;
624
+ }
625
+ }
626
+ }
627
+ for (size_t i = 0; i < paddedOut.size(); i++) {
628
+ if (paddedOut[i][d] != 1) {
629
+ if (ref == -1) ref = paddedOut[i][d];
630
+ else if (paddedOut[i][d] != ref) {
631
+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON("CheckBroadcastShape", "output size and ref size",
632
+ (std::string("dim ") + std::to_string(d) + " output[" + std::to_string(i) +
633
+ "] size " + std::to_string(paddedOut[i][d]) + " and " + std::to_string(ref)).c_str(),
634
+ "broadcast incompatible: output sizes must be equal or 1");
635
+ return false;
636
+ }
637
+ }
638
+ }
639
+ // 输出稠密性校验: 该维存在非 1 维值 (ref != -1) 时, 输出不允许为广播维 (1)。
640
+ // 广播输出维 stride=0, 多核 tile 映射到同一 GM 地址并发写, 构成写-写数据竞争,
641
+ // 且本算子为就地 assign 语义, 广播输出无定义, Host 侧直接拒绝。
642
+ if (ref != -1) {
643
+ for (size_t i = 0; i < paddedOut.size(); i++) {
644
+ if (paddedOut[i][d] == 1) {
645
+ OP_LOGE_FOR_INVALID_VALUES_WITH_REASON("CheckBroadcastShape", "output size and ref size",
646
+ (std::string("dim ") + std::to_string(d) + " output[" + std::to_string(i) +
647
+ "] size 1 and " + std::to_string(ref)).c_str(),
648
+ "broadcast output is not supported: output must be dense (equal to broadcast max dim)");
649
+ return false;
650
+ }
651
+ }
652
+ }
653
+ }
654
+ return true;
655
+ }
656
+
657
+ bool PadAndSqueeze(
658
+ const std::vector<std::vector<int64_t>>& inputShapes,
659
+ const std::vector<std::vector<int64_t>>& outputShapes,
660
+ std::vector<int64_t>& maximumBroShape,
661
+ std::vector<std::vector<int64_t>>& normalInputShapes,
662
+ std::vector<std::vector<int64_t>>& normalOutputShapes
663
+ ) {
664
+ int64_t numInputs = (int64_t)inputShapes.size();
665
+ int64_t numOutputs = (int64_t)outputShapes.size();
666
+
667
+ // 合并所有 shape 找 maxRank
668
+ int64_t maxRank = 0;
669
+ for (auto& s : inputShapes) maxRank = std::max(maxRank, (int64_t)s.size());
670
+ for (auto& s : outputShapes) maxRank = std::max(maxRank, (int64_t)s.size());
671
+
672
+ // 补 1 — 低 rank 在 shape 最前面补 1
673
+ auto padShape = [&](const std::vector<int64_t>& s) {
674
+ std::vector<int64_t> p;
675
+ int64_t pad = maxRank - (int64_t)s.size();
676
+ p.assign(pad, 1);
677
+ p.insert(p.end(), s.begin(), s.end());
678
+ return p;
679
+ };
680
+ std::vector<std::vector<int64_t>> paddedIn(numInputs), paddedOut(numOutputs);
681
+ for (int64_t i = 0; i < numInputs; i++) paddedIn[i] = padShape(inputShapes[i]);
682
+ for (int64_t i = 0; i < numOutputs; i++) paddedOut[i] = padShape(outputShapes[i]);
683
+
684
+ // 去 1 — 所有入参+出参都为 1 的轴 squeeze,其余轴取 max
685
+ maximumBroShape.clear();
686
+ normalInputShapes.assign(numInputs, std::vector<int64_t>());
687
+ normalOutputShapes.assign(numOutputs, std::vector<int64_t>());
688
+ for (int64_t d = 0; d < maxRank; d++) {
689
+ bool allOne = true;
690
+ int64_t maxDim = 0;
691
+ for (int64_t i = 0; i < numInputs; i++) { if (paddedIn[i][d] != 1) allOne = false; maxDim = std::max(maxDim, paddedIn[i][d]); }
692
+ for (int64_t i = 0; i < numOutputs; i++) { if (paddedOut[i][d] != 1) allOne = false; maxDim = std::max(maxDim, paddedOut[i][d]); }
693
+ if (!allOne) {
694
+ maximumBroShape.push_back(maxDim);
695
+ for (int64_t i = 0; i < numInputs; i++) normalInputShapes[i].push_back(paddedIn[i][d]);
696
+ for (int64_t i = 0; i < numOutputs; i++) normalOutputShapes[i].push_back(paddedOut[i][d]);
697
+ }
698
+ }
699
+
700
+ // 归一:全标量 → (1,)
701
+ if (maximumBroShape.empty()) {
702
+ maximumBroShape.push_back(1);
703
+ for (int64_t i = 0; i < numInputs; i++) normalInputShapes[i].push_back(1);
704
+ for (int64_t i = 0; i < numOutputs; i++) normalOutputShapes[i].push_back(1);
705
+ }
706
+
707
+ return true;
708
+ }
709
+ ```
710
+
711
+ ##### 5.1.3.3 验证文件
712
+
713
+ | 文件 | 内容 |
714
+ |------|------|
715
+ | `verify/test_pad_and_squeeze.cpp` | 去 1 补 1 自验证程序 |
716
+
717
+ 覆盖:100 次随机 shape 组合(2~10 入参,rank 1~5,dim 1~16),不变量全部满足。✅
718
+
719
+ 例(补 1 个 1):
720
+ ```
721
+ 输入: A=(4,8), B=(1,8), C=(8,)
722
+
723
+ 补 1 → C 最前面补 1 → A=(4,8), B=(1,8), C=(1,8)
724
+ 去 1 → dim0: A=4, B=1, C=1 → 不全为1保留
725
+ dim1: A=8, B=8, C=8 → 全8≠1保留
726
+
727
+ expected: maximumBroShape = (4,8)
728
+ normal_A = (4,8), normal_B = (1,8), normal_C = (1,8)
729
+ actual: maximumBroShape = (4,8) ✓
730
+ normal_A = (4,8), normal_B = (1,8), normal_C = (1,8) ✓
731
+ 校验 → dim0: 4,1,1 → ref=4 ✓; dim1: 8,8,8 → ref=8 ✓
732
+ ```
733
+
734
+ 例(补多个 1):
735
+ ```
736
+ 输入: A=(2,4,8), B=(8,)
737
+
738
+ 补 1 → B 最前面补 1,1 → A=(2,4,8), B=(1,1,8)
739
+ 去 1 → dim0: A=2, B=1 → 不全为1保留
740
+ dim1: A=4, B=1 → 不全为1保留
741
+ dim2: A=8, B=8 → 全8≠1保留
742
+
743
+ expected: maximumBroShape = (2,4,8)
744
+ normal_A = (2,4,8), normal_B = (1,1,8)
745
+ actual: maximumBroShape = (2,4,8) ✓
746
+ normal_A = (2,4,8), normal_B = (1,1,8) ✓
747
+ 校验 → dim0: 2,1 → ref=2 ✓; dim1: 4,1 → ref=4 ✓; dim2: 8,8 → ref=8 ✓
748
+ ```
749
+
750
+ 例(broadcast 不兼容报错):
751
+ ```
752
+ 输入: A=(4,8), B=(4,3)
753
+
754
+ 补 1 → A=(4,8), B=(4,3) // 同 rank,无需补 1
755
+ 去 1 → dim0: 4,4 → 不全为1保留; dim1: 8,3 → 不全为1保留
756
+ 校验 → dim1: A=8, B=3 均非 1 且 8≠3
757
+ → OP_LOGE_FOR_INVALID_VALUES_WITH_REASON("CheckBroadcastShape", "input size and ref size", "dim 1 input[1] size 3 and 8", "broadcast incompatible: input sizes must be equal or 1")
758
+ → return false ✓
759
+ ```
760
+
761
+ ##### 5.1.3.4 结论
762
+
763
+ 补 1 仅在 shape 最前面。去 1 消废维后,maximumBroShape 统一到 ≥1 rank,无废维度,标量已归一为 (1,)。normalInputShapes 和 normalOutputShapes 均与坐标系同 rank,输入 dim=1 标识 broadcast 轴,输出必须稠密(无 dim=1 轴)。归一化完成后由 CheckBroadcastShape 逐维校验 broadcast 兼容性(输入同维非 1 大小不一致、或输出存在广播维则报错)。
764
+
765
+ ##### 5.1.3.5 对本算子的意义
766
+
767
+ maximumBroShape + normalInputShapes + normalOutputShapes 交付给 5.2 做 UB 切分坐标系,交付给 5.5 做各入参/出参的 GM 偏移和搬运量计算。broadcast 兼容校验在 Tiling 侧提前拦截非法 shape 组合,避免 kernel 侧运行时异常。
768
+
769
+ ---
770
+
771
+ ### 5.2 UB 切分
772
+
773
+ #### 5.2.1 核心原则
774
+
775
+ UB 切分解决"有效数据远超单 buffer 容量"的问题。以 maximumBroShape 为坐标系,选一根轴切分——内侧全带进 UB,外侧循环迭代。切分因子由物理存活节点 P 框定的 buffer 上限 + UB 最大利用率原则共同决定。
776
+
777
+ 切分对象 = maximumBroShape(所有入参 broadcast 的最大坐标系)。目前仅含单切分——从最内轴向外扫描,算子用这一种即可实现功能全覆盖 + 部分场景性能最优。后续学习过程中会陆续引入新的切分算法。
778
+
779
+ #### 5.2.2 物理意义
780
+
781
+ UB 切分轴选择,三处依据汇到一个决策:
782
+
783
+ 1. **切分对象 = maximumBroShape**。基于它切分兼容所有小 shape 场景(部分场景非最优性能,后续性能模板可替换)。
784
+ 2. **单切分模型**。被切分轴 a = ubOuter × ubFactor。ubFactor 及所有内侧轴为「UB 内轴」;ubOuter 至最外侧轴为「UB 外轴」,是 UB 外的 for 循环。
785
+ 3. **单 buffer 上限 = UB/P**。来自 §2 物理存活节点,ubFactor × inner ≤ perBufferElems。
786
+
787
+ #### 5.2.3 UB 单切分
788
+
789
+ ##### 5.2.3.1 物理意义
790
+
791
+ 选轴方法:从最内轴向最外轴扫描,累积内侧轴连乘 inner。当 dK × inner > perBufferElems 时,该轴无法全量随内侧轴放入 buffer——在此切分。
792
+
793
+ ```
794
+ inner = 1
795
+ for k from rank-1 down to 0:
796
+ if dK × inner > perBufElems: → split at k, ubFactor = perBufElems / inner
797
+ inner ×= dK
798
+ ```
799
+
800
+ 边界:
801
+ - d_{n-1} > perBufElems → 在最末轴切分,ubFactor = perBufElems
802
+ - 全量 ≤ perBufElems → 走到 k=0 也不超,ubSplitIdx=0, ubFactor = d_0, ubOuter = 1
803
+ - 选轴永不失败——至少有一根可切轴
804
+
805
+ ##### 5.2.3.2 函数模块
806
+
807
+ ```
808
+ 数据结构:SplitResult
809
+ 文件归属:Tiling → TilingData
810
+ 字段:
811
+ ubSplitIdx 选中的切分轴
812
+ ubFactor 内切因子
813
+ ubOuter 外切因子(外循环轮数)
814
+ ubTail 尾轮内切因子(dK % ubFactor,整除时为 ubFactor)
815
+ ```
816
+
817
+ ```cpp
818
+ struct SplitResult {
819
+ int64_t ubSplitIdx;
820
+ int64_t ubFactor;
821
+ int64_t ubOuter;
822
+ int64_t ubTail;
823
+ };
824
+ ```
825
+
826
+ ```
827
+ 函数名:FindSplitAxis
828
+ 文件归属:Tiling
829
+ 作用:UB 单切分选轴 — 从最内轴向外扫描,dK × inner > perBufElems 时在 k 切分
830
+ in: maximumBroShape 有效 shape(坐标系)
831
+ in: dtypeSize sizeof(dtype)
832
+ in: ubPerCore UB = 256 × 1024
833
+ in: physNodes 物理存活节点数 P
834
+ out: out SplitResult → TilingData
835
+ ```
836
+
837
+ ```cpp
838
+ // Ops::Base::CeilDiv 需在 tiling 侧 #include "util/math_util.h"(位于 op_common/op_host 下)
839
+ void FindSplitAxis(
840
+ const std::vector<int64_t>& maximumBroShape,
841
+ int64_t dtypeSize,
842
+ int64_t ubPerCore,
843
+ int64_t physNodes,
844
+ SplitResult & out
845
+ ) {
846
+ int64_t perBufBytes = (ubPerCore / physNodes) & UB_ALIGN_MASK; // 32B 对齐 (TBuf 硬件要求)
847
+ int64_t perBufElems = perBufBytes / dtypeSize;
848
+ int64_t rank = (int64_t)maximumBroShape.size();
849
+
850
+ int64_t inner = 1;
851
+ for (int64_t k = rank - 1; k >= 0; k--) {
852
+ if (maximumBroShape[k] * inner > perBufElems) {
853
+ out.ubFactor = perBufElems / inner;
854
+ out.ubOuter = Ops::Base::CeilDiv(maximumBroShape[k], out.ubFactor);
855
+ int64_t rem = maximumBroShape[k] % out.ubFactor;
856
+ out.ubTail = (rem == 0) ? out.ubFactor : rem;
857
+ out.ubSplitIdx = k;
858
+ return;
859
+ }
860
+ if (k == 0) {
861
+ out.ubSplitIdx = 0;
862
+ out.ubFactor = maximumBroShape[0];
863
+ out.ubOuter = 1;
864
+ out.ubTail = maximumBroShape[0];
865
+ return;
866
+ }
867
+ inner *= maximumBroShape[k];
868
+ }
869
+ }
870
+ ```
871
+
872
+ ##### 5.2.3.3 验证文件
873
+
874
+ | 文件 | 内容 |
875
+ |------|------|
876
+ | `verify/test_find_split_axis.cpp` | FindSplitAxis 自验证程序 |
877
+
878
+ 覆盖:8 固定 case + 100 次随机 shape(rank 1~5,dim 1~200000,FP16/FP32,P=3/5/7),不变量全部满足。✅
879
+
880
+ 例:
881
+ ```
882
+ 输入:maximumBroShape=(200000, 200000), dtype=FP16, P=5
883
+ perBufElems = 256K/5 / 2 = 26214
884
+
885
+ k=1: d_1=200000 > 26214 → split at ubSplitIdx=1
886
+ ubFactor = 26214/1 = 26214
887
+ ubOuter = ceil(200000/26214) = 8
888
+ ubTail = 200000 % 26214 = 16552
889
+
890
+ expected: ubSplitIdx=1, ubFactor=26214, ubOuter=8, ubTail=16552 ✓
891
+ ```
892
+
893
+ ##### 5.2.3.4 结论
894
+
895
+ 选轴永不失败,ubFactor × inner ≤ perBufElems 恒成立。
896
+
897
+ ##### 5.2.3.5 对本算子的意义
898
+
899
+ SplitResult 交付给 5.3 做多核切分、5.4 做 kernel 循环骨架。
900
+
901
+ ---
902
+
903
+ ### 5.3 多核切分
904
+
905
+ #### 5.3.1 核心原则
906
+
907
+ 多核切分的轴天然在 UB 外轴上选择——UB 内轴是一个 tile 的原子单位,不可跨核拆分。切分顺序是先 UB 再 多核,两刀独立。核间无数据交互,纯 data-parallel,各自 UB 独立,遵守相同的物理存活节点约束。
908
+
909
+ #### 5.3.2 物理意义
910
+
911
+ 三个要素:
912
+
913
+ ```
914
+ 要素 1 — UB 内外轴(FindSplitAxis 产出)
915
+
916
+ maximumBroShape = (d_0, ... , d_{k-1}, dK, d_{k+1}, ... , d_{n-1})
917
+ ↑ 切分轴
918
+ UB 外轴: d_0 × ... × d_{k-1} × ubOuter (ubOuter 含主/尾两段)
919
+ UB 内轴: ubFactor × d_{k+1} × ... × d_{n-1}
920
+
921
+ 多核切分的候选轴天然落在 UB 外轴集合里——UB 内轴是一个 tile 的原子单位,
922
+ 不能被拆到多个核上。
923
+
924
+ 要素 2 — 先切 UB,再切多核
925
+
926
+ 第一刀(UB 切分):沿轴 k 切,产生 UB 主块(ubFactor)和 UB 尾块(ubTail)。
927
+ 第二刀(多核切分):在 UB 外轴的迭代空间上按核分配。多核切分不关心 ubOuter 的
928
+ 主/尾边界——它对 UB 外轴的空间做划分,产生多核主块(正常核)和多核尾块(尾核)。
929
+
930
+ 两刀先后独立,第二刀不区分第一刀的内部结构。因此一个核的迭代区间内可能同时
931
+ 覆盖 UB 主块和 UB 尾块——产生四种组合:
932
+
933
+ ┌────────────┬─────────────────────┬──────────────────────┐
934
+ │ │ UB 主块 (ubFactor) │ UB 尾块 (ubTail) │
935
+ ├────────────┼─────────────────────┼──────────────────────┤
936
+ │ 多核主块 │ 主-主 │ 主-尾 │
937
+ │ (正常核) │ ubFactor × inner 全量搬运 │ ubTail × inner 搬运 │
938
+ ├────────────┼─────────────────────┼──────────────────────┤
939
+ │ 多核尾块 │ 尾-主 │ 尾-尾 │
940
+ │ (尾核) │ ubFactor × inner 全量搬运 │ ubTail × inner 搬运 │
941
+ └────────────┴─────────────────────┴──────────────────────┘
942
+
943
+ 四种块的区别:搬运尺寸不同(ubFactor vs ubTail)× 迭代次数不同(主核 vs 尾核)。
944
+ ```
945
+
946
+ #### 5.3.3 函数模块
947
+
948
+ ```
949
+ 数据结构:MultiCoreResult
950
+ 文件归属:Tiling → TilingData
951
+ 字段:
952
+ usedCoreNum 实际使用的核数(≤ maxCores, ≤ totalTiles)
953
+ totalTiles UB 外轴迭代空间的总 tile 数
954
+ mainTiles 每核主块 tile 数 = CeilDiv(totalTiles, usedCoreNum)
955
+ mainCoreNum 主核数量(前 mainCoreNum 核各处理 mainTiles 块,其余核各处理 mainTiles-1 块)
956
+ ```
957
+
958
+ ```cpp
959
+ struct MultiCoreResult {
960
+ int64_t usedCoreNum;
961
+ int64_t totalTiles;
962
+ int64_t mainTiles;
963
+ int64_t mainCoreNum;
964
+ };
965
+ ```
966
+
967
+ ```
968
+ 函数名:MultiCoreSplit
969
+ 文件归属:Tiling
970
+ 作用:UB 外轴迭代空间按核均分 — 前 mainCoreNum 核各处理 mainTiles 块,其余核各处理 mainTiles-1 块
971
+ in: maximumBroShape 有效 shape
972
+ in: ubSplit FindSplitAxis 输出
973
+ in: maxCores 可用总核数(如 56)
974
+ out: out MultiCoreResult → TilingData
975
+ ```
976
+
977
+ ```cpp
978
+ bool MultiCoreSplit(
979
+ const std::vector<int64_t>& maximumBroShape,
980
+ const SplitResult & ubSplit,
981
+ int64_t maxCores,
982
+ MultiCoreResult & out
983
+ ) {
984
+ int64_t k = ubSplit.ubSplitIdx;
985
+ int64_t outerProd = 1;
986
+ for (int64_t j = 0; j < k; j++) {
987
+ outerProd *= maximumBroShape[j];
988
+ }
989
+ out.totalTiles = outerProd * ubSplit.ubOuter;
990
+
991
+ out.usedCoreNum = (out.totalTiles < maxCores) ? out.totalTiles : maxCores;
992
+ out.mainTiles = Ops::Base::CeilDiv(out.totalTiles, out.usedCoreNum);
993
+ out.mainCoreNum = out.totalTiles - (out.mainTiles - 1) * out.usedCoreNum;
994
+
995
+ return true;
996
+ }
997
+ ```
998
+
999
+ #### 5.3.4 验证文件
1000
+
1001
+ | 文件 | 内容 |
1002
+ |------|------|
1003
+ | `verify/test_multi_core_split.cpp` | MultiCoreSplit 自验证程序 |
1004
+
1005
+ 覆盖:8 固定 case + 100 次随机(rank 2~5,dim 1~1000,maxCores 1~56),不变量全部满足。✅
1006
+
1007
+ 例:
1008
+ ```
1009
+ 输入:maximumBroShape=(100, 200, 300), ubSplit.ubSplitIdx=1, ubSplit.ubOuter=8, maxCores=56
1010
+ outerProd = 100, totalTiles = 100 × 8 = 800
1011
+
1012
+ usedCoreNum = min(800, 56) = 56
1013
+ mainTiles = ceil(800 / 56) = 15
1014
+ mainCoreNum = 800 - (15-1) × 56 = 16
1015
+
1016
+ expected: usedCoreNum=56, totalTiles=800, mainTiles=15, mainCoreNum=16 ✓
1017
+ 验证:15 × 16 + 14 × 40 = 240 + 560 = 800 = totalTiles ✓
1018
+ ```
1019
+
1020
+ #### 5.3.5 结论
1021
+
1022
+ totalTiles > 0,usedCoreNum ≤ maxCores 且每核 tile 数差 ≤ 1,核间负载均衡。
1023
+
1024
+ #### 5.3.6 对本算子的意义
1025
+
1026
+ MultiCoreResult 交付给 5.4 做 kernel 循环骨架(GetCoreRange)。
1027
+
1028
+ ---
1029
+
1030
+ ### 5.4 Kernel 循环骨架
1031
+
1032
+ #### 5.4.1 核心原则
1033
+
1034
+ §5.2 切出了 UB 内/外轴,§5.3 把 UB 外轴空间按核均分。kernel 侧需要回答两个问题:
1035
+
1036
+ 1. **UB 外循环怎么跑** — 每个核分别跑哪些 tile?
1037
+ 2. **每轮用主块还是尾块** — 这轮用 `ubFactor` 还是 `ubTail`?
1038
+
1039
+ 答案来自两个函数:`GetCoreRange` 给出纵向区间,`GetUBSplitRange` 给出横向段长,两者正交产生四种块,不需预分类。
1040
+
1041
+ #### 5.4.2 物理意义
1042
+
1043
+ **UB 外循环 = flatten 迭代**
1044
+
1045
+ UB 外轴空间打平为一维,`ubOuter` 是最内维:
1046
+
1047
+ ```
1048
+ flatten 空间 = (d_0 × d_1 × ... × d_{k-1}) × ubOuter
1049
+ ↑ ubOuter 是最内循环
1050
+ ```
1051
+
1052
+ `MultiCoreResult` 已算出每核 tile 区间。`GetCoreRange(coreId)` 算出 `[start, end)`。
1053
+
1054
+ **主/尾块判定 = `flat % ubOuter`**
1055
+
1056
+ 不需要坐标映射。`ubOuter` 是 flatten 空间的最内维,直接取模:
1057
+
1058
+ ```
1059
+ ubBlockIdx = flat % ubOuter
1060
+ → ubBlockIdx == ubOuter - 1 → UB 尾块(ubTail)
1061
+ → 其余 → UB 主块(ubFactor)
1062
+ ```
1063
+
1064
+ **四种块是两套判定的自然结果**
1065
+
1066
+ 纵向 `GetCoreRange`(多核主/尾)× 横向 `GetUBSplitRange`(UB 主/尾),产生四种组合。kernel 不需要预分类,迭代到具体 flat 时两套判定正交生效即可。
1067
+
1068
+ #### 5.4.3 函数模块
1069
+
1070
+ ##### GetCoreRange
1071
+
1072
+ ```
1073
+ 函数名:GetCoreRange
1074
+ 文件归属:Kernel
1075
+ 作用:每核 flatten 迭代范围,前 mainCoreNum 核各处理 mainTiles 块,其余核各处理 mainTiles-1 块
1076
+ in: coreId 当前核编号
1077
+ in: usedCoreNum 总核数
1078
+ in: totalTiles 总 tile 数
1079
+ in: mainTiles 每核主块 tile 数
1080
+ in: mainCoreNum 主核数
1081
+ out: start, end 该核 [start, end) tile 区间
1082
+ ```
1083
+
1084
+ ```cpp
1085
+ inline void GetCoreRange(
1086
+ int64_t coreId,
1087
+ int64_t usedCoreNum,
1088
+ int64_t totalTiles,
1089
+ int64_t mainTiles,
1090
+ int64_t mainCoreNum,
1091
+ int64_t& start,
1092
+ int64_t& end
1093
+ ) {
1094
+ if (coreId < mainCoreNum) {
1095
+ start = coreId * mainTiles;
1096
+ end = start + mainTiles;
1097
+ } else {
1098
+ start = mainCoreNum * mainTiles
1099
+ + (coreId - mainCoreNum) * (mainTiles - 1);
1100
+ end = start + mainTiles - 1;
1101
+ }
1102
+ }
1103
+ ```
1104
+
1105
+ ##### GetUBSplitRange
1106
+
1107
+ ```
1108
+ 函数名:GetUBSplitRange
1109
+ 文件归属:Kernel
1110
+ 作用:本轮切分轴段长,ubOuter 最后一段用 ubTail,其余用 ubFactor
1111
+ in: ubBlockIdx 当前 flat 在 ubOuter 上的段号
1112
+ in: ubOuter ubOuter 总段数
1113
+ in: ubFactor 切分轴主段长
1114
+ in: ubTail 切分轴尾段长
1115
+ ret: 切分轴段长(非元素总数)
1116
+ ```
1117
+
1118
+ ```cpp
1119
+ inline int64_t GetUBSplitRange(
1120
+ int64_t ubBlockIdx,
1121
+ int64_t ubOuter,
1122
+ int64_t ubFactor,
1123
+ int64_t ubTail
1124
+ ) {
1125
+ return (ubBlockIdx == ubOuter - 1) ? ubTail : ubFactor;
1126
+ }
1127
+ ```
1128
+
1129
+ ##### 主循环
1130
+
1131
+ ```
1132
+ // 入参:SplitResult + MultiCoreResult
1133
+
1134
+ int64_t start, end;
1135
+ GetCoreRange(coreId, usedCoreNum, totalTiles, mainTiles, mainCoreNum, start, end);
1136
+
1137
+ for (int64_t flat = start; flat < end; flat++) {
1138
+ int64_t ubBlockIdx = flat % ubOuter;
1139
+ int64_t ubBlockLength = GetUBSplitRange(ubBlockIdx, ubOuter, ubFactor, ubTail); // 切分轴段长
1140
+
1141
+ // DataCopy GM→UB (偏移计算见 §5.5)
1142
+ // 执行计算流
1143
+ // DataCopy UB→GM
1144
+ }
1145
+ ```
1146
+
1147
+ #### 5.4.4 验证文件
1148
+
1149
+ | 文件 | 内容 |
1150
+ |------|------|
1151
+ | `verify/test_tile_iter_control.cpp` | GetCoreRange + GetUBSplitRange 自验证程序 |
1152
+
1153
+ 覆盖:8 固定 case + 100 次随机 shape(rank 2~5,dim 1~20,FP16/FP32,P=3/5/7,maxCores 1~56),不变量全部满足。✅
1154
+
1155
+ 例:
1156
+ ```
1157
+ 输入:maximumBroShape=(4, 7), ubSplitIdx=1, ubOuter=3, ubFactor=3, ubTail=1
1158
+ totalTiles=4×3=12, mainTiles=ceil(12/5)=3, mainCoreNum=12-(3-1)×5=2, usedCoreNum=5, coreId=0
1159
+
1160
+ GetCoreRange(0, 5, 12, 3, 2):
1161
+ coreId=0 < mainCoreNum=2 → start=0×3=0, end=3
1162
+ 该核跑 flat ∈ [0, 3)
1163
+
1164
+ flat=0: ubBlockIdx=0, GetUBSplitRange(0, 3, 3, 1)=3 (主段, 搬 3×inner)
1165
+ flat=1: ubBlockIdx=1, GetUBSplitRange(1, 3, 3, 1)=3 (主段, 搬 3×inner)
1166
+ flat=2: ubBlockIdx=2, GetUBSplitRange(2, 3, 3, 1)=1 (尾段, 搬 1×inner, ubTail≠ubFactor)
1167
+ → 核 0:2 个主段 + 1 个尾段 = 3 tiles ✓
1168
+ ```
1169
+
1170
+ #### 5.4.5 结论
1171
+
1172
+ GetCoreRange + GetUBSplitRange 两函数覆盖 kernel 循环全部跑法,四种块无需预分类。
1173
+
1174
+ #### 5.4.6 对本算子的意义
1175
+
1176
+ 主循环伪码直接嵌入 kernel 实现,§5.5 在此基础上补完地址偏移。
1177
+
1178
+ ---
1179
+
1180
+ ### 5.5 地址偏移计算
1181
+
1182
+ #### 5.5.1 核心原则
1183
+
1184
+ kernel 循环在 output shape 坐标系上迭代(`flat`、`ubBlockLength`)。DataCopy 要的是每个 tensor 在自己 shape 空间里的 GM 始址和搬运量。对输出——输出稠密(shape=maximumBroShape),需要 stride 预计算完成坐标系到 GM 偏移的线性映射。对输入——坐标系不同,需要从 output shape 坐标映射回各入参自身 shape:broadcast 轴 dim=1 锁 0,其余轴照搬。映射逻辑在 Tiling 侧预计算为 stride(broadcast 轴设 0),kernel 侧只剩乘加。
1185
+
1186
+ #### 5.5.2 物理意义
1187
+
1188
+ 地址计算分两路:
1189
+
1190
+ - **输出**:输出稠密,normalOutputShape=maximumBroShape。effCoord 通过预计算 stride 映射为 GM 偏移。搬运量按输出自身 shape 计算。
1191
+ - **输入**:每个入参有自己的 normalInputShape,需要从 maximumBroShape 坐标映射回入参实际坐标——broadcast 轴 dim=1 锁 0,stride 预计算(broadcast 轴设 0)。搬运量按入参自身 shape 计算,切分轴 broadcast 则只搬 1 份。
1192
+
1193
+ #### 5.5.3 函数模块
1194
+
1195
+ ##### FlatToEffectiveCoord
1196
+
1197
+ ```
1198
+ 函数名:FlatToEffectiveCoord
1199
+ 文件归属:Kernel
1200
+ 作用:flat → 多维坐标
1201
+ in: flat 当前 flat tile 索引
1202
+ in: maxBroShape 坐标系指针 (int64_t[RANK])
1203
+ in: rank 维度数
1204
+ in: ubSplitIdx 切分轴 k
1205
+ in: ubFactor 切分轴主段长
1206
+ in: ubOuter ubOuter 段数
1207
+ out: effCoord 输出坐标 (int64_t[RANK])
1208
+ ```
1209
+
1210
+ ```cpp
1211
+ bool FlatToEffectiveCoord(
1212
+ int64_t flat, const int64_t* maxBroShape, int64_t rank,
1213
+ int64_t ubSplitIdx, int64_t ubFactor, int64_t ubOuter,
1214
+ int64_t* effCoord)
1215
+ {
1216
+ for (int64_t d = 0; d < rank; d++) effCoord[d] = 0;
1217
+ int64_t ubBlockIdx = flat % ubOuter;
1218
+ int64_t outer = flat / ubOuter;
1219
+ for (int64_t d = ubSplitIdx - 1; d >= 0; d--) {
1220
+ effCoord[d] = outer % maxBroShape[d];
1221
+ outer /= maxBroShape[d];
1222
+ }
1223
+ effCoord[ubSplitIdx] = ubBlockIdx * ubFactor;
1224
+ return true;
1225
+ }
1226
+ ```
1227
+
1228
+ 例:maximumBroShape=(4,6,5),切 k=1,ubFactor=2,ubOuter=3
1229
+
1230
+ ```
1231
+ flatten 空间 = d_0 × ubOuter = 4 × 3 = 12 个 tile
1232
+
1233
+ flat=0: ubBlockIdx=0, outer=0 → coord=(0, 0, 0)
1234
+ flat=1: ubBlockIdx=1, outer=0 → coord=(0, 2, 0)
1235
+ flat=2: ubBlockIdx=2, outer=0 → coord=(0, 4, 0)
1236
+ flat=3: ubBlockIdx=0, outer=1 → coord=(1, 0, 0)
1237
+ flat=4: ubBlockIdx=1, outer=1 → coord=(1, 2, 0)
1238
+ ...
1239
+ flat=11: ubBlockIdx=2, outer=3 → coord=(3, 4, 0)
1240
+
1241
+ outer 用 radix 展开还原轴 0 坐标:outer=1 → coord[0]=1%4=1
1242
+ ubBlockIdx 乘 ubFactor 得轴 1 偏移:ubBlockIdx=1 → coord[1]=1×2=2
1243
+ 内侧轴(轴 2)填 0:coord[2]=0
1244
+ ```
1245
+
1246
+ ##### 输入地址 — GM 偏移
1247
+
1248
+ `effCoord` → 入参 GM 元素偏移。broadcast 轴 dim=1 → 坐标锁 0。stride 在 Tiling 侧预计算(broadcast 轴设 0),kernel 侧纯乘加。GlobalTensor::operator[] 取元素索引,非字节。
1249
+
1250
+ ```
1251
+ 函数名:PrecomputeStrides
1252
+ 文件归属:Tiling
1253
+ 作用:预计算某个入参/输出的 stride,broadcast 轴设 0(输入与输出规则相同,同一函数复用)
1254
+ in: normalShape 该入参/输出归一化后 shape
1255
+ out: strides broadcast 轴 = 0,其余 = Π_{j>d} normalShape[j] → TilingData
1256
+ ```
1257
+
1258
+ ```cpp
1259
+ bool PrecomputeStrides(
1260
+ const std::vector<int64_t>& normalShape,
1261
+ std::vector<int64_t>& strides
1262
+ ) {
1263
+ int64_t rank = (int64_t)normalShape.size();
1264
+ strides.assign(rank, 0);
1265
+ for (int64_t d = rank - 1; d >= 0; d--) {
1266
+ if (normalShape[d] == 1) {
1267
+ strides[d] = 0;
1268
+ } else {
1269
+ int64_t prod = 1;
1270
+ for (int64_t j = d + 1; j < rank; j++) {
1271
+ prod *= normalShape[j];
1272
+ }
1273
+ strides[d] = prod;
1274
+ }
1275
+ }
1276
+ return true;
1277
+ }
1278
+ ```
1279
+
1280
+ 例:normalInputShape = (4, 1, 8),rank=3
1281
+
1282
+ ```
1283
+ d=2: dim=8≠1 → stride[2] = Π_{j>2} = 1 (最内侧,右侧无轴)
1284
+ d=1: dim=1 → stride[1] = 0 (broadcast 轴)
1285
+ d=0: dim=4≠1 → stride[0] = Π_{j>0} = 1×8 = 8
1286
+
1287
+ strides = [8, 0, 1]
1288
+
1289
+ 对 effCoord=(2, 0, 5):
1290
+ offset = 2×8 + 0×0 + 5×1 = 21 elements (轴1的0×0自动归零,不受effCoord[1]影响)
1291
+ ```
1292
+
1293
+ ```
1294
+ 函数名:CalcOffset
1295
+ 文件归属:Kernel
1296
+ 作用:有效坐标 + stride → GM 元素偏移(GlobalTensor::operator[] 取元素索引,非字节)
1297
+ 输入与输出规则相同,同一函数复用
1298
+ in: effCoord 坐标数组 (int64_t[RANK])
1299
+ in: strides stride 数组 (int64_t[RANK])
1300
+ in: rank 维度数
1301
+ ret: GM 元素偏移
1302
+ ```
1303
+
1304
+ ```cpp
1305
+ int64_t CalcOffset(
1306
+ const int64_t* effCoord, const int64_t* strides, int64_t rank)
1307
+ {
1308
+ int64_t offset = 0;
1309
+ for (int64_t d = 0; d < rank; d++) offset += effCoord[d] * strides[d];
1310
+ return offset; // 元素个数
1311
+ }
1312
+ ```
1313
+
1314
+ ##### 输入地址 — 搬运元素数
1315
+
1316
+ `ubBlockLength` 是 maximumBroShape 切分轴上的段长。入参在该轴可能只有 1 个元素(broadcast),实际只需搬 1 份,由 NDDMA 展开。内侧轴同理按入参自身 shape。
1317
+
1318
+ ```
1319
+ 切分轴搬运量 = (normalInputShape[k] == 1) ? 1 : ubBlockLength
1320
+ 内侧轴搬运量 = Π_{d>k} normalInputShape[d]
1321
+ 搬运总数 = 切分轴搬运量 × 内侧轴搬运量
1322
+ ```
1323
+
1324
+ ```
1325
+ 函数名:CalcTransferCount
1326
+ 文件归属:Kernel
1327
+ 作用:本轮搬运元素数(broadcast 轴只搬 1 份;输入与输出规则相同,同一函数复用)
1328
+ in: normalShape 入参/输出归一化 shape (int64_t[RANK])
1329
+ in: rank 维度数
1330
+ in: ubSplitIdx 切分轴 k
1331
+ in: ubBlockLength 本轮切分轴段长
1332
+ ret: 搬运元素数
1333
+ ```
1334
+
1335
+ ```cpp
1336
+ int64_t CalcTransferCount(
1337
+ const int64_t* normalShape, int64_t rank, int64_t ubSplitIdx, int64_t ubBlockLength)
1338
+ {
1339
+ int64_t splitElems = (normalShape[ubSplitIdx] == 1) ? 1 : ubBlockLength;
1340
+ int64_t innerElems = 1;
1341
+ for (int64_t d = ubSplitIdx + 1; d < rank; d++) innerElems *= normalShape[d];
1342
+ return splitElems * innerElems;
1343
+ }
1344
+ ```
1345
+
1346
+ ##### 输出地址 — 搬运元素数
1347
+
1348
+ 输出搬运量的逻辑和输入一路对称:输出稠密(shape=maximumBroShape),切分轴与内侧轴照常参与搬运量计算。
1349
+
1350
+ ```
1351
+ 切分轴搬运量 = (normalOutputShape[k] == 1) ? 1 : ubBlockLength
1352
+ 内侧轴搬运量 = Π_{d>k} normalOutputShape[d]
1353
+ 搬运总数 = 切分轴搬运量 × 内侧轴搬运量
1354
+ ```
1355
+
1356
+ ```
1357
+ 函数名:CalcOutputTransferCount → 已并入 CalcTransferCount
1358
+ 文件归属:Kernel
1359
+ 作用:输出本轮搬运元素数——与输入同一规则,复用 CalcTransferCount,不再单独定义
1360
+ ```
1361
+
1362
+ ##### 输出地址 — GM 偏移
1363
+
1364
+ 输出稠密,shape=maximumBroShape(广播输出在 Host 侧已被 CheckBroadcastShape 拒绝)。输出 stride 即坐标系自身的线性映射,直接复用 `PrecomputeStrides`,不再单独定义。GM 偏移同理复用 `CalcOffset`。
1365
+
1366
+ ```
1367
+ 函数名:CalcOffset(输出侧复用)
1368
+ ```
1369
+
1370
+ ##### 主循环
1371
+
1372
+ ```cpp
1373
+ // strides 已在 Tiling 侧预计算好
1374
+
1375
+ int64_t start, end;
1376
+ GetCoreRange(coreId, usedCoreNum, totalTiles, mainTiles, mainCoreNum, start, end);
1377
+
1378
+ for (int64_t flat = start; flat < end; flat++) {
1379
+ int64_t ubBlockIdx = flat % ubOuter;
1380
+ int64_t ubBlockLength = GetUBSplitRange(ubBlockIdx, ubOuter, ubFactor, ubTail);
1381
+
1382
+ std::vector<int64_t> effCoord;
1383
+ FlatToEffectiveCoord(flat, maximumBroShape, ubSplitIdx, ubFactor, ubOuter, effCoord);
1384
+
1385
+ // 入参搬入
1386
+ // DataCopy(CalcOffset(effCoord, stridesInput0),
1387
+ // GM→UB, CalcTransferCount(normalInput0, ubSplitIdx, ubBlockLength), ...)
1388
+ // ...
1389
+
1390
+ // 执行计算流(见 §3)
1391
+
1392
+ // 出参搬出
1393
+ // DataCopy(CalcOffset(effCoord, stridesOutput),
1394
+ // UB→GM, CalcTransferCount(normalOutput, ubSplitIdx, ubBlockLength), ...)
1395
+ }
1396
+ ```
1397
+
1398
+ #### 5.5.4 验证文件
1399
+
1400
+ | 文件 | 内容 |
1401
+ |------|------|
1402
+ | `verify/test_address_offset.cpp` | FlatToEffectiveCoord + 输入/输出 GM 偏移 + CalcTransferCount 自验证程序 |
1403
+
1404
+ 覆盖:FlatToEffectiveCoord 6 hand-computed + 100 随机;Strides/Offset 100 随机;Input/Output TransferCount 各 2 hand-computed + 100 随机;broadcast zeroing + output dim=1 stride。6 组全部 PASS。✅
1405
+
1406
+ #### 5.5.5 结论
1407
+
1408
+ 8 个函数覆盖地址计算全流程:flat → 坐标(公共)→ GM 偏移 + 搬运量(输入/输出两路)。输入 stride 预计算消除 kernel 侧 broadcast 分支。
1409
+
1410
+ #### 5.5.6 对本算子的意义
1411
+
1412
+ 地址计算是 kernel 循环的最后一块拼图。与 5.1~5.4 的产出合在一起,kernel 实现的所有参数(坐标、偏移、搬运量、循环区间)全部就位。
1413
+
1414
+ ---
1415
+
1416
+ ### 5.6 TilingData 统合
1417
+
1418
+ #### 5.6.1 核心原则
1419
+
1420
+ §5.6 的目标是产出一套可直接合入 CANN 算子仓的 Tiling 代码。本节以 ops-math(CANN 数学类算子仓)为目标仓库,wiki 读完本节后应能独立完成:生产 Tiling 文件及目录 → ops-math 本地 UT 验证通过 → 提交 PR。
1421
+
1422
+ **目标仓库**:`cann/ops-math`,目录范式 `math/{算子名}/`
1423
+
1424
+ **关键技术**(两项):
1425
+
1426
+ 1. **双档 TilingData** — 所有场景都走 8 维 `maxBroShape[8]` 太臃肿。以 rank 为分界:rank≤4 用 `AdamTilingData<4>`(120 int64),rank≥5 用 `AdamTilingData<8>`(228 int64)。两个 struct 大小 → 两个 kernel 实例 → TilingData 体积随实际场景压缩。
1427
+
1428
+ 2. **Tiling 模板编程** — 取代传统的 `TILING_KEY_IS` 写法。CANN 标准体系:`ASCENDC_TPL_ARGS_DECL` 声明模板参数 RANK ∈ {4,8},Host 侧 `GET_TPL_TILING_KEY(RANK=mapped)` 生成 key,Kernel 侧 `template<int32_t RANK>` + `if constexpr` 编译期分支——不再有 `TILING_KEY_IS(1)`、`TILING_KEY_IS(2)` 这种看不出含义的魔术数字(参考 `Tiling模板编程` 文档)。`adam_apply_one_assign_struct.h` 是此项技术在 Adam 算子上的落地。
1429
+
1430
+ **交付物**:
1431
+
1432
+ | 文件 | 位置 | 内容 |
1433
+ |------|------|------|
1434
+ | `CMakeLists.txt` | `math/{op}/` | `add_all_modules_sources(OPTYPE ... COMPUTE_UNIT ascend950 TILING_DIR arch35)` 注册算子到 cmake 体系 |
1435
+ | `adam_apply_one_assign_struct.h` | `op_kernel/arch35/` | Tiling 模板参数:`ASCENDC_TPL_ARGS_DECL` 声明 RANK ∈ {4,8},`ASCENDC_TPL_SEL` 声明 2 组合法组合 |
1436
+ | `adam_apply_one_assign_tiling_struct.h` | `op_kernel/arch35/` | `AdamTilingData<RANK>` C++ POD 模板,`GetTilingData<AdamTilingData<R>>()` 读写,Kernel 侧 `GET_TILING_DATA_WITH_STRUCT` 消费 |
1437
+ | `adam_apply_one_assign_arch35.h` | `op_host/arch35/` | 函数声明 + `AdamTiling` 类声明(对接 CANN 框架) |
1438
+ | `adam_apply_one_assign_arch35.cpp` | `op_host/arch35/` | CANN 主线:`GetShapeInfo`(PadAndSqueeze 一次)+ `DoTilingAndSet<R>`(模板填充)+ `GET_TPL_TILING_KEY` + `TilingFunc` + `TilingPrepare`(空实现)+ `IMPL_OP_OPTILING` 注册 |
1439
+ | `test_adam_tiling.cpp` | `tests/ut/op_host/arch35/` | UT,使用 ops-math 框架 `TilingContextPara` + `ExecuteTestCase` |
1440
+
1441
+ **CANN 框架对接**:
1442
+ ```
1443
+ IMPL_OP_OPTILING(OpName).Tiling(TilingFunc).TilingParse<CompileInfo>(TilingPrepare)
1444
+ ```
1445
+ - `TilingFunc(gert::TilingContext*)`:运行期入口。从 context 取 shape/dtype → PadAndSqueeze 得实际 rank → 映射为 RANK=4 或 8 → `GetTilingData<AdamTilingData<R>>()` 写入 → `GET_TPL_TILING_KEY(RANK=R)` 生成 tiling key → `SetTilingKey` → `SetBlockDim` → 设 workspace
1446
+ - `TilingPrepare(gert::TilingParseContext*)`:编译期入口,空实现(CompileInfo 为空结构)
1447
+ - 平台参数(`coreNum`/`ubSize`):`TilingFunc` 内通过 `GetPlatformInfo()` + `PlatformAscendC` 现场获取,不经 CompileInfo 中转
1448
+
1449
+ **验证标准**:在 ops-math 仓根目录执行 `bash build.sh -u --ops={op} --soc=ascend950`,编译 + UT 全部 PASS,UT 用例覆盖小 shape 无切分 + 大 shape 切分多核。
1450
+
1451
+ **最终动作**:代码合入 `examples/{算子}/code/`(同时可直接 copy 到 ops-math 仓的 `math/{算子}/`),提交 PR 到 `cann/ops-math`。
1452
+
1453
+ #### 5.6.2 物理意义
1454
+
1455
+ TilingData 是 §4(计算流验证)和 §5.1–§5.5(详细设计)全部决策的物化。下半句同样重要:**这些决策最终以 CANN 框架规定的物理形式落盘为代码文件和 UT。**
1456
+
1457
+ **1. 文件层的物理意义 — `arch35/` 子目录**
1458
+
1459
+ 不同芯片 UB 大小、核数不同。`op_host/arch35/` 是 ascend950 的专属 Tiling 代码目录。`CMakeLists.txt` 通过 `SUPPORT_COMPUTE_UNIT`/`SUPPORT_TILING_DIR` 这组 KV 对做"芯片→代码目录"的映射。新芯片来了,加一对 KV、新建一个 `archXX/` 目录即可,不会影响已有芯片的逻辑。
1460
+
1461
+ **2. 函数层的物理意义 — GetShapeInfo / DoTilingAndSet<R> / RunTiling 链**
1462
+
1463
+ CANN 路径的主线不是某个"纯逻辑"函数一次搞定——因为运行期 PadAndSqueeze 之后才知道 rank,而 C++ 无法根据运行期 rank 返回不同大小的 struct。真正的做法是单次归一化、映射、模板填充:
1464
+
1465
+ `GetShapeInfo`:从 context 取原始 shape/dtype,调 `PadAndSqueeze` 一次,归一化 shape 和 rank 全存为成员变量。这是链的起点——后续所有步骤都基于这次产出。
1466
+
1467
+ `RunTiling`:将实际 rank(1~8)映射为 4 或 8,调用 `DoTilingAndSet<4>()` 或 `<8>()`。映射是物理必要的——只有两个 kernel 实例,不是八个。
1468
+
1469
+ `DoTilingAndSet<R>()`:模板方法,编译期 R 确定数组大小。直接用 `GetShapeInfo` 存好的归一化 shape 做 FindSplitAxis/MultiCoreSplit/stride/打包,写 `GetTilingData<AdamTilingData<R>>()`、`SetBlockDim`、`GET_TPL_TILING_KEY(RANK=R)`。
1470
+
1471
+ `平台参数`:`TilingPrepare` 为空实现(CompileInfo 为空结构,仅保留注册挂载点)——平台常数在 `DoTilingAndSet<R>` 内直接 `GetPlatformInfo()` + `PlatformAscendC` 取 `coreNum`/`ubSize`(零值守卫),不经 CompileInfo 中转。若后续需要 binary 复用的跨次缓存字段,挂到 CompileInfo 并在 TilingParse 中解析。
1472
+
1473
+ **3. TilingData 的物理意义 — POD 约束的根因**
1474
+
1475
+ `GetTilingData<T>()` 返回的指针指向 host→device 共享内存。不是 C++ 语法限制,是物理传输限制:这块内存要跨进程/跨地址空间传递,指针和虚表在目标侧无意义。Kernel 侧 `GET_TILING_DATA` 拿到的是同一块数据的只读视图。
1476
+
1477
+ **4. UT 的物理意义 — TilingContextPara = 无芯片的 context**
1478
+
1479
+ ops-math 的 Tiling UT 统一用 `TilingContextPara` 构造一个 fake context——填入 shape、dtype 等参数,就能调用 `TilingFunc` 走完整 Tiling 流程。`ExecuteTestCase` 验证返回值、tilingKey、workspace。不需要真实芯片和 CANN runtime,直接 g++ 编译 + 本地运行。
1480
+
1481
+ #### 5.6.3 工程目录结构
1482
+
1483
+ 算子上库 ops-math 仓的标准目录范式如下(对标 `math/add/` 结构)。wiki 产出的代码文件应直接可放入此目录树,通过 `bash build.sh -u --ops=adam_apply_one_assign --soc=ascend950` 编译并运行 UT:
1484
+
1485
+ ```
1486
+ math/adam_apply_one_assign/
1487
+ ├── CMakeLists.txt # 算子注册到 cmake 体系
1488
+ ├── op_kernel/
1489
+ │ └── arch35/
1490
+ │ ├── adam_apply_one_assign_struct.h # TilingKey 模板参数(RANK ∈ {4,8})
1491
+ │ └── adam_apply_one_assign_tiling_struct.h # AdamTilingData<RANK> 模板
1492
+ ├── op_host/
1493
+ │ └── arch35/
1494
+ │ ├── adam_apply_one_assign_arch35.h # 函数声明 + AdamTiling 类
1495
+ │ └── adam_apply_one_assign_arch35.cpp # 全量实现 + CANN 注册
1496
+ └── tests/
1497
+ └── ut/
1498
+ └── op_host/
1499
+ └── arch35/
1500
+ └── test_adam_tiling.cpp # Tiling UT
1501
+ ```
1502
+
1503
+ 六份文件的职责:
1504
+
1505
+ | 文件 | 谁读 | 内容 |
1506
+ |------|------|------|
1507
+ | `CMakeLists.txt` | cmake | `add_all_modules_sources(OPTYPE adam_apply_one_assign ...)` 注册算子 |
1508
+ | `adam_apply_one_assign_struct.h` | Tiling + Kernel | `ASCENDC_TPL_ARGS_DECL` 定义 RANK 模板参数(4 和 8),`ASCENDC_TPL_SEL` 声明 2 组合法组合 |
1509
+ | `adam_apply_one_assign_tiling_struct.h` | Tiling + Kernel | `AdamTilingData<RANK>` C++ POD 模板,`RANK=4`(120 int64)或 `RANK=8`(228 int64),Kernel 侧 `GET_TILING_DATA_WITH_STRUCT` 消费 |
1510
+ | `adam_apply_one_assign_arch35.h` | Tiling 实现 | 函数模块声明 + `AdamTiling` 类声明(`GetShapeInfo` / `DoTilingAndSet<R>` / `RunTiling`) |
1511
+ | `adam_apply_one_assign_arch35.cpp` | Tiling 实现 | CANN 主线:`GetShapeInfo`(归一化一次)+ `DoTilingAndSet<R>`(模板填充)+ `GET_TPL_TILING_KEY` + `TilingFunc` + `TilingPrepare`(空实现)+ `IMPL_OP_OPTILING` 注册 |
1512
+ | `test_adam_tiling.cpp` | UT | `TilingContextPara` + `ExecuteTestCase` 验证 Tiling 全流程 |
1513
+
1514
+ 以下逐文件说明关键代码。
1515
+
1516
+ #### 5.6.4 CMakeLists.txt
1517
+
1518
+ `add_all_modules_sources` 是 ops-math 统一入口。`SUPPORT_COMPUTE_UNIT`/`SUPPORT_TILING_DIR` 这组 KV 对建立"芯片→代码目录"映射——新芯片加一对 KV、新建对应 `archXX/` 目录即可:
1519
+
1520
+ ```cmake
1521
+ set(SUPPORT_COMPUTE_UNIT "ascend950")
1522
+ set(SUPPORT_TILING_DIR "arch35")
1523
+ add_all_modules_sources(OPTYPE adam_apply_one_assign ACLNNTYPE aclnn_exclude
1524
+ COMPUTE_UNIT ${SUPPORT_COMPUTE_UNIT} TILING_DIR ${SUPPORT_TILING_DIR}
1525
+ DISABLE_IN_OPP FALSE)
1526
+ ```
1527
+
1528
+ `DISABLE_IN_OPP FALSE` 确保本地 UT 编译时 Tiling 源文件被纳入。`ACLNNTYPE aclnn_exclude` 表示本算子暂无 aclnn API。
1529
+
1530
+ #### 5.6.5 op_kernel/arch35/ — TilingKey 模板参数 + TilingData
1531
+
1532
+ `op_kernel/arch35/` 下两个头文件,分别定义 TilingKey 模板参数和 TilingData 结构体。
1533
+
1534
+ ##### adam_apply_one_assign_struct.h — TilingKey 模板参数
1535
+
1536
+ 按 CANN Tiling 模板编程规范,用 `ASCENDC_TPL_ARGS_DECL` 将 RANK 声明为模板参数。只设两个值——`RANK_4`(覆盖实际 rank=1~4)和 `RANK_8`(覆盖实际 rank=5~8)。Host 侧按实际 rank 映射后调用 `GET_TPL_TILING_KEY(RANK=mapped)`。Kernel 侧 `template<int32_t RANK>` `if constexpr` 编译期分支,**完全不用 `TILING_KEY_IS`**。2 个 tiling key → 2 个 kernel 模板实例。
1537
+
1538
+ ```cpp
1539
+ // math/adam_apply_one_assign/op_kernel/arch35/adam_apply_one_assign_struct.h
1540
+ #include "ascendc/host_api/tiling/template_argument.h"
1541
+
1542
+ #define ADAM_RANK_4 4
1543
+ #define ADAM_RANK_8 8
1544
+
1545
+ ASCENDC_TPL_ARGS_DECL(AdamApplyOneAssign,
1546
+ ASCENDC_TPL_UINT_DECL(RANK, ASCENDC_TPL_4_BW, ASCENDC_TPL_UI_LIST, ADAM_RANK_4, ADAM_RANK_8)
1547
+ );
1548
+
1549
+ ASCENDC_TPL_SEL(
1550
+ ASCENDC_TPL_ARGS_SEL(ASCENDC_TPL_UINT_SEL(RANK, ASCENDC_TPL_UI_LIST, ADAM_RANK_4)),
1551
+ ASCENDC_TPL_ARGS_SEL(ASCENDC_TPL_UINT_SEL(RANK, ASCENDC_TPL_UI_LIST, ADAM_RANK_8))
1552
+ );
1553
+ ```
1554
+
1555
+ ##### adam_apply_one_assign_tiling_struct.h — TilingData
1556
+
1557
+ POD 约束的物理根因:`GetTilingData<T>()` 返回的指针指向 host→device 共享内存。Tiling 运行期先调 `PadAndSqueeze` 归一化得到实际 rank(1~8),再映射为模板参数 RANK=4 或 8——此时才确定选 `AdamTilingData<4>`(120 int64)还是 `AdamTilingData<8>`(228 int64),以及 `GET_TPL_TILING_KEY(RANK=4)` 还是 `RANK=8`。归一化是第一环,切分、分核、stride、选 struct、选 key 全依赖它的产出。
1558
+
1559
+ ```
1560
+ 数据结构:AdamTilingData<RANK>
1561
+ 字段:
1562
+ split SplitResult (§5.2) UB 切分结果
1563
+ multicore MultiCoreResult (§5.3) 多核切分结果
1564
+ rank int64_t (§5.1) 实际 rank(1~8),Host 侧写入供 dump 对齐,Kernel 不读取(用 RANK 模板参数)
1565
+ perBufBytes int64_t (§2) UB/P 向下对齐 32B,Kernel 用此初始化 TBuf
1566
+ maxBroShape int64_t[RANK] (§5.1) 坐标系
1567
+ numInputs int64_t 实际入参数
1568
+ numOutputs int64_t 实际出参数
1569
+ inputShapes int64_t[10][RANK] (§5.1) 每入参归一化 shape
1570
+ inputStrides int64_t[10][RANK] (§5.5) 每入参 stride
1571
+ outputShapes int64_t[3][RANK] (§5.1) 每出参归一化 shape
1572
+ outputStrides int64_t[3][RANK] (§5.5) 每出参 stride
1573
+ ```
1574
+
1575
+ ```cpp
1576
+ // math/adam_apply_one_assign/op_kernel/arch35/adam_apply_one_assign_tiling_struct.h
1577
+ #ifndef ADAM_APPLY_ONE_ASSIGN_TILING_STRUCT_H_
1578
+ #define ADAM_APPLY_ONE_ASSIGN_TILING_STRUCT_H_
1579
+ #include <cstdint>
1580
+
1581
+ // 防御性初值(NSDMI):计数/块数类字段默认 1(单块、单核退化配置),索引默认 0,
1582
+ // 避免 Host 侧异常路径(如空 shape 导致 FindSplitAxis 未写入)时 Kernel 读到未定义值
1583
+ struct SplitResult {
1584
+ int64_t ubSplitIdx = 0;
1585
+ int64_t ubFactor = 1;
1586
+ int64_t ubOuter = 1;
1587
+ int64_t ubTail = 1;
1588
+ };
1589
+
1590
+ struct MultiCoreResult {
1591
+ int64_t usedCoreNum = 1;
1592
+ int64_t totalTiles = 1;
1593
+ int64_t mainTiles = 1;
1594
+ int64_t mainCoreNum = 1;
1595
+ };
1596
+
1597
+ template<int64_t RANK>
1598
+ struct AdamTilingData {
1599
+ SplitResult split;
1600
+ MultiCoreResult multicore;
1601
+ int64_t rank = 1; // 实际 rank (1~8),Host 侧写入供 dump 对齐,Kernel 不读取(用 RANK 模板参数)
1602
+ int64_t perBufBytes = 0; // UB / P,Kernel 用此初始化 TBuf
1603
+ int64_t maxBroShape[RANK] = {0};
1604
+ int64_t numInputs = 0;
1605
+ int64_t numOutputs = 0;
1606
+ int64_t inputShapes [10][RANK] = {0};
1607
+ int64_t inputStrides[10][RANK] = {0};
1608
+ int64_t outputShapes[3][RANK] = {0};
1609
+ int64_t outputStrides[3][RANK] = {0};
1610
+ };
1611
+ // 实际使用:AdamTilingData<4> 或 AdamTilingData<8>
1612
+ ```
1613
+
1614
+ | RANK | 覆盖实际 rank | `maxBroShape` | TilingData 大小 |
1615
+ |-------|-------------|-----------------|-----------------|
1616
+ | 4 | 1~4 | 4 | 120 int64 |
1617
+ | 8 | 5~8 | 8 | 228 int64 |
1618
+
1619
+ rank=1~4 的场景用 `AdamTilingData<4>`,相较 228 int64 节省约 48% 空间。rank≤4 的 dim 填不满 4 的用 0 补齐。
1620
+
1621
+ #### 5.6.6 op_host/arch35/ — Tiling 实现 + CANN 注册
1622
+
1623
+ `.h` 声明函数模块和 `AdamTiling` 类,`.cpp` 包含全量实现。CANN 主线是单次归一化→映射→模板填充,`PadAndSqueeze` 只跑一次。
1624
+
1625
+ **CANN 主线** — `GetShapeInfo` 归一化 → `RunTiling` 映射 → `DoTilingAndSet<R>` 填充:
1626
+
1627
+ `GetShapeInfo()` 从 context 取原始 shape/dtype,调 `PadAndSqueeze` 一次,产出的归一化 shape 和 rank 全存为成员变量。`RunTiling()` 将实际 rank 映射为模板参数 RANK=4 或 8,调用 `DoTilingAndSet<R>()`——该模板方法直接用存好的归一化 shape 做 FindSplitAxis、MultiCoreSplit、stride 计算、打包,写 `GetTilingData<AdamTilingData<R>>()`、`SetBlockDim`、`GET_TPL_TILING_KEY(RANK=R)`、workspace。PadAndSqueeze 不跑第二次。
1628
+
1629
+ Tiling 的核心逻辑由 `PadAndSqueeze`、`CheckBroadcastShape`、`FindSplitAxis`、`MultiCoreSplit`、`PrecomputeStrides` 这些无状态函数承载——它们与 CANN 框架零耦合,直接在 `DoTilingAndSet<R>` 中被调用。
1630
+
1631
+ **关键 1 — 平台参数直接从系统获取**。本算子无跨次编译缓存信息:`AdamCompileInfo` 为空结构,`TilingPrepareForAdam` 为空实现(恒返回成功),仅保留注册挂载点。平台常数(AIV 核数、UB 大小)在 Tiling 阶段通过 `ctx_->GetPlatformInfo()` + `platform_ascendc::PlatformAscendC` 现场获取,任一为 0 视为环境异常直接失败。后续若做 binary 复用,缓存字段挂 CompileInfo 并在 TilingParse 中解析。
1632
+
1633
+ **关键 2 — TilingKey 模板化 + 双档 TilingData**。`PadAndSqueeze` 产出实际 rank(1~8)后,映射为 4 或 8,`DoTilingAndSet<R>()` 内 `GetTilingData<AdamTilingData<R>>()` 选对应大小的 struct,`GET_TPL_TILING_KEY(RANK=R)` 生成 key。Kernel 侧 `template<int32_t RANK>` + `if constexpr` 编译期分支,**完全不用 `TILING_KEY_IS`**:
1634
+
1635
+ ```cpp
1636
+ template<int32_t RANK>
1637
+ __global__ __aicore__ void adam_apply_one_assign(
1638
+ GM_ADDR input0, GM_ADDR input1, GM_ADDR input2, GM_ADDR input3, GM_ADDR input4,
1639
+ GM_ADDR mul0_x, GM_ADDR mul1_x, GM_ADDR mul2_x, GM_ADDR mul3_x, GM_ADDR add2_y,
1640
+ GM_ADDR out0, GM_ADDR out1, GM_ADDR out2,
1641
+ GM_ADDR workspace, GM_ADDR tiling)
1642
+ {
1643
+ if constexpr (RANK == 4) {
1644
+ GET_TILING_DATA_WITH_STRUCT(AdamTilingData<4>, td, tiling);
1645
+ } else {
1646
+ GET_TILING_DATA_WITH_STRUCT(AdamTilingData<8>, td, tiling);
1647
+ }
1648
+ // td.rank → 实际 rank;for (int32_t d = 0; d < RANK; d++) — 编译期常量
1649
+ }
1650
+ ```
1651
+
1652
+ 2 个 tiling key → 2 种 TilingData 大小 → 2 个 kernel 模板实例。
1653
+
1654
+ ```
1655
+ 数据结构:AdamCompileInfo
1656
+ 文件归属:op_host/arch35/adam_apply_one_assign_arch35.h → TilingParse
1657
+ 字段:无(空结构,仅作 TilingParse 注册的挂载类型;
1658
+ 平台参数 coreNum/ubSize 在 Tiling 阶段直接从系统 GetPlatformInfo 获取,不经此缓存。
1659
+ 后续若做 binary 复用,缓存字段挂此结构并在 TilingParse 中解析)
1660
+ ```
1661
+
1662
+ ```
1663
+ 类名:AdamTiling
1664
+ 文件归属:op_host/arch35/adam_apply_one_assign_arch35.h
1665
+ 作用:CANN 主线——单次归一化→映射→模板填充
1666
+ 方法:
1667
+ RunTiling() 串联 GetShapeInfo → 映射 rank → DoTilingAndSet<R>
1668
+ GetShapeInfo() 从 context 取 shape/dtype,PadAndSqueeze 一次,存归一化结果和 rank
1669
+ DoTilingAndSet<R>() 模板方法,用存好的归一化 shape 做切分/分核/stride/打包,写 TilingData+BlockDim+Key
1670
+ ```
1671
+
1672
+ ```cpp
1673
+ // op_host/arch35/adam_apply_one_assign_arch35.cpp
1674
+ #include "math/adam_apply_one_assign/op_kernel/arch35/adam_apply_one_assign_struct.h"
1675
+
1676
+ // GetShapeInfo() — PadAndSqueeze 一次,存归一化结果和 rank_
1677
+ ge::graphStatus AdamTiling::GetShapeInfo() {
1678
+ for (size_t i = 0; i < ctx_->GetComputeNodeInfo()->GetInputsNum(); ++i) {
1679
+ auto shape = ctx_->GetInputShape(i);
1680
+ const gert::Shape& s = shape->GetStorageShape();
1681
+ const size_t rank = s.GetDimNum();
1682
+ std::vector<int64_t> dims;
1683
+ for (size_t d = 0; d < rank; ++d) dims.push_back(s.GetDim(d));
1684
+ rawInputShapes_.push_back(dims);
1685
+ }
1686
+ for (size_t i = 0; i < ctx_->GetComputeNodeInfo()->GetOutputsNum(); ++i) {
1687
+ auto shape = ctx_->GetOutputShape(i);
1688
+ const gert::Shape& s = shape->GetStorageShape();
1689
+ const size_t rank = s.GetDimNum();
1690
+ std::vector<int64_t> dims;
1691
+ for (size_t d = 0; d < rank; ++d) dims.push_back(s.GetDim(d));
1692
+ rawOutputShapes_.push_back(dims);
1693
+ }
1694
+ auto inputDesc = ctx_->GetInputDesc(0);
1695
+ ge::DataType dtype = inputDesc->GetDataType();
1696
+ const std::set<ge::DataType> supportedDtypes = {ge::DT_FLOAT16, ge::DT_FLOAT};
1697
+ OP_CHECK_IF(supportedDtypes.count(dtype) == 0,
1698
+ OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(ctx_->GetNodeName(), "input0",
1699
+ ge::TypeUtils::DataTypeToSerialString(dtype).c_str(),
1700
+ "only DT_FLOAT16 and DT_FLOAT are supported"),
1701
+ return GRAPH_FAILED);
1702
+ dtypeSize_ = static_cast<int64_t>(ge::GetSizeByDataType(dtype));
1703
+
1704
+ PadAndSqueeze(rawInputShapes_, rawOutputShapes_,
1705
+ maxBroShape_, normalInputShapes_, normalOutputShapes_);
1706
+ rank_ = (int64_t)maxBroShape_.size();
1707
+
1708
+ OP_CHECK_IF(
1709
+ !CheckBroadcastShape(normalInputShapes_, normalOutputShapes_, rank_),
1710
+ OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON(ctx_->GetNodeName(), "input/output",
1711
+ "incompatible", "check broadcast shape failed, shapes must be broadcast-compatible"),
1712
+ return ge::GRAPH_FAILED);
1713
+
1714
+ return GRAPH_SUCCESS;
1715
+ }
1716
+
1717
+ // RunTiling() — 串联 GetShapeInfo → 映射 → 填充
1718
+ ge::graphStatus AdamTiling::RunTiling() {
1719
+ GetShapeInfo(); // 1. 归一化,得 rank_
1720
+ int64_t mapped = (rank_ <= 4) ? 4 : 8; // 2. 映射为 4 或 8
1721
+ if (mapped == 4) { // 3. 模板填充 + SetTilingKey
1722
+ auto ret = DoTilingAndSet<4>();
1723
+ ctx_->SetTilingKey(GET_TPL_TILING_KEY(ADAM_RANK_4));
1724
+ return ret;
1725
+ } else {
1726
+ auto ret = DoTilingAndSet<8>();
1727
+ ctx_->SetTilingKey(GET_TPL_TILING_KEY(ADAM_RANK_8));
1728
+ return ret;
1729
+ }
1730
+ }
1731
+
1732
+ // DoTilingAndSet<R>() — 模板填充
1733
+ template<int64_t R>
1734
+ ge::graphStatus AdamTiling::DoTilingAndSet() {
1735
+ auto* td = ctx_->GetTilingData<AdamTilingData<R>>();
1736
+
1737
+ // 平台参数 tiling 时直接从系统获取(不经 CompileInfo 缓存),任一为 0 视为环境异常
1738
+ fe::PlatFormInfos *platformInfo = ctx_->GetPlatformInfo();
1739
+ auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo);
1740
+ int64_t coreNum = static_cast<int64_t>(ascendcPlatform.GetCoreNumAiv());
1741
+ uint64_t ubSize = 0;
1742
+ ascendcPlatform.GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);
1743
+ int64_t ubPerCore = static_cast<int64_t>(ubSize);
1744
+
1745
+ FindSplitAxis(maxBroShape_, dtypeSize_, ubPerCore, PHYS_NODES, td->split);
1746
+ MultiCoreSplit(maxBroShape_, td->split, coreNum, td->multicore);
1747
+ int64_t ni = normalInputShapes_.size(), no = normalOutputShapes_.size();
1748
+ std::vector<std::vector<int64_t>> ist(ni), ost(no);
1749
+ for (int64_t i = 0; i < ni; i++) PrecomputeStrides(normalInputShapes_[i], ist[i]);
1750
+ for (int64_t i = 0; i < no; i++) PrecomputeStrides(normalOutputShapes_[i], ost[i]);
1751
+
1752
+ td->rank = rank_;
1753
+ for (int64_t d = 0; d < rank_; d++) td->maxBroShape[d] = maxBroShape_[d];
1754
+ for (int64_t d = rank_; d < R; d++) td->maxBroShape[d] = 0;
1755
+
1756
+ td->numInputs = ni; td->numOutputs = no;
1757
+ for (int64_t i = 0; i < ni; i++)
1758
+ for (int64_t d = 0; d < rank_; d++) {
1759
+ td->inputShapes[i][d] = normalInputShapes_[i][d];
1760
+ td->inputStrides[i][d] = ist[i][d];
1761
+ }
1762
+ for (int64_t i = 0; i < no; i++)
1763
+ for (int64_t d = 0; d < rank_; d++) {
1764
+ td->outputShapes[i][d] = normalOutputShapes_[i][d];
1765
+ td->outputStrides[i][d] = ost[i][d];
1766
+ }
1767
+
1768
+ ctx_->SetBlockDim(td->multicore.usedCoreNum);
1769
+ return GRAPH_SUCCESS;
1770
+ }
1771
+
1772
+ // 注册:CompileInfo 为空结构,TilingParse 为空实现(平台参数在 Tiling 时直取)
1773
+ IMPL_OP_OPTILING(AdamApplyOneAssign)
1774
+ .Tiling(TilingFuncAdam)
1775
+ .TilingParse<AdamCompileInfo>(TilingPrepareForAdam);
1776
+ ```
1777
+
1778
+ `AdamTiling` 的完整实现见 `example/examples-adam-code/op_host/arch35/adam_apply_one_assign_tiling_arch35.cpp`,§5.1–§5.5 的函数模块(`PadAndSqueeze`、`CheckBroadcastShape`、`FindSplitAxis`、`MultiCoreSplit`、`PrecomputeStrides` 等)均在同一个 `.cpp` 文件中。
1779
+
1780
+ #### 5.6.7 Tiling UT
1781
+
1782
+ Tiling UT 用 ops-math 标准框架 `TilingContextPara` + `ExecuteTestCase` 验证 §5.1–§5.6 的全部 Tiling 逻辑。每个用例列出完整 10入3出的 shape、预期 TilingData 各字段的取值、以及 golden 字符串。标杆由 Python 脚本 `code/tests/gen_golden.py` 预计算,UT 逐 `int64_t` 精确对比。
1783
+
1784
+ 以下 10 个用例均固定 FP32、P=5、ub=256KB、maxCores=56。
1785
+
1786
+ ##### 1. case1 — 主测 PadAndSqueeze(混合 rank + 标量 + broadcast)
1787
+
1788
+ **输入(10 个):**
1789
+
1790
+ | # | shape | 说明 |
1791
+ |---|-------|------|
1792
+ | 0 | (4, 6, 3, 5) | 4D 全量,坐标基准 |
1793
+ | 1 | (6, 3, 5) | 3D → 补 1 为 (1, 6, 3, 5),broadcast 轴 0 |
1794
+ | 2 | (3, 5) | 2D → 补 1 为 (1, 1, 3, 5),broadcast 轴 0,1 |
1795
+ | 3 | (5,) | 1D → 补 1 为 (1, 1, 1, 5),broadcast 轴 0,1,2 |
1796
+ | 4 | (4, 1, 1, 5) | 4D,轴 1,2 为 1,broadcast 轴 1,2 |
1797
+ | 5 | (4, 6, 1, 1) | 4D,轴 2,3 为 1,broadcast 轴 2,3 |
1798
+ | 6 | () | 标量 → 归一为 (1, 1, 1, 1) |
1799
+ | 7 | (4, 1, 1, 1) | 4D,仅轴 0 dim≠1 |
1800
+ | 8 | (1, 1, 1, 5) | 4D,仅轴 3 dim≠1,broadcast 轴 0,1,2 |
1801
+ | 9 | (4, 6, 3, 5) | 4D 全量 |
1802
+
1803
+ **输出(3 个):** `(4, 6, 3, 5)` ×3
1804
+
1805
+ **预期结果:**
1806
+
1807
+ | 字段 | 值 | 说明 |
1808
+ |------|-----|------|
1809
+ | maxBroShape | (4, 6, 3, 5), rank=4 | 各轴取 max,无废维 |
1810
+ | input1 归一化 shape | (1, 6, 3, 5) | 3D→4D,轴 0 补 1 |
1811
+ | input3 归一化 shape | (1, 1, 1, 5) | 1D→4D |
1812
+ | input6 归一化 shape | (1, 1, 1, 1) | 标量→4D 全 1 |
1813
+ | input1 stride | (0, 15, 5, 1) | 轴 0 broadcast → stride=0 |
1814
+ | input3 stride | (0, 0, 0, 1) | 轴 0,1,2 broadcast |
1815
+ | input6 stride | (0, 0, 0, 0) | 全 1 → stride 全 0 |
1816
+ | SplitResult | ubSplitIdx=0, ubFactor=4, ubOuter=1, ubTail=4 | 全量 360≪13107,不切 |
1817
+ | MultiCoreResult | usedCoreNum=1, totalTiles=1, mainTiles=1, mainCoreNum=1 | 单核 |
1818
+
1819
+ ##### 2. case2 — 主测 PadAndSqueeze(去 1)
1820
+
1821
+ **输入(10 个):** 全部 `(1, 4, 6)`
1822
+ **输出(3 个):** 全部 `(1, 4, 6)`
1823
+
1824
+ **预期结果:** 轴 0 全为 1 → squeeze 掉。maxBroShape=(4, 6), rank=2。SplitResult: ubSplitIdx=0, ubFactor=4, ubOuter=1。单核。
1825
+
1826
+ ##### 3. case3 — 主测 PadAndSqueeze(全标量)
1827
+
1828
+ **输入(10 个):** 全部 `()`
1829
+ **输出(3 个):** 全部 `()`
1830
+
1831
+ **预期结果:** maxBroShape=(1), rank=1。SplitResult: ubFactor=1, ubOuter=1。单核。
1832
+
1833
+ ##### 4. case4 — 主测 FindSplitAxis(不整切)
1834
+
1835
+ **输入(10 个)+ 输出(3 个):** 全部 `(1, 1, 203, 200)`
1836
+
1837
+ **预期结果:**
1838
+
1839
+ | 字段 | 值 | 说明 |
1840
+ |------|-----|------|
1841
+ | maxBroShape | (203, 200), rank=2 | 轴 0,1 全为 1 → squeeze |
1842
+ | perBufElems | 13107 | 256K/5/4 |
1843
+ | SplitResult | ubSplitIdx=0, ubFactor=65, ubOuter=4, ubTail=8 | d=1: 200≤13107→inner=200; d=0: 203×200=40600>13107→切分 |
1844
+ | MultiCoreResult | usedCoreNum=4, totalTiles=4, mainTiles=1, mainCoreNum=4 | outerProd=1, ubOuter=4 |
1845
+
1846
+ ##### 5. case5 — 主测 FindSplitAxis(全量入 UB 不切)
1847
+
1848
+ **输入(10 个):** `(3, 16, 32)` ×7 + `(1, 16, 32)` ×3
1849
+ **输出(3 个):** `(3, 16, 32)` ×3
1850
+
1851
+ **预期结果:** total=1536≪13107。ubSplitIdx=0, ubFactor=3, ubOuter=1。单核。
1852
+
1853
+ ##### 6. case6 — 主测 MultiCoreSplit(多核均分)
1854
+
1855
+ **输入(10 个)+ 输出(3 个):** 全部 `(7, 13, 203, 200)`
1856
+
1857
+ **预期结果:**
1858
+
1859
+ | 字段 | 值 | 说明 |
1860
+ |------|-----|------|
1861
+ | SplitResult | ubSplitIdx=2, ubFactor=65, ubOuter=4, ubTail=8 | case4 同逻辑,轴 2 切分 |
1862
+ | outerProd | 7×13=91 | 轴 0,1 乘积 |
1863
+ | MultiCoreResult | usedCoreNum=56, totalTiles=364, mainTiles=7, mainCoreNum=28 | 91×4=364, ceil(364/56)=7, 364-(7-1)×56=28 |
1864
+
1865
+ ##### 7. case7 — 主测 MultiCoreSplit(单核)
1866
+
1867
+ **输入(10 个)+ 输出(3 个):** 全部 `(1, 1, 100, 100)`
1868
+
1869
+ **预期结果:** ubSplitIdx=0, ubOuter=1, totalTiles=1, usedCoreNum=1。
1870
+
1871
+ ##### 8. case8 — 主测 Stride(broadcast 三种模式)
1872
+
1873
+ **输入(10 个):**
1874
+
1875
+ | # | shape | broadcast 模式 |
1876
+ |---|-------|---------------|
1877
+ | 0 | (4, 6, 195, 200) | 无 broad |
1878
+ | 1 | (4, 1, 195, 200) | 单轴 broad(轴 1) |
1879
+ | 2 | (1, 1, 1, 200) | 全 broad(仅末轴) |
1880
+ | 3~9 | 同 input0 | 无 broad |
1881
+
1882
+ **输出(3 个):** `(4, 6, 195, 200)` ×3
1883
+
1884
+ **预期结果:**
1885
+
1886
+ | 入参 | stride | 说明 |
1887
+ |------|--------|------|
1888
+ | input0 | (234000, 39000, 200, 1) | 全非 0 |
1889
+ | input1 | (39000, 0, 200, 1) | 轴 1 broadcast → stride[1]=0 |
1890
+ | input2 | (0, 0, 0, 1) | 仅末轴 dim≠1 → stride=(0,0,0,1) |
1891
+
1892
+ ##### 9. case9 — 主测 Stride(无 broadcast)
1893
+
1894
+ **输入(10 个)+ 输出(3 个):** 全部 `(4, 6, 195, 200)`
1895
+
1896
+ **预期结果:** 所有 stride 全非 0,值 = (234000, 39000, 200, 1)。
1897
+
1898
+ ##### 10. case10 — 贯通(10入3出全开)
1899
+
1900
+ **输入(10 个):**
1901
+
1902
+ | # | shape | 说明 |
1903
+ |---|-------|------|
1904
+ | 0 | (7, 13, 203, 200) | 4D 坐标基准 |
1905
+ | 1 | (13, 203, 200) | 3D → 补 1,broadcast 轴 0 |
1906
+ | 2 | (203, 200) | 2D → 补 1,broadcast 轴 0,1 |
1907
+ | 3 | (200,) | 1D → 补 1,broadcast 轴 0,1,2 |
1908
+ | 4 | (7, 1, 203, 200) | 4D,broadcast 轴 1 |
1909
+ | 5 | (7, 13, 1, 200) | 4D,broadcast 轴 2 |
1910
+ | 6 | (7, 1, 1, 200) | 4D,broadcast 轴 1,2 |
1911
+ | 7 | (1, 1, 1, 200) | 4D,broadcast 轴 0,1,2 |
1912
+ | 8 | (7, 13, 203, 200) | 4D 全量 |
1913
+ | 9 | (7, 13, 203, 200) | 4D 全量 |
1914
+
1915
+ **输出(3 个):** `(7, 13, 203, 200)` ×3
1916
+
1917
+ **预期结果:** maxBroShape=(7,13,203,200), rank=4。SplitResult: ubSplitIdx=2, ubFactor=65, ubOuter=4, ubTail=8。MultiCoreResult: usedCoreNum=56, totalTiles=364, mainTiles=7, mainCoreNum=28。input1 stride=(0, 40600, 200, 1);input3 stride=(0, 0, 0, 1);input5 stride=(2600, 200, 0, 1)。
1918
+
1919
+ ##### 验证
1920
+
1921
+ 在 ops-math 仓根目录执行:
1922
+
1923
+ ```bash
1924
+ bash build.sh -u --ops=adam_apply_one_assign --soc=ascend950
1925
+ ```
1926
+
1927
+ 预期 10/10 PASS。每条用例走完整 CANN 路径,`expectTilingData` 由 `code/tests/gen_golden.py` 预计算,`ExecuteTestCase` 逐 `int64_t` 精确对比。后续修改 Tiling 逻辑后重跑此命令即可拦截回归。
1928
+
1929
+ ---
1930
+
1931
+ ## 6. Kernel 详细设计
1932
+
1933
+ ### 6.1 核心原则
1934
+
1935
+ **1. Kernel 文件划分**
1936
+
1937
+ | 文件 | 意义 |
1938
+ |------|------|
1939
+ | `{算子}_apt.cpp` | Kernel 对外入口。`template<int32_t RANK>` 编译期确定数组大小,`GET_TILING_DATA_WITH_STRUCT` 取 TilingData,实例化 Kernel 类,调 `Init()` → `Process()`。 |
1940
+ | `{算子}_kernel.h` | Kernel 类。`Init()` 绑定 GM 地址 + 初始化 TBuf;`Process()` 按计算流伪码交替搬运与计算。私有方法 `CopyInBrc` / `CopyOutOne` 分别处理单路 GM↔UB 搬运。 |
1941
+
1942
+ **2. 约束**
1943
+
1944
+ 1. 申请内存使用 `TBuf`
1945
+ 2. 申请多少内存依赖存活节点分析(P 来自 §2,`perBufBytes = UB / P`,须 32B 对齐)。内存资源使用 TBuf(详见 `knowledge/coding/Tbuf.md`)
1946
+ 3. 业务编码遵循 §3 计算流伪码
1947
+ 4. API 使用 AscendC 基础 API / RegBase API,不使用 ATVOSS
1948
+ 5. 持有注释判定依据为全流程生命表(全局视角),不可局部推理。格式:`持有=N: name(buffer)→未来消费者`(无→=当前计算步消费),计算进行中增标 `执行中持有=N ← 峰值`
1949
+
1950
+ **3. 推演方法论**
1951
+
1952
+ Kernel 设计不是一步写出完整代码,是按以下顺序逐层推进、每层验证通过后再进下一层:
1953
+
1954
+ ```
1955
+ §3 计算流伪码 ← 唯一参照源
1956
+ ↓
1957
+ 6.4.2 无同步版 ← 先把业务写对, 持有法则验证 P 不超
1958
+ ↓ (持有注释暴露 RAW/WAR)
1959
+ 6.4.3 同步版 ← 从持有注释推导同步点, 精准插入 SetFlag/WaitFlag
1960
+ ↓ (抽函数, 看 API 契约)
1961
+ 6.4.4 函数模块 ← NDDMA 接口契约, VF 融合, 基础版→优化版推演
1962
+ ↓ (取各节最优版本)
1963
+ 6.4.5 kernel.h 完全体 ← 收束, 前面小毛病在此统一修掉
1964
+ ```
1965
+
1966
+ 每层只解决一个问题。遇到未知 API(NDDMA、RegBase、SetFlag)先学官方文档落知识文件,再回设计文档应用。
1967
+
1968
+ **4. 代码生成流程**
1969
+
1970
+ 1. 先生成 `apt.cpp`,再生成 `_kernel.h`
1971
+ 2. `_kernel.h` 第一版不带同步,全局分析 buffer 依赖后生成带同步版本
1972
+
1973
+ ### 6.2 文件布局
1974
+
1975
+ ```
1976
+ math/adam_apply_one_assign/op_kernel/
1977
+ ├── adam_apply_one_assign.cpp # Kernel 入口
1978
+ └── arch35/
1979
+ └── adam_apply_one_assign_kernel.h # AdamKernel<T, RANK> 类
1980
+ ```
1981
+
1982
+ ### 6.3 Kernel 入口 — {算子}_apt.cpp
1983
+
1984
+ Kernel 入口的核心职责是"消费 Tiling 决定的 Key"。Key 的数量和取值由 Tiling 阶段确定,Kernel 入口用模板化方案对接。
1985
+
1986
+ 以本算子为例:Tiling(§5.6.5)通过 `ASCENDC_TPL_ARGS_DECL` 声明了 2 个 Key——RANK=4(覆盖 rank 1~4)和 RANK=8(覆盖 rank 5~8)。Host 侧 `DoTilingAndSet<4>` / `DoTilingAndSet<8>` 各填一份不同大小的 `AdamTilingData<4>`(120 int64)和 `<8>`(228 int64)。Kernel 入口用 `template<int32_t RANK>` + `if constexpr (RANK == 4/8)` 做编译期分支,`GET_TILING_DATA_WITH_STRUCT` 取对应 struct,实例化 `AdamKernel<T,RANK>`。
1987
+
1988
+ 模板化的好处:RANK 是编译期常量后,`int64_t[RANK]` 数组、`MultiCopyLoopInfo<RANK>`、NDDMA dim 全部编译期展开,Device 侧不需要 VLA 和 `std::vector`。
1989
+
1990
+ ```cpp
1991
+ #include "arch35/adam_apply_one_assign_kernel.h"
1992
+ #include "arch35/adam_apply_one_assign_tiling_struct.h"
1993
+
1994
+ template<int32_t RANK>
1995
+ __global__ __aicore__ void adam_apply_one_assign(
1996
+ GM_ADDR input0, GM_ADDR input1, GM_ADDR input2, GM_ADDR input3, GM_ADDR input4,
1997
+ GM_ADDR mul0_x, GM_ADDR mul1_x, GM_ADDR mul2_x, GM_ADDR mul3_x, GM_ADDR add2_y,
1998
+ GM_ADDR out0, GM_ADDR out1, GM_ADDR out2,
1999
+ GM_ADDR workspace, GM_ADDR tiling)
2000
+ {
2001
+ if constexpr (RANK == 4) {
2002
+ GET_TILING_DATA_WITH_STRUCT(AdamTilingData<4>, td, tiling);
2003
+ AdamKernel<half, 4> kernel;
2004
+ GM_ADDR ins[10] = {input0, input1, input2, input3, input4,
2005
+ mul0_x, mul1_x, mul2_x, mul3_x, add2_y};
2006
+ GM_ADDR outs[3] = {out0, out1, out2};
2007
+ kernel.Init(ins, outs, &td);
2008
+ kernel.Process();
2009
+ } else {
2010
+ GET_TILING_DATA_WITH_STRUCT(AdamTilingData<8>, td, tiling);
2011
+ AdamKernel<half, 8> kernel;
2012
+ GM_ADDR ins[10] = {input0, input1, input2, input3, input4,
2013
+ mul0_x, mul1_x, mul2_x, mul3_x, add2_y};
2014
+ GM_ADDR outs[3] = {out0, out1, out2};
2015
+ kernel.Init(ins, outs, &td);
2016
+ kernel.Process();
2017
+ }
2018
+ }
2019
+ ```
2020
+
2021
+ ### 6.4 Kernel 类 — {算子}_kernel.h
2022
+
2023
+ #### 成员变量
2024
+
2025
+ 5 个 TBuf buffer 就是 5 个物理 UB buffer。每个 buffer 不绑定死角色——本轮迭代中,同一个 buffer 可以先拿来做 CopyIn,释放后做中间结果,再释放后做 CopyOut。这种动态复用是 TBuf 相比 TQue 的核心优势。
2026
+
2027
+ | 成员 | 类型 | 数量 | 物理意义 |
2028
+ |------|------|------|---------|
2029
+ | `td_` | `const AdamTilingData<RANK>*` | 1 | 只读 TilingData 指针 |
2030
+ | `pipe_` | `TPipe` | 1 | 流水线管理器 |
2031
+ | `gmIn_[i]` | `GlobalTensor<T>` | 10 | 入参 GM 视图 |
2032
+ | `gmOut_[i]` | `GlobalTensor<T>` | 3 | 出参 GM 视图 |
2033
+ | `buf_[i]` | `TBuf<TPosition::VECCALC>` | 5 | **P=5 个万能 UB buffer buffer** |
2034
+
2035
+ #### 方法
2036
+
2037
+ | 方法 | 访问 | 职责 |
2038
+ |------|------|------|
2039
+ | `Init` | public | 绑定 10+3 个 GlobalTensor,初始化 5 个 TBuf |
2040
+ | `Process` | public | 主循环:按 §3 计算流逐步 Copy→Compute,遵从生命表 |
2041
+ | `CopyInBrc` | private | 搬单个入参到指定 TBuf buffer |
2042
+ | `CopyOutOne` | private | 从指定 TBuf buffer 搬单个出参到 GM |
2043
+
2044
+ #### 类声明
2045
+
2046
+ ```cpp
2047
+ template <typename T, int64_t RANK>
2048
+ class AdamKernel {
2049
+ public:
2050
+ __aicore__ inline void Init(
2051
+ GM_ADDR inputs[10], GM_ADDR outputs[3],
2052
+ const AdamTilingData<RANK>* td);
2053
+ __aicore__ inline void Process();
2054
+
2055
+ private:
2056
+ __aicore__ inline void CopyInBrc(
2057
+ const int64_t* coord, int32_t inputIdx, int32_t buffer, int64_t count);
2058
+ __aicore__ inline void CopyOutOne(
2059
+ const int64_t* coord, int32_t outputIdx, int32_t buffer, int64_t count);
2060
+
2061
+ TPipe pipe_;
2062
+ const AdamTilingData<RANK>* td_;
2063
+ GlobalTensor<T> gmIn_[10];
2064
+ GlobalTensor<T> gmOut_[3];
2065
+ TBuf<TPosition::VECCALC> buf_[5];
2066
+ };
2067
+ ```
2068
+
2069
+ 以下逐方法展开实现。
2070
+
2071
+ #### 6.4.1 Init — 建立流水线
2072
+
2073
+ 绑定 GM 地址,初始化 5 个 TBuf 为最大 tile 大小。
2074
+
2075
+ ```cpp
2076
+ __aicore__ inline void Init(
2077
+ GM_ADDR inputs[10], GM_ADDR outputs[3],
2078
+ const AdamTilingData<RANK>* td)
2079
+ {
2080
+ td_ = td;
2081
+ for (int32_t i = 0; i < 10; i++)
2082
+ gmIn_[i].SetGlobalBuffer((__gm__ T*)inputs[i]);
2083
+ for (int32_t i = 0; i < 3; i++)
2084
+ gmOut_[i].SetGlobalBuffer((__gm__ T*)outputs[i]);
2085
+
2086
+ for (int32_t i = 0; i < 5; i++)
2087
+ pipe_.InitBuffer(buf_[i], td_->perBufBytes);
2088
+ }
2089
+ ```
2090
+
2091
+ #### 6.4.2 Process — 主循环(无同步版)
2092
+
2093
+ **本节目标**:
2094
+ 1. **实现** — 基于 §3 计算流伪码实现 Kernel 主循环
2095
+ 2. **标注** — 基于持有法则,每个执行动作标注执行前/中/后 buffer 持有列表(详见 `knowledge/coding/hold-law.md`)
2096
+ 3. **验证** — 计算流、内存持有、物理存活节点 P=5、§3 伪码 四者一致。不一致不通过
2097
+
2098
+ 同步后置,本版本不包含。
2099
+
2100
+ ```cpp
2101
+ __aicore__ inline void Process() {
2102
+ int64_t start, end;
2103
+ GetCoreRange(GetBlockIdx(), td_->multicore.usedCoreNum,
2104
+ td_->multicore.totalTiles, td_->multicore.mainTiles,
2105
+ td_->multicore.mainCoreNum, start, end);
2106
+
2107
+ constexpr int32_t UB0 = 0, UB1 = 1, UB2 = 2, UB3 = 3, UB4 = 4;
2108
+ constexpr int32_t IN0 = 0, IN1 = 1, IN2 = 2, IN3 = 3, IN4 = 4;
2109
+ constexpr int32_t MUL = 5, MUL1 = 6, MUL2 = 7, MUL3 = 8, ADD2 = 9;
2110
+ constexpr int32_t OUT0 = 0, OUT1 = 1, OUT2 = 2;
2111
+
2112
+ int64_t coord[8] = {};
2113
+ for (int64_t flat = start; flat < end; flat++) {
2114
+ int64_t ubBlockLength = GetUBSplitRange(flat % td_->split.ubOuter, td_->split.ubOuter,
2115
+ td_->split.ubFactor, td_->split.ubTail);
2116
+ int64_t count = ubBlockLength;
2117
+ FlatToEffectiveCoord(flat, td_->maxBroShape, RANK,
2118
+ td_->split.ubSplitIdx, td_->split.ubFactor, td_->split.ubOuter, coord);
2119
+
2120
+ // ═══ S1: in0 → square ═══
2121
+ // 执行前: 持有=[]
2122
+ // 执行中: 持有=[UB0]
2123
+ // 执行后: 持有=[UB0]
2124
+ CopyInBrc(coord, IN0, UB0);
2125
+ // 执行前: 持有=[UB0]
2126
+ // 执行中: 持有=[UB0, UB2]
2127
+ // 执行后: 持有=[UB0, UB2]
2128
+ AscendC::Mul(buf_[UB2].Get<T>(), buf_[UB0].Get<T>(), buf_[UB0].Get<T>(), count);
2129
+
2130
+ // ═══ S2: in0·mul1_x → mul1 ═══
2131
+ // 执行前: 持有=[UB0, UB2]
2132
+ // 执行中: 持有=[UB0, UB1, UB2]
2133
+ // 执行后: 持有=[UB0, UB1, UB2]
2134
+ CopyInBrc(coord, MUL1, UB1);
2135
+ // 执行前: 持有=[UB0, UB1, UB2]
2136
+ // 执行中: 持有=[UB0, UB1, UB2, UB3]
2137
+ // 执行后: 持有=[UB2, UB3]
2138
+ AscendC::Mul(buf_[UB3].Get<T>(), buf_[UB0].Get<T>(), buf_[UB1].Get<T>(), count);
2139
+
2140
+ // ═══ S3: MulAddDst(mul1, dataM, mul0_x) → output1 ═══
2141
+ // 执行前: 持有=[UB2, UB3]
2142
+ // 执行中: 持有=[UB0, UB2, UB3]
2143
+ // 执行后: 持有=[UB0, UB2, UB3]
2144
+ CopyInBrc(coord, IN2, UB0);
2145
+ // 执行前: 持有=[UB0, UB2, UB3]
2146
+ // 执行中: 持有=[UB0, UB1, UB2, UB3]
2147
+ // 执行后: 持有=[UB0, UB1, UB2, UB3]
2148
+ CopyInBrc(coord, MUL, UB1);
2149
+ // 执行前: 持有=[UB0, UB1, UB2, UB3]
2150
+ // 执行中: 持有=[UB0, UB1, UB2, UB3]
2151
+ // 执行后: 持有=[UB2, UB3]
2152
+ asc_vf_call<MulAddVF<T>>(buf_[UB3], buf_[UB1], buf_[UB0], count);
2153
+
2154
+ // ═══ S4: square·mul3_x → mul3 ═══
2155
+ // 执行前: 持有=[UB2, UB3]
2156
+ // 执行中: 持有=[UB2, UB3, UB4]
2157
+ // 执行后: 持有=[UB2, UB3, UB4]
2158
+ CopyInBrc(coord, MUL3, UB4);
2159
+ // 执行前: 持有=[UB2, UB3, UB4]
2160
+ // 执行中: 持有=[UB2, UB3, UB4]
2161
+ // 执行后: 持有=[UB3, UB4]
2162
+ AscendC::Mul(buf_[UB4].Get<T>(), buf_[UB2].Get<T>(), buf_[UB4].Get<T>(), count);
2163
+
2164
+ // ═══ S5: MulAddDst(mul3, dataV, mul2_x) → output0 ═══
2165
+ // 执行前: 持有=[UB3, UB4]
2166
+ // 执行中: 持有=[UB0, UB3, UB4]
2167
+ // 执行后: 持有=[UB0, UB3, UB4]
2168
+ CopyInBrc(coord, IN1, UB0);
2169
+ // 执行前: 持有=[UB0, UB3, UB4]
2170
+ // 执行中: 持有=[UB0, UB2, UB3, UB4]
2171
+ // 执行后: 持有=[UB0, UB2, UB3, UB4]
2172
+ CopyInBrc(coord, MUL2, UB2);
2173
+ // 执行前: 持有=[UB0, UB2, UB3, UB4]
2174
+ // 执行中: 持有=[UB0, UB2, UB3, UB4]
2175
+ // 执行后: 持有=[UB3, UB4]
2176
+ asc_vf_call<MulAddVF<T>>(buf_[UB4], buf_[UB0], buf_[UB2], count);
2177
+
2178
+ // ═══ S6: sqrt(output0) → sqrt ═══
2179
+ // 执行前: 持有=[UB3, UB4]
2180
+ // 执行中: 持有=[UB0, UB3, UB4]
2181
+ // 执行后: 持有=[UB0, UB3, UB4]
2182
+ AscendC::Sqrt(buf_[UB0].Get<T>(), buf_[UB4].Get<T>(), count);
2183
+
2184
+ // ═══ S7: sqrt + add2_y → add2 ═══
2185
+ // 执行前: 持有=[UB0, UB3, UB4]
2186
+ // 执行中: 持有=[UB0, UB2, UB3, UB4]
2187
+ // 执行后: 持有=[UB0, UB2, UB3, UB4]
2188
+ CopyInBrc(coord, ADD2, UB2);
2189
+ // 执行前: 持有=[UB0, UB2, UB3, UB4]
2190
+ // 执行中: 持有=[UB0, UB1, UB2, UB3, UB4]
2191
+ // 执行后: 持有=[UB1, UB3, UB4]
2192
+ AscendC::Add(buf_[UB1].Get<T>(), buf_[UB0].Get<T>(), buf_[UB2].Get<T>(), count);
2193
+
2194
+ // ═══ S8: output1 / add2 → truediv ═══
2195
+ // 执行前: 持有=[UB1, UB3, UB4]
2196
+ // 执行中: 持有=[UB1, UB2, UB3, UB4]
2197
+ // 执行后: 持有=[UB2, UB3, UB4]
2198
+ AscendC::Div(buf_[UB2].Get<T>(), buf_[UB3].Get<T>(), buf_[UB1].Get<T>(), count);
2199
+
2200
+ // ═══ S9: truediv·input4 → mul4 ═══
2201
+ // 执行前: 持有=[UB2, UB3, UB4]
2202
+ // 执行中: 持有=[UB0, UB2, UB3, UB4]
2203
+ // 执行后: 持有=[UB0, UB2, UB3, UB4]
2204
+ CopyInBrc(coord, IN4, UB0);
2205
+ // 执行前: 持有=[UB0, UB2, UB3, UB4]
2206
+ // 执行中: 持有=[UB0, UB1, UB2, UB3, UB4]
2207
+ // 执行后: 持有=[UB1, UB3, UB4]
2208
+ AscendC::Mul(buf_[UB1].Get<T>(), buf_[UB2].Get<T>(), buf_[UB0].Get<T>(), count);
2209
+
2210
+ // ═══ S10: dataVar − mul4 → output2 ═══
2211
+ // 执行前: 持有=[UB1, UB3, UB4]
2212
+ // 执行中: 持有=[UB0, UB1, UB3, UB4]
2213
+ // 执行后: 持有=[UB0, UB1, UB3, UB4]
2214
+ CopyInBrc(coord, IN3, UB0);
2215
+ // 执行前: 持有=[UB0, UB1, UB3, UB4]
2216
+ // 执行中: 持有=[UB0, UB1, UB2, UB3, UB4]
2217
+ // 执行后: 持有=[UB2, UB3, UB4]
2218
+ AscendC::Sub(buf_[UB2].Get<T>(), buf_[UB0].Get<T>(), buf_[UB1].Get<T>(), count);
2219
+
2220
+ // ═══ CopyOut ═══
2221
+ // 执行前: 持有=[UB2, UB3, UB4]
2222
+ // 执行中: 持有=[UB2, UB3, UB4]
2223
+ // 执行后: 持有=[UB2, UB3]
2224
+ CopyOutOne(coord, OUT0, UB4);
2225
+ // 执行前: 持有=[UB2, UB3]
2226
+ // 执行中: 持有=[UB2, UB3]
2227
+ // 执行后: 持有=[UB2]
2228
+ CopyOutOne(coord, OUT1, UB3);
2229
+ // 执行前: 持有=[UB2]
2230
+ // 执行中: 持有=[UB2]
2231
+ // 执行后: 持有=[]
2232
+ CopyOutOne(coord, OUT2, UB2);
2233
+ }
2234
+ }
2235
+ ```
2236
+
2237
+ **UB 生命周期验证**(逐列 = 该步最后一个 Compute 执行后持有,与代码注释逐行对照):
2238
+
2239
+ | UB | S1 | S2 | S3 | S4 | S5 | S6 | S7 | S8 | S9 | S10 |
2240
+ |----|----|----|----|----|----|----|----|----|----|-----|
2241
+ | UB0 | in0→S2 | — | — | — | — | sqrt→S7 | — | — | — | — |
2242
+ | UB1 | — | — | — | — | — | — | add2→S8 | — | mul4→S10 | — |
2243
+ | UB2 | square→S4 | square→S4 | square→S4 | — | — | — | — | truediv→S9 | — | output2→Out |
2244
+ | UB3 | — | mul1→S3 | output1→S8 | output1→S8 | output1→S8 | output1→S8 | output1→S8 | output1→Out | output1→Out | output1→Out |
2245
+ | UB4 | — | — | — | mul3→S5 | output0→Out | output0→Out | output0→Out | output0→Out | output0→Out | output0→Out |
2246
+ | 持有 | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 | 3 |
2247
+ | 执行中峰值 | 2 | 4 | 4 | 3 | 4 | 3 | **5** | 4 | **5** | **5** |
2248
+
2249
+ 验证:持有行 ≤3 ≤ P=5 ✓;峰值 S7/S9/S10 达到 5,与 §2 一致 ✓;释放时机与 §3 一致 ✓。
2250
+
2251
+ #### 6.4.3 Process — 主循环(同步版)
2252
+
2253
+ **本节目标**:在 6.4.2 无同步版基础上,基于持有法则暴露的 RAW/WAR 依赖,插入 SetFlag/WaitFlag(详见 `knowledge/coding/sync.md`)。
2254
+
2255
+ **同步点推导**(从 6.4.2 持有注释逐行分析):
2256
+
2257
+ | 事件 | 依赖 | 次数 | 触发条件(持有注释直接可见) |
2258
+ |------|------|------|---------------------------|
2259
+ | MTE2_V | RAW | 8 | CopyIn 后执行后含某 buffer → 下一 Compute 执行中含该 buffer(S1/S2/S3/S4+S5/S7/S9/S10) |
2260
+ | V_MTE2 | WAR | 4 | V 执行后持有某 buffer → 后续 CopyIn 要覆盖该 buffer(S2→S3 覆盖 UB0,UB1 / S4→S5 覆盖 UB2 / S8→S9 覆盖 UB0 / S9→S10 覆盖 UB0) |
2261
+ | V_MTE3 | RAW | 1 | S10 执行后持有 [UB2,UB3,UB4] → CopyOut 的 MTE3 要读这些 buffer |
2262
+ | MTE3_MTE2 | WAR 跨迭代 | 1 | 上轮 CopyOut 读 UB2 → 下轮 S5 CopyIn 写 UB2 |
2263
+
2264
+ ```cpp
2265
+ __aicore__ inline void Process() {
2266
+ event_t evMTE2toV = static_cast<event_t>(
2267
+ GetTPipePtr()->FetchEventID(HardEvent::MTE2_V));
2268
+ event_t evVtoMTE2 = static_cast<event_t>(
2269
+ GetTPipePtr()->FetchEventID(HardEvent::V_MTE2));
2270
+ event_t evVtoMTE3 = static_cast<event_t>(
2271
+ GetTPipePtr()->FetchEventID(HardEvent::V_MTE3));
2272
+ event_t evMTE3toMTE2 = static_cast<event_t>(
2273
+ GetTPipePtr()->FetchEventID(HardEvent::MTE3_MTE2));
2274
+
2275
+ int64_t start, end;
2276
+ GetCoreRange(GetBlockIdx(), td_->multicore.usedCoreNum,
2277
+ td_->multicore.totalTiles, td_->multicore.mainTiles,
2278
+ td_->multicore.mainCoreNum, start, end);
2279
+
2280
+ constexpr int32_t UB0 = 0, UB1 = 1, UB2 = 2, UB3 = 3, UB4 = 4;
2281
+ constexpr int32_t IN0 = 0, IN1 = 1, IN2 = 2, IN3 = 3, IN4 = 4;
2282
+ constexpr int32_t MUL = 5, MUL1 = 6, MUL2 = 7, MUL3 = 8, ADD2 = 9;
2283
+ constexpr int32_t OUT0 = 0, OUT1 = 1, OUT2 = 2;
2284
+
2285
+ int64_t coord[8] = {};
2286
+ for (int64_t flat = start; flat < end; flat++) {
2287
+ int64_t ubBlockLength = GetUBSplitRange(flat % td_->split.ubOuter, td_->split.ubOuter,
2288
+ td_->split.ubFactor, td_->split.ubTail);
2289
+ int64_t count = ubBlockLength;
2290
+ FlatToEffectiveCoord(flat, td_->maxBroShape, RANK,
2291
+ td_->split.ubSplitIdx, td_->split.ubFactor, td_->split.ubOuter, coord);
2292
+
2293
+ // MTE3→MTE2: 等上一轮 CopyOut 读完 UB (首轮跳过)
2294
+ if (flat != start) WaitFlag<HardEvent::MTE3_MTE2>(evMTE3toMTE2);
2295
+
2296
+ // ═══ S1: in0 → square ═══
2297
+ // 执行前: 持有=[]
2298
+ // 执行中: 持有=[UB0]
2299
+ // 执行后: 持有=[UB0]
2300
+ CopyInBrc(coord, IN0, UB0);
2301
+ // MTE2→V: MTE2 写完 UB0, V 可以读
2302
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2303
+ // 执行前: 持有=[UB0]
2304
+ // 执行中: 持有=[UB0, UB2]
2305
+ // 执行后: 持有=[UB0, UB2]
2306
+ AscendC::Mul(buf_[UB2].Get<T>(), buf_[UB0].Get<T>(), buf_[UB0].Get<T>(), count);
2307
+
2308
+ // ═══ S2: in0·mul1_x → mul1 ═══
2309
+ // 执行前: 持有=[UB0, UB2]
2310
+ // 执行中: 持有=[UB0, UB1, UB2]
2311
+ // 执行后: 持有=[UB0, UB1, UB2]
2312
+ CopyInBrc(coord, MUL1, UB1);
2313
+ // MTE2→V
2314
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2315
+ // 执行前: 持有=[UB0, UB1, UB2]
2316
+ // 执行中: 持有=[UB0, UB1, UB2, UB3]
2317
+ // 执行后: 持有=[UB2, UB3]
2318
+ AscendC::Mul(buf_[UB3].Get<T>(), buf_[UB0].Get<T>(), buf_[UB1].Get<T>(), count);
2319
+ // V→MTE2: V 读完 UB0,UB1, MTE2 可覆盖 (S3 将写 UB0,UB1)
2320
+ SetFlag<HardEvent::V_MTE2>(evVtoMTE2); WaitFlag<HardEvent::V_MTE2>(evVtoMTE2);
2321
+
2322
+ // ═══ S3: MulAddDst(mul1, dataM, mul0_x) → output1 ═══
2323
+ // 执行前: 持有=[UB2, UB3]
2324
+ // 执行中: 持有=[UB0, UB2, UB3]
2325
+ // 执行后: 持有=[UB0, UB2, UB3]
2326
+ CopyInBrc(coord, IN2, UB0);
2327
+ // 执行前: 持有=[UB0, UB2, UB3]
2328
+ // 执行中: 持有=[UB0, UB1, UB2, UB3]
2329
+ // 执行后: 持有=[UB0, UB1, UB2, UB3]
2330
+ CopyInBrc(coord, MUL, UB1);
2331
+ // MTE2→V
2332
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2333
+ // 执行前: 持有=[UB0, UB1, UB2, UB3]
2334
+ // 执行中: 持有=[UB0, UB1, UB2, UB3]
2335
+ // 执行后: 持有=[UB2, UB3]
2336
+ asc_vf_call<MulAddVF<T>>(buf_[UB3], buf_[UB1], buf_[UB0], count);
2337
+
2338
+ // ═══ S4: square·mul3_x → mul3 ═══
2339
+ // 执行前: 持有=[UB2, UB3]
2340
+ // 执行中: 持有=[UB2, UB3, UB4]
2341
+ // 执行后: 持有=[UB2, UB3, UB4]
2342
+ CopyInBrc(coord, MUL3, UB4);
2343
+ // MTE2→V
2344
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2345
+ // 执行前: 持有=[UB2, UB3, UB4]
2346
+ // 执行中: 持有=[UB2, UB3, UB4]
2347
+ // 执行后: 持有=[UB3, UB4]
2348
+ AscendC::Mul(buf_[UB4].Get<T>(), buf_[UB2].Get<T>(), buf_[UB4].Get<T>(), count);
2349
+ // V→MTE2: V 读完 UB2, MTE2 可覆盖 (S5 将写 UB2)
2350
+ SetFlag<HardEvent::V_MTE2>(evVtoMTE2); WaitFlag<HardEvent::V_MTE2>(evVtoMTE2);
2351
+
2352
+ // ═══ S5: MulAddDst(mul3, dataV, mul2_x) → output0 ═══
2353
+ // 执行前: 持有=[UB3, UB4]
2354
+ // 执行中: 持有=[UB0, UB3, UB4]
2355
+ // 执行后: 持有=[UB0, UB3, UB4]
2356
+ CopyInBrc(coord, IN1, UB0);
2357
+ // 执行前: 持有=[UB0, UB3, UB4]
2358
+ // 执行中: 持有=[UB0, UB2, UB3, UB4]
2359
+ // 执行后: 持有=[UB0, UB2, UB3, UB4]
2360
+ CopyInBrc(coord, MUL2, UB2);
2361
+ // MTE2→V
2362
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2363
+ // 执行前: 持有=[UB0, UB2, UB3, UB4]
2364
+ // 执行中: 持有=[UB0, UB2, UB3, UB4]
2365
+ // 执行后: 持有=[UB3, UB4]
2366
+ asc_vf_call<MulAddVF<T>>(buf_[UB4], buf_[UB0], buf_[UB2], count);
2367
+
2368
+ // ═══ S6: sqrt(output0) → sqrt ═══
2369
+ // 执行前: 持有=[UB3, UB4]
2370
+ // 执行中: 持有=[UB0, UB3, UB4]
2371
+ // 执行后: 持有=[UB0, UB3, UB4]
2372
+ AscendC::Sqrt(buf_[UB0].Get<T>(), buf_[UB4].Get<T>(), count);
2373
+
2374
+ // ═══ S7: sqrt + add2_y → add2 ═══
2375
+ // 执行前: 持有=[UB0, UB3, UB4]
2376
+ // 执行中: 持有=[UB0, UB2, UB3, UB4]
2377
+ // 执行后: 持有=[UB0, UB2, UB3, UB4]
2378
+ CopyInBrc(coord, ADD2, UB2);
2379
+ // MTE2→V
2380
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2381
+ // 执行前: 持有=[UB0, UB2, UB3, UB4]
2382
+ // 执行中: 持有=[UB0, UB1, UB2, UB3, UB4]
2383
+ // 执行后: 持有=[UB1, UB3, UB4]
2384
+ AscendC::Add(buf_[UB1].Get<T>(), buf_[UB0].Get<T>(), buf_[UB2].Get<T>(), count);
2385
+
2386
+ // ═══ S8: output1 / add2 → truediv ═══
2387
+ // 执行前: 持有=[UB1, UB3, UB4]
2388
+ // 执行中: 持有=[UB1, UB2, UB3, UB4]
2389
+ // 执行后: 持有=[UB2, UB3, UB4]
2390
+ AscendC::Div(buf_[UB2].Get<T>(), buf_[UB3].Get<T>(), buf_[UB1].Get<T>(), count);
2391
+ // V→MTE2: V 读完 UB0 (S7 Add), MTE2 可覆盖 (S9 将写 UB0)
2392
+ SetFlag<HardEvent::V_MTE2>(evVtoMTE2); WaitFlag<HardEvent::V_MTE2>(evVtoMTE2);
2393
+
2394
+ // ═══ S9: truediv·input4 → mul4 ═══
2395
+ // 执行前: 持有=[UB2, UB3, UB4]
2396
+ // 执行中: 持有=[UB0, UB2, UB3, UB4]
2397
+ // 执行后: 持有=[UB0, UB2, UB3, UB4]
2398
+ CopyInBrc(coord, IN4, UB0);
2399
+ // MTE2→V
2400
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2401
+ // 执行前: 持有=[UB0, UB2, UB3, UB4]
2402
+ // 执行中: 持有=[UB0, UB1, UB2, UB3, UB4]
2403
+ // 执行后: 持有=[UB1, UB3, UB4]
2404
+ AscendC::Mul(buf_[UB1].Get<T>(), buf_[UB2].Get<T>(), buf_[UB0].Get<T>(), count);
2405
+ // V→MTE2: V 读完 UB0, MTE2 可覆盖 (S10 将写 UB0)
2406
+ SetFlag<HardEvent::V_MTE2>(evVtoMTE2); WaitFlag<HardEvent::V_MTE2>(evVtoMTE2);
2407
+
2408
+ // ═══ S10: dataVar − mul4 → output2 ═══
2409
+ // 执行前: 持有=[UB1, UB3, UB4]
2410
+ // 执行中: 持有=[UB0, UB1, UB3, UB4]
2411
+ // 执行后: 持有=[UB0, UB1, UB3, UB4]
2412
+ CopyInBrc(coord, IN3, UB0);
2413
+ // MTE2→V
2414
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2415
+ // 执行前: 持有=[UB0, UB1, UB3, UB4]
2416
+ // 执行中: 持有=[UB0, UB1, UB2, UB3, UB4]
2417
+ // 执行后: 持有=[UB2, UB3, UB4]
2418
+ AscendC::Sub(buf_[UB2].Get<T>(), buf_[UB0].Get<T>(), buf_[UB1].Get<T>(), count);
2419
+
2420
+ // V→MTE3: V 写完 UB2,UB3,UB4 → MTE3 可搬
2421
+ SetFlag<HardEvent::V_MTE3>(evVtoMTE3); WaitFlag<HardEvent::V_MTE3>(evVtoMTE3);
2422
+
2423
+ // ═══ CopyOut ═══
2424
+ // 执行前: 持有=[UB2, UB3, UB4]
2425
+ // 执行中: 持有=[UB2, UB3, UB4]
2426
+ // 执行后: 持有=[UB2, UB3]
2427
+ CopyOutOne(coord, OUT0, UB4);
2428
+ // 执行前: 持有=[UB2, UB3]
2429
+ // 执行中: 持有=[UB2, UB3]
2430
+ // 执行后: 持有=[UB2]
2431
+ CopyOutOne(coord, OUT1, UB3);
2432
+ // 执行前: 持有=[UB2]
2433
+ // 执行中: 持有=[UB2]
2434
+ // 执行后: 持有=[]
2435
+ CopyOutOne(coord, OUT2, UB2);
2436
+
2437
+ // MTE3→MTE2: MTE3 读完, 通知下轮 MTE2 (末轮跳过)
2438
+ if (flat != end - 1) SetFlag<HardEvent::MTE3_MTE2>(evMTE3toMTE2);
2439
+ }
2440
+ }
2441
+ ```
2442
+
2443
+ #### 6.4.4 函数模块
2444
+
2445
+ **本节目标**:将 §3 计算流伪码中的 DataCopy 映射为 AscendC API。核心是搞清楚 NDDMA 的接口契约,把 broadcast 做对。这不是 Adam 特例,是所有 Vector 算子搬入搬出的通用模式。详见 `knowledge/coding/nddma-programming.md`。
2446
+
2447
+ 三条关键知识:
2448
+ - **loopSize = 目标 shape**(broadcast 后大小),非源 shape;srcStride=0 控制播轴
2449
+ - **NDDMA dim[0]=最内维**,Tiling d=RANK-1=最内维,`nd = RANK-1-d` 翻转
2450
+ - **inputStrides = GM 物理 stride**(PrecomputeStrides 已算好,播轴=0),直接填 loopSrcStride
2451
+
2452
+ ##### CopyInBrc — 基础版
2453
+
2454
+ NDDMA 随路 broadcast 搬入。每 tile 调用时构造 loopInfo,只有 `ubBlockLength` 和受其影响的 `inner`/`dstStride` 是动态的。
2455
+
2456
+ ```cpp
2457
+ __aicore__ inline void CopyInBrc(
2458
+ const int64_t* coord, int32_t inputIdx, int32_t buffer, int64_t ubBlockLength)
2459
+ {
2460
+ int64_t k = td_->split.ubSplitIdx;
2461
+ int64_t off = CalcOffset(coord, td_->inputStrides[inputIdx], RANK);
2462
+ const int64_t* dstShape = td_->maxBroShape;
2463
+
2464
+ if constexpr (RANK <= MAX_NDDMA_DIMS) {
2465
+ AscendC::MultiCopyLoopInfo<RANK> loopInfo;
2466
+ int64_t inner = 1;
2467
+ for (int64_t d = RANK - 1; d >= 0; d--) {
2468
+ int64_t nd = RANK - 1 - d;
2469
+ loopInfo.loopSize[nd] = (d == k) ? ubBlockLength : dstShape[d];
2470
+ loopInfo.loopSrcStride[nd] = td_->inputStrides[inputIdx][d];
2471
+ loopInfo.loopDstStride[nd] = inner;
2472
+ inner *= loopInfo.loopSize[nd];
2473
+ }
2474
+ AscendC::MultiCopyParams<T, RANK> params = { loopInfo, 0 };
2475
+ static constexpr AscendC::NdDmaConfig cfg = { false };
2476
+ AscendC::DataCopy<T, RANK, cfg>(buf_[buffer].Get<T>(), gmIn_[inputIdx][off], params);
2477
+
2478
+ } else {
2479
+ constexpr int64_t ND = MAX_NDDMA_DIMS, outerRank = RANK - ND;
2480
+ AscendC::MultiCopyLoopInfo<ND> loopInfo;
2481
+ int64_t inner = 1;
2482
+ for (int64_t d = RANK - 1; d >= outerRank; d--) {
2483
+ int64_t nd = RANK - 1 - d;
2484
+ loopInfo.loopSize[nd] = (d == k) ? ubBlockLength : dstShape[d];
2485
+ loopInfo.loopSrcStride[nd] = td_->inputStrides[inputIdx][d];
2486
+ loopInfo.loopDstStride[nd] = inner;
2487
+ inner *= loopInfo.loopSize[nd];
2488
+ }
2489
+ AscendC::MultiCopyParams<T, ND> params = { loopInfo, 0 };
2490
+ static constexpr AscendC::NdDmaConfig cfg = { false };
2491
+ LocalTensor<T> buf = buf_[buffer].Get<T>();
2492
+
2493
+ int64_t outerIters = 1;
2494
+ for (int64_t d = 0; d < outerRank; d++)
2495
+ outerIters *= (d == k) ? ubBlockLength : dstShape[d];
2496
+
2497
+ int64_t elemBase = off / sizeof(T);
2498
+ for (int64_t oi = 0; oi < outerIters; oi++) {
2499
+ int64_t elemAdj = 0, tmp = oi;
2500
+ for (int64_t d = outerRank - 1; d >= 0; d--) {
2501
+ int64_t sz = (d == k) ? ubBlockLength : dstShape[d];
2502
+ elemAdj += (tmp % sz) * td_->inputStrides[inputIdx][d];
2503
+ tmp /= sz;
2504
+ }
2505
+ AscendC::DataCopy<T, ND, cfg>(
2506
+ buf[oi * inner], gmIn_[inputIdx][elemBase + elemAdj], params);
2507
+ }
2508
+ }
2509
+ }
2510
+ ```
2511
+
2512
+ ##### CopyInBrc — 优化版
2513
+
2514
+ 基础版中 loopSrcStride、非切分轴 loopSize、loopLpSize/loopRpSize 不随 tile 变化。Init 时预计算 10 路输入的 `MultiCopyParams` 存入成员数组,运行时直接复用——仅切分轴的 `loopSize[k]` 及依赖它的 `inner`/`dstStride` 需要按 `ubBlockLength` 调整。
2515
+
2516
+ 成员变量新增:
2517
+
2518
+ ```cpp
2519
+ // RANK≤5 时用 MultiCopyParams<T,RANK>, RANK>5 时用 MultiCopyParams<T,MAX_NDDMA_DIMS>
2520
+ static constexpr int64_t MAX_NDDMA_DIMS = 5;
2521
+ static constexpr int64_t ND = (RANK <= MAX_NDDMA_DIMS) ? RANK : MAX_NDDMA_DIMS;
2522
+ AscendC::MultiCopyParams<T, ND> nddmaParams_[MAX_INPUT_SLOTS]; // 每输入一路, Init 预填
2523
+ int64_t nddmaOuterIters_[MAX_INPUT_SLOTS]; // RANK>5 时外维迭代总数
2524
+ ```
2525
+
2526
+ Init 中预计算(与基础版构造逻辑相同,`ubBlockLength` 位置先填占位值 `0`):
2527
+
2528
+ ```cpp
2529
+ for (int32_t inp = 0; inp < 10; inp++) {
2530
+ int64_t inner = 1;
2531
+ for (int64_t d = RANK - 1; d >= RANK - ND; d--) {
2532
+ int64_t nd = RANK - 1 - d;
2533
+ nddmaParams_[inp].loopInfo.loopSize[nd] = (d == k) ? 0 /* 占位 */ : dstShape[d];
2534
+ nddmaParams_[inp].loopInfo.loopSrcStride[nd] = td_->inputStrides[inp][d];
2535
+ nddmaParams_[inp].loopInfo.loopDstStride[nd] = inner;
2536
+ inner *= (d == k) ? td_->split.ubFactor : dstShape[d]; // 按满 tile 算 inner
2537
+ }
2538
+ // RANK>5 时算外维迭代数
2539
+ nddmaOuterIters_[inp] = 1;
2540
+ for (int64_t d = 0; d < RANK - ND; d++)
2541
+ nddmaOuterIters_[inp] *= (d == k) ? td_->split.ubFactor : dstShape[d];
2542
+ }
2543
+ ```
2544
+
2545
+ ```cpp
2546
+ __aicore__ inline void CopyInBrcFast(
2547
+ const int64_t* coord, int32_t inputIdx, int32_t buffer, int64_t ubBlockLength)
2548
+ {
2549
+ int64_t k = td_->split.ubSplitIdx;
2550
+ int64_t off = CalcOffset(coord, td_->inputStrides[inputIdx], RANK);
2551
+ const int64_t* dstShape = td_->maxBroShape;
2552
+
2553
+ // 复用预计算参数,仅更新受 ubBlockLength 影响的字段
2554
+ auto params = nddmaParams_[inputIdx];
2555
+ int64_t baseInner = params.loopInfo.loopDstStride[0];
2556
+ int64_t kNd = RANK - 1 - k;
2557
+ int64_t inner = 1;
2558
+ for (int64_t nd = 0; nd < ND; nd++) {
2559
+ if (nd == kNd) {
2560
+ params.loopInfo.loopSize[nd] = ubBlockLength;
2561
+ }
2562
+ params.loopInfo.loopDstStride[nd] = inner;
2563
+ inner *= params.loopInfo.loopSize[nd];
2564
+ }
2565
+
2566
+ static constexpr AscendC::NdDmaConfig cfg = { false };
2567
+
2568
+ if constexpr (RANK <= MAX_NDDMA_DIMS) {
2569
+ AscendC::DataCopy<T, ND, cfg>(buf_[buffer].Get<T>(), gmIn_[inputIdx][off], params);
2570
+ } else {
2571
+ LocalTensor<T> buf = buf_[buffer].Get<T>();
2572
+ int64_t elemBase = off / sizeof(T);
2573
+ for (int64_t oi = 0; oi < nddmaOuterIters_[inputIdx]; oi++) {
2574
+ int64_t elemAdj = 0, tmp = oi;
2575
+ for (int64_t d = RANK - ND - 1; d >= 0; d--) {
2576
+ int64_t sz = (d == k) ? ubBlockLength : dstShape[d];
2577
+ elemAdj += (tmp % sz) * td_->inputStrides[inputIdx][d];
2578
+ tmp /= sz;
2579
+ }
2580
+ AscendC::DataCopy<T, ND, cfg>(
2581
+ buf[oi * inner], gmIn_[inputIdx][elemBase + elemAdj], params);
2582
+ }
2583
+ }
2584
+ }
2585
+ ```
2586
+
2587
+ ##### MulAddVF
2588
+
2589
+ `Reg::MulAddDst` 的 VF 包装。单指令 `dst = src0 * src1 + dst`,替代 Mul + Add 两步。
2590
+
2591
+ ```cpp
2592
+ template <typename T>
2593
+ __simd_vf__ inline void MulAddVF(
2594
+ __ubuf__ T* dstAddr, __ubuf__ T* src0Addr, __ubuf__ T* src1Addr,
2595
+ uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes)
2596
+ {
2597
+ AscendC::Reg::RegTensor<T> srcReg0, srcReg1, dstReg;
2598
+ AscendC::Reg::MaskReg mask;
2599
+ AscendC::Reg::AddrReg aReg;
2600
+
2601
+ for (uint16_t i = 0; i < repeatTimes; ++i) {
2602
+ aReg = AscendC::Reg::CreateAddrReg<T>(i, oneRepeatSize);
2603
+ mask = AscendC::Reg::UpdateMask<T>(count);
2604
+ AscendC::Reg::LoadAlign(srcReg0, src0Addr, aReg);
2605
+ AscendC::Reg::LoadAlign(srcReg1, src1Addr, aReg);
2606
+ AscendC::Reg::LoadAlign(dstReg, dstAddr, aReg);
2607
+ AscendC::Reg::MulAddDst(dstReg, srcReg0, srcReg1, mask);
2608
+ AscendC::Reg::StoreAlign(dstAddr, dstReg, aReg, mask);
2609
+ }
2610
+ }
2611
+ ```
2612
+
2613
+ ##### CopyOutOne
2614
+
2615
+ UB→GM 单路搬出。无 broadcast,普通 DataCopy。
2616
+
2617
+ ```cpp
2618
+ // coord — 当前 tile 的 multi-index 坐标, +outputStrides → GM 地址
2619
+ // outputIdx — 哪个输出 (0..2), 索引 td_->outputShapes/outputStrides/gmOut_
2620
+ // buffer — 源 TBuf (UB0..UB4)
2621
+ // ubBlockLength — 切分轴本轮段长, 决定搬运元素数
2622
+ __aicore__ inline void CopyOutOne(
2623
+ const int64_t* coord, int32_t outputIdx, int32_t buffer, int64_t ubBlockLength)
2624
+ {
2625
+ int64_t off = CalcOffset(coord, td_->outputStrides[outputIdx], RANK);
2626
+ int64_t cnt = CalcTransferCount(td_->outputShapes[outputIdx], RANK,
2627
+ td_->split.ubSplitIdx, ubBlockLength);
2628
+ LocalTensor<T> buf = buf_[buffer].Get<T>();
2629
+ DataCopy(gmOut_[outputIdx][off], buf, cnt);
2630
+ }
2631
+ ```
2632
+
2633
+ - NDDMA 不支持 UB→GM,直接普通 DataCopy
2634
+ - output 无 broadcast 需求,shape 已是 broadcast 后形态
2635
+
2636
+ #### 6.4.5 kernel.h 完全体
2637
+
2638
+ 取各节最优版本,统一修掉前面的小毛病,产出完整可用的 `adam_apply_one_assign_kernel.h`。
2639
+
2640
+ **取法**:Init = 6.4.1 + 6.4.4 优化版,Process = 6.4.3 同步版 + 6.4.4 函数模块,私有方法 = 6.4.4 优化版,MulAddVF = 见 6.4.4。
2641
+
2642
+ ```cpp
2643
+ template <typename T, int64_t RANK>
2644
+ class AdamKernel {
2645
+ static constexpr int64_t MAX_NDDMA_DIMS = 5;
2646
+ static constexpr int64_t ND = (RANK <= MAX_NDDMA_DIMS) ? RANK : MAX_NDDMA_DIMS;
2647
+ static constexpr uint32_t VL = AscendC::GetVecLen() / sizeof(T);
2648
+
2649
+ TPipe pipe_;
2650
+ const AdamTilingData<RANK>* td_;
2651
+ GlobalTensor<T> gmIn_[10];
2652
+ GlobalTensor<T> gmOut_[3];
2653
+ TBuf<TPosition::VECCALC> buf_[5];
2654
+ AscendC::MultiCopyParams<T, ND> nddmaParams_[10];
2655
+ int64_t nddmaOuterIters_[10];
2656
+
2657
+ public:
2658
+ __aicore__ inline void Init(GM_ADDR inputs[10], GM_ADDR outputs[3],
2659
+ const AdamTilingData<RANK>* td)
2660
+ {
2661
+ td_ = td;
2662
+ for (int32_t i = 0; i < 10; i++)
2663
+ gmIn_[i].SetGlobalBuffer((__gm__ T*)inputs[i]);
2664
+ for (int32_t i = 0; i < 3; i++)
2665
+ gmOut_[i].SetGlobalBuffer((__gm__ T*)outputs[i]);
2666
+ for (int32_t i = 0; i < 5; i++)
2667
+ pipe_.InitBuffer(buf_[i], td_->perBufBytes);
2668
+
2669
+ // 预计算 10 路 NDDMA 参数 (静态部分, ubBlockLength 运行时更新)
2670
+ const int64_t* dstShape = td_->maxBroShape;
2671
+ int64_t k = td_->split.ubSplitIdx;
2672
+ for (int32_t inp = 0; inp < 10; inp++) {
2673
+ int64_t inner = 1;
2674
+ for (int64_t d = RANK - 1; d >= RANK - ND; d--) {
2675
+ int64_t nd = RANK - 1 - d;
2676
+ nddmaParams_[inp].loopInfo.loopSize[nd] = (d == k) ? 0 : dstShape[d];
2677
+ nddmaParams_[inp].loopInfo.loopSrcStride[nd] = td_->inputStrides[inp][d];
2678
+ nddmaParams_[inp].loopInfo.loopDstStride[nd] = inner;
2679
+ inner *= (d == k) ? td_->split.ubFactor : dstShape[d];
2680
+ }
2681
+ nddmaOuterIters_[inp] = 1;
2682
+ for (int64_t d = 0; d < RANK - ND; d++)
2683
+ nddmaOuterIters_[inp] *= (d == k) ? td_->split.ubFactor : dstShape[d];
2684
+ }
2685
+ }
2686
+
2687
+ __aicore__ inline void Process()
2688
+ {
2689
+ event_t evMTE2toV = static_cast<event_t>(
2690
+ GetTPipePtr()->FetchEventID(HardEvent::MTE2_V));
2691
+ event_t evVtoMTE2 = static_cast<event_t>(
2692
+ GetTPipePtr()->FetchEventID(HardEvent::V_MTE2));
2693
+ event_t evVtoMTE3 = static_cast<event_t>(
2694
+ GetTPipePtr()->FetchEventID(HardEvent::V_MTE3));
2695
+ event_t evMTE3toMTE2 = static_cast<event_t>(
2696
+ GetTPipePtr()->FetchEventID(HardEvent::MTE3_MTE2));
2697
+
2698
+ int64_t start, end;
2699
+ GetCoreRange(GetBlockIdx(), td_->multicore.usedCoreNum,
2700
+ td_->multicore.totalTiles, td_->multicore.mainTiles,
2701
+ td_->multicore.mainCoreNum, start, end);
2702
+
2703
+ constexpr int32_t UB0 = 0, UB1 = 1, UB2 = 2, UB3 = 3, UB4 = 4;
2704
+ constexpr int32_t IN0 = 0, IN1 = 1, IN2 = 2, IN3 = 3, IN4 = 4;
2705
+ constexpr int32_t MUL = 5, MUL1 = 6, MUL2 = 7, MUL3 = 8, ADD2 = 9;
2706
+ constexpr int32_t OUT0 = 0, OUT1 = 1, OUT2 = 2;
2707
+
2708
+ int64_t innerCount = 1;
2709
+ for (int64_t d = td_->split.ubSplitIdx + 1; d < RANK; d++)
2710
+ innerCount *= td_->maxBroShape[d];
2711
+
2712
+ int64_t coord[8] = {};
2713
+ for (int64_t flat = start; flat < end; flat++) {
2714
+ int64_t ubBlockLength = GetUBSplitRange(flat % td_->split.ubOuter, td_->split.ubOuter,
2715
+ td_->split.ubFactor, td_->split.ubTail);
2716
+ int64_t count = ubBlockLength * innerCount;
2717
+ FlatToEffectiveCoord(flat, td_->maxBroShape, RANK,
2718
+ td_->split.ubSplitIdx, td_->split.ubFactor, td_->split.ubOuter, coord);
2719
+
2720
+ if (flat != start) WaitFlag<HardEvent::MTE3_MTE2>(evMTE3toMTE2);
2721
+
2722
+ // ═══ S1: in0 → square ═══
2723
+ // 执行前: 持有=[] 执行中: 持有=[UB0] 执行后: 持有=[UB0]
2724
+ CopyInBrc(coord, IN0, UB0, ubBlockLength);
2725
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2726
+ // 执行前: 持有=[UB0] 执行中: 持有=[UB0,UB2] 执行后: 持有=[UB0,UB2]
2727
+ AscendC::Mul(buf_[UB2].Get<T>(), buf_[UB0].Get<T>(), buf_[UB0].Get<T>(), count);
2728
+
2729
+ // ═══ S2: in0·mul1_x → mul1 ═══
2730
+ // 执行前: 持有=[UB0,UB2] 执行中: 持有=[UB0,UB1,UB2] 执行后: 持有=[UB0,UB1,UB2]
2731
+ CopyInBrc(coord, MUL1, UB1, ubBlockLength);
2732
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2733
+ // 执行前: 持有=[UB0,UB1,UB2] 执行中: 持有=[UB0,UB1,UB2,UB3] 执行后: 持有=[UB2,UB3]
2734
+ AscendC::Mul(buf_[UB3].Get<T>(), buf_[UB0].Get<T>(), buf_[UB1].Get<T>(), count);
2735
+ SetFlag<HardEvent::V_MTE2>(evVtoMTE2); WaitFlag<HardEvent::V_MTE2>(evVtoMTE2);
2736
+
2737
+ // ═══ S3: MulAddDst → output1 ═══
2738
+ // 执行前: 持有=[UB2,UB3] 执行中: 持有=[UB0,UB2,UB3] 执行后: 持有=[UB0,UB2,UB3]
2739
+ CopyInBrc(coord, IN2, UB0, ubBlockLength);
2740
+ // 执行前: 持有=[UB0,UB2,UB3] 执行中: 持有=[UB0,UB1,UB2,UB3] 执行后: 持有=[UB0,UB1,UB2,UB3]
2741
+ CopyInBrc(coord, MUL, UB1, ubBlockLength);
2742
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2743
+ // 执行前: 持有=[UB0,UB1,UB2,UB3] 执行中: 持有=[UB0,UB1,UB2,UB3] 执行后: 持有=[UB2,UB3]
2744
+ uint16_t repeatTimesS3 = AscendC::CeilDivision(count, VL);
2745
+ asc_vf_call<MulAddVF<T>>((__ubuf__ T*)buf_[UB3].Get<T>().GetPhyAddr(),
2746
+ (__ubuf__ T*)buf_[UB1].Get<T>().GetPhyAddr(),
2747
+ (__ubuf__ T*)buf_[UB0].Get<T>().GetPhyAddr(),
2748
+ count, VL, repeatTimesS3);
2749
+
2750
+ // ═══ S4: square·mul3_x → mul3 ═══
2751
+ // 执行前: 持有=[UB2,UB3] 执行中: 持有=[UB2,UB3,UB4] 执行后: 持有=[UB2,UB3,UB4]
2752
+ CopyInBrc(coord, MUL3, UB4, ubBlockLength);
2753
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2754
+ // 执行前: 持有=[UB2,UB3,UB4] 执行中: 持有=[UB2,UB3,UB4] 执行后: 持有=[UB3,UB4]
2755
+ AscendC::Mul(buf_[UB4].Get<T>(), buf_[UB2].Get<T>(), buf_[UB4].Get<T>(), count);
2756
+ SetFlag<HardEvent::V_MTE2>(evVtoMTE2); WaitFlag<HardEvent::V_MTE2>(evVtoMTE2);
2757
+
2758
+ // ═══ S5: MulAddDst → output0 ═══
2759
+ // 执行前: 持有=[UB3,UB4] 执行中: 持有=[UB0,UB3,UB4] 执行后: 持有=[UB0,UB3,UB4]
2760
+ CopyInBrc(coord, IN1, UB0, ubBlockLength);
2761
+ // 执行前: 持有=[UB0,UB3,UB4] 执行中: 持有=[UB0,UB2,UB3,UB4] 执行后: 持有=[UB0,UB2,UB3,UB4]
2762
+ CopyInBrc(coord, MUL2, UB2, ubBlockLength);
2763
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2764
+ // 执行前: 持有=[UB0,UB2,UB3,UB4] 执行中: 持有=[UB0,UB2,UB3,UB4] 执行后: 持有=[UB3,UB4]
2765
+ uint16_t repeatTimesS5 = AscendC::CeilDivision(count, VL);
2766
+ asc_vf_call<MulAddVF<T>>((__ubuf__ T*)buf_[UB4].Get<T>().GetPhyAddr(),
2767
+ (__ubuf__ T*)buf_[UB0].Get<T>().GetPhyAddr(),
2768
+ (__ubuf__ T*)buf_[UB2].Get<T>().GetPhyAddr(),
2769
+ count, VL, repeatTimesS5);
2770
+
2771
+ // ═══ S6: sqrt(output0) → sqrt ═══
2772
+ // 执行前: 持有=[UB3,UB4] 执行中: 持有=[UB0,UB3,UB4] 执行后: 持有=[UB0,UB3,UB4]
2773
+ AscendC::Sqrt(buf_[UB0].Get<T>(), buf_[UB4].Get<T>(), count);
2774
+
2775
+ // ═══ S7: sqrt + add2_y → add2 ═══
2776
+ // 执行前: 持有=[UB0,UB3,UB4] 执行中: 持有=[UB0,UB2,UB3,UB4] 执行后: 持有=[UB0,UB2,UB3,UB4]
2777
+ CopyInBrc(coord, ADD2, UB2, ubBlockLength);
2778
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2779
+ // 执行前: 持有=[UB0,UB2,UB3,UB4] 执行中: 持有=[UB0,UB1,UB2,UB3,UB4] 执行后: 持有=[UB1,UB3,UB4]
2780
+ AscendC::Add(buf_[UB1].Get<T>(), buf_[UB0].Get<T>(), buf_[UB2].Get<T>(), count);
2781
+
2782
+ // ═══ S8: output1 / add2 → truediv ═══
2783
+ // 执行前: 持有=[UB1,UB3,UB4] 执行中: 持有=[UB1,UB2,UB3,UB4] 执行后: 持有=[UB2,UB3,UB4]
2784
+ AscendC::Div(buf_[UB2].Get<T>(), buf_[UB3].Get<T>(), buf_[UB1].Get<T>(), count);
2785
+ SetFlag<HardEvent::V_MTE2>(evVtoMTE2); WaitFlag<HardEvent::V_MTE2>(evVtoMTE2);
2786
+
2787
+ // ═══ S9: truediv·input4 → mul4 ═══
2788
+ // 执行前: 持有=[UB2,UB3,UB4] 执行中: 持有=[UB0,UB2,UB3,UB4] 执行后: 持有=[UB0,UB2,UB3,UB4]
2789
+ CopyInBrc(coord, IN4, UB0, ubBlockLength);
2790
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2791
+ // 执行前: 持有=[UB0,UB2,UB3,UB4] 执行中: 持有=[UB0,UB1,UB2,UB3,UB4] 执行后: 持有=[UB1,UB3,UB4]
2792
+ AscendC::Mul(buf_[UB1].Get<T>(), buf_[UB2].Get<T>(), buf_[UB0].Get<T>(), count);
2793
+ SetFlag<HardEvent::V_MTE2>(evVtoMTE2); WaitFlag<HardEvent::V_MTE2>(evVtoMTE2);
2794
+
2795
+ // ═══ S10: dataVar − mul4 → output2 ═══
2796
+ // 执行前: 持有=[UB1,UB3,UB4] 执行中: 持有=[UB0,UB1,UB3,UB4] 执行后: 持有=[UB0,UB1,UB3,UB4]
2797
+ CopyInBrc(coord, IN3, UB0, ubBlockLength);
2798
+ SetFlag<HardEvent::MTE2_V>(evMTE2toV); WaitFlag<HardEvent::MTE2_V>(evMTE2toV);
2799
+ // 执行前: 持有=[UB0,UB1,UB3,UB4] 执行中: 持有=[UB0,UB1,UB2,UB3,UB4] 执行后: 持有=[UB2,UB3,UB4]
2800
+ AscendC::Sub(buf_[UB2].Get<T>(), buf_[UB0].Get<T>(), buf_[UB1].Get<T>(), count);
2801
+
2802
+ SetFlag<HardEvent::V_MTE3>(evVtoMTE3); WaitFlag<HardEvent::V_MTE3>(evVtoMTE3);
2803
+
2804
+ // ═══ CopyOut ═══
2805
+ // 执行前: 持有=[UB2,UB3,UB4] 执行后: 持有=[UB2,UB3]
2806
+ CopyOutOne(coord, OUT0, UB4, ubBlockLength);
2807
+ // 执行前: 持有=[UB2,UB3] 执行后: 持有=[UB2]
2808
+ CopyOutOne(coord, OUT1, UB3, ubBlockLength);
2809
+ // 执行前: 持有=[UB2] 执行后: 持有=[]
2810
+ CopyOutOne(coord, OUT2, UB2, ubBlockLength);
2811
+
2812
+ if (flat != end - 1) SetFlag<HardEvent::MTE3_MTE2>(evMTE3toMTE2);
2813
+ }
2814
+ }
2815
+
2816
+ private:
2817
+ __aicore__ inline void CopyInBrc(
2818
+ const int64_t* coord, int32_t inputIdx, int32_t buffer, int64_t ubBlockLength)
2819
+ {
2820
+ int64_t k = td_->split.ubSplitIdx;
2821
+ int64_t off = CalcOffset(coord, td_->inputStrides[inputIdx], RANK);
2822
+ const int64_t* dstShape = td_->maxBroShape;
2823
+
2824
+ auto params = nddmaParams_[inputIdx];
2825
+ int64_t kNd = RANK - 1 - k;
2826
+ int64_t inner = 1;
2827
+ for (int64_t nd = 0; nd < ND; nd++) {
2828
+ if (nd == kNd) params.loopInfo.loopSize[nd] = ubBlockLength;
2829
+ params.loopInfo.loopDstStride[nd] = inner;
2830
+ inner *= params.loopInfo.loopSize[nd];
2831
+ }
2832
+
2833
+ static constexpr AscendC::NdDmaConfig cfg = { false };
2834
+
2835
+ if constexpr (RANK <= MAX_NDDMA_DIMS) {
2836
+ AscendC::DataCopy<T, ND, cfg>(
2837
+ buf_[buffer].Get<T>(), gmIn_[inputIdx][off], params);
2838
+ } else {
2839
+ LocalTensor<T> buf = buf_[buffer].Get<T>();
2840
+ int64_t elemBase = off / sizeof(T);
2841
+ for (int64_t oi = 0; oi < nddmaOuterIters_[inputIdx]; oi++) {
2842
+ int64_t elemAdj = 0, tmp = oi;
2843
+ for (int64_t d = RANK - ND - 1; d >= 0; d--) {
2844
+ int64_t sz = (d == k) ? ubBlockLength : dstShape[d];
2845
+ elemAdj += (tmp % sz) * td_->inputStrides[inputIdx][d];
2846
+ tmp /= sz;
2847
+ }
2848
+ AscendC::DataCopy<T, ND, cfg>(
2849
+ buf[oi * inner], gmIn_[inputIdx][elemBase + elemAdj], params);
2850
+ }
2851
+ }
2852
+ }
2853
+
2854
+ __aicore__ inline void CopyOutOne(
2855
+ const int64_t* coord, int32_t outputIdx, int32_t buffer, int64_t ubBlockLength)
2856
+ {
2857
+ int64_t off = CalcOffset(coord, td_->outputStrides[outputIdx], RANK);
2858
+ int64_t cnt = CalcTransferCount(td_->outputShapes[outputIdx], RANK,
2859
+ td_->split.ubSplitIdx, ubBlockLength);
2860
+ DataCopy(gmOut_[outputIdx][off], buf_[buffer].Get<T>(), cnt);
2861
+ }
2862
+ };
2863
+
2864
+ // MulAddVF 定义见 §6.4.4
2865
+ ```