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