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

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 +104 -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 +384 -0
  1286. package/lib/client.js.map +1 -0
  1287. package/lib/index.js +20 -0
  1288. package/locale/en.json +1 -0
  1289. package/locale/zh.json +1 -0
  1290. package/package.json +63 -3
  1291. package/upstream.json +10 -0
@@ -0,0 +1,1848 @@
1
+ #!/usr/bin/env python3
2
+ # Copyright (c) 2026 Huawei Technologies Co., Ltd.
3
+ # This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4
+ # CANN Open Software License Agreement Version 2.0 (the "License").
5
+ # Please refer to the License for details. You may not use this file except in compliance with the License.
6
+ # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7
+ # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8
+ # See LICENSE in the root of the software repository for the full text of the License.
9
+
10
+ """spec.yaml validator — full 12-stage L0 校验.
11
+
12
+ Stage 1: jsonschema validation against schemas/op-spec.json.
13
+ Stage 2: category ↔ paradigm consistency, mutual exclusion,
14
+ paradigm internal constraints, and white-list checks for
15
+ primitives.op / invariants.kind / machine_check.kind / synthesize.patterns / error_type.
16
+ Stage 3: shape_closure — solve outputs[].shape_rule via shape DSL.
17
+ Stage 4: dtype_closure — cross-check dtype_rule with supported_combinations.
18
+ Stage 5: broadcast_legality — validate broadcast semantics of operator computation.
19
+ Stage 6: boundary_min_set — per-paradigm minimum case set.
20
+ Stage 7: tolerance_coverage — per-dtype tolerance covers output dtypes + tightness.
21
+ Stage 8: formula_smoke_eval — run formula on tiny tensors via numpy sandbox.
22
+ Stage 9: oracle_reachable — real import framework + walk api attribute chain.
23
+ Stage 10: formula_oracle_equiv — compare formula vs oracle outputs on special-value inputs (NaN/inf/large/signed-zero).
24
+
25
+ Stage interface contract:
26
+ - status ∈ {PASS, FAIL, SKIP}
27
+ - findings: list of {severity, rule_id, field_path, message, suggested_fix}
28
+
29
+ Usage:
30
+ python3 validate_spec.py path/to/spec.yaml
31
+ python3 validate_spec.py path/to/spec.yaml --json # machine-readable output
32
+ python3 validate_spec.py path/to/spec.yaml --strict # exit non-zero on warnings too
33
+ """
34
+
35
+ from __future__ import annotations
36
+
37
+ import argparse
38
+ import ast
39
+ import functools
40
+ import json
41
+ import re
42
+ import sys
43
+ from dataclasses import dataclass, field, asdict
44
+ from pathlib import Path
45
+ from typing import Any
46
+
47
+ import yaml
48
+
49
+ try:
50
+ import jsonschema
51
+ from jsonschema import Draft202012Validator
52
+ except ImportError:
53
+ print("ERROR: jsonschema not installed. Run: pip install jsonschema pyyaml", file=sys.stderr)
54
+ sys.exit(2)
55
+
56
+ SKILL_DIR = Path(__file__).resolve().parent.parent
57
+ REGISTRIES = SKILL_DIR / "registries"
58
+ SCHEMA_PATH = SKILL_DIR / "schemas" / "op-spec.json"
59
+
60
+
61
+ @dataclass
62
+ class Finding:
63
+ severity: str # error | warning | info
64
+ rule_id: str
65
+ field_path: str
66
+ message: str
67
+ suggested_fix: str | None = None
68
+
69
+
70
+ @dataclass
71
+ class StageResult:
72
+ stage_id: int
73
+ status: str # PASS | FAIL | SKIP
74
+ findings: list[Finding] = field(default_factory=list)
75
+
76
+
77
+ def _load_yaml(p: Path) -> dict:
78
+ """Load a YAML file. Raises yaml.YAMLError on parse error (caller decides exit code)."""
79
+ with open(p, "r", encoding="utf-8") as f:
80
+ return yaml.safe_load(f)
81
+
82
+
83
+ def _get(d: dict, *path, default=None):
84
+ cur: Any = d
85
+ for k in path:
86
+ if isinstance(cur, dict) and k in cur:
87
+ cur = cur[k]
88
+ else:
89
+ return default
90
+ return cur
91
+
92
+
93
+ def stage_1(spec: dict) -> StageResult:
94
+ """Validate against op-spec.json (Draft 2020-12)."""
95
+ res = StageResult(stage_id=1, status="PASS")
96
+ schema = _load_schema()
97
+ validator = Draft202012Validator(schema)
98
+ errors = sorted(validator.iter_errors(spec), key=lambda e: list(e.absolute_path))
99
+ for err in errors:
100
+ path = "/".join(str(p) for p in err.absolute_path) or "<root>"
101
+ res.findings.append(Finding(
102
+ severity="error",
103
+ rule_id="schema_static",
104
+ field_path=path,
105
+ message=err.message,
106
+ suggested_fix=None,
107
+ ))
108
+ if res.findings:
109
+ res.status = "FAIL"
110
+ return res
111
+
112
+
113
+ @functools.lru_cache(maxsize=1)
114
+ def _load_schema() -> dict:
115
+ """Cached JSON Schema; deserialized once per process."""
116
+ return json.loads(SCHEMA_PATH.read_text(encoding="utf-8"))
117
+
118
+
119
+ def _output_count_attr_determined(spec: dict) -> bool:
120
+ """True 当算子声明 op.output_count_determined_by=attribute(split/chunk/unbind 类:
121
+ 输出个数由属性决定,非 data-dependent)。用于豁免 VariableOutput 的 data_dependent_shape
122
+ 与 nonzero 类 boundary case。"""
123
+ return (spec.get("op") or {}).get("output_count_determined_by", "data") == "attribute"
124
+
125
+
126
+ def stage_2(spec: dict, registries: dict) -> StageResult:
127
+ """category ↔ paradigm consistency + paradigm internal constraints + whitelists.
128
+
129
+ Dispatches to 6 focused checks; each appends to res.findings. Overall FAIL if
130
+ any error-severity finding is produced. Sub-checks correspond to the design
131
+ doc's lettered sub-rule groups (A/B/C/D/E/F + the H 'hint' group).
132
+ """
133
+ res = StageResult(stage_id=2, status="PASS")
134
+ cat = _get(spec, "op", "category")
135
+ paradigms = set(_get(spec, "op", "paradigms", default=[]) or [])
136
+
137
+ _check_category_paradigm_consistency(cat, paradigms, registries, res.findings)
138
+ _check_mutually_exclusive_paradigms(paradigms, registries, res.findings)
139
+ _check_paradigm_internal_constraints(spec, paradigms, registries, res.findings)
140
+ _check_paradigm_groups(spec, paradigms, res.findings)
141
+ _check_invariants(spec, registries, res.findings)
142
+ _check_machine_check(spec, registries, res.findings)
143
+ _check_synthesize_patterns(spec, registries, res.findings)
144
+ _check_supported_chips(spec, registries, res.findings)
145
+ _check_anti_pattern_ids(spec, registries, res.findings)
146
+ _check_op_error_codes(spec, registries, res.findings)
147
+ _check_composition_hint(spec, paradigms, res.findings)
148
+ _check_broadcast_paradigm_hint(spec, paradigms, res.findings)
149
+ _check_format_variants(spec, res.findings)
150
+ _check_interface_contracts(spec, res.findings)
151
+ _check_data_distribution(spec, cat, paradigms, res.findings)
152
+
153
+ if any(f.severity == "error" for f in res.findings):
154
+ res.status = "FAIL"
155
+ return res
156
+
157
+
158
+ # ---------- stage 2 sub-checks --------------------------------------------
159
+
160
+
161
+ def _check_interface_contracts(spec: dict, findings: list[Finding]) -> None:
162
+ """Validate TensorList and conditional-interface additions.
163
+
164
+ JSON Schema owns field types and conditional requiredness. This stage owns
165
+ cross-reference validation (list-length references and semantic cases) and
166
+ the deliberately small, non-executable guard/expression languages.
167
+ """
168
+ inputs = spec.get("inputs") or []
169
+ outputs = spec.get("outputs") or []
170
+ attributes = spec.get("attributes") or []
171
+ input_by_name = {item.get("name"): item for item in inputs}
172
+ output_by_name = {item.get("name"): item for item in outputs}
173
+ attr_names = {item.get("name") for item in attributes}
174
+ attrs_by_name = {item.get("name"): item for item in attributes}
175
+
176
+ def error(rule_id: str, path: str, message: str, fix: str) -> None:
177
+ findings.append(Finding("error", rule_id, path, message, fix))
178
+
179
+ def check_list_length(item: dict, path: str, default_role: str) -> None:
180
+ role = item.get("role", default_role)
181
+ length = item.get("list_length")
182
+ if role == "tensor_list" and not isinstance(length, dict):
183
+ error(
184
+ "interface_contract.tensor_list_length_missing", path,
185
+ "role=tensor_list 必须声明 list_length。",
186
+ "添加 list_length: {kind: unconstrained} 或来源支持的更强约束。",
187
+ )
188
+ return
189
+ if role != "tensor_list" and length is not None:
190
+ error(
191
+ "interface_contract.list_length_non_list", f"{path}.list_length",
192
+ "list_length 只允许用于 role=tensor_list。",
193
+ "删除 list_length,或将 role 改为 tensor_list。",
194
+ )
195
+ return
196
+ if not isinstance(length, dict):
197
+ return
198
+
199
+ kind = length.get("kind")
200
+ allowed_fields = {
201
+ "unconstrained": {"kind"},
202
+ "fixed": {"kind", "value"},
203
+ "range": {"kind", "min", "max"},
204
+ "same_as": {"kind", "ref"},
205
+ "expression": {"kind", "value"},
206
+ }
207
+ if kind in allowed_fields and (unexpected := set(length) - allowed_fields[kind]):
208
+ error(
209
+ "interface_contract.list_length_unexpected_field", f"{path}.list_length",
210
+ f"list_length.kind={kind!r} 不允许字段 {sorted(unexpected)}。",
211
+ f"仅保留 {sorted(allowed_fields[kind])}。",
212
+ )
213
+ if kind == "fixed" and isinstance(length.get("value"), int):
214
+ if length["value"] < 0:
215
+ error(
216
+ "interface_contract.list_length_negative", f"{path}.list_length.value",
217
+ "list_length.fixed value 必须非负。",
218
+ "将 value 设置为大于等于 0 的整数。",
219
+ )
220
+ elif kind == "range" and isinstance(length.get("min"), int) and isinstance(length.get("max"), int):
221
+ if length["min"] < 0 or length["max"] < 0:
222
+ error(
223
+ "interface_contract.list_length_negative", f"{path}.list_length",
224
+ "list_length.range 的 min 和 max 必须非负。",
225
+ "将 min 和 max 设置为大于等于 0 的整数。",
226
+ )
227
+ if length["min"] > length["max"]:
228
+ error(
229
+ "interface_contract.list_length_invalid_range", f"{path}.list_length",
230
+ "list_length.range 必须满足 min <= max。",
231
+ "交换或修正 min/max。",
232
+ )
233
+ elif kind == "same_as":
234
+ ref = length.get("ref")
235
+ target = None
236
+ if isinstance(ref, str) and ref.startswith("input."):
237
+ target = input_by_name.get(ref.removeprefix("input."))
238
+ elif isinstance(ref, str) and ref.startswith("output."):
239
+ target = output_by_name.get(ref.removeprefix("output."))
240
+ if target is None:
241
+ error(
242
+ "interface_contract.list_length_unknown_ref", f"{path}.list_length.ref",
243
+ f"list_length.same_as 引用了不存在的 {ref!r}。",
244
+ "引用已声明的 input.<name> 或 output.<name>。",
245
+ )
246
+ elif target.get("role", "tensor") != "tensor_list":
247
+ error(
248
+ "interface_contract.list_length_ref_not_list", f"{path}.list_length.ref",
249
+ f"{ref!r} 不是 role=tensor_list,不能作为列表长度引用。",
250
+ "改为引用 tensor_list,或为目标声明 role: tensor_list。",
251
+ )
252
+ elif kind == "expression":
253
+ expression = length.get("value")
254
+ if isinstance(expression, str):
255
+ for message in _validate_list_length_expression(expression, attrs_by_name, set(input_by_name)):
256
+ error(
257
+ "interface_contract.list_length_expression", f"{path}.list_length.value",
258
+ message,
259
+ "只使用 attr.<name>、len(attr.<list_attr>)、shape.<input>[<常量轴>]、整数、+、-、* 和括号。",
260
+ )
261
+
262
+ for index, item in enumerate(inputs):
263
+ check_list_length(item, f"inputs[{index}]", "tensor")
264
+ for index, item in enumerate(outputs):
265
+ check_list_length(item, f"outputs[{index}]", "tensor")
266
+ _check_list_length_cycles(inputs, outputs, findings)
267
+
268
+ seen_ids: set[str] = set()
269
+ signatures: dict[str, tuple[set[str], set[str], set[str], set[str]]] = {}
270
+ for index, case in enumerate(spec.get("semantic_cases") or []):
271
+ path = f"semantic_cases[{index}]"
272
+ case_id = case.get("id")
273
+ if case_id in seen_ids:
274
+ error(
275
+ "interface_contract.semantic_case_duplicate_id", f"{path}.id",
276
+ f"semantic case id {case_id!r} 重复。",
277
+ "为每个 semantic case 使用唯一 id。",
278
+ )
279
+ seen_ids.add(case_id)
280
+
281
+ when = case.get("when")
282
+ if isinstance(when, str):
283
+ for message in _validate_semantic_guard(when, attr_names, set(input_by_name)):
284
+ error(
285
+ "interface_contract.semantic_case_invalid_guard", f"{path}.when", message,
286
+ "guard 只可引用 attr.<name>、input.<name>.dtype、input.<name>.is_present,"
287
+ "并使用 ==/!=/in/not in/and/or/not。",
288
+ )
289
+
290
+ case_inputs = case.get("inputs") or {}
291
+ case_outputs = case.get("outputs") or {}
292
+ required = set(case_inputs.get("required") or [])
293
+ forbidden = set(case_inputs.get("forbidden") or [])
294
+ present = set(case_outputs.get("present") or [])
295
+ absent = set(case_outputs.get("absent") or [])
296
+ _check_case_name_set(required, forbidden, input_by_name, "input", path, findings)
297
+ _check_case_name_set(present, absent, output_by_name, "output", path, findings)
298
+
299
+ for name in required | forbidden:
300
+ if name in input_by_name and not input_by_name[name].get("optional", False):
301
+ error(
302
+ "interface_contract.semantic_case_input_not_optional", f"{path}.inputs",
303
+ f"{name!r} 不是 optional input,不能由 semantic_cases 改变存在性。",
304
+ "在 input 上添加 optional: true,或删除该 case 约束。",
305
+ )
306
+ for name in present | absent:
307
+ if name in output_by_name and not output_by_name[name].get("optional", False):
308
+ error(
309
+ "interface_contract.semantic_case_output_not_optional", f"{path}.outputs",
310
+ f"{name!r} 不是 optional output,不能由 semantic_cases 改变存在性。",
311
+ "在 output 上添加 optional: true,或删除该 case 约束。",
312
+ )
313
+
314
+ signature = (required, forbidden, present, absent)
315
+ if isinstance(when, str) and when in signatures and signatures[when] != signature:
316
+ error(
317
+ "interface_contract.semantic_case_conflicting_same_guard", path,
318
+ f"guard {when!r} 与先前 case 的 input/output 存在性约束冲突。",
319
+ "合并 case,或使用互斥的 when guard。",
320
+ )
321
+ elif isinstance(when, str):
322
+ signatures[when] = signature
323
+
324
+ _check_layout_contract(
325
+ spec.get("layout_contract"), input_by_name, output_by_name, attr_names, findings,
326
+ )
327
+
328
+
329
+ def _check_layout_contract(
330
+ contract: Any, input_by_name: dict, output_by_name: dict,
331
+ attr_names: set[str], findings: list[Finding],
332
+ ) -> None:
333
+ """Validate cross references in the optional logical-layout contract.
334
+
335
+ Schema validation owns the tree shape, identifiers and duplicate axis names.
336
+ This function owns references to the declared interface, guard DSL reuse and
337
+ the one rank fact available in the current interface model: input.rank_range.
338
+ """
339
+ if not isinstance(contract, dict):
340
+ return
341
+
342
+ def error(rule_id: str, path: str, message: str, fix: str) -> None:
343
+ findings.append(Finding("error", rule_id, path, message, fix))
344
+
345
+ seen_ids: set[str] = set()
346
+ for index, variant in enumerate(contract.get("variants") or []):
347
+ if not isinstance(variant, dict):
348
+ continue
349
+ path = f"layout_contract.variants[{index}]"
350
+ variant_id = variant.get("id")
351
+ if variant_id in seen_ids:
352
+ error(
353
+ "interface_contract.layout_contract_duplicate_variant_id", f"{path}.id",
354
+ f"layout variant id {variant_id!r} 重复。",
355
+ "为每个 layout variant 使用唯一 id。",
356
+ )
357
+ seen_ids.add(variant_id)
358
+
359
+ when = variant.get("when")
360
+ if isinstance(when, str):
361
+ for message in _validate_semantic_guard(when, attr_names, set(input_by_name)):
362
+ error(
363
+ "interface_contract.layout_contract_invalid_guard", f"{path}.when", message,
364
+ "guard 只可引用 attr.<name>、input.<name>.dtype、input.<name>.is_present,"
365
+ "并使用 ==/!=/in/not in/and/or/not。",
366
+ )
367
+
368
+ seen_refs: set[str] = set()
369
+ for tensor_index, tensor in enumerate(variant.get("tensors") or []):
370
+ if not isinstance(tensor, dict):
371
+ continue
372
+ tensor_path = f"{path}.tensors[{tensor_index}]"
373
+ ref = tensor.get("ref")
374
+ if ref in seen_refs:
375
+ error(
376
+ "interface_contract.layout_contract_duplicate_tensor_ref", f"{tensor_path}.ref",
377
+ f"{ref!r} 在同一 layout variant 中重复。",
378
+ "每个 Tensor 在一个 variant 中只声明一次 logical_axes。",
379
+ )
380
+ seen_refs.add(ref)
381
+
382
+ target = None
383
+ is_input = False
384
+ if isinstance(ref, str) and ref.startswith("input."):
385
+ target = input_by_name.get(ref.removeprefix("input."))
386
+ is_input = True
387
+ elif isinstance(ref, str) and ref.startswith("output."):
388
+ target = output_by_name.get(ref.removeprefix("output."))
389
+ if target is None:
390
+ error(
391
+ "interface_contract.layout_contract_unknown_ref", f"{tensor_path}.ref",
392
+ f"layout_contract 引用了未声明的 Tensor {ref!r}。",
393
+ "引用已声明的 input.<name> 或 output.<name>。",
394
+ )
395
+ continue
396
+ if target.get("role", "tensor") != "tensor":
397
+ error(
398
+ "interface_contract.layout_contract_ref_not_tensor", f"{tensor_path}.ref",
399
+ f"{ref!r} 的 role={target.get('role', 'tensor')!r},不能声明单 Tensor 的 logical_axes。",
400
+ "只引用 role=tensor 的 input/output;TensorList 的元素布局需单独建模。",
401
+ )
402
+ continue
403
+
404
+ # Outputs currently have no rank_range. Do not infer rank from a
405
+ # shape formula; only validate an explicit, exact input rank.
406
+ rank_range = target.get("rank_range") if is_input else None
407
+ axes = tensor.get("logical_axes")
408
+ if (
409
+ isinstance(rank_range, list) and len(rank_range) == 2
410
+ and rank_range[0] == rank_range[1]
411
+ and isinstance(rank_range[0], int)
412
+ and isinstance(axes, list) and len(axes) != rank_range[0]
413
+ ):
414
+ error(
415
+ "interface_contract.layout_contract_rank_mismatch", f"{tensor_path}.logical_axes",
416
+ f"{ref!r} 的固定 rank 为 {rank_range[0]},但 logical_axes 有 {len(axes)} 项。",
417
+ "使 logical_axes 项数与该 input 的固定 rank 一致,或修正 rank_range。",
418
+ )
419
+
420
+
421
+ def _check_case_name_set(
422
+ positive: set[str], negative: set[str], declared: dict, kind: str,
423
+ path: str, findings: list[Finding],
424
+ ) -> None:
425
+ if overlap := positive & negative:
426
+ findings.append(Finding(
427
+ "error", "interface_contract.semantic_case_conflicting_members", path,
428
+ f"同一 semantic case 中 {kind} 同时出现在相反集合:{sorted(overlap)}。",
429
+ "将每个名称仅保留在 required/forbidden 或 present/absent 的一侧。",
430
+ ))
431
+ for name in sorted((positive | negative) - set(declared)):
432
+ findings.append(Finding(
433
+ "error", "interface_contract.semantic_case_unknown_member", path,
434
+ f"semantic case 引用了未声明的 {kind} {name!r}。",
435
+ f"改为已声明的 {kind} 名称,或先在接口中声明它。",
436
+ ))
437
+
438
+
439
+ def _check_list_length_cycles(inputs: list[dict], outputs: list[dict], findings: list[Finding]) -> None:
440
+ """same_as may follow input/output references, but it must not form a cycle."""
441
+ refs: dict[str, str] = {}
442
+ for prefix, items in (("input", inputs), ("output", outputs)):
443
+ for item in items:
444
+ length = item.get("list_length") or {}
445
+ if length.get("kind") == "same_as" and isinstance(length.get("ref"), str):
446
+ refs[f"{prefix}.{item.get('name')}"] = length["ref"]
447
+
448
+ reported_cycles: set[frozenset[str]] = set()
449
+ for start in refs:
450
+ seen: list[str] = []
451
+ current = start
452
+ while current in refs:
453
+ if current in seen:
454
+ cycle = seen[seen.index(current):] + [current]
455
+ cycle_nodes = frozenset(cycle[:-1])
456
+ if cycle_nodes not in reported_cycles:
457
+ findings.append(Finding(
458
+ "error", "interface_contract.list_length_cycle", "list_length.ref",
459
+ f"list_length.same_as 存在循环引用:{' -> '.join(cycle)}。",
460
+ "让至少一个 TensorList 使用 unconstrained/fixed/range/expression 作为长度根。",
461
+ ))
462
+ reported_cycles.add(cycle_nodes)
463
+ break
464
+ seen.append(current)
465
+ current = refs[current]
466
+ def _validate_semantic_guard(guard: str, attr_names: set[str], input_names: set[str]) -> list[str]:
467
+ """Return validation errors for the non-executable semantic-case guard DSL."""
468
+ try:
469
+ tree = ast.parse(guard, mode="eval")
470
+ except SyntaxError as exc:
471
+ return [f"guard 不是合法表达式:{exc.msg}。"]
472
+
473
+ errors: list[str] = []
474
+ parents = {
475
+ id(child): parent
476
+ for parent in ast.walk(tree)
477
+ for child in ast.iter_child_nodes(parent)
478
+ }
479
+
480
+ def ref(node: ast.AST) -> tuple[str, str, str] | None:
481
+ if not isinstance(node, ast.Attribute):
482
+ return None
483
+ if isinstance(node.value, ast.Name) and node.value.id == "attr":
484
+ return ("attr", node.attr, "")
485
+ if isinstance(node.value, ast.Name) and node.value.id == "input":
486
+ # `input.x` 是 `input.x.dtype/is_present` 的中间 AST 节点。
487
+ return ("input_base", node.attr, "")
488
+ if isinstance(node.value, ast.Attribute) and isinstance(node.value.value, ast.Name) and node.value.value.id == "input":
489
+ return ("input", node.value.attr, node.attr)
490
+ return None
491
+
492
+ for node in ast.walk(tree):
493
+ if isinstance(node, ast.Call):
494
+ errors.append("guard 不允许函数调用。")
495
+ elif isinstance(node, ast.BinOp):
496
+ errors.append("guard 不允许算术运算。")
497
+ elif isinstance(node, ast.Compare) and any(not isinstance(op, (ast.Eq, ast.NotEq, ast.In, ast.NotIn)) for op in node.ops):
498
+ errors.append("guard 只允许 ==、!=、in、not in 比较。")
499
+ elif isinstance(node, ast.Attribute):
500
+ parsed = ref(node)
501
+ if parsed is None:
502
+ errors.append("guard 引用必须是 attr.<name>、input.<name>.dtype 或 input.<name>.is_present。")
503
+ continue
504
+ kind, name, leaf = parsed
505
+ if kind == "attr" and name not in attr_names:
506
+ errors.append(f"guard 引用了未声明属性 attr.{name}。")
507
+ if kind in {"input", "input_base"}:
508
+ if name not in input_names:
509
+ errors.append(f"guard 引用了未声明输入 input.{name}。")
510
+ if kind == "input_base":
511
+ parent = parents.get(id(node))
512
+ if not (isinstance(parent, ast.Attribute) and parent.value is node):
513
+ errors.append(
514
+ f"guard 不支持裸 input.{name};只允许 input.{name}.dtype 或 input.{name}.is_present。"
515
+ )
516
+ if kind == "input" and leaf not in {"dtype", "is_present"}:
517
+ errors.append(f"guard 不支持 input.{name}.{leaf};只允许 dtype 或 is_present。")
518
+ elif isinstance(node, ast.Name) and node.id not in {"attr", "input", "true", "false"}:
519
+ errors.append(f"guard 不允许名称 {node.id!r}。")
520
+ elif isinstance(node, (ast.Expression, ast.Name, ast.BoolOp, ast.UnaryOp, ast.Compare, ast.Load,
521
+ ast.And, ast.Or, ast.Not, ast.Eq, ast.NotEq, ast.In, ast.NotIn,
522
+ ast.Constant, ast.List, ast.Tuple)):
523
+ continue
524
+ elif isinstance(node, ast.Attribute):
525
+ continue
526
+ else:
527
+ errors.append(f"guard 不允许语法节点 {type(node).__name__}。")
528
+ return list(dict.fromkeys(errors))
529
+
530
+
531
+ def _validate_list_length_expression(
532
+ expression: str, attrs_by_name: dict[str, dict], input_names: set[str],
533
+ ) -> list[str]:
534
+ """Validate the intentionally small integer-expression language for list length."""
535
+ try:
536
+ tree = ast.parse(expression, mode="eval")
537
+ except SyntaxError as exc:
538
+ return [f"list_length expression 不是合法表达式:{exc.msg}。"]
539
+
540
+ errors: list[str] = []
541
+
542
+ def attribute_interval(name: str) -> tuple[int | None, int | None]:
543
+ """Return the statically known integer interval for an attribute."""
544
+ attr = attrs_by_name.get(name)
545
+ if not attr or attr.get("type") != "int64":
546
+ return None, None
547
+ constraint = attr.get("machine_constraint") or {}
548
+ lower = constraint.get("lower_inclusive")
549
+ upper = constraint.get("upper_inclusive")
550
+ if not isinstance(lower, int) or isinstance(lower, bool):
551
+ lower = None
552
+ if not isinstance(upper, int) or isinstance(upper, bool):
553
+ upper = None
554
+ return lower, upper
555
+
556
+ def interval(node: ast.AST) -> tuple[int | None, int | None]:
557
+ if isinstance(node, ast.Constant) and isinstance(node.value, int) and not isinstance(node.value, bool):
558
+ return node.value, node.value
559
+ if isinstance(node, ast.Attribute) and isinstance(node.value, ast.Name) and node.value.id == "attr":
560
+ return attribute_interval(node.attr)
561
+ if isinstance(node, ast.Call):
562
+ return 0, None
563
+ if isinstance(node, ast.Subscript):
564
+ return 0, None
565
+ if isinstance(node, ast.BinOp):
566
+ left_lower, left_upper = interval(node.left)
567
+ right_lower, right_upper = interval(node.right)
568
+ if isinstance(node.op, ast.Add):
569
+ lower = (
570
+ left_lower + right_lower
571
+ if left_lower is not None and right_lower is not None else None
572
+ )
573
+ upper = (
574
+ left_upper + right_upper
575
+ if left_upper is not None and right_upper is not None else None
576
+ )
577
+ return lower, upper
578
+ if isinstance(node.op, ast.Mult):
579
+ # A product is provably non-negative only when both operands
580
+ # are provably non-negative.
581
+ lower = (
582
+ left_lower * right_lower
583
+ if left_lower is not None and right_lower is not None
584
+ and left_lower >= 0 and right_lower >= 0
585
+ else None
586
+ )
587
+ if None not in (left_lower, left_upper, right_lower, right_upper):
588
+ products = [
589
+ left_lower * right_lower,
590
+ left_lower * right_upper,
591
+ left_upper * right_lower,
592
+ left_upper * right_upper,
593
+ ]
594
+ return min(products), max(products)
595
+ return lower, None
596
+ if isinstance(node.op, ast.Sub):
597
+ lower = (
598
+ left_lower - right_upper
599
+ if left_lower is not None and right_upper is not None else None
600
+ )
601
+ upper = (
602
+ left_upper - right_lower
603
+ if left_upper is not None and right_lower is not None else None
604
+ )
605
+ return lower, upper
606
+ return None, None
607
+
608
+ for node in ast.walk(tree):
609
+ if isinstance(node, ast.Name) and node.id not in {"attr", "shape", "len"}:
610
+ errors.append(f"list_length expression 不允许名称 {node.id!r}。")
611
+ elif isinstance(node, ast.Attribute):
612
+ if isinstance(node.value, ast.Name) and node.value.id == "attr":
613
+ if node.attr not in attrs_by_name:
614
+ errors.append(f"list_length expression 引用了未声明属性 attr.{node.attr}。")
615
+ elif isinstance(node.value, ast.Name) and node.value.id == "shape":
616
+ if node.attr not in input_names:
617
+ errors.append(f"list_length expression 引用了未声明输入 shape.{node.attr}。")
618
+ else:
619
+ errors.append("list_length expression 的属性引用只允许 attr.<name> 或 shape.<input>。")
620
+ elif isinstance(node, ast.Call):
621
+ valid_len_arg = (
622
+ len(node.args) == 1 and isinstance(node.args[0], ast.Attribute)
623
+ and isinstance(node.args[0].value, ast.Name) and node.args[0].value.id == "attr"
624
+ )
625
+ if not (isinstance(node.func, ast.Name) and node.func.id == "len" and valid_len_arg and not node.keywords):
626
+ errors.append("list_length expression 只允许 len(attr.<list_attr>) 调用。")
627
+ elif not str(attrs_by_name.get(node.args[0].attr, {}).get("type", "")).startswith("list["):
628
+ errors.append(f"len(attr.{node.args[0].attr}) 只能引用 list[...] 类型属性。")
629
+ elif isinstance(node, ast.Subscript):
630
+ if not (isinstance(node.value, ast.Attribute) and isinstance(node.value.value, ast.Name)
631
+ and node.value.value.id == "shape" and isinstance(node.slice, ast.Constant)
632
+ and isinstance(node.slice.value, int) and node.slice.value >= 0):
633
+ errors.append("list_length expression 下标只允许 shape.<input>[<非负常量轴>]。")
634
+ elif isinstance(node, ast.BinOp) and not isinstance(node.op, (ast.Add, ast.Sub, ast.Mult)):
635
+ errors.append("list_length expression 只允许 +、-、* 运算。")
636
+ elif isinstance(node, ast.Constant) and (not isinstance(node.value, int) or isinstance(node.value, bool) or node.value < 0):
637
+ errors.append("list_length expression 只允许非负整数常量。")
638
+ elif isinstance(node, (ast.Expression, ast.Name, ast.Attribute, ast.Call, ast.Subscript,
639
+ ast.BinOp, ast.Add, ast.Sub, ast.Mult, ast.Load, ast.Constant)):
640
+ continue
641
+ else:
642
+ errors.append(f"list_length expression 不允许语法节点 {type(node).__name__}。")
643
+ bound, _ = interval(tree.body)
644
+ if bound is None:
645
+ errors.append(
646
+ "list_length expression 无法由已声明约束证明非负;使用非负 shape/len,"
647
+ "或为 int64 属性声明 machine_constraint.lower_inclusive >= 0;减法还需要 RHS upper_inclusive。"
648
+ )
649
+ elif bound < 0:
650
+ errors.append("list_length expression 的可证明下界小于 0。")
651
+ return list(dict.fromkeys(errors))
652
+
653
+
654
+ def _check_category_paradigm_consistency(cat, paradigms, registries, findings):
655
+ """A. category 必含 paradigm 是否齐全;fused_composite 额外要求 ≥ 2 条基础 paradigm。"""
656
+ cmap = registries["category_map"]
657
+ required = set(cmap["category_requires_paradigms"].get(cat, []))
658
+ missing = required - paradigms
659
+ if missing:
660
+ findings.append(Finding(
661
+ severity="error",
662
+ rule_id="category_paradigm_consistency.required_paradigm_missing",
663
+ field_path="op.paradigms",
664
+ message=f"category={cat} 必含 paradigm {sorted(missing)}",
665
+ suggested_fix=f"在 op.paradigms 中加入 {sorted(missing)}",
666
+ ))
667
+
668
+ if cat == "FusedComposite":
669
+ basic = {"Broadcast", "Reduction", "Contraction",
670
+ "ArgReduce", "LayoutTransform"}
671
+ if len(paradigms & basic) < 2:
672
+ findings.append(Finding(
673
+ severity="error",
674
+ rule_id="category_paradigm_consistency.fused_composite_basics",
675
+ field_path="op.paradigms",
676
+ message="category=fused_composite 必须含 ≥ 2 条基础 paradigm(Elementwise 被其他范式吸收,不计入)",
677
+ suggested_fix=f"从 {sorted(basic)} 中至少选 2 条加入 paradigms",
678
+ ))
679
+
680
+
681
+ def _check_broadcast_paradigm_hint(spec, paradigms, findings):
682
+ """G. broadcast.kind=numpy 时 paradigms 应含 Broadcast(交叉校验:shape_rule 含 broadcast_shapes)。"""
683
+ broadcast_kind = (spec.get("broadcast") or {}).get("kind", "none")
684
+ has_broadcast_shape_rule = any(
685
+ "broadcast_shapes" in (out.get("shape_rule") or "")
686
+ for out in (spec.get("outputs") or [])
687
+ )
688
+
689
+ if broadcast_kind == "numpy" and "Broadcast" not in paradigms:
690
+ findings.append(Finding(
691
+ severity="error",
692
+ rule_id="category_paradigm_consistency.broadcast_kind_requires_paradigm",
693
+ field_path="op.paradigms",
694
+ message=(
695
+ f"broadcast.kind=numpy 但 paradigms {sorted(paradigms)} 不含 Broadcast。"
696
+ "当算子计算需要 broadcast 数据时,paradigms 必须包含 Broadcast"
697
+ ),
698
+ suggested_fix="在 op.paradigms 中加入 Broadcast,并将 op.category 改为 Broadcast",
699
+ ))
700
+
701
+ if has_broadcast_shape_rule and "Broadcast" not in paradigms:
702
+ findings.append(Finding(
703
+ severity="error",
704
+ rule_id="category_paradigm_consistency.shape_rule_broadcast_requires_paradigm",
705
+ field_path="op.paradigms",
706
+ message=(
707
+ f"outputs[].shape_rule 使用了 np.broadcast_shapes 但 paradigms {sorted(paradigms)} 不含 Broadcast。"
708
+ "输出 shape 由 broadcast 推导的算子应使用 Broadcast paradigm"
709
+ ),
710
+ suggested_fix="在 op.paradigms 中加入 Broadcast,并将 op.category 改为 Broadcast",
711
+ ))
712
+
713
+
714
+ def _check_mutually_exclusive_paradigms(paradigms, registries, findings):
715
+ """B. paradigm 互斥对(同时出现 ⇒ FAIL)。"""
716
+ cmap = registries["category_map"]
717
+ for pair in cmap.get("mutually_exclusive_paradigms", []):
718
+ if set(pair) <= paradigms:
719
+ findings.append(Finding(
720
+ severity="error",
721
+ rule_id="category_paradigm_consistency.mutually_exclusive",
722
+ field_path="op.paradigms",
723
+ message=f"paradigms 互斥:{pair}",
724
+ suggested_fix=f"删除 {pair} 之一;写冲突另成 atomic_update",
725
+ ))
726
+
727
+
728
+ def _check_paradigm_internal_constraints(spec, paradigms, registries, findings):
729
+ """C. 每个 paradigm 的内部结构性要求。
730
+
731
+ 本函数是该规则的**真值**(category_paradigm_map.yaml 的 paradigm_constraints
732
+ 段已删除,因为通用 mini-DSL 表达力不足,且会让维护者误以为改 yaml 即可改逻辑)。
733
+ """
734
+ primitives_wl = set(registries["primitives"])
735
+
736
+ if "NumericalStable" in paradigms:
737
+ if not _get(spec, "numerical_stability", "required"):
738
+ findings.append(Finding(
739
+ severity="error",
740
+ rule_id="paradigm_constraint.numerical_stable",
741
+ field_path="numerical_stability.required",
742
+ message="paradigms 含 NumericalStable ⇒ numerical_stability.required 必须为 true",
743
+ suggested_fix="把 numerical_stability.required 改为 true 并补 techniques",
744
+ ))
745
+
746
+ if "FusedComposite" in paradigms:
747
+ _check_fused_composite(spec, primitives_wl, findings)
748
+
749
+ if "Reduction" in paradigms and "Recurrence" not in paradigms:
750
+ inputs = spec.get("inputs") or []
751
+ has_input_axis = any(
752
+ inp.get("name") in ("axes", "axis", "dim")
753
+ and set(inp.get("dtype_set") or []).issubset({"int32", "int64"})
754
+ for inp in inputs
755
+ )
756
+
757
+ attrs = spec.get("attributes") or []
758
+ axis_names_attr = {a.get("name") for a in attrs}
759
+ has_attr_axis = bool(axis_names_attr & {"axis", "dim", "axes"})
760
+
761
+ reduction = spec.get("reduction") or {}
762
+ has_fixed_axis = reduction.get("axis_source") == "fixed"
763
+ has_implicit_all = reduction.get("axis_source") == "implicit_all"
764
+
765
+ if not (has_input_axis or has_attr_axis or has_fixed_axis or has_implicit_all):
766
+ findings.append(Finding(
767
+ severity="error",
768
+ rule_id="paradigm_constraint.reduction_axis_missing",
769
+ field_path="inputs | attributes | reduction",
770
+ message=(
771
+ "paradigms 含 Reduction(且不含 Recurrence)⇒ 必须通过以下方式之一指定规约轴:"
772
+ "(A) 名为 axes/axis/dim 且 dtype∈{int32,int64} 的输入张量;"
773
+ "(B) 名为 axis/dim/axes 的属性;"
774
+ "(C) reduction.axis_source: fixed 声明固定轴;"
775
+ "(D) reduction.axis_source: implicit_all 声明隐式全轴归约"
776
+ ),
777
+ suggested_fix=(
778
+ "添加 axes/axis/dim 输入、添加 axis/dim/axes 属性、"
779
+ "声明 reduction: {axis_source: fixed, fixed_value: <N>}、"
780
+ "或声明 reduction: {axis_source: implicit_all}"
781
+ ),
782
+ ))
783
+
784
+ if "ArgReduce" in paradigms:
785
+ # ArgReduce 输出必须是 int32 / int64;用 dtype_eval 求值后检查
786
+ try:
787
+ sys.path.insert(0, str(Path(__file__).parent))
788
+ from evaluators import dtype_eval as _de
789
+ from evaluators.types import DslError as _DslError
790
+ except ImportError:
791
+ _de = None # type: ignore
792
+ for i, out in enumerate(spec.get("outputs", [])):
793
+ rule = (out.get("dtype_rule") or "").strip()
794
+ kind = out.get("dtype_rule_kind", "numpy_expr")
795
+ derived: str | None = None
796
+ if _de is not None and kind == "numpy_expr" and rule:
797
+ # 用 dtype_policy.supported_combinations[0] 作为试探输入;
798
+ # ArgReduce 通常 dtype_rule 是 `y.dtype = np.int32 / int64` 不依赖输入
799
+ combos = ((spec.get("dtype_policy") or {})
800
+ .get("supported_combinations") or [])
801
+ in_dt = combos[0].get("inputs", {}) if combos else {}
802
+ try:
803
+ derived = _de.evaluate_dtype_rule(
804
+ rule, output_name=out.get("name"),
805
+ input_dtypes=in_dt,
806
+ )
807
+ except _DslError:
808
+ derived = None
809
+ if derived not in ("int32", "int64"):
810
+ findings.append(Finding(
811
+ severity="error",
812
+ rule_id="paradigm_constraint.argreduce_dtype",
813
+ field_path=f"outputs[{i}].dtype_rule",
814
+ message=f"ArgReduce 输出 dtype 必须为 int32 / int64,当前 dtype_rule={rule!r} 推得 {derived!r}",
815
+ suggested_fix="把 dtype_rule 改为 `<output>.dtype = np.int32` 或 `np.int64`",
816
+ ))
817
+
818
+ if "Stateful" in paradigms:
819
+ has_state_input = any(inp.get("role") == "state" for inp in spec.get("inputs", []))
820
+ has_inplace_output = any(
821
+ re.match(r"^inplace_with\(", out.get("aliasing") or "")
822
+ for out in spec.get("outputs", [])
823
+ )
824
+ if not (has_state_input or has_inplace_output):
825
+ findings.append(Finding(
826
+ severity="error",
827
+ rule_id="paradigm_constraint.stateful_state_or_inplace",
828
+ field_path="inputs[*].role | outputs[*].aliasing",
829
+ message="Stateful 必须有 inputs.role=state 或 outputs.aliasing=inplace_with(<state_input>)",
830
+ suggested_fix="添加 role: state 的 input,或在某 output 加 aliasing: inplace_with(<state_input>)",
831
+ ))
832
+
833
+ if "Quantization" in paradigms:
834
+ attr_names = {a.get("name") for a in (spec.get("attributes") or [])}
835
+ input_names = {i.get("name") for i in (spec.get("inputs") or [])}
836
+ # 量化算子的 scale/zero_point 可以是 attribute 或 tensor input;接受 5 种合法形式:
837
+ # 1. {scale, zero_point} —— 经典非对称量化(W8A16 标准 quantize)
838
+ # 2. {scale} —— 对称量化(CANN QuantMatmul: deqScale 无 zp)
839
+ # 3. {x1Scale, x2Scale} —— 双输入分别量化(CANN FusedQuantMatmul)
840
+ # 4. {dequant_scale} —— 反量化算子专用
841
+ # 5. {deqScale} —— CANN 驼峰别名
842
+ # 6. 算子名含 "quant" —— 兜底:名称明确标识为量化算子
843
+ all_names = attr_names | input_names
844
+ canonical_forms = [
845
+ {"scale", "zero_point"},
846
+ {"scale"},
847
+ {"x1Scale", "x2Scale"},
848
+ {"dequant_scale"},
849
+ {"deqScale"},
850
+ ]
851
+ op_name = (_get(spec, "op", "name") or "").lower()
852
+ name_match = "quant" in op_name
853
+ if not name_match and not any(form <= all_names for form in canonical_forms):
854
+ findings.append(Finding(
855
+ severity="error",
856
+ rule_id="paradigm_constraint.quantization_attrs",
857
+ field_path="attributes",
858
+ message=(
859
+ "Quantization 必须含以下任一组量化参数(attribute 或 input 均可):"
860
+ "{scale, zero_point} / {scale} / {x1Scale, x2Scale} / "
861
+ "{dequant_scale} / {deqScale},或算子名含 'quant'"
862
+ ),
863
+ suggested_fix="按算子语义选择对应形式;对称量化只需 scale;双输入分别量化用 x1Scale + x2Scale",
864
+ ))
865
+
866
+ if "VariableOutput" in paradigms:
867
+ # 属性决定输出个数(split/chunk/unbind 类):输出个数与 shape 由属性决定,
868
+ # 非 data-dependent,豁免 data_dependent_shape 约束(仍走 attribute-driven shape_rule)。
869
+ _attr_determined = _output_count_attr_determined(spec)
870
+ if not _attr_determined:
871
+ for i, out in enumerate(spec.get("outputs", [])):
872
+ if not out.get("data_dependent_shape"):
873
+ findings.append(Finding(
874
+ severity="error",
875
+ rule_id="paradigm_constraint.variable_output_flag",
876
+ field_path=f"outputs[{i}].data_dependent_shape",
877
+ message="VariableOutput 输出必须配 data_dependent_shape: true",
878
+ suggested_fix="在该 output 加 data_dependent_shape: true,或若输出个数由属性决定则在 op 声明 output_count_determined_by: attribute",
879
+ ))
880
+
881
+ if "RandomSampling" in paradigms:
882
+ attr_names = {a.get("name") for a in (spec.get("attributes") or [])}
883
+ if "seed" not in attr_names:
884
+ findings.append(Finding(
885
+ severity="error",
886
+ rule_id="paradigm_constraint.random_sampling_seed",
887
+ field_path="attributes",
888
+ message="RandomSampling 必须含 seed 属性",
889
+ suggested_fix="在 attributes 中添加 seed (int64)",
890
+ ))
891
+
892
+ if "CollectiveCommunication" in paradigms:
893
+ if not _get(spec, "op", "platform_constraints", "requires_hccl"):
894
+ findings.append(Finding(
895
+ severity="error",
896
+ rule_id="paradigm_constraint.collective_hccl",
897
+ field_path="op.platform_constraints.requires_hccl",
898
+ message="CollectiveCommunication 必须声明 op.platform_constraints.requires_hccl: true",
899
+ suggested_fix="在 op 下添加 platform_constraints: {requires_hccl: true}",
900
+ ))
901
+
902
+
903
+ def _check_paradigm_groups(spec, paradigms, findings):
904
+ """paradigm_groups 校验:
905
+ - 所有组的 paradigms 并集必须是 op.paradigms 的子集(未分组的视为修饰符)
906
+ - fusion 组内 ≥ 2 基础范式(Elementwise 不计入)
907
+ - combination 组必须有 switch + when
908
+ - 当有 ≥ 2 个基础范式且 paradigm_groups 缺失时,提示应声明组合关系
909
+ - 当存在模式切换属性(string_in/enum_in)但 paradigm_groups 缺失时,提示检查
910
+ """
911
+ groups = _get(spec, "op", "paradigm_groups", default=[]) or []
912
+
913
+ # ── 通用信号检测:模式切换属性 ────────────────────────────────────────
914
+ # string_in 和 enum_in 语义等价,都表示属性在多个离散值之间切换。
915
+ # int_in_range 且 lower_inclusive=0 也视为模式切换信号(0 值通常对应
916
+ # none/identity/passthrough,如 reduction=0→none, mode=0→求值 等)。
917
+ _MODE_SWITCH_KINDS = {"string_in", "enum_in"}
918
+ attrs = spec.get("attributes") or []
919
+ mode_switch_attr = next(
920
+ (a for a in attrs
921
+ if (a.get("machine_constraint") or {}).get("kind") in _MODE_SWITCH_KINDS),
922
+ None,
923
+ )
924
+ # 扩展检测:int_in_range + lower=0 也暗示模式切换
925
+ if mode_switch_attr is None:
926
+ mode_switch_attr = next(
927
+ (a for a in attrs
928
+ if (a.get("machine_constraint") or {}).get("kind") == "int_in_range"
929
+ and (a.get("machine_constraint") or {}).get("lower_inclusive", 1) == 0),
930
+ None,
931
+ )
932
+
933
+ # ── combination_should_exist ──────────────────────────────────────────
934
+ # 修饰符范式(不参与计算主路径,不强制要求分组)
935
+ _MODIFIER_PARADIGMS = {
936
+ "NumericalStable", "FusedComposite", "Quantization",
937
+ "RandomSampling", "DynamicShape", "VariableOutput",
938
+ "Stateful", "Sparse", "CollectiveCommunication",
939
+ }
940
+ base_paradigms = paradigms - _MODIFIER_PARADIGMS
941
+
942
+ if not groups:
943
+ if len(base_paradigms) >= 2:
944
+ # 情况 A:≥2 基础范式 + 无 groups → 明确需要 paradigm_groups
945
+ findings.append(Finding(
946
+ severity="warning",
947
+ rule_id="paradigm_groups.combination_should_exist",
948
+ field_path="op.paradigm_groups",
949
+ message=(
950
+ f"op.paradigms 包含 ≥ 2 个基础范式 {sorted(base_paradigms)} "
951
+ f"但未声明 paradigm_groups。"
952
+ + (f"属性 {mode_switch_attr.get('name')!r} 是模式切换属性"
953
+ f"({mode_switch_attr.get('machine_constraint', {}).get('kind')}),"
954
+ f"强烈暗示横向组合(combination)。"
955
+ if mode_switch_attr else "")
956
+ + " 建议声明 paradigm_groups 明确范式之间的关系"
957
+ "(combination=横向组合 / fusion=纵向融合)"
958
+ ),
959
+ suggested_fix=(
960
+ "添加 paradigm_groups,参考 stage-rules.md 中的 mse_loss 横向组合示例"
961
+ ),
962
+ ))
963
+ elif mode_switch_attr and "Elementwise" not in paradigms:
964
+ # 情况 B:只有 1 个基础范式,但有模式切换属性,且 Elementwise 未在 paradigms 中
965
+ # 典型场景:mse_loss 的 reduction=none 使算子退化为 Elementwise,
966
+ # 但 spec 作者只看到了 Reduction 范式
967
+ mc = mode_switch_attr.get("machine_constraint") or {}
968
+ mc_kind = mc.get("kind", "")
969
+ values = mc.get("values") or []
970
+ none_like = [v for v in values if str(v).lower() in ("none", "identity", "passthrough")]
971
+ # int_in_range + lower=0:值 0 通常对应 none/identity 模式
972
+ if mc_kind == "int_in_range" and mc.get("lower_inclusive", 1) == 0:
973
+ none_like = [0]
974
+ if none_like:
975
+ findings.append(Finding(
976
+ severity="warning",
977
+ rule_id="paradigm_groups.mode_switch_may_need_combination",
978
+ field_path="op.paradigm_groups",
979
+ message=(
980
+ f"属性 {mode_switch_attr.get('name')!r} 存在模式切换值 "
981
+ f"{none_like}(kind={mc.get('kind')}),"
982
+ f"该值可能使算子退化为 Elementwise 等非归约行为,"
983
+ f"但 paradigms 中未包含对应范式且无 paradigm_groups。"
984
+ f" 建议检查该属性值下的计算模式,必要时添加 Elementwise 范式"
985
+ f"并声明 paradigm_groups combination"
986
+ ),
987
+ suggested_fix=(
988
+ f"分析 {mode_switch_attr.get('name')}={none_like[0]} 时的计算行为;"
989
+ f"若为逐元素输出,添加 Elementwise 到 paradigms 并声明 "
990
+ f"paradigm_groups combination(参考 stage-rules.md mse_loss 示例)"
991
+ ),
992
+ ))
993
+
994
+ if not groups:
995
+ return
996
+
997
+ basic = {"Broadcast", "Reduction", "Contraction", "ArgReduce", "LayoutTransform"}
998
+ all_grouped = set()
999
+
1000
+ for i, group in enumerate(groups):
1001
+ kind = group.get("kind")
1002
+ group_paradigms = set(group.get("paradigms") or [])
1003
+ all_grouped.update(group_paradigms)
1004
+
1005
+ if kind == "fusion":
1006
+ basic_count = len(group_paradigms & basic)
1007
+ if basic_count < 2:
1008
+ findings.append(Finding(
1009
+ severity="error",
1010
+ rule_id="paradigm_groups.fusion_min_basic",
1011
+ field_path=f"op.paradigm_groups[{i}].paradigms",
1012
+ message=f"fusion 组必须含 ≥ 2 条基础范式(Elementwise 不计入),当前 {basic_count} 条",
1013
+ suggested_fix=f"从 {sorted(basic)} 中至少选 2 条加入该组 paradigms",
1014
+ ))
1015
+ elif kind == "combination":
1016
+ if not group.get("switch"):
1017
+ findings.append(Finding(
1018
+ severity="error",
1019
+ rule_id="paradigm_groups.combination_missing_switch",
1020
+ field_path=f"op.paradigm_groups[{i}].switch",
1021
+ message="combination 组必须有 switch 字段",
1022
+ suggested_fix="添加 switch: <属性名>",
1023
+ ))
1024
+ if "when" not in group:
1025
+ findings.append(Finding(
1026
+ severity="error",
1027
+ rule_id="paradigm_groups.combination_missing_when",
1028
+ field_path=f"op.paradigm_groups[{i}].when",
1029
+ message="combination 组必须有 when 字段",
1030
+ suggested_fix="添加 when: <属性值>",
1031
+ ))
1032
+
1033
+ extra = all_grouped - paradigms
1034
+ if extra:
1035
+ findings.append(Finding(
1036
+ severity="error",
1037
+ rule_id="paradigm_groups.mismatch",
1038
+ field_path="op.paradigm_groups",
1039
+ message=f"paradigm_groups 包含 op.paradigms 中没有的 {sorted(extra)}",
1040
+ suggested_fix="确保 paradigm_groups 中的 paradigms 都在 op.paradigms 中",
1041
+ ))
1042
+
1043
+
1044
+ def _check_fused_composite(spec, primitives_wl, findings):
1045
+ """FusedComposite 子项:composition 必填、primitives ≥ 2、白名单、不泄漏、闭合。"""
1046
+ comp = _get(spec, "math_semantics", "composition")
1047
+ if comp is None:
1048
+ findings.append(Finding(
1049
+ severity="error",
1050
+ rule_id="paradigm_constraint.fused_composite_composition_missing",
1051
+ field_path="math_semantics.composition",
1052
+ message="paradigms 含 FusedComposite ⇒ math_semantics.composition 必填",
1053
+ suggested_fix="添加 composition.primitives (≥2 条) 与 dataflow",
1054
+ ))
1055
+ return
1056
+
1057
+ prims = comp.get("primitives", []) or []
1058
+ if len(prims) < 2:
1059
+ findings.append(Finding(
1060
+ severity="error",
1061
+ rule_id="paradigm_constraint.fused_composite_min_primitives",
1062
+ field_path="math_semantics.composition.primitives",
1063
+ message=f"FusedComposite 要求 primitives 长度 ≥ 2(当前 {len(prims)})",
1064
+ suggested_fix="拆分成至少 2 条白名单内原语",
1065
+ ))
1066
+ for i, prim in enumerate(prims):
1067
+ if prim.get("op") not in primitives_wl:
1068
+ findings.append(Finding(
1069
+ severity="error",
1070
+ rule_id="paradigm_constraint.primitive_not_whitelisted",
1071
+ field_path=f"math_semantics.composition.primitives[{i}].op",
1072
+ message=f"原语 op={prim.get('op')!r} 不在 PRIMITIVE_WHITELIST",
1073
+ suggested_fix=f"改为白名单内之一: {sorted(primitives_wl)}",
1074
+ ))
1075
+
1076
+ df = comp.get("dataflow") or {}
1077
+ if df.get("no_leak"):
1078
+ output_names = {o["name"] for o in spec.get("outputs", [])}
1079
+ leaked = set(df.get("intermediates") or []) & output_names
1080
+ if leaked:
1081
+ findings.append(Finding(
1082
+ severity="error",
1083
+ rule_id="paradigm_constraint.intermediate_leak",
1084
+ field_path="math_semantics.composition.dataflow.intermediates",
1085
+ message=f"中间 tensor 泄漏到 outputs: {sorted(leaked)}",
1086
+ suggested_fix="把这些名字从 intermediates 移除或重命名 outputs",
1087
+ ))
1088
+
1089
+ # dataflow 闭合:每个 prim.input 要么是 spec.inputs,要么是先前 prim.outputs
1090
+ produced = {inp["name"] for inp in spec.get("inputs", [])}
1091
+ for i, prim in enumerate(prims):
1092
+ for x in (prim.get("inputs") or []):
1093
+ if x not in produced:
1094
+ findings.append(Finding(
1095
+ severity="error",
1096
+ rule_id="paradigm_constraint.dataflow_unclosed",
1097
+ field_path=f"math_semantics.composition.primitives[{i}].inputs",
1098
+ message=f"未定义的中间 tensor: {x!r}",
1099
+ suggested_fix=f"先在前序 primitive 的 outputs 中产出 {x}",
1100
+ ))
1101
+ produced.update(prim.get("outputs") or [])
1102
+
1103
+
1104
+ def _check_invariants(spec, registries, findings):
1105
+ """D. invariants[].kind 白名单 + required_fields + tolerance_inherit 约束。"""
1106
+ invariant_kinds = registries["invariant_kinds"]
1107
+ invariants = _get(spec, "math_semantics", "invariants", default=[]) or []
1108
+ for i, inv in enumerate(invariants):
1109
+ kind = inv.get("kind")
1110
+ info = invariant_kinds.get(kind)
1111
+ if info is None:
1112
+ findings.append(Finding(
1113
+ severity="error",
1114
+ rule_id="invariant_kind_resolved.unknown_kind",
1115
+ field_path=f"math_semantics.invariants[{i}].kind",
1116
+ message=f"未知 invariant kind: {kind!r}",
1117
+ suggested_fix="使用 registries/invariant_kind_registry.yaml 中的 kind",
1118
+ ))
1119
+ continue
1120
+ for f in info.get("required_fields", []):
1121
+ if f not in inv:
1122
+ findings.append(Finding(
1123
+ severity="error",
1124
+ rule_id="invariant_kind_resolved.missing_field",
1125
+ field_path=f"math_semantics.invariants[{i}].{f}",
1126
+ message=f"invariant kind={kind} 缺必填字段 {f!r}",
1127
+ suggested_fix=f"补充 {f}",
1128
+ ))
1129
+ if info.get("forbid_tolerance_inherit") and inv.get("tolerance_inherit") is True:
1130
+ findings.append(Finding(
1131
+ severity="error",
1132
+ rule_id="invariant_kind_resolved.tolerance_inherit_forbidden",
1133
+ field_path=f"math_semantics.invariants[{i}].tolerance_inherit",
1134
+ message=f"kind={kind} 不允许 tolerance_inherit: true(结构性/离散)",
1135
+ suggested_fix="改为 false 或删除该字段",
1136
+ ))
1137
+ if info.get("require_tolerance_inherit") and not inv.get("tolerance_inherit"):
1138
+ findings.append(Finding(
1139
+ severity="warning",
1140
+ rule_id="invariant_kind_resolved.tolerance_inherit_required",
1141
+ field_path=f"math_semantics.invariants[{i}].tolerance_inherit",
1142
+ message=f"kind={kind} 建议 tolerance_inherit: true(浮点累加)",
1143
+ suggested_fix="添加 tolerance_inherit: true",
1144
+ ))
1145
+
1146
+
1147
+ def _check_machine_check(spec, registries, findings):
1148
+ """E. boundary/extreme 的 machine_check.kind 白名单 + raises_error.error_type 枚举。"""
1149
+ machine_check_kinds = set(registries["machine_check_kinds"])
1150
+ error_codes = set(registries["error_codes"])
1151
+ for sect in ("boundary_conditions", "extreme_inputs"):
1152
+ for i, c in enumerate(spec.get(sect) or []):
1153
+ mc = c.get("machine_check") or {}
1154
+ kind = mc.get("kind")
1155
+ if kind not in machine_check_kinds:
1156
+ findings.append(Finding(
1157
+ severity="error",
1158
+ rule_id="machine_check_kind_unknown",
1159
+ field_path=f"{sect}[{i}].machine_check.kind",
1160
+ message=f"未知 machine_check.kind: {kind!r}",
1161
+ suggested_fix="使用 registries/machine_check_kind_registry.yaml 中的 kind",
1162
+ ))
1163
+ elif kind == "raises_error":
1164
+ etype = mc.get("error_type")
1165
+ if etype not in error_codes:
1166
+ findings.append(Finding(
1167
+ severity="error",
1168
+ rule_id="error_type_unknown",
1169
+ field_path=f"{sect}[{i}].machine_check.error_type",
1170
+ message=f"未知 error_type: {etype!r}",
1171
+ suggested_fix=f"使用 registries/error_code_enum.yaml 中的枚举值",
1172
+ ))
1173
+
1174
+
1175
+ _PATTERN_RE = re.compile(r"^(?P<name>[a-z_]+)(\([^()]*\))?$")
1176
+
1177
+
1178
+ def _check_synthesize_patterns(spec, registries, findings):
1179
+ """F. extreme_inputs.synthesize.patterns[].pattern 白名单(兼容旧 pattern: 顶层写法)。"""
1180
+ pattern_names = set(registries["patterns"])
1181
+ for i, c in enumerate(spec.get("extreme_inputs") or []):
1182
+ synth = c.get("synthesize") or {}
1183
+ plist: list[tuple[int | None, str | None]] = []
1184
+ if "patterns" in synth and isinstance(synth["patterns"], list):
1185
+ plist = [(idx, p.get("pattern")) for idx, p in enumerate(synth["patterns"])]
1186
+ elif "pattern" in synth:
1187
+ plist = [(None, synth["pattern"])]
1188
+ findings.append(Finding(
1189
+ severity="warning",
1190
+ rule_id="synthesize_legacy_format",
1191
+ field_path=f"extreme_inputs[{i}].synthesize",
1192
+ message="旧 'pattern:' 顶层写法已过时(v1 兼容期 90 天),建议迁移到 'patterns: [{pattern, target}]'",
1193
+ suggested_fix="改为 patterns: [{pattern: <name>, target: <input_name>}, ...]",
1194
+ ))
1195
+ for idx, pname in plist:
1196
+ if not pname:
1197
+ continue
1198
+ m = _PATTERN_RE.match(pname)
1199
+ if not m or m.group("name") not in pattern_names:
1200
+ fp = (f"extreme_inputs[{i}].synthesize.patterns[{idx}].pattern"
1201
+ if idx is not None else f"extreme_inputs[{i}].synthesize.pattern")
1202
+ findings.append(Finding(
1203
+ severity="error",
1204
+ rule_id="synthesize_pattern_unknown",
1205
+ field_path=fp,
1206
+ message=f"未知 pattern: {pname!r}",
1207
+ suggested_fix=f"使用 registries/synthesize_pattern_registry.yaml 中的 name",
1208
+ ))
1209
+
1210
+
1211
+ def _check_supported_chips(spec, registries, findings):
1212
+ """G. 平台兼容性校验。
1213
+
1214
+ 若 spec 声明 supported_chips(可选),其中任一芯片必须支持所有 inputs.dtype_set
1215
+ + supported_combinations 涉及的 dtype。
1216
+ """
1217
+ chip_ids = _get(spec, "op", "platform_constraints", "supported_chips", default=None)
1218
+ if not chip_ids:
1219
+ return
1220
+ chips = registries.get("chips") or {}
1221
+ if not chips:
1222
+ return # registry 缺失走 schema-only 校验,跳过此项
1223
+
1224
+ # 收集 spec 涉及的所有 dtype
1225
+ declared_dtypes: set = set()
1226
+ for inp in spec.get("inputs") or []:
1227
+ declared_dtypes.update(inp.get("dtype_set") or [])
1228
+ for combo in (spec.get("dtype_policy") or {}).get("supported_combinations") or []:
1229
+ for d in (combo.get("inputs") or {}).values():
1230
+ declared_dtypes.add(d)
1231
+ for d in (combo.get("outputs") or {}).values():
1232
+ declared_dtypes.add(d)
1233
+
1234
+ for chip_id in chip_ids:
1235
+ chip = chips.get(chip_id)
1236
+ if chip is None:
1237
+ findings.append(Finding(
1238
+ severity="error",
1239
+ rule_id="paradigm_constraint.unknown_chip",
1240
+ field_path="op.platform_constraints.supported_chips",
1241
+ message=f"未注册的芯片 id: {chip_id!r}",
1242
+ suggested_fix="在 registries/chip_registry.yaml 登记,或修正拼写",
1243
+ ))
1244
+ continue
1245
+ unsupported = declared_dtypes - chip["dtypes"]
1246
+ if unsupported:
1247
+ findings.append(Finding(
1248
+ severity="error",
1249
+ rule_id="paradigm_constraint.dtype_chip_mismatch",
1250
+ field_path="op.platform_constraints.supported_chips",
1251
+ message=(
1252
+ f"芯片 {chip_id!r} 不支持以下 dtype: {sorted(unsupported)};"
1253
+ f"已知该芯片支持: {sorted(chip['dtypes'])}"
1254
+ ),
1255
+ suggested_fix=(
1256
+ "从 supported_chips 移除不兼容的型号,或从 dtype_set / "
1257
+ "supported_combinations 移除该芯片不支持的 dtype"
1258
+ ),
1259
+ ))
1260
+
1261
+
1262
+ def _check_anti_pattern_ids(spec, registries, findings):
1263
+ """I. numerical_stability.techniques[].anti_pattern_id 必须在 anti_pattern_registry 中。
1264
+
1265
+ schema 已用 ^AP-\\d{3}$ 卡格式;本检查锁定**有效编号集合**,避免 AP-999 / AP-001
1266
+ (未分配)混入 spec。
1267
+ """
1268
+ valid = registries.get("anti_patterns") or set()
1269
+ if not valid:
1270
+ return # registry 缺失走 schema-only 校验,跳过此项
1271
+ techniques = _get(spec, "numerical_stability", "techniques", default=[]) or []
1272
+ for i, tech in enumerate(techniques):
1273
+ ap_id = tech.get("anti_pattern_id")
1274
+ if ap_id is None:
1275
+ continue
1276
+ if ap_id not in valid:
1277
+ findings.append(Finding(
1278
+ severity="error",
1279
+ rule_id="paradigm_constraint.unknown_anti_pattern",
1280
+ field_path=f"numerical_stability.techniques[{i}].anti_pattern_id",
1281
+ message=(
1282
+ f"未注册的 anti_pattern_id: {ap_id!r};已知 IDs={sorted(valid)}"
1283
+ ),
1284
+ suggested_fix=(
1285
+ "在 registries/anti_pattern_registry.yaml 中登记新编号,或修正拼写"
1286
+ ),
1287
+ ))
1288
+
1289
+
1290
+ def _check_op_error_codes(spec, registries, findings):
1291
+ """J. boundary_conditions[].machine_check.error_type 必须在 op.error_codes 全集内。
1292
+
1293
+ 若 spec 没声明 op.error_codes 但在 boundary/extreme 中使用了 raises_error,
1294
+ 报 error 强制声明(error_codes 是算子契约的一部分,不是可选描述)。
1295
+ """
1296
+ declared_raw = _get(spec, "op", "error_codes", default=None)
1297
+ declared_set = set(declared_raw or [])
1298
+
1299
+ raises_cases: list[tuple[str, int, str]] = []
1300
+ for sect in ("boundary_conditions", "extreme_inputs"):
1301
+ for i, case in enumerate(spec.get(sect) or []):
1302
+ mc = case.get("machine_check") or {}
1303
+ if mc.get("kind") != "raises_error":
1304
+ continue
1305
+ etype = mc.get("error_type")
1306
+ if etype:
1307
+ raises_cases.append((sect, i, etype))
1308
+
1309
+ if not declared_set and raises_cases:
1310
+ etypes_used = sorted({e for _, _, e in raises_cases})
1311
+ findings.append(Finding(
1312
+ severity="error",
1313
+ rule_id="paradigm_constraint.error_codes_undeclared",
1314
+ field_path="op.error_codes",
1315
+ message=(
1316
+ f"boundary/extreme 中使用了 raises_error (error_type={etypes_used}) "
1317
+ f"但 op.error_codes 未声明;error_codes 是算子契约,必须显式列全集"
1318
+ ),
1319
+ suggested_fix=f"在 op 块下添加 error_codes: {etypes_used}",
1320
+ ))
1321
+ return
1322
+
1323
+ for sect, i, etype in raises_cases:
1324
+ if etype not in declared_set:
1325
+ findings.append(Finding(
1326
+ severity="error",
1327
+ rule_id="paradigm_constraint.error_code_not_declared",
1328
+ field_path=f"{sect}[{i}].machine_check.error_type",
1329
+ message=(
1330
+ f"error_type={etype!r} 不在 op.error_codes 声明的全集 "
1331
+ f"{sorted(declared_set)} 中"
1332
+ ),
1333
+ suggested_fix="把该 error_type 加到 op.error_codes,或修正本 case",
1334
+ ))
1335
+
1336
+
1337
+ def _check_composition_hint(spec, paradigms, findings):
1338
+ """H. composition 存在但 paradigms 缺 FusedComposite ⇒ WARN(不算 FAIL)。"""
1339
+ has_comp = _get(spec, "math_semantics", "composition") is not None
1340
+ if not has_comp or "FusedComposite" in paradigms:
1341
+ return
1342
+ prims = _get(spec, "math_semantics", "composition", "primitives", default=[]) or []
1343
+ if len(prims) >= 2:
1344
+ findings.append(Finding(
1345
+ severity="warning",
1346
+ rule_id="composition_without_fused_composite",
1347
+ field_path="op.paradigms",
1348
+ message="composition.primitives ≥ 2 但 paradigms 不含 FusedComposite,建议补 FusedComposite",
1349
+ suggested_fix="在 op.paradigms 添加 FusedComposite",
1350
+ ))
1351
+ elif len(prims) == 1:
1352
+ findings.append(Finding(
1353
+ severity="warning",
1354
+ rule_id="composition_single_primitive",
1355
+ field_path="math_semantics.composition",
1356
+ message="composition.primitives 只有 1 条,建议删除 composition 段",
1357
+ suggested_fix="删除 math_semantics.composition",
1358
+ ))
1359
+
1360
+
1361
+ def _check_format_variants(spec, findings):
1362
+ """format_variants 合法性:rank 范围、reduction_axes 合法、oracle_kwargs 与 axes 对齐。"""
1363
+ variants = _get(spec, "math_semantics", "format_variants")
1364
+ if not variants:
1365
+ return
1366
+
1367
+ # 从 shape_constraints.symbols 推算最大 rank
1368
+ symbols = _get(spec, "shape_constraints", "symbols", default={}) or {}
1369
+ # inputs 的 rank_range 是更准确的来源
1370
+ inputs = _get(spec, "inputs", default=[]) or []
1371
+ max_rank = 0
1372
+ for inp in inputs:
1373
+ if isinstance(inp, dict):
1374
+ rr = inp.get("rank_range")
1375
+ if rr and isinstance(rr, list) and len(rr) == 2:
1376
+ max_rank = max(max_rank, rr[1])
1377
+ # 回退:按 symbols 数量推算
1378
+ if max_rank == 0 and symbols:
1379
+ max_rank = len(symbols)
1380
+
1381
+ for i, v in enumerate(variants):
1382
+ if not isinstance(v, dict):
1383
+ continue
1384
+ prefix = f"math_semantics.format_variants[{i}]"
1385
+
1386
+ # 1. reduction_axes 合法性:非负且 < min(ranks)
1387
+ # 同一 variant 的 reduction_axes 必须对所有适用 rank 都合法
1388
+ axes = v.get("reduction_axes", [])
1389
+ ranks = v.get("rank", [])
1390
+ variant_max_rank = min(ranks) if ranks else max_rank
1391
+
1392
+ for ax in axes:
1393
+ if not isinstance(ax, int):
1394
+ continue
1395
+ if ax < 0:
1396
+ findings.append(Finding(
1397
+ severity="error",
1398
+ rule_id="format_variants.reduction_axes_negative",
1399
+ field_path=f"{prefix}.reduction_axes",
1400
+ message=f"reduction_axes 含负值 {ax}({v.get('format', '?')} 格式)",
1401
+ suggested_fix="使用非负轴索引",
1402
+ ))
1403
+ elif variant_max_rank > 0 and ax >= variant_max_rank:
1404
+ findings.append(Finding(
1405
+ severity="error",
1406
+ rule_id="format_variants.reduction_axes_out_of_rank",
1407
+ field_path=f"{prefix}.reduction_axes",
1408
+ message=(f"reduction_axes 含 {ax},超出 {v.get('format', '?')} "
1409
+ f"格式的 rank={variant_max_rank}"),
1410
+ suggested_fix=f"确保所有 reduction_axes < {variant_max_rank}",
1411
+ ))
1412
+
1413
+ # 2. oracle_kwargs.dim 与 reduction_axes 对齐
1414
+ oracle_kw = v.get("oracle_kwargs")
1415
+ if oracle_kw and isinstance(oracle_kw, dict):
1416
+ dim_val = oracle_kw.get("dim")
1417
+ if dim_val is not None and isinstance(dim_val, list):
1418
+ if sorted(dim_val) != sorted(axes):
1419
+ findings.append(Finding(
1420
+ severity="warning",
1421
+ rule_id="format_variants.oracle_kwargs_dim_mismatch",
1422
+ field_path=f"{prefix}.oracle_kwargs",
1423
+ message=(f"{v.get('format', '?')} 格式:oracle_kwargs.dim={dim_val} "
1424
+ f"与 reduction_axes={axes} 不一致"),
1425
+ suggested_fix=f"将 oracle_kwargs.dim 改为 {axes}",
1426
+ ))
1427
+
1428
+
1429
+ # 涉及累加的 category —— 这些算子的输入数据分布必须是正态分布(normal),
1430
+ # 因为均匀分布在累加链路上容易掩盖精度问题(值域窄、无大数吃小数),正态分布
1431
+ # 能暴露累加顺序敏感的精度缺陷。
1432
+ _ACCUMULATION_CATEGORIES = {
1433
+ "Reduction", "ReductionComposite",
1434
+ "Recurrence", "AtomicUpdate", "Histogram",
1435
+ }
1436
+
1437
+
1438
+ def _check_data_distribution(spec, cat, paradigms, findings):
1439
+ """data_distribution 约束:
1440
+ - 累加类算子(Reduction/ReductionComposite/Recurrence/AtomicUpdate/Histogram)⇒
1441
+ tensor role 的数据输入必须声明 data_distribution: normal
1442
+ (dtype_set 全为整型的索引/轴输入跳过,不适用正态分布)
1443
+ 注:Contraction(matmul)不计入累加类——矩阵乘法精度取决于条件数而非累加顺序
1444
+ - 非累加类算子 ⇒ 不应声明 data_distribution(留空 / 不写)
1445
+ """
1446
+ is_accum = cat in _ACCUMULATION_CATEGORIES
1447
+ inputs = spec.get("inputs") or []
1448
+ _integer_dtypes = {"int4", "int8", "int16", "int32", "int64",
1449
+ "uint1", "uint4", "uint8", "uint16", "uint32", "uint64", "bool"}
1450
+
1451
+ for i, inp in enumerate(inputs):
1452
+ if not isinstance(inp, dict):
1453
+ continue
1454
+ # 只检查 tensor role 的输入(跳过 scalar / attribute_alias / state)
1455
+ if inp.get("role") != "tensor":
1456
+ continue
1457
+ # 跳过整型索引/轴输入(如 axis/dim/axes/index)—— 正态分布不适用于索引值
1458
+ dtype_set = set(inp.get("dtype_set") or [])
1459
+ if dtype_set and dtype_set.issubset(_integer_dtypes):
1460
+ continue
1461
+ dist = inp.get("data_distribution")
1462
+ prefix = f"inputs[{i}]({inp.get('name', '?')}).data_distribution"
1463
+
1464
+ if is_accum:
1465
+ if dist != "normal":
1466
+ findings.append(Finding(
1467
+ severity="error",
1468
+ rule_id="data_distribution.accumulation_requires_normal",
1469
+ field_path=prefix,
1470
+ message=(
1471
+ f"category={cat} 属累加类算子,tensor 数据输入必须声明 "
1472
+ f"data_distribution: normal(当前为 {dist!r})。"
1473
+ "正态分布能暴露累加顺序敏感的精度缺陷,均匀分布会掩盖"
1474
+ ),
1475
+ suggested_fix="添加 data_distribution: normal",
1476
+ ))
1477
+ else:
1478
+ if dist is not None:
1479
+ findings.append(Finding(
1480
+ severity="error",
1481
+ rule_id="data_distribution.non_accumulation_must_omit",
1482
+ field_path=prefix,
1483
+ message=(
1484
+ f"category={cat} 非累加类算子,不应声明 data_distribution"
1485
+ f"(当前为 {dist!r})。data_distribution 仅累加类算子填写"
1486
+ ),
1487
+ suggested_fix="删除该字段的 data_distribution",
1488
+ ))
1489
+
1490
+
1491
+ def stage_6(spec: dict, registries: dict) -> StageResult:
1492
+ """boundary_min_set — 按 paradigms 检查 spec 是否覆盖各范式必含的最低 case 集。
1493
+
1494
+ 数据源:registries/boundary_min_cases.yaml
1495
+ 匹配方式(双轨):
1496
+ 1. 显式 tag 优先:spec 的 case 可声明 `tags: [<requirement.id>, ...]`,命中
1497
+ 即覆盖。新写 spec 推荐做法,避免子串歧义。
1498
+ 2. 关键词子串兜底:req.match_any 任一关键词出现在 case 描述里也算覆盖。保留兼容。
1499
+ 结构性约束(如 DynamicShape 的 shape_set ≥ 3)走 special_check。
1500
+ """
1501
+ res = StageResult(stage_id=6, status="PASS")
1502
+ paradigms = set(_get(spec, "op", "paradigms", default=[]) or [])
1503
+ requirements = (registries.get("boundary_min_cases") or {}).get("paradigm_requirements", {})
1504
+
1505
+ boundary_cases = spec.get("boundary_conditions") or []
1506
+ extreme_cases = spec.get("extreme_inputs") or []
1507
+
1508
+ def _section_data(section: str) -> tuple[str, set]:
1509
+ cases = boundary_cases if section == "boundary_conditions" else extreme_cases
1510
+ text = " | ".join(str(c.get("case", "")) for c in cases)
1511
+ tags: set = set()
1512
+ for c in cases:
1513
+ for t in (c.get("tags") or []):
1514
+ tags.add(str(t))
1515
+ return text, tags
1516
+
1517
+ broadcast_kind = (spec.get("broadcast") or {}).get("kind", "none")
1518
+
1519
+ _attr_determined_output = _output_count_attr_determined(spec)
1520
+ for paradigm in sorted(paradigms):
1521
+ # Broadcast paradigm 的 boundary cases 仅适用于输入间广播(kind != none);
1522
+ # 单输入或内部计算广播(kind=none)不需要这些 case。
1523
+ if paradigm == "Broadcast" and broadcast_kind == "none":
1524
+ continue
1525
+ # 属性决定输出个数(split 类):VariableOutput 的 empty/full/sparse case
1526
+ # 是为 nonzero/where 这类数据决定输出个数的算子设计的,不适用于属性决定。
1527
+ if paradigm == "VariableOutput" and _attr_determined_output:
1528
+ continue
1529
+
1530
+ for req in requirements.get(paradigm, []) or []:
1531
+ req_id = req.get("id")
1532
+ summary = req.get("summary", req_id)
1533
+
1534
+ if "special_check" in req:
1535
+ # 历史遗留特殊校验已随弃用字段(test_matrix 等)移除;
1536
+ # registry 里若还残留 special_check,直接跳过,不再产生 finding。
1537
+ continue
1538
+
1539
+ section = req.get("section", "boundary_conditions")
1540
+ text, tags = _section_data(section)
1541
+ keywords = req.get("match_any", []) or []
1542
+
1543
+ if req_id in tags:
1544
+ continue # 显式 tag 命中
1545
+ if any(kw in text for kw in keywords):
1546
+ continue # 子串兜底命中
1547
+
1548
+ res.findings.append(Finding(
1549
+ severity="error",
1550
+ rule_id="boundary_min_set.missing_required_case",
1551
+ field_path=f"{section}",
1552
+ message=f"paradigm={paradigm} 缺必含 case: {summary} (id={req_id})",
1553
+ suggested_fix=(
1554
+ f"在 {section} 中添加一条 case,加 `tags: [{req_id}]` "
1555
+ f"或描述包含以下任一关键词:{keywords}"
1556
+ ),
1557
+ ))
1558
+
1559
+ if any(f.severity == "error" for f in res.findings):
1560
+ res.status = "FAIL"
1561
+ return res
1562
+
1563
+
1564
+ # 容差紧度阈值从 registries/tolerance_defaults.yaml 加载(与 generator 共享数据源)
1565
+ @functools.lru_cache(maxsize=1)
1566
+ def _tolerance_tight_threshold() -> dict[str, float]:
1567
+ data = yaml.safe_load((REGISTRIES / "tolerance_defaults.yaml").read_text(encoding="utf-8"))
1568
+ return data.get("tightness_threshold") or {}
1569
+
1570
+
1571
+ def stage_7(spec: dict) -> StageResult:
1572
+ """tolerance_coverage — numerical_tolerance.per_dtype 是否覆盖所有声明的输出 dtype。
1573
+
1574
+ 与 stage 4 (dtype DSL 求解) 完整版的差别:本 stage 用 dtype_policy.supported_combinations
1575
+ 显式枚举的输出 dtype 作为代理,stage 4 实现后会改为用 DSL 推导结果。两者通常一致。
1576
+
1577
+ 额外做"容差过紧"启发式检查 (WARN):rtol 显著低于 dtype 单步舍入精度时提示。
1578
+ """
1579
+ res = StageResult(stage_id=7, status="PASS")
1580
+
1581
+ declared_output_dtypes: set[str] = set()
1582
+ for combo in _get(spec, "dtype_policy", "supported_combinations", default=[]) or []:
1583
+ for d in (combo.get("outputs") or {}).values():
1584
+ declared_output_dtypes.add(d)
1585
+
1586
+ per_dtype = _get(spec, "numerical_tolerance", "per_dtype", default={}) or {}
1587
+ declared_tol_dtypes = set(per_dtype.keys())
1588
+
1589
+ uncovered = declared_output_dtypes - declared_tol_dtypes
1590
+ for d in sorted(uncovered):
1591
+ res.findings.append(Finding(
1592
+ severity="error",
1593
+ rule_id="tolerance_coverage.uncovered_output_dtype",
1594
+ field_path=f"numerical_tolerance.per_dtype.{d}",
1595
+ message=f"输出 dtype {d!r} 未在 numerical_tolerance.per_dtype 中声明容差",
1596
+ suggested_fix=f"为 {d} 补充 {{rtol, atol, metric}}",
1597
+ ))
1598
+
1599
+ # 紧度提示(启发式 WARN)
1600
+ thresholds = _tolerance_tight_threshold()
1601
+ for d, entry in per_dtype.items():
1602
+ threshold = thresholds.get(d)
1603
+ if threshold is None:
1604
+ continue
1605
+ rtol = entry.get("rtol")
1606
+ if isinstance(rtol, (int, float)) and 0 < rtol < threshold:
1607
+ res.findings.append(Finding(
1608
+ severity="warning",
1609
+ rule_id="tolerance_coverage.tolerance_too_tight",
1610
+ field_path=f"numerical_tolerance.per_dtype.{d}.rtol",
1611
+ message=(
1612
+ f"{d} rtol={rtol:.1e} 低于该 dtype 单步舍入量级 ({threshold:.0e});"
1613
+ "大量累加后实际不可能达到,可能导致 PR 误报"
1614
+ ),
1615
+ suggested_fix=f"放宽 {d} 的 rtol 到至少 {threshold:.0e}",
1616
+ ))
1617
+
1618
+ if any(f.severity == "error" for f in res.findings):
1619
+ res.status = "FAIL"
1620
+ return res
1621
+
1622
+
1623
+ @functools.lru_cache(maxsize=1)
1624
+ def load_registries() -> dict:
1625
+ """Load all registries from disk; cached per-process."""
1626
+ inv = {}
1627
+ inv_data = yaml.safe_load((REGISTRIES / "invariant_kind_registry.yaml").read_text(encoding="utf-8"))
1628
+ for group in ("value", "algebraic", "structural"):
1629
+ for entry in inv_data.get(group, []) or []:
1630
+ inv[entry["kind"]] = entry
1631
+
1632
+ return {
1633
+ "primitives": yaml.safe_load((REGISTRIES / "primitive_whitelist.yaml").read_text(encoding="utf-8"))["primitives"],
1634
+ "invariant_kinds": inv,
1635
+ "machine_check_kinds": [
1636
+ x["kind"] for x in
1637
+ yaml.safe_load((REGISTRIES / "machine_check_kind_registry.yaml").read_text(encoding="utf-8"))["machine_check_kinds"]
1638
+ ],
1639
+ "patterns": [
1640
+ x["name"] for x in
1641
+ yaml.safe_load((REGISTRIES / "synthesize_pattern_registry.yaml").read_text(encoding="utf-8"))["patterns"]
1642
+ ],
1643
+ "error_codes": yaml.safe_load((REGISTRIES / "error_code_enum.yaml").read_text(encoding="utf-8"))["error_codes"],
1644
+ "category_map": yaml.safe_load((REGISTRIES / "category_paradigm_map.yaml").read_text(encoding="utf-8")),
1645
+ "boundary_min_cases": yaml.safe_load((REGISTRIES / "boundary_min_cases.yaml").read_text(encoding="utf-8")),
1646
+ "chips": _load_chip_registry(),
1647
+ "anti_patterns": _load_anti_pattern_registry(),
1648
+ }
1649
+
1650
+
1651
+ def _load_anti_pattern_registry() -> set:
1652
+ """加载 anti_pattern_registry.yaml;返回 {AP-XXX, ...}。"""
1653
+ path = REGISTRIES / "anti_pattern_registry.yaml"
1654
+ if not path.exists():
1655
+ return set()
1656
+ data = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
1657
+ return {x["id"] for x in data.get("anti_patterns") or []}
1658
+
1659
+
1660
+ def _load_chip_registry() -> dict:
1661
+ """加载 chip_registry.yaml;返回 {chip_id: {dtypes: set}}。"""
1662
+ path = REGISTRIES / "chip_registry.yaml"
1663
+ if not path.exists():
1664
+ return {}
1665
+ data = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
1666
+ out = {}
1667
+ for c in data.get("chips") or []:
1668
+ out[c["id"]] = {
1669
+ "dtypes": set(c.get("supported_dtypes") or []),
1670
+ }
1671
+ return out
1672
+
1673
+
1674
+ def _run_eval_stages(spec: dict) -> tuple[StageResult, ...]:
1675
+ """Lazily import the evaluators package; if it fails, return SKIP stages.
1676
+
1677
+ Returns eight StageResult objects in order: stage 3, 4, 5, 8, 9, 10, 11, 12.
1678
+ Stage 8 / 9 / 10 / 11 / 12 may individually SKIP based on env (numpy/framework not
1679
+ installed) even when the evaluators package itself imports fine.
1680
+ """
1681
+ try:
1682
+ from evaluators import stages as eval_stages
1683
+ from evaluators import (formula_eval, oracle_check, formula_oracle_equiv,
1684
+ invariant_exec, extreme_inputs_check)
1685
+ except ImportError as e:
1686
+ skip_finding = Finding(
1687
+ severity="info",
1688
+ rule_id="stage_skipped",
1689
+ field_path="<evaluators import>",
1690
+ message=f"evaluators 子包不可用,stage 3-5/8/9/10/11/12 跳过:{e}",
1691
+ suggested_fix="确认 scripts/evaluators/ 子包文件齐全",
1692
+ )
1693
+ return tuple(
1694
+ StageResult(stage_id=sid, status="SKIP", findings=[skip_finding])
1695
+ for sid in (3, 4, 5, 8, 9, 10, 11, 12)
1696
+ )
1697
+
1698
+ pipeline = (
1699
+ (3, eval_stages.stage_3),
1700
+ (4, eval_stages.stage_4),
1701
+ (5, eval_stages.stage_5),
1702
+ (8, formula_eval.stage_8),
1703
+ (9, oracle_check.stage_9),
1704
+ (10, formula_oracle_equiv.stage_10),
1705
+ (11, invariant_exec.stage_11),
1706
+ (12, extreme_inputs_check.stage_12),
1707
+ )
1708
+ results: list[StageResult] = []
1709
+ for stage_id, fn in pipeline:
1710
+ try:
1711
+ status, raw_findings = fn(spec)
1712
+ except Exception as ex: # 防御性 — DSL 内部 bug 不应整体打断
1713
+ results.append(StageResult(
1714
+ stage_id=stage_id,
1715
+ status="FAIL",
1716
+ findings=[Finding(
1717
+ severity="error",
1718
+ rule_id=f"stage_{stage_id}_internal_error",
1719
+ field_path="<internal>",
1720
+ message=f"stage {stage_id} 内部异常:{type(ex).__name__}: {ex}",
1721
+ suggested_fix="向 ops-spec-gen 维护者反馈完整堆栈",
1722
+ )]
1723
+ ))
1724
+ continue
1725
+ findings = [Finding(**f) for f in raw_findings]
1726
+ results.append(StageResult(stage_id=stage_id, status=status, findings=findings))
1727
+ return tuple(results)
1728
+
1729
+
1730
+ def render_text(stages: list[StageResult], *, quiet: bool = False) -> str:
1731
+ """Render stage results as text. quiet=True 时只打 FAIL 的 stage(PASS/SKIP 折叠为一行汇总)。"""
1732
+ lines: list[str] = []
1733
+ icons = {"PASS": "✓", "FAIL": "✗", "SKIP": "↷"}
1734
+
1735
+ if quiet:
1736
+ # 只列 FAIL,PASS/SKIP 计数
1737
+ passed = [s for s in stages if s.status == "PASS"]
1738
+ skipped = [s for s in stages if s.status == "SKIP"]
1739
+ failed = [s for s in stages if s.status == "FAIL"]
1740
+ if passed:
1741
+ lines.append(f" {icons['PASS']} {len(passed)} 个 stage PASS: "
1742
+ + ", ".join(f"stage {s.stage_id}" for s in passed))
1743
+ if skipped:
1744
+ lines.append(f" {icons['SKIP']} {len(skipped)} 个 stage SKIP: "
1745
+ + ", ".join(f"stage {s.stage_id}" for s in skipped))
1746
+ for st in failed:
1747
+ lines.append(f"\n[stage {st.stage_id}] {icons[st.status]} {st.status}")
1748
+ for f in st.findings:
1749
+ if f.severity not in ("error", "warning"):
1750
+ continue
1751
+ sev = {"error": "ERR ", "warning": "WARN"}[f.severity]
1752
+ lines.append(f" {sev} {f.rule_id}")
1753
+ lines.append(f" path: {f.field_path}")
1754
+ lines.append(f" msg : {f.message}")
1755
+ if f.suggested_fix:
1756
+ lines.append(f" fix : {f.suggested_fix}")
1757
+ else:
1758
+ for st in stages:
1759
+ lines.append(f"\n[stage {st.stage_id}] {icons[st.status]} {st.status}")
1760
+ for f in st.findings:
1761
+ sev = {"error": "ERR ", "warning": "WARN", "info": "INFO"}[f.severity]
1762
+ lines.append(f" {sev} {f.rule_id}")
1763
+ lines.append(f" path: {f.field_path}")
1764
+ lines.append(f" msg : {f.message}")
1765
+ if f.suggested_fix:
1766
+ lines.append(f" fix : {f.suggested_fix}")
1767
+
1768
+ overall = (
1769
+ "PASS"
1770
+ if all(s.status in ("PASS", "SKIP") for s in stages)
1771
+ else "FAIL"
1772
+ )
1773
+ lines.append(f"\n=== overall: {overall} ===")
1774
+ return "\n".join(lines)
1775
+
1776
+
1777
+ def main() -> int:
1778
+ ap = argparse.ArgumentParser(description="Validate spec.yaml (full 12-stage).")
1779
+ ap.add_argument("spec_path")
1780
+ ap.add_argument("--json", action="store_true", help="Emit JSON instead of text")
1781
+ ap.add_argument("--strict", action="store_true",
1782
+ help="Exit non-zero on warnings as well as errors")
1783
+ ap.add_argument("--stage", action="append", type=int, choices=range(1, 13),
1784
+ metavar="N",
1785
+ help="只跑指定 stage(可多次:--stage 1 --stage 2);省略时跑全部 12 个")
1786
+ ap.add_argument("--quiet", action="store_true",
1787
+ help="只打 FAIL 的 stage(仍输出 overall 行)")
1788
+ args = ap.parse_args()
1789
+
1790
+ spec_path = Path(args.spec_path)
1791
+ if not spec_path.exists():
1792
+ print(f"ERROR: spec file not found: {spec_path}", file=sys.stderr)
1793
+ return 2
1794
+ try:
1795
+ spec = _load_yaml(spec_path)
1796
+ except yaml.YAMLError as e:
1797
+ print(f"ERROR: YAML 解析失败 {spec_path}", file=sys.stderr)
1798
+ print(f" {e}", file=sys.stderr)
1799
+ return 2
1800
+ if not isinstance(spec, dict):
1801
+ print(f"ERROR: {args.spec_path} did not parse as a YAML mapping", file=sys.stderr)
1802
+ return 2
1803
+
1804
+ selected = set(args.stage) if args.stage else None
1805
+ registries = load_registries()
1806
+
1807
+ # 按需跑 stage —— 跳过的 stage 不出现在 stages 列表中
1808
+ stages: list[StageResult] = []
1809
+ if selected is None or 1 in selected:
1810
+ stages.append(stage_1(spec))
1811
+ if selected is None or 2 in selected:
1812
+ stages.append(stage_2(spec, registries))
1813
+ # stage 3/4/5/8/9/10/11 共享 DSL 子包 lazy import;选中其一即触发
1814
+ dsl_needed = selected is None or selected & {3, 4, 5, 8, 9, 10, 11, 12}
1815
+ if dsl_needed:
1816
+ eval_srs = _run_eval_stages(spec)
1817
+ for sid, sr in zip((3, 4, 5, 8, 9, 10, 11, 12), eval_srs):
1818
+ if selected is None or sid in selected:
1819
+ stages.append(sr)
1820
+ if selected is None or 6 in selected:
1821
+ stages.append(stage_6(spec, registries))
1822
+ if selected is None or 7 in selected:
1823
+ stages.append(stage_7(spec))
1824
+
1825
+ # 按 stage_id 排序,确保打印顺序与 1..10 一致
1826
+ stages.sort(key=lambda s: s.stage_id)
1827
+
1828
+ if args.json:
1829
+ print(json.dumps({
1830
+ "spec": str(args.spec_path),
1831
+ "stages": [{"stage_id": s.stage_id, "status": s.status,
1832
+ "findings": [asdict(f) for f in s.findings]}
1833
+ for s in stages],
1834
+ }, ensure_ascii=False, indent=2))
1835
+ else:
1836
+ print(render_text(stages, quiet=args.quiet))
1837
+
1838
+ has_error = any(f.severity == "error" for s in stages for f in s.findings)
1839
+ has_warning = any(f.severity == "warning" for s in stages for f in s.findings)
1840
+ if has_error:
1841
+ return 1
1842
+ if args.strict and has_warning:
1843
+ return 1
1844
+ return 0
1845
+
1846
+
1847
+ if __name__ == "__main__":
1848
+ sys.exit(main())