@cannbot-plugin/cannbot-harness 0.0.0-stage → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -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 +384 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +20 -0
- package/locale/en.json +1 -0
- package/locale/zh.json +1 -0
- package/package.json +63 -3
- package/upstream.json +10 -0
|
@@ -0,0 +1,2469 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2026 Huawei Technologies Co., Ltd.
|
|
4
|
+
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
|
|
5
|
+
# CANN Open Software License Agreement Version 2.0 (the "License").
|
|
6
|
+
# Please refer to the License for details. You may not use this file except in compliance with the License.
|
|
7
|
+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
|
|
8
|
+
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
# See LICENSE in the root of the software repository for the full text of the License.
|
|
10
|
+
#
|
|
11
|
+
# ----------------------------------------------------------------------------------------------------------
|
|
12
|
+
# msprof 解析 & 归档 & 对比测试脚本(统一入口)
|
|
13
|
+
#
|
|
14
|
+
# 支持三种模式:
|
|
15
|
+
# 1. 标准模式 (默认): 解析 PROF_GROUP,生成 summary.txt 并归档 CSV
|
|
16
|
+
# python3 msprof_perf_summary.py <PROF_GROUP_dir> <ops_dir>
|
|
17
|
+
#
|
|
18
|
+
# 2. 对比模式 (--compare): 对算子目录做 model.py vs model_new_ascendc.py 对比测试
|
|
19
|
+
# python3 msprof_perf_summary.py --compare --output-dir <op_dir> [--warm-up=N] [--device=N]
|
|
20
|
+
#
|
|
21
|
+
# 3. 批量模式 (--batch): 扫描多个算子目录,汇总批量报告
|
|
22
|
+
# python3 msprof_perf_summary.py --batch <base_dir> [--output-md <path>] [--output-json <path>]
|
|
23
|
+
#
|
|
24
|
+
# 归档位置 (与 perf_summary.py 保持一致):
|
|
25
|
+
# <ops_dir>/docs/perf/round_NNN/
|
|
26
|
+
# op_summary_<Metric>.csv (7 份)
|
|
27
|
+
# task_time.csv (若存在)
|
|
28
|
+
# op_statistic.csv (若存在)
|
|
29
|
+
# summary.txt (合并后的统计摘要)
|
|
30
|
+
# ----------------------------------------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
import argparse
|
|
33
|
+
import csv
|
|
34
|
+
import importlib.util
|
|
35
|
+
import inspect
|
|
36
|
+
import json
|
|
37
|
+
import logging
|
|
38
|
+
import glob
|
|
39
|
+
import math
|
|
40
|
+
import os
|
|
41
|
+
import re
|
|
42
|
+
import shutil
|
|
43
|
+
import signal
|
|
44
|
+
import sqlite3
|
|
45
|
+
import statistics
|
|
46
|
+
import subprocess
|
|
47
|
+
import sys
|
|
48
|
+
import time
|
|
49
|
+
import types
|
|
50
|
+
from pathlib import Path
|
|
51
|
+
from dataclasses import dataclass, field
|
|
52
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
53
|
+
|
|
54
|
+
LOGGER = logging.getLogger(__name__)
|
|
55
|
+
|
|
56
|
+
METRICS = [
|
|
57
|
+
"PipeUtilization",
|
|
58
|
+
"ArithmeticUtilization",
|
|
59
|
+
"Memory",
|
|
60
|
+
"MemoryL0",
|
|
61
|
+
"MemoryUB",
|
|
62
|
+
"L2Cache",
|
|
63
|
+
"ResourceConflictRatio",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# ============================================================================
|
|
68
|
+
# 通用工具函数
|
|
69
|
+
# ============================================================================
|
|
70
|
+
|
|
71
|
+
def safe_float(val: Any, default: float = 0.0) -> float:
|
|
72
|
+
if val is None:
|
|
73
|
+
return default
|
|
74
|
+
s = str(val).strip().rstrip("\t ")
|
|
75
|
+
if s in ("", "N/A", "NA", "-"):
|
|
76
|
+
return default
|
|
77
|
+
try:
|
|
78
|
+
return float(s)
|
|
79
|
+
except (ValueError, TypeError):
|
|
80
|
+
return default
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def safe_int(val: Any, default: int = 0) -> int:
|
|
84
|
+
return int(safe_float(val, default))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def read_csv_rows(path: str) -> List[Dict[str, str]]:
|
|
88
|
+
if not os.path.exists(path):
|
|
89
|
+
return []
|
|
90
|
+
with open(path, "r", encoding="utf-8", errors="replace") as f:
|
|
91
|
+
return list(csv.DictReader(f))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def find_next_round(perf_dir: str) -> str:
|
|
95
|
+
if not os.path.exists(perf_dir):
|
|
96
|
+
return os.path.join(perf_dir, "round_001")
|
|
97
|
+
existing = [d for d in os.listdir(perf_dir) if re.match(r"round_\d+", d)]
|
|
98
|
+
if not existing:
|
|
99
|
+
return os.path.join(perf_dir, "round_001")
|
|
100
|
+
nums = [int(re.search(r"\d+", d).group()) for d in existing]
|
|
101
|
+
return os.path.join(perf_dir, f"round_{max(nums) + 1:03d}")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# ============================================================================
|
|
105
|
+
# 标准模式:解析 PROF_GROUP
|
|
106
|
+
# ============================================================================
|
|
107
|
+
|
|
108
|
+
def find_op_summary(prof_metric_dir: str) -> Optional[str]:
|
|
109
|
+
pattern = os.path.join(prof_metric_dir, "**", "mindstudio_profiler_output", "op_summary_*.csv")
|
|
110
|
+
hits = sorted(glob.glob(pattern, recursive=True))
|
|
111
|
+
return hits[-1] if hits else None
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def pick_target_row(rows: List[Dict[str, str]], target_name: Optional[str]) -> Optional[Dict[str, str]]:
|
|
115
|
+
if not rows:
|
|
116
|
+
return None
|
|
117
|
+
if target_name:
|
|
118
|
+
for r in rows:
|
|
119
|
+
if r.get("Op Name", "").strip() == target_name:
|
|
120
|
+
return r
|
|
121
|
+
ai_core_rows = []
|
|
122
|
+
for r in rows:
|
|
123
|
+
if "AI_CORE" in r.get("Task Type", "") \
|
|
124
|
+
or "AIV" in r.get("Task Type", "") \
|
|
125
|
+
or "MIX" in r.get("Task Type", ""):
|
|
126
|
+
ai_core_rows.append(r)
|
|
127
|
+
candidates = ai_core_rows or rows
|
|
128
|
+
return max(candidates, key=lambda r: safe_float(r.get("Task Duration(us)")))
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _merge_row_values(merged: Dict[str, Any], row: Dict[str, str]) -> None:
|
|
132
|
+
for k, v in row.items():
|
|
133
|
+
if k in (None, ""):
|
|
134
|
+
continue
|
|
135
|
+
if k not in merged:
|
|
136
|
+
merged[k] = v
|
|
137
|
+
else:
|
|
138
|
+
old = merged[k]
|
|
139
|
+
if (old in (None, "", "N/A", "NA")) and v not in (None, "", "N/A", "NA"):
|
|
140
|
+
merged[k] = v
|
|
141
|
+
elif safe_float(old) == 0 and safe_float(v) != 0:
|
|
142
|
+
merged[k] = v
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def merge_metric_rows(group_dir: str, target_name: Optional[str]) -> Dict[str, Any]:
|
|
146
|
+
merged: Dict[str, Any] = {}
|
|
147
|
+
merged["_metric_sources"] = {}
|
|
148
|
+
merged["_missing_metrics"] = []
|
|
149
|
+
|
|
150
|
+
for metric in METRICS:
|
|
151
|
+
prof_metric_dir = os.path.join(group_dir, f"PROF_{metric}")
|
|
152
|
+
if not os.path.isdir(prof_metric_dir):
|
|
153
|
+
merged["_missing_metrics"].append(metric)
|
|
154
|
+
continue
|
|
155
|
+
csv_path = find_op_summary(prof_metric_dir)
|
|
156
|
+
if not csv_path:
|
|
157
|
+
merged["_missing_metrics"].append(metric)
|
|
158
|
+
continue
|
|
159
|
+
rows = read_csv_rows(csv_path)
|
|
160
|
+
row = pick_target_row(rows, target_name)
|
|
161
|
+
if not row:
|
|
162
|
+
merged["_missing_metrics"].append(metric)
|
|
163
|
+
continue
|
|
164
|
+
merged["_metric_sources"][metric] = csv_path
|
|
165
|
+
_merge_row_values(merged, row)
|
|
166
|
+
return merged
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def load_per_core_cycles(group_dir: str) -> List[Tuple[int, int]]:
|
|
170
|
+
candidates = glob.glob(os.path.join(group_dir, "PROF_Sample", "PROF_*", "device_0", "sqlite", "aicore.db"))
|
|
171
|
+
if not candidates:
|
|
172
|
+
return []
|
|
173
|
+
db = sorted(candidates)[-1]
|
|
174
|
+
try:
|
|
175
|
+
conn = sqlite3.connect(db)
|
|
176
|
+
cur = conn.cursor()
|
|
177
|
+
rows = list(cur.execute(
|
|
178
|
+
"SELECT coreid, SUM(task_cyc) FROM AICoreOriginalData WHERE task_cyc>0 GROUP BY coreid ORDER BY coreid"
|
|
179
|
+
))
|
|
180
|
+
conn.close()
|
|
181
|
+
return [(int(cid), int(cyc)) for cid, cyc in rows if cid is not None]
|
|
182
|
+
except sqlite3.Error:
|
|
183
|
+
return []
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def per_core_balance_section(merged: Dict[str, Any], group_dir: str) -> List[str]:
|
|
187
|
+
core_rows = load_per_core_cycles(group_dir)
|
|
188
|
+
if not core_rows:
|
|
189
|
+
return []
|
|
190
|
+
aicore_time_us = safe_float(merged.get("aicore_time(us)"))
|
|
191
|
+
if aicore_time_us <= 0:
|
|
192
|
+
return []
|
|
193
|
+
max_cyc = max(c for _, c in core_rows)
|
|
194
|
+
if max_cyc <= 0:
|
|
195
|
+
return []
|
|
196
|
+
ns_per_cyc = aicore_time_us * 1000.0 / max_cyc
|
|
197
|
+
freq_ghz = 1.0 / ns_per_cyc
|
|
198
|
+
times = [(cid, cyc * ns_per_cyc / 1000.0) for cid, cyc in core_rows]
|
|
199
|
+
t_values = [t for _, t in times]
|
|
200
|
+
t_min = min(t_values)
|
|
201
|
+
t_max = max(t_values)
|
|
202
|
+
t_avg = statistics.mean(t_values)
|
|
203
|
+
spread_pct = (t_max - t_min) / t_max * 100.0 if t_max > 0 else 0.0
|
|
204
|
+
|
|
205
|
+
if spread_pct < 10:
|
|
206
|
+
verdict = "达标 (<10%)"
|
|
207
|
+
elif spread_pct < 30:
|
|
208
|
+
verdict = "警告 (10~30%)"
|
|
209
|
+
else:
|
|
210
|
+
verdict = "严重问题 (>30%)"
|
|
211
|
+
|
|
212
|
+
lines = ["", "--- 逐核负载均衡 (sample-based aicore.db) ---"]
|
|
213
|
+
lines.append(f" 有效核数: {len(times)} | 主频推算: {freq_ghz:.3f} GHz ({ns_per_cyc:.4f} ns/cycle)")
|
|
214
|
+
lines.append(f" min={t_min:.3f}us avg={t_avg:.3f}us max={t_max:.3f}us")
|
|
215
|
+
lines.append(f" (max-min)/max = {spread_pct:.2f}% -> {verdict}")
|
|
216
|
+
|
|
217
|
+
sorted_desc = sorted(times, key=lambda x: -x[1])
|
|
218
|
+
slow_top = sorted_desc[:3]
|
|
219
|
+
fast_top = sorted_desc[-3:][::-1]
|
|
220
|
+
lines.append(" Top-3 慢核: " + ", ".join(f"Core{cid}={t:.2f}us" for cid, t in slow_top))
|
|
221
|
+
lines.append(" Top-3 快核: " + ", ".join(f"Core{cid}={t:.2f}us" for cid, t in fast_top))
|
|
222
|
+
|
|
223
|
+
sorted_by_id = sorted(times, key=lambda x: x[0])
|
|
224
|
+
if len(sorted_by_id) >= 4:
|
|
225
|
+
mid = len(sorted_by_id) // 2
|
|
226
|
+
g1 = [t for _, t in sorted_by_id[:mid]]
|
|
227
|
+
g2 = [t for _, t in sorted_by_id[mid:]]
|
|
228
|
+
g1_avg = statistics.mean(g1)
|
|
229
|
+
g2_avg = statistics.mean(g2)
|
|
230
|
+
gap = abs(g1_avg - g2_avg) / max(g1_avg, g2_avg) * 100.0
|
|
231
|
+
if gap >= 2.0:
|
|
232
|
+
lines.append(
|
|
233
|
+
f" [提示] 前半段 core 均值 {g1_avg:.2f}us vs 后半段 {g2_avg:.2f}us,"
|
|
234
|
+
f"差距 {gap:.2f}%"
|
|
235
|
+
)
|
|
236
|
+
lines.append(
|
|
237
|
+
f" 疑似两簇 (NUMA / L2 slice) 负载偏斜,"
|
|
238
|
+
f"建议尝试 block swat / 尾轮均衡策略。"
|
|
239
|
+
)
|
|
240
|
+
return lines
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def archive_per_core_csv(group_dir: str, round_dir: str) -> Optional[str]:
|
|
244
|
+
core_rows = load_per_core_cycles(group_dir)
|
|
245
|
+
if not core_rows:
|
|
246
|
+
return None
|
|
247
|
+
out = os.path.join(round_dir, "per_core_cycles.csv")
|
|
248
|
+
with open(out, "w", encoding="utf-8", newline="") as f:
|
|
249
|
+
w = csv.writer(f)
|
|
250
|
+
w.writerow(["coreid", "task_cycles"])
|
|
251
|
+
for cid, cyc in core_rows:
|
|
252
|
+
w.writerow([cid, cyc])
|
|
253
|
+
return out
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def archive_csvs(group_dir: str, round_dir: str) -> List[str]:
|
|
257
|
+
os.makedirs(round_dir, exist_ok=True)
|
|
258
|
+
copied = []
|
|
259
|
+
for metric in METRICS:
|
|
260
|
+
prof_metric_dir = os.path.join(group_dir, f"PROF_{metric}")
|
|
261
|
+
if not os.path.isdir(prof_metric_dir):
|
|
262
|
+
continue
|
|
263
|
+
op_csv = find_op_summary(prof_metric_dir)
|
|
264
|
+
if op_csv:
|
|
265
|
+
dst = os.path.join(round_dir, f"op_summary_{metric}.csv")
|
|
266
|
+
shutil.copy2(op_csv, dst)
|
|
267
|
+
copied.append(os.path.basename(dst))
|
|
268
|
+
mso_dir = os.path.dirname(op_csv) if op_csv else None
|
|
269
|
+
if mso_dir:
|
|
270
|
+
_copy_extra_csvs(mso_dir, metric, round_dir, copied)
|
|
271
|
+
return copied
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def _copy_extra_csvs(mso_dir: str, metric: str, round_dir: str, copied: List[str]) -> None:
|
|
275
|
+
for extra in ("op_statistic_", "task_time_", "api_statistic_"):
|
|
276
|
+
for f in sorted(glob.glob(os.path.join(mso_dir, f"{extra}*.csv"))):
|
|
277
|
+
name = f"{extra.rstrip('_')}_{metric}.csv"
|
|
278
|
+
dst = os.path.join(round_dir, name)
|
|
279
|
+
if not os.path.exists(dst):
|
|
280
|
+
shutil.copy2(f, dst)
|
|
281
|
+
copied.append(os.path.basename(dst))
|
|
282
|
+
break
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def fmt_ratio(val: Any, width: int = 6) -> str:
|
|
286
|
+
v = safe_float(val) * 100.0
|
|
287
|
+
return f"{v:>{width}.2f}%"
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def fmt_float(val: Any, width: int = 10, prec: int = 2) -> str:
|
|
291
|
+
return f"{safe_float(val):>{width}.{prec}f}"
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def _add_memory_section(lines: List[str], merged: Dict[str, Any]) -> None:
|
|
295
|
+
_mem_keys = [
|
|
296
|
+
"aic_main_mem_read_bw(GB/s)", "aic_main_mem_write_bw(GB/s)",
|
|
297
|
+
"aiv_main_mem_read_bw(GB/s)", "aiv_main_mem_write_bw(GB/s)",
|
|
298
|
+
"aic_l1_read_bw(GB/s)", "aic_l1_write_bw(GB/s)",
|
|
299
|
+
"aiv_ub_read_bw(GB/s)", "aiv_ub_write_bw(GB/s)",
|
|
300
|
+
]
|
|
301
|
+
has_mem = any(safe_float(merged.get(k)) > 0 for k in _mem_keys)
|
|
302
|
+
if not has_mem:
|
|
303
|
+
return
|
|
304
|
+
lines.append("")
|
|
305
|
+
lines.append("--- Memory 带宽 (aic-metrics=Memory) ---")
|
|
306
|
+
mem_rows = [
|
|
307
|
+
("aic main_mem read", "aic_main_mem_read_bw(GB/s)"),
|
|
308
|
+
("aic main_mem write", "aic_main_mem_write_bw(GB/s)"),
|
|
309
|
+
("aiv main_mem read", "aiv_main_mem_read_bw(GB/s)"),
|
|
310
|
+
("aiv main_mem write", "aiv_main_mem_write_bw(GB/s)"),
|
|
311
|
+
("aic L1 read", "aic_l1_read_bw(GB/s)"),
|
|
312
|
+
("aic L1 write", "aic_l1_write_bw(GB/s)"),
|
|
313
|
+
("aiv UB read", "aiv_ub_read_bw(GB/s)"),
|
|
314
|
+
("aiv UB write", "aiv_ub_write_bw(GB/s)"),
|
|
315
|
+
]
|
|
316
|
+
for label, key in mem_rows:
|
|
317
|
+
v = safe_float(merged.get(key))
|
|
318
|
+
if v > 0:
|
|
319
|
+
lines.append(f" {label}: {v:.2f} GB/s")
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def _add_memory_l0_section(lines: List[str], merged: Dict[str, Any]) -> None:
|
|
323
|
+
_l0_keys = [
|
|
324
|
+
"aic_l0a_read_bw(GB/s)", "aic_l0a_write_bw(GB/s)",
|
|
325
|
+
"aic_l0b_read_bw(GB/s)", "aic_l0b_write_bw(GB/s)",
|
|
326
|
+
"aic_l0c_read_bw_cube(GB/s)", "aic_l0c_write_bw_cube(GB/s)",
|
|
327
|
+
]
|
|
328
|
+
has_l0 = any(safe_float(merged.get(k)) > 0 for k in _l0_keys)
|
|
329
|
+
if not has_l0:
|
|
330
|
+
return
|
|
331
|
+
lines.append("")
|
|
332
|
+
lines.append("--- MemoryL0 ---")
|
|
333
|
+
for label, key in [
|
|
334
|
+
("L0A read", "aic_l0a_read_bw(GB/s)"),
|
|
335
|
+
("L0A write", "aic_l0a_write_bw(GB/s)"),
|
|
336
|
+
("L0B read", "aic_l0b_read_bw(GB/s)"),
|
|
337
|
+
("L0B write", "aic_l0b_write_bw(GB/s)"),
|
|
338
|
+
("L0C read (cube)", "aic_l0c_read_bw_cube(GB/s)"),
|
|
339
|
+
("L0C write (cube)", "aic_l0c_write_bw_cube(GB/s)"),
|
|
340
|
+
]:
|
|
341
|
+
v = safe_float(merged.get(key))
|
|
342
|
+
if v > 0:
|
|
343
|
+
lines.append(f" {label}: {v:.2f} GB/s")
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def _add_memory_ub_section(lines: List[str], merged: Dict[str, Any]) -> None:
|
|
347
|
+
_ub_keys = [
|
|
348
|
+
"aiv_ub_read_bw_vector(GB/s)", "aiv_ub_write_bw_vector(GB/s)",
|
|
349
|
+
"aiv_ub_read_bw_scalar(GB/s)", "aiv_ub_write_bw_scalar(GB/s)",
|
|
350
|
+
"aic_ub_read_bw_scalar(GB/s)", "aic_ub_write_bw_scalar(GB/s)",
|
|
351
|
+
"aiv_fixp2ub_write_bw(GB/s)", "aic_fixp2ub_write_bw(GB/s)",
|
|
352
|
+
]
|
|
353
|
+
has_ub = any(safe_float(merged.get(k)) > 0 for k in _ub_keys)
|
|
354
|
+
if not has_ub:
|
|
355
|
+
return
|
|
356
|
+
lines.append("")
|
|
357
|
+
lines.append("--- MemoryUB ---")
|
|
358
|
+
for label, key in [
|
|
359
|
+
("UB read (vector)", "aiv_ub_read_bw_vector(GB/s)"),
|
|
360
|
+
("UB write (vector)", "aiv_ub_write_bw_vector(GB/s)"),
|
|
361
|
+
("UB read (scalar)", "aiv_ub_read_bw_scalar(GB/s)"),
|
|
362
|
+
("UB write (scalar)", "aiv_ub_write_bw_scalar(GB/s)"),
|
|
363
|
+
("aic UB read (scalar)", "aic_ub_read_bw_scalar(GB/s)"),
|
|
364
|
+
("aic UB write (scalar)", "aic_ub_write_bw_scalar(GB/s)"),
|
|
365
|
+
("aiv fixp2ub write", "aiv_fixp2ub_write_bw(GB/s)"),
|
|
366
|
+
("aic fixp2ub write", "aic_fixp2ub_write_bw(GB/s)"),
|
|
367
|
+
]:
|
|
368
|
+
v = safe_float(merged.get(key))
|
|
369
|
+
if v > 0:
|
|
370
|
+
lines.append(f" {label}: {v:.2f} GB/s")
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def _add_l2cache_section(lines: List[str], merged: Dict[str, Any]) -> None:
|
|
374
|
+
l2_fields_aic = [
|
|
375
|
+
("aic read hit", "aic_read_local_l2_hit"),
|
|
376
|
+
("aic read miss", "aic_read_local_l2_miss"),
|
|
377
|
+
("aic read victim", "aic_read_local_l2_victim"),
|
|
378
|
+
("aic write hit", "aic_write_local_l2_hit"),
|
|
379
|
+
("aic write miss", "aic_write_local_l2_miss"),
|
|
380
|
+
("aic write victim", "aic_write_local_l2_victim"),
|
|
381
|
+
]
|
|
382
|
+
l2_fields_aiv = [
|
|
383
|
+
("aiv read hit", "aiv_read_local_l2_hit"),
|
|
384
|
+
("aiv read miss", "aiv_read_local_l2_miss"),
|
|
385
|
+
("aiv read victim", "aiv_read_local_l2_victim"),
|
|
386
|
+
("aiv write hit", "aiv_write_local_l2_hit"),
|
|
387
|
+
("aiv write miss", "aiv_write_local_l2_miss"),
|
|
388
|
+
("aiv write victim", "aiv_write_local_l2_victim"),
|
|
389
|
+
]
|
|
390
|
+
l2_has = any(safe_float(merged.get(k)) > 0 for _, k in l2_fields_aic + l2_fields_aiv)
|
|
391
|
+
if not l2_has:
|
|
392
|
+
return
|
|
393
|
+
lines.append("")
|
|
394
|
+
lines.append("--- L2Cache ---")
|
|
395
|
+
|
|
396
|
+
def _emit(group_label, fields):
|
|
397
|
+
hit = safe_float(merged.get(fields[0][1]))
|
|
398
|
+
miss = safe_float(merged.get(fields[1][1]))
|
|
399
|
+
total = hit + miss
|
|
400
|
+
if total > 0:
|
|
401
|
+
rate = hit / total * 100.0
|
|
402
|
+
lines.append(f" {group_label} read: hit={int(hit)} miss={int(miss)} hit_rate={rate:.2f}%")
|
|
403
|
+
whit = safe_float(merged.get(fields[3][1]))
|
|
404
|
+
wmiss = safe_float(merged.get(fields[4][1]))
|
|
405
|
+
wtotal = whit + wmiss
|
|
406
|
+
if wtotal > 0:
|
|
407
|
+
rate = whit / wtotal * 100.0
|
|
408
|
+
lines.append(f" {group_label} write: hit={int(whit)} miss={int(wmiss)} hit_rate={rate:.2f}%")
|
|
409
|
+
|
|
410
|
+
_emit("aic", l2_fields_aic)
|
|
411
|
+
_emit("aiv", l2_fields_aiv)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
def _add_rc_section(lines: List[str], merged: Dict[str, Any]) -> None:
|
|
415
|
+
rc_fields = [
|
|
416
|
+
("vec_bank_cflt", "aiv_vec_bank_cflt_ratio"),
|
|
417
|
+
("vec_resc_cflt", "aiv_vec_resc_cflt_ratio"),
|
|
418
|
+
]
|
|
419
|
+
if not any(safe_float(merged.get(k)) > 0 for _, k in rc_fields):
|
|
420
|
+
return
|
|
421
|
+
lines.append("")
|
|
422
|
+
lines.append("--- ResourceConflict ---")
|
|
423
|
+
parts = [f"{label}={fmt_ratio(merged.get(key))}" for label, key in rc_fields]
|
|
424
|
+
lines.append(" " + " | ".join(parts))
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
def _add_arith_section(lines: List[str], merged: Dict[str, Any]) -> None:
|
|
428
|
+
arith_fields = [
|
|
429
|
+
("mac_fp16", "aic_mac_fp16_ratio"),
|
|
430
|
+
("mac_int8", "aic_mac_int8_ratio"),
|
|
431
|
+
]
|
|
432
|
+
has_arith_fields = any(
|
|
433
|
+
safe_float(merged.get(k)) > 0 for _, k in arith_fields
|
|
434
|
+
)
|
|
435
|
+
arith_has = has_arith_fields or safe_float(merged.get("aic_cube_fops")) > 0
|
|
436
|
+
if not arith_has:
|
|
437
|
+
return
|
|
438
|
+
lines.append("")
|
|
439
|
+
lines.append("--- ArithmeticUtilization ---")
|
|
440
|
+
parts = []
|
|
441
|
+
for label, key in arith_fields:
|
|
442
|
+
v = safe_float(merged.get(key))
|
|
443
|
+
if v > 0:
|
|
444
|
+
parts.append(f"{label}={fmt_ratio(merged.get(key))}")
|
|
445
|
+
fops = safe_float(merged.get("aic_cube_fops"))
|
|
446
|
+
if fops > 0:
|
|
447
|
+
parts.append(f"cube_fops={fops:.0f}")
|
|
448
|
+
if parts:
|
|
449
|
+
lines.append(" " + " | ".join(parts))
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def _add_basic_info(lines: List[str], merged: Dict[str, Any]) -> Tuple[float, float, float]:
|
|
453
|
+
op_name = merged.get("Op Name", "unknown")
|
|
454
|
+
op_type = merged.get("OP Type", "unknown")
|
|
455
|
+
task_type = merged.get("Task Type", "")
|
|
456
|
+
duration = safe_float(merged.get("Task Duration(us)"))
|
|
457
|
+
block_dim = safe_int(merged.get("Block Num", 0))
|
|
458
|
+
mix_block = safe_int(merged.get("Mix Block Num", 0))
|
|
459
|
+
aicore_time = safe_float(merged.get("aicore_time(us)"))
|
|
460
|
+
aiv_time = safe_float(merged.get("aiv_time(us)"))
|
|
461
|
+
|
|
462
|
+
lines.append("=== 上板性能统计摘要 (msprof) ===")
|
|
463
|
+
lines.append(f"Op: {op_name}")
|
|
464
|
+
lines.append(
|
|
465
|
+
f"Type: {op_type} | TaskType: {task_type} | Duration: {duration}us"
|
|
466
|
+
f" | BlockDim: {block_dim} (mix={mix_block})"
|
|
467
|
+
)
|
|
468
|
+
if merged.get("_missing_metrics"):
|
|
469
|
+
lines.append(f"[WARN] 缺失指标: {', '.join(merged['_missing_metrics'])}")
|
|
470
|
+
lines.append("")
|
|
471
|
+
lines.append("[注] msprof 的 op_summary 是 per-op 聚合值(不含逐核 min/avg/max);")
|
|
472
|
+
lines.append(" 如需逐核数据请改用 msprof op (需要 msopprof 二进制)。")
|
|
473
|
+
return duration, aicore_time, aiv_time
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def _add_pipe_ratios(lines: List[str], merged: Dict[str, Any], aicore_time: float, aiv_time: float) -> None:
|
|
477
|
+
lines.append("")
|
|
478
|
+
aic_cube_like = max(safe_float(merged.get("aic_mac_ratio")), safe_float(merged.get("aic_mte2_ratio")))
|
|
479
|
+
aiv_vec_like = safe_float(merged.get("aiv_vec_ratio"))
|
|
480
|
+
prefix = "aic" if aic_cube_like >= aiv_vec_like else "aiv"
|
|
481
|
+
lines.append(f"--- Pipe ratios (主导核 = {prefix}) ---")
|
|
482
|
+
lines.append(f" aicore_time: {aicore_time:.3f}us | aiv_time: {aiv_time:.3f}us")
|
|
483
|
+
|
|
484
|
+
aic_fields = [
|
|
485
|
+
("aic_mac_ratio", "mac"),
|
|
486
|
+
("aic_cube_ratio", "cube"),
|
|
487
|
+
("aic_mte1_ratio", "mte1"),
|
|
488
|
+
("aic_mte2_ratio", "mte2"),
|
|
489
|
+
("aic_mte3_ratio", "mte3"),
|
|
490
|
+
("aic_fixpipe_ratio", "fixpipe"),
|
|
491
|
+
("aic_scalar_ratio", "scalar"),
|
|
492
|
+
("aic_icache_miss_rate", "icache_miss"),
|
|
493
|
+
]
|
|
494
|
+
parts = [f"{label}={fmt_ratio(merged.get(key))}" for key, label in aic_fields if safe_float(merged.get(key)) > 0]
|
|
495
|
+
if parts:
|
|
496
|
+
lines.append(" aic: " + " | ".join(parts))
|
|
497
|
+
|
|
498
|
+
aiv_fields = [
|
|
499
|
+
("aiv_vec_ratio", "vec"),
|
|
500
|
+
("aiv_scalar_ratio", "scalar"),
|
|
501
|
+
("aiv_mte2_ratio", "mte2"),
|
|
502
|
+
("aiv_mte3_ratio", "mte3"),
|
|
503
|
+
("aiv_icache_miss_rate", "icache_miss"),
|
|
504
|
+
]
|
|
505
|
+
parts = [f"{label}={fmt_ratio(merged.get(key))}" for key, label in aiv_fields if safe_float(merged.get(key)) > 0]
|
|
506
|
+
if parts:
|
|
507
|
+
lines.append(" aiv: " + " | ".join(parts))
|
|
508
|
+
|
|
509
|
+
util = safe_float(merged.get("cube_utilization(%)"))
|
|
510
|
+
if util > 0:
|
|
511
|
+
lines.append(f" cube_utilization: {util:.2f}%")
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
def _add_overhead(lines: List[str], duration: float, aicore_time: float, aiv_time: float) -> None:
|
|
515
|
+
lines.append("")
|
|
516
|
+
core_time_max = max(aicore_time, aiv_time)
|
|
517
|
+
overhead = max(0.0, duration - core_time_max)
|
|
518
|
+
overhead_pct = (overhead / duration * 100.0) if duration > 0 else 0.0
|
|
519
|
+
lines.append("--- 头开销 ---")
|
|
520
|
+
lines.append(
|
|
521
|
+
f" Task Duration: {duration}us | 核最长耗时: {core_time_max:.3f}us"
|
|
522
|
+
f" | 头开销: {overhead:.3f}us ({overhead_pct:.1f}%)"
|
|
523
|
+
)
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
def _add_footer(lines: List[str], merged: Dict[str, Any], round_dir: str, group_dir: str) -> None:
|
|
527
|
+
lines.append("")
|
|
528
|
+
lines.append("--- 原始数据位置 ---")
|
|
529
|
+
lines.append(f" 归档 CSV : {round_dir}/")
|
|
530
|
+
lines.append(f" 原始 PROF: {group_dir}/")
|
|
531
|
+
lines.append(" 按 aic-metrics 拆分的 op_summary_<Metric>.csv 均已复制到归档目录,")
|
|
532
|
+
lines.append(" 如需逐列查看可直接 Read。")
|
|
533
|
+
if merged.get("_metric_sources"):
|
|
534
|
+
lines.append("")
|
|
535
|
+
lines.append("--- Metric 来源 ---")
|
|
536
|
+
for m in METRICS:
|
|
537
|
+
src = merged["_metric_sources"].get(m)
|
|
538
|
+
if src:
|
|
539
|
+
lines.append(f" {m:<22s} <- {src}")
|
|
540
|
+
else:
|
|
541
|
+
lines.append(f" {m:<22s} <MISSING>")
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
def generate_summary(merged: Dict[str, Any], round_dir: str, group_dir: str) -> str:
|
|
545
|
+
lines: List[str] = []
|
|
546
|
+
duration, aicore_time, aiv_time = _add_basic_info(lines, merged)
|
|
547
|
+
_add_pipe_ratios(lines, merged, aicore_time, aiv_time)
|
|
548
|
+
_add_overhead(lines, duration, aicore_time, aiv_time)
|
|
549
|
+
_add_memory_section(lines, merged)
|
|
550
|
+
_add_memory_l0_section(lines, merged)
|
|
551
|
+
_add_memory_ub_section(lines, merged)
|
|
552
|
+
_add_l2cache_section(lines, merged)
|
|
553
|
+
_add_rc_section(lines, merged)
|
|
554
|
+
_add_arith_section(lines, merged)
|
|
555
|
+
lines.extend(per_core_balance_section(merged, group_dir))
|
|
556
|
+
_add_footer(lines, merged, round_dir, group_dir)
|
|
557
|
+
return "\n".join(lines)
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
# ============================================================================
|
|
561
|
+
# 对比模式:model.py vs model_new_ascendc.py
|
|
562
|
+
# ============================================================================
|
|
563
|
+
|
|
564
|
+
def _load_module(path: str, name: str):
|
|
565
|
+
spec = importlib.util.spec_from_file_location(name, path)
|
|
566
|
+
m = importlib.util.module_from_spec(spec)
|
|
567
|
+
sys.modules[name] = m
|
|
568
|
+
spec.loader.exec_module(m)
|
|
569
|
+
return m
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
def _find_cls(module, preferred: str):
|
|
573
|
+
import torch.nn as nn
|
|
574
|
+
c = getattr(module, preferred, None)
|
|
575
|
+
if inspect.isclass(c) and issubclass(c, nn.Module):
|
|
576
|
+
return c
|
|
577
|
+
for _, v in vars(module).items():
|
|
578
|
+
if inspect.isclass(v) and issubclass(v, nn.Module) and v is not nn.Module:
|
|
579
|
+
return v
|
|
580
|
+
raise AttributeError(f"no nn.Module subclass found in {module.__file__}")
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
def _move(v, d):
|
|
584
|
+
import torch
|
|
585
|
+
if isinstance(v, torch.Tensor):
|
|
586
|
+
return v.to(d)
|
|
587
|
+
if isinstance(v, (list, tuple)):
|
|
588
|
+
return type(v)(_move(x, d) for x in v)
|
|
589
|
+
return v
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
def _clone(v):
|
|
593
|
+
"""Deep clone tensor / list of tensors."""
|
|
594
|
+
import torch
|
|
595
|
+
if isinstance(v, torch.Tensor):
|
|
596
|
+
return v.clone()
|
|
597
|
+
if isinstance(v, (list, tuple)):
|
|
598
|
+
return type(v)(_clone(x) for x in v)
|
|
599
|
+
return v
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
def _read_jsonl_file(path: Path):
|
|
603
|
+
"""读取 JSONL 文件,返回解析后的 cases 列表。"""
|
|
604
|
+
cases = []
|
|
605
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
606
|
+
for line in f:
|
|
607
|
+
line = line.strip()
|
|
608
|
+
if not line:
|
|
609
|
+
continue
|
|
610
|
+
cases.append(json.loads(line))
|
|
611
|
+
return cases
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
def _load_cases_jsonl(out_dir: Path):
|
|
615
|
+
patterns = ["*_perf_cases.jsonl", "*.jsonl"]
|
|
616
|
+
for pattern in patterns:
|
|
617
|
+
jsonl_files = sorted(out_dir.glob(pattern))
|
|
618
|
+
if jsonl_files:
|
|
619
|
+
path = jsonl_files[0]
|
|
620
|
+
cases = _read_jsonl_file(path)
|
|
621
|
+
return cases, f"jsonl:{path.name}"
|
|
622
|
+
return [], None
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
def _load_cases_json(out_dir: Path):
|
|
626
|
+
"""从输出目录中查找并解析 JSON 文件。
|
|
627
|
+
|
|
628
|
+
找到第一个非备份、非排除的 JSON 文件,优先按标准 JSON 文档解析(单对象或数组),
|
|
629
|
+
失败时回退到 JSONL 逐行解析。
|
|
630
|
+
"""
|
|
631
|
+
json_files = sorted(out_dir.glob("*.json"))
|
|
632
|
+
json_path = None
|
|
633
|
+
for f in json_files:
|
|
634
|
+
if not f.name.endswith(".bak") and f.name not in ("performance.json", "perf_report.json"):
|
|
635
|
+
json_path = f
|
|
636
|
+
break
|
|
637
|
+
if not json_path:
|
|
638
|
+
return [], None
|
|
639
|
+
|
|
640
|
+
with open(json_path, "r", encoding="utf-8") as f:
|
|
641
|
+
raw = f.read()
|
|
642
|
+
# 优先按标准 JSON 文档解析(单对象或数组),失败时回退到 JSONL 逐行解析
|
|
643
|
+
try:
|
|
644
|
+
parsed = json.loads(raw)
|
|
645
|
+
if isinstance(parsed, list):
|
|
646
|
+
cases = parsed
|
|
647
|
+
elif isinstance(parsed, dict):
|
|
648
|
+
cases = [parsed]
|
|
649
|
+
else:
|
|
650
|
+
raise ValueError("Unexpected JSON root type")
|
|
651
|
+
except ValueError:
|
|
652
|
+
cases = []
|
|
653
|
+
for line in raw.splitlines():
|
|
654
|
+
line = line.strip()
|
|
655
|
+
if line:
|
|
656
|
+
cases.append(json.loads(line))
|
|
657
|
+
return cases, f"json:{json_path.name}"
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
def _extract_shape_dtype_from_jsonl(case):
|
|
661
|
+
inputs = case.get("inputs", [])
|
|
662
|
+
if not inputs:
|
|
663
|
+
return "?", "?"
|
|
664
|
+
for inp in inputs:
|
|
665
|
+
if inp.get("type") == "tensor":
|
|
666
|
+
return str(inp.get("shape", "?")), inp.get("dtype", "?")
|
|
667
|
+
return str(inputs[0].get("shape", "?")), inputs[0].get("dtype", "?")
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
def _case_has_empty_tensor(case):
|
|
671
|
+
"""判断 case 中是否包含 0 元素张量(空 tensor)。
|
|
672
|
+
|
|
673
|
+
shape 缺失或为 None 表示形状未指定(如可选 bias),不应视作空 tensor;
|
|
674
|
+
shape == [] 是 0-d 标量(numel == 1,合法可测输入),同样不是空 tensor
|
|
675
|
+
——与 npubench_runner 的 numel()==0 语义一致。
|
|
676
|
+
只有形状为列表且明确包含 0 维度的才是真正的空 tensor。
|
|
677
|
+
"""
|
|
678
|
+
if not case:
|
|
679
|
+
return False
|
|
680
|
+
for inp in case.get("inputs", []):
|
|
681
|
+
if inp.get("type") == "tensor":
|
|
682
|
+
shape = inp.get("shape")
|
|
683
|
+
if not isinstance(shape, list):
|
|
684
|
+
continue
|
|
685
|
+
if any(s == 0 for s in shape):
|
|
686
|
+
return True
|
|
687
|
+
return False
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
def _resolve_jsonl_scalar_value(inp):
|
|
691
|
+
"""Resolve a raw scalar value from a JSONL/KernelBench input descriptor.
|
|
692
|
+
|
|
693
|
+
Returns the resolved value or None if no value can be determined.
|
|
694
|
+
"""
|
|
695
|
+
val = inp.get("value")
|
|
696
|
+
if val is not None:
|
|
697
|
+
return val
|
|
698
|
+
rv = inp.get("range_values")
|
|
699
|
+
if isinstance(rv, (int, float, bool, complex)):
|
|
700
|
+
return rv
|
|
701
|
+
if isinstance(rv, list) and len(rv) > 0:
|
|
702
|
+
return rv[0]
|
|
703
|
+
if isinstance(rv, dict):
|
|
704
|
+
mean = rv.get("mean")
|
|
705
|
+
if isinstance(mean, list) and len(mean) > 0:
|
|
706
|
+
return mean[0]
|
|
707
|
+
return None
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
def _jsonl_scalar_default_by_dtype(dtype_str):
|
|
711
|
+
"""Return a default scalar value for the given dtype string."""
|
|
712
|
+
if dtype_str == "bool":
|
|
713
|
+
return True
|
|
714
|
+
if dtype_str.startswith("int") or dtype_str.startswith("uint"):
|
|
715
|
+
return 1
|
|
716
|
+
return 1.0
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
def _cast_jsonl_scalar_by_dtype(val, dtype_str):
|
|
720
|
+
"""Cast a resolved scalar value to the Python type indicated by dtype_str."""
|
|
721
|
+
if dtype_str == "str" or isinstance(val, str):
|
|
722
|
+
return str(val)
|
|
723
|
+
if dtype_str == "list" or isinstance(val, list):
|
|
724
|
+
return list(val)
|
|
725
|
+
if dtype_str == "bool":
|
|
726
|
+
return bool(val)
|
|
727
|
+
if dtype_str.startswith("complex"):
|
|
728
|
+
return complex(val)
|
|
729
|
+
if dtype_str.startswith("int") or dtype_str.startswith("uint"):
|
|
730
|
+
return int(val)
|
|
731
|
+
return float(val)
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
def _jsonl_scalar_value(inp):
|
|
735
|
+
"""从 JSONL/KernelBench 标量描述中提取一个 Python 标量值。"""
|
|
736
|
+
val = _resolve_jsonl_scalar_value(inp)
|
|
737
|
+
if val is None:
|
|
738
|
+
val = _jsonl_scalar_default_by_dtype(inp.get("dtype", ""))
|
|
739
|
+
return _cast_jsonl_scalar_by_dtype(val, inp.get("dtype", ""))
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
# JSONL/KernelBench dtype string → torch dtype expression mapping.
|
|
743
|
+
# Shared by _jsonl_tensor_code and _jsonl_tensor_dtype_repr.
|
|
744
|
+
_JSONL_DTYPE_MAP = {
|
|
745
|
+
"fp16": "torch.float16", "float16": "torch.float16", "half": "torch.float16",
|
|
746
|
+
"fp32": "torch.float32", "float32": "torch.float32", "float": "torch.float32",
|
|
747
|
+
"fp64": "torch.float64", "float64": "torch.float64",
|
|
748
|
+
"bf16": "torch.bfloat16", "bfloat16": "torch.bfloat16",
|
|
749
|
+
"int8": "torch.int8", "int16": "torch.int16", "int32": "torch.int32",
|
|
750
|
+
"int": "torch.int32", "int64": "torch.int64", "long": "torch.int64",
|
|
751
|
+
"uint8": "torch.uint8", "uint16": "torch.uint16", "uint32": "torch.uint32", "uint64": "torch.uint64",
|
|
752
|
+
"bool": "torch.bool",
|
|
753
|
+
"complex64": "torch.complex64", "complex128": "torch.complex128",
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
def _jsonl_tensor_code(shape, dtype_str: str) -> str:
|
|
758
|
+
"""根据 KernelBench 的 dtype/shape 生成构造 tensor 的代码。"""
|
|
759
|
+
dtype = _JSONL_DTYPE_MAP.get(dtype_str, "torch.float32")
|
|
760
|
+
shape_expr = str(shape)
|
|
761
|
+
|
|
762
|
+
if dtype_str == "bool":
|
|
763
|
+
return f"inputs.append(torch.randint(0, 2, {shape_expr}, dtype={dtype}))"
|
|
764
|
+
if dtype_str.startswith("int") or dtype_str.startswith("uint"):
|
|
765
|
+
# 先以 int64 生成再转换到目标类型,避免 torch.randint 不支持 uint/低精度 int
|
|
766
|
+
return f"inputs.append(torch.randint(-100, 100, {shape_expr}, dtype=torch.int64).to({dtype}))"
|
|
767
|
+
if dtype_str.startswith("complex"):
|
|
768
|
+
return f"inputs.append(torch.randn({shape_expr}, dtype={dtype}))"
|
|
769
|
+
# float/half/bf16
|
|
770
|
+
return f"inputs.append(torch.randn({shape_expr}, dtype={dtype}))"
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
def _jsonl_tensor_expr(shape, dtype_str: str) -> str:
|
|
774
|
+
"""返回构造 tensor 的表达式字符串(不带 ``inputs.append()`` 包装)。"""
|
|
775
|
+
code = _jsonl_tensor_code(shape, dtype_str)
|
|
776
|
+
# _jsonl_tensor_code returns "inputs.append(TORCH_EXPR)"
|
|
777
|
+
prefix = "inputs.append("
|
|
778
|
+
if not (code.startswith(prefix) and code.endswith(")")):
|
|
779
|
+
raise ValueError(f"unexpected tensor code: {code}")
|
|
780
|
+
return code[len(prefix):-1] # strip "inputs.append(" and trailing ")"
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
def _jsonl_tensor_dtype_repr(dtype_str: str) -> str:
|
|
784
|
+
"""将 JSONL dtype 字符串映射为 torch dtype 表达式(用于 torch.tensor(..., dtype=...))。"""
|
|
785
|
+
return _JSONL_DTYPE_MAP.get(dtype_str, "torch.float32")
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
# attr dtype=str 且值为 torch dtype 名称时,映射到 torch.xxx 表达式(而非字符串字面量)
|
|
789
|
+
_TORCH_DTYPE_EXPR_MAP = {
|
|
790
|
+
"float16": "torch.float16", "bfloat16": "torch.bfloat16",
|
|
791
|
+
"float32": "torch.float32", "float64": "torch.float64",
|
|
792
|
+
"int8": "torch.int8", "int16": "torch.int16",
|
|
793
|
+
"int32": "torch.int32", "int64": "torch.int64",
|
|
794
|
+
"uint8": "torch.uint8", "bool": "torch.bool",
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
# 名称提示为 offsets/cumsum 类结构性整型参数的集合(随机合成时保证单调不减)
|
|
799
|
+
_OFFSETS_LIKE_NAMES = frozenset({
|
|
800
|
+
"offs", "offsets", "group_list", "group_offsets", "cumsum",
|
|
801
|
+
"cu_seqlens", "cu_seqlens_q", "cu_seqlens_k", "seqlens", "seq_lens",
|
|
802
|
+
})
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
def _append_tensor_input(lines, inp, name):
|
|
806
|
+
"""Append a tensor-type input line to *lines*, keeping nesting depth ≤ 4."""
|
|
807
|
+
dtype_str = inp.get("dtype", "float16")
|
|
808
|
+
# 优先使用显式 value(如 group_list / cumsum 等结构参数)
|
|
809
|
+
explicit_val = inp.get("value")
|
|
810
|
+
if explicit_val is not None:
|
|
811
|
+
dtype_repr = _jsonl_tensor_dtype_repr(dtype_str)
|
|
812
|
+
lines.append(f"_inputs_dict[{repr(name)}] = torch.tensor({repr(explicit_val)}, dtype={dtype_repr})")
|
|
813
|
+
return
|
|
814
|
+
shape = inp.get("shape", [])
|
|
815
|
+
# offsets/cumsum 类结构性整型参数:完全随机的值几乎必然违反
|
|
816
|
+
# 单调性约束导致被测实现直接抛异常,退化为单调不减序列更稳妥
|
|
817
|
+
if name.lower() in _OFFSETS_LIKE_NAMES and dtype_str.startswith(("int", "uint")):
|
|
818
|
+
dtype_repr = _jsonl_tensor_dtype_repr(dtype_str)
|
|
819
|
+
lines.append(f"_inputs_dict[{repr(name)}] = "
|
|
820
|
+
f"torch.randint(0, 100, {shape}, dtype=torch.int64).cumsum(0).to({dtype_repr})")
|
|
821
|
+
return
|
|
822
|
+
tensor_expr = _jsonl_tensor_expr(shape, dtype_str)
|
|
823
|
+
lines.append(f"_inputs_dict[{repr(name)}] = {tensor_expr}")
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
def _append_attr_scalar_input(lines, inp, name):
|
|
827
|
+
"""Append an attr/scalar-type input line to *lines*, keeping nesting depth ≤ 4."""
|
|
828
|
+
# 显式 "value": null 表示可选参数未启用(如 offsets=None),
|
|
829
|
+
# 必须生成 None 而不是默认标量,否则会把 None 语义错传成 1.0/1
|
|
830
|
+
if "value" in inp and inp.get("value") is None:
|
|
831
|
+
lines.append(f"_inputs_dict[{repr(name)}] = None")
|
|
832
|
+
return
|
|
833
|
+
val = _jsonl_scalar_value(inp)
|
|
834
|
+
# attr 的 dtype 为 str 且值是 torch dtype 名时,生成 torch.xxx 表达式而非字符串字面量
|
|
835
|
+
if inp.get("dtype") == "str" and isinstance(val, str):
|
|
836
|
+
dtype_expr = _TORCH_DTYPE_EXPR_MAP.get(val)
|
|
837
|
+
if dtype_expr is not None:
|
|
838
|
+
lines.append(f"_inputs_dict[{repr(name)}] = {dtype_expr}")
|
|
839
|
+
return
|
|
840
|
+
lines.append(f"_inputs_dict[{repr(name)}] = {repr(val)}")
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
def _serialize_jsonl_inputs(case):
|
|
844
|
+
"""Generate kwargs dict code from JSONL inputs, using 'name' fields as keys.
|
|
845
|
+
|
|
846
|
+
Uses named keyword arguments (``model(**kwargs)``) so that parameter binding
|
|
847
|
+
is independent of the order of inputs in the JSONL file.
|
|
848
|
+
"""
|
|
849
|
+
lines = ["_inputs_dict = {}"]
|
|
850
|
+
for inp in case.get("inputs", []):
|
|
851
|
+
name = inp.get("name", "")
|
|
852
|
+
typ = inp.get("type", "tensor")
|
|
853
|
+
if typ == "tensor":
|
|
854
|
+
_append_tensor_input(lines, inp, name)
|
|
855
|
+
elif typ in ("attr", "scalar"):
|
|
856
|
+
_append_attr_scalar_input(lines, inp, name)
|
|
857
|
+
elif typ == "tensor_list":
|
|
858
|
+
lines.append("_tensors = []")
|
|
859
|
+
for tinfo in inp.get("value", []):
|
|
860
|
+
shape = tinfo.get("shape", [])
|
|
861
|
+
dtype_str = tinfo.get("dtype", "float16")
|
|
862
|
+
tensor_expr = _jsonl_tensor_expr(shape, dtype_str)
|
|
863
|
+
lines.append(f"_tensors.append({tensor_expr})")
|
|
864
|
+
lines.append(f"_inputs_dict[{repr(name)}] = _tensors")
|
|
865
|
+
else:
|
|
866
|
+
val = _jsonl_scalar_value(inp)
|
|
867
|
+
lines.append(f"_inputs_dict[{repr(name)}] = {repr(val)}")
|
|
868
|
+
return "\n".join(lines)
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
@dataclass
|
|
872
|
+
class _WrapperConfig:
|
|
873
|
+
"""封装 _generate_wrapper_script 的参数。"""
|
|
874
|
+
out_dir: Path
|
|
875
|
+
case_idx: int
|
|
876
|
+
impl: str
|
|
877
|
+
seed: int
|
|
878
|
+
device_id: int
|
|
879
|
+
warmup: int
|
|
880
|
+
jsonl_case: Optional[Dict[str, Any]] = None
|
|
881
|
+
repeats: int = 1
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
_WRAPPER_SCRIPT_TEMPLATE = """\
|
|
885
|
+
#!/usr/bin/env python3
|
|
886
|
+
import importlib.util
|
|
887
|
+
import inspect
|
|
888
|
+
import logging
|
|
889
|
+
import os
|
|
890
|
+
import sys
|
|
891
|
+
|
|
892
|
+
# Pin the visible device BEFORE torch import: CANN re-reads this variable at
|
|
893
|
+
# first device touch, so setting it after ``import torch`` contradicts the
|
|
894
|
+
# RawDriver the engine already bound and faults with 507033 / "Operation not
|
|
895
|
+
# permitted" (empty stderr, silent wrapper exit). setdefault never overrides
|
|
896
|
+
# an exec-time pin the engine applied for its physical lane; standalone use
|
|
897
|
+
# (no pin) still gets the --device value here.
|
|
898
|
+
os.environ.setdefault("ASCEND_RT_VISIBLE_DEVICES", "{device_id}")
|
|
899
|
+
|
|
900
|
+
import torch
|
|
901
|
+
from pathlib import Path
|
|
902
|
+
|
|
903
|
+
LOGGER = logging.getLogger(__name__)
|
|
904
|
+
|
|
905
|
+
out_dir = Path("{out_dir}")
|
|
906
|
+
sys.path.insert(0, str(out_dir / "kernel" / "build"))
|
|
907
|
+
sys.path.insert(0, str(out_dir))
|
|
908
|
+
|
|
909
|
+
torch.manual_seed({seed})
|
|
910
|
+
try:
|
|
911
|
+
torch.npu.manual_seed_all({seed})
|
|
912
|
+
except Exception:
|
|
913
|
+
pass
|
|
914
|
+
|
|
915
|
+
def _load(path, name):
|
|
916
|
+
spec = importlib.util.spec_from_file_location(name, path)
|
|
917
|
+
m = importlib.util.module_from_spec(spec)
|
|
918
|
+
sys.modules[name] = m
|
|
919
|
+
spec.loader.exec_module(m)
|
|
920
|
+
return m
|
|
921
|
+
|
|
922
|
+
mod = _load(out_dir / "{model_file}", "prof_mod")
|
|
923
|
+
cls = getattr(mod, "{cls_name}")
|
|
924
|
+
|
|
925
|
+
{inputs_code}
|
|
926
|
+
|
|
927
|
+
device = torch.device("npu")
|
|
928
|
+
def _move(v):
|
|
929
|
+
if isinstance(v, torch.Tensor):
|
|
930
|
+
return v.to(device)
|
|
931
|
+
if isinstance(v, (list, tuple)):
|
|
932
|
+
return type(v)(_move(x) for x in v)
|
|
933
|
+
return v
|
|
934
|
+
|
|
935
|
+
_use_kwargs = inputs is None
|
|
936
|
+
if _use_kwargs:
|
|
937
|
+
for _k, _v in _inputs_dict.items():
|
|
938
|
+
if isinstance(_v, torch.Tensor):
|
|
939
|
+
_inputs_dict[_k] = _v.to(device)
|
|
940
|
+
elif isinstance(_v, list):
|
|
941
|
+
_inputs_dict[_k] = [_move(x) for x in _v]
|
|
942
|
+
# build positional list from dict values (preserving JSONL order) for fallback
|
|
943
|
+
_inputs_list = list(_inputs_dict.values())
|
|
944
|
+
else:
|
|
945
|
+
inputs = _move(inputs)
|
|
946
|
+
|
|
947
|
+
# ---- model construction (honour get_init_inputs if present) ----
|
|
948
|
+
_init_args = []
|
|
949
|
+
_init_kwargs = {{}}
|
|
950
|
+
try:
|
|
951
|
+
ref_for_init = _load(out_dir / "{model_file}", "ref_for_init")
|
|
952
|
+
if hasattr(ref_for_init, "get_init_inputs"):
|
|
953
|
+
_all_init = ref_for_init.get_init_inputs()
|
|
954
|
+
_idx = {case_idx}
|
|
955
|
+
if isinstance(_all_init, list) and _idx < len(_all_init):
|
|
956
|
+
_entry = _all_init[_idx]
|
|
957
|
+
if isinstance(_entry, dict):
|
|
958
|
+
_init_kwargs = _entry
|
|
959
|
+
elif isinstance(_entry, (list, tuple)):
|
|
960
|
+
_init_args = list(_entry)
|
|
961
|
+
except Exception:
|
|
962
|
+
pass
|
|
963
|
+
|
|
964
|
+
if _init_kwargs:
|
|
965
|
+
model = cls(**_init_kwargs).to(device).eval()
|
|
966
|
+
elif _init_args:
|
|
967
|
+
model = cls(*_init_args).to(device).eval()
|
|
968
|
+
else:
|
|
969
|
+
model = cls().to(device).eval()
|
|
970
|
+
|
|
971
|
+
def _bind_ok(sig, args, kwargs):
|
|
972
|
+
try:
|
|
973
|
+
sig.bind(*args, **kwargs)
|
|
974
|
+
return True
|
|
975
|
+
except TypeError:
|
|
976
|
+
return False
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
_forward_sig = None
|
|
980
|
+
try:
|
|
981
|
+
_forward_sig = inspect.signature(model.forward)
|
|
982
|
+
except Exception:
|
|
983
|
+
pass
|
|
984
|
+
|
|
985
|
+
# 0=kwargs, 1=spread, 2=tuple
|
|
986
|
+
# 先按 forward 签名预绑定选择调用方式:仅当确认参数确实绑定不上时才降级;
|
|
987
|
+
# 运行期调用抛出的 TypeError 视为模型内部真实错误,直接失败,不再静默降级
|
|
988
|
+
# (否则 forward 内部的业务 TypeError 会被误判成"参数形式不匹配"而测错调用方式)。
|
|
989
|
+
_use_positional_fallback = 0
|
|
990
|
+
if _use_kwargs and _forward_sig is not None:
|
|
991
|
+
if _bind_ok(_forward_sig, (), _inputs_dict):
|
|
992
|
+
_use_positional_fallback = 0
|
|
993
|
+
elif _bind_ok(_forward_sig, tuple(_inputs_list), dict()):
|
|
994
|
+
_use_positional_fallback = 1
|
|
995
|
+
elif _bind_ok(_forward_sig, (tuple(_inputs_list),), dict()):
|
|
996
|
+
_use_positional_fallback = 2
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
def _one_iter():
|
|
1000
|
+
with torch.no_grad():
|
|
1001
|
+
if _use_kwargs:
|
|
1002
|
+
if _use_positional_fallback == 0:
|
|
1003
|
+
_ = model(**_inputs_dict)
|
|
1004
|
+
elif _use_positional_fallback == 1:
|
|
1005
|
+
_ = model(*_inputs_list)
|
|
1006
|
+
else:
|
|
1007
|
+
_ = model(tuple(_inputs_list))
|
|
1008
|
+
else:
|
|
1009
|
+
_ = model(*inputs)
|
|
1010
|
+
torch.npu.synchronize()
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
# ---- in-process warmup: 与 torch_npu profiler 的 warmup 语义一致 ----
|
|
1014
|
+
# 这些迭代同样落在 msprof 采集窗口内,解析时按 run 拆分后丢弃前 {warmup} 次。
|
|
1015
|
+
# 任一迭代失败(含模型内部异常)时记录 case 编号后优雅退出,不打印原始 traceback。
|
|
1016
|
+
try:
|
|
1017
|
+
for _ in range({warmup}):
|
|
1018
|
+
_one_iter()
|
|
1019
|
+
|
|
1020
|
+
# ---- timed repeats ----
|
|
1021
|
+
for _ in range({repeats}):
|
|
1022
|
+
_one_iter()
|
|
1023
|
+
except Exception as _e:
|
|
1024
|
+
LOGGER.info("[CASE %s] model call failed, skip case: %s", {case_idx}, _e)
|
|
1025
|
+
sys.exit(1)
|
|
1026
|
+
"""
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
def _build_wrapper_script_content(cfg, model_file, cls_name, inputs_code):
|
|
1030
|
+
"""Build the wrapper script string from components."""
|
|
1031
|
+
return _WRAPPER_SCRIPT_TEMPLATE.format(
|
|
1032
|
+
out_dir=cfg.out_dir,
|
|
1033
|
+
device_id=cfg.device_id,
|
|
1034
|
+
case_idx=cfg.case_idx,
|
|
1035
|
+
warmup=cfg.warmup,
|
|
1036
|
+
repeats=cfg.repeats,
|
|
1037
|
+
seed=cfg.seed,
|
|
1038
|
+
model_file=model_file,
|
|
1039
|
+
cls_name=cls_name,
|
|
1040
|
+
inputs_code=inputs_code,
|
|
1041
|
+
)
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
# 优先从 model.py 自带的输入生成器取真实输入(保证 offsets/cumsum 等结构性
|
|
1045
|
+
# 参数合法,且与 evaluate 输入同源);取不到时 inputs 保持 None,回退到
|
|
1046
|
+
# JSONL 随机合成的 _inputs_dict kwargs 路径。
|
|
1047
|
+
_REAL_INPUTS_CODE = """\
|
|
1048
|
+
# Prefer real inputs from model.py's own generator (valid structural params,
|
|
1049
|
+
# same source as evaluate); fall back to serialized kwargs when unavailable.
|
|
1050
|
+
inputs = None
|
|
1051
|
+
try:
|
|
1052
|
+
_ref_mod = _load(out_dir / "model.py", "ref_for_inputs")
|
|
1053
|
+
_gen = getattr(_ref_mod, "get_input_groups", getattr(_ref_mod, "get_inputs", None))
|
|
1054
|
+
if _gen is not None:
|
|
1055
|
+
_all_input_groups = _gen()
|
|
1056
|
+
if 0 <= {case_idx} < len(_all_input_groups):
|
|
1057
|
+
_entry = _all_input_groups[{case_idx}]
|
|
1058
|
+
inputs = list(_entry) if isinstance(_entry, (list, tuple)) else [_entry]
|
|
1059
|
+
except Exception:
|
|
1060
|
+
inputs = None
|
|
1061
|
+
"""
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
def _generate_wrapper_script(cfg: _WrapperConfig):
|
|
1065
|
+
if cfg.impl == "reference":
|
|
1066
|
+
model_file = "model.py"
|
|
1067
|
+
cls_name = "Model"
|
|
1068
|
+
else:
|
|
1069
|
+
model_file = "model_new_ascendc.py"
|
|
1070
|
+
cls_name = "ModelNew"
|
|
1071
|
+
|
|
1072
|
+
if cfg.jsonl_case is not None:
|
|
1073
|
+
# 先准备 JSONL 随机合成的 kwargs 作为兜底,再尝试真实输入覆盖
|
|
1074
|
+
inputs_code = (_serialize_jsonl_inputs(cfg.jsonl_case) + "\n\n"
|
|
1075
|
+
+ _REAL_INPUTS_CODE.format(case_idx=cfg.case_idx))
|
|
1076
|
+
else:
|
|
1077
|
+
# 无 JSONL case 时只能依赖 model.py 的输入生成器
|
|
1078
|
+
inputs_code = (_REAL_INPUTS_CODE.format(case_idx=cfg.case_idx) + """
|
|
1079
|
+
if inputs is None:
|
|
1080
|
+
raise RuntimeError("failed to obtain inputs from model.py get_input_groups()/get_inputs()")
|
|
1081
|
+
""")
|
|
1082
|
+
return _build_wrapper_script_content(cfg, model_file, cls_name, inputs_code)
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
def _find_msprof_script():
|
|
1086
|
+
script_dir = Path(__file__).resolve().parent
|
|
1087
|
+
candidate = script_dir / "msprof_profile_run.sh"
|
|
1088
|
+
if candidate.exists():
|
|
1089
|
+
return str(candidate)
|
|
1090
|
+
return "msprof_profile_run.sh"
|
|
1091
|
+
|
|
1092
|
+
|
|
1093
|
+
def _save_app_output(output_dir: str, stdout: str, stderr: str) -> str:
|
|
1094
|
+
"""把被测 app 的输出落盘,便于采集失败时回溯真实原因。返回日志路径。"""
|
|
1095
|
+
log_path = os.path.join(output_dir, "app_output.log")
|
|
1096
|
+
try:
|
|
1097
|
+
with open(log_path, "w", encoding="utf-8", errors="replace") as f:
|
|
1098
|
+
f.write("=== stdout ===\n" + (stdout or "") + "\n=== stderr ===\n" + (stderr or ""))
|
|
1099
|
+
except OSError:
|
|
1100
|
+
pass
|
|
1101
|
+
return log_path
|
|
1102
|
+
|
|
1103
|
+
|
|
1104
|
+
def _extract_app_crash(stdout: str, stderr: str):
|
|
1105
|
+
"""从 msprof 输出中检测被测 app 的 Python 异常。
|
|
1106
|
+
|
|
1107
|
+
msprof 在 app 崩溃时仍返回退出码 0(只打 WARNING),若不主动检测,
|
|
1108
|
+
上层只能看到 "no csv found" 这类误导性错误。返回最后一行异常信息或 None。
|
|
1109
|
+
"""
|
|
1110
|
+
text = (stdout or "") + "\n" + (stderr or "")
|
|
1111
|
+
if "Traceback" not in text and "An exception has occurred in process App" not in text:
|
|
1112
|
+
return None
|
|
1113
|
+
exc_lines = re.findall(r"^(\w[\w.]*(?:Error|Exception|Interrupt)\b[^\n]*)", text, re.M)
|
|
1114
|
+
if exc_lines:
|
|
1115
|
+
return exc_lines[-1].strip()[:200]
|
|
1116
|
+
return "app raised an exception during profiling"
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
def _run_msprof_standard(wrapper_script: str, output_dir: str, device_id: int, warmup: int = 3):
|
|
1120
|
+
"""调用 msprof_profile_run.sh 进行完整采集(7 组 aic-metrics + sample-based)。
|
|
1121
|
+
|
|
1122
|
+
注意:不设置 timeout,与原来 kernel_perf.py 行为一致(默认无限等待)。
|
|
1123
|
+
8 轮采集(7 metrics + 1 sample)耗时较长,由调用方控制整体超时。
|
|
1124
|
+
"""
|
|
1125
|
+
wrapper_path = os.path.join(output_dir, "_wrapper.py")
|
|
1126
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
1127
|
+
with open(wrapper_path, "w", encoding="utf-8") as f:
|
|
1128
|
+
f.write(wrapper_script)
|
|
1129
|
+
|
|
1130
|
+
cmd = [
|
|
1131
|
+
"bash", _find_msprof_script(),
|
|
1132
|
+
f"--warm-up={warmup}",
|
|
1133
|
+
f"--output={output_dir}",
|
|
1134
|
+
"--",
|
|
1135
|
+
sys.executable, wrapper_path
|
|
1136
|
+
]
|
|
1137
|
+
env = os.environ.copy()
|
|
1138
|
+
result = subprocess.run(cmd, capture_output=True, text=True, env=env)
|
|
1139
|
+
|
|
1140
|
+
try:
|
|
1141
|
+
os.remove(wrapper_path)
|
|
1142
|
+
except OSError:
|
|
1143
|
+
pass
|
|
1144
|
+
|
|
1145
|
+
app_log = _save_app_output(output_dir, result.stdout, result.stderr)
|
|
1146
|
+
|
|
1147
|
+
if result.returncode != 0:
|
|
1148
|
+
return None, f"msprof failed: {result.stderr[-500:]}\n(app log: {app_log})"
|
|
1149
|
+
|
|
1150
|
+
app_crash = _extract_app_crash(result.stdout, result.stderr)
|
|
1151
|
+
if app_crash:
|
|
1152
|
+
return None, f"profiled app crashed: {app_crash} (app log: {app_log})"
|
|
1153
|
+
|
|
1154
|
+
prof_dirs = sorted(Path(output_dir).glob("PROF_GROUP_*"))
|
|
1155
|
+
if not prof_dirs:
|
|
1156
|
+
return None, f"no PROF_GROUP directory found (app log: {app_log})"
|
|
1157
|
+
return str(prof_dirs[-1]), None
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
_MSPROF_QUICK_CALL_TIMEOUT_ENV = "CANNBOT_MSPROF_QUICK_CALL_TIMEOUT_SEC"
|
|
1161
|
+
# Degraded-driver slow state makes each fresh wrapper/msprof process pay ~90s
|
|
1162
|
+
# torch init; a shorter cap risks false timeouts on a slow-but-alive box
|
|
1163
|
+
# (a false timeout aborts the whole perf run).
|
|
1164
|
+
_MSPROF_QUICK_CALL_TIMEOUT_DEFAULT = 1200
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
def _quick_call_timeout_seconds() -> int:
|
|
1168
|
+
raw = os.environ.get(_MSPROF_QUICK_CALL_TIMEOUT_ENV)
|
|
1169
|
+
if raw is None:
|
|
1170
|
+
return _MSPROF_QUICK_CALL_TIMEOUT_DEFAULT
|
|
1171
|
+
try:
|
|
1172
|
+
value = int(raw.strip())
|
|
1173
|
+
except ValueError:
|
|
1174
|
+
return _MSPROF_QUICK_CALL_TIMEOUT_DEFAULT
|
|
1175
|
+
return max(value, 1)
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
def _run_guarded(cmd, env, timeout_seconds, label):
|
|
1179
|
+
"""Bounded subprocess with process-group kill (msprof spawns children).
|
|
1180
|
+
|
|
1181
|
+
During host bad-state windows the device profiler wedges and
|
|
1182
|
+
msprof/wrapper hang forever (wrappers busy-spin at 100%+ CPU while the
|
|
1183
|
+
card stays idle). The legacy code waited indefinitely, so one wedged
|
|
1184
|
+
case stalled the whole perf task until the outer task timeout. This
|
|
1185
|
+
guard converts a hang into a fast per-case failure.
|
|
1186
|
+
"""
|
|
1187
|
+
try:
|
|
1188
|
+
proc = subprocess.Popen(
|
|
1189
|
+
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
|
1190
|
+
text=True, env=env, start_new_session=True,
|
|
1191
|
+
)
|
|
1192
|
+
try:
|
|
1193
|
+
out, err = proc.communicate(timeout=timeout_seconds)
|
|
1194
|
+
return proc.returncode, out, err, False
|
|
1195
|
+
except subprocess.TimeoutExpired:
|
|
1196
|
+
try:
|
|
1197
|
+
os.killpg(proc.pid, signal.SIGKILL)
|
|
1198
|
+
except OSError as kill_exc:
|
|
1199
|
+
# The wedged group may have already exited (or be unsignalable);
|
|
1200
|
+
# the drain below still reaps whatever is left. Never fatal here:
|
|
1201
|
+
# the caller only needs the timed-out verdict.
|
|
1202
|
+
LOGGER.debug("%s: process-group kill skipped: %s", label, kill_exc)
|
|
1203
|
+
try:
|
|
1204
|
+
out, err = proc.communicate(timeout=10)
|
|
1205
|
+
except Exception as drain_exc: # noqa: BLE001 - best-effort drain
|
|
1206
|
+
LOGGER.debug("%s: post-kill output drain failed: %s", label, drain_exc)
|
|
1207
|
+
out, err = "", ""
|
|
1208
|
+
return None, out, err, True
|
|
1209
|
+
except OSError as exc:
|
|
1210
|
+
return None, "", f"{label} failed to start: {exc}", False
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
def _run_msprof_quick(wrapper_script: str, output_dir: str, device_id: int, warmup: int = 3):
|
|
1214
|
+
"""快速模式:只采集 1 轮(不采集 7 个 aic-metrics,只获取 kernel 时间)。
|
|
1215
|
+
|
|
1216
|
+
直接调用 msprof 命令(不通过 msprof_profile_run.sh,避免循环调用)。
|
|
1217
|
+
使用 msprof --ai-core=on --task-time=on --ascendcl=on,不设置 --aic-metrics。
|
|
1218
|
+
|
|
1219
|
+
warmup 在 msprof 外部执行:先单独跑 warmup 次 wrapper 预热 NPU,
|
|
1220
|
+
msprof 只采集正式 timed run,确保 task_time.csv 不含预热数据。
|
|
1221
|
+
"""
|
|
1222
|
+
wrapper_path = os.path.join(output_dir, "_wrapper.py")
|
|
1223
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
1224
|
+
with open(wrapper_path, "w", encoding="utf-8") as f:
|
|
1225
|
+
f.write(wrapper_script)
|
|
1226
|
+
|
|
1227
|
+
env = os.environ.copy()
|
|
1228
|
+
|
|
1229
|
+
# Warmup: 在 msprof 外部执行,不采集
|
|
1230
|
+
call_timeout = _quick_call_timeout_seconds()
|
|
1231
|
+
warmup_crash = None
|
|
1232
|
+
for _ in range(warmup):
|
|
1233
|
+
rc, wout, werr, timed_out = _run_guarded(
|
|
1234
|
+
[sys.executable, wrapper_path], env, call_timeout, "warmup wrapper")
|
|
1235
|
+
if timed_out:
|
|
1236
|
+
return None, f"msprof quick timed out after {call_timeout}s (warmup wrapper)"
|
|
1237
|
+
if rc != 0 and warmup_crash is None:
|
|
1238
|
+
warmup_crash = _extract_app_crash(wout, werr) or (werr or "")[-200:]
|
|
1239
|
+
|
|
1240
|
+
# Measurement: msprof 只采集正式 timed run
|
|
1241
|
+
cmd = [
|
|
1242
|
+
"msprof",
|
|
1243
|
+
f"--output={output_dir}",
|
|
1244
|
+
"--ai-core=on",
|
|
1245
|
+
"--task-time=on",
|
|
1246
|
+
"--ascendcl=on",
|
|
1247
|
+
sys.executable, wrapper_path
|
|
1248
|
+
]
|
|
1249
|
+
rc, mout, merr, timed_out = _run_guarded(
|
|
1250
|
+
cmd, env, call_timeout, "msprof measurement")
|
|
1251
|
+
result = types.SimpleNamespace(
|
|
1252
|
+
returncode=rc, stdout=mout or "", stderr=merr or "")
|
|
1253
|
+
|
|
1254
|
+
try:
|
|
1255
|
+
os.remove(wrapper_path)
|
|
1256
|
+
except OSError:
|
|
1257
|
+
pass
|
|
1258
|
+
|
|
1259
|
+
app_log = _save_app_output(output_dir, result.stdout, result.stderr)
|
|
1260
|
+
|
|
1261
|
+
if timed_out:
|
|
1262
|
+
return None, (
|
|
1263
|
+
f"msprof quick timed out after {call_timeout}s "
|
|
1264
|
+
f"(measurement; app log: {app_log})")
|
|
1265
|
+
if result.returncode != 0:
|
|
1266
|
+
return None, f"msprof failed: {result.stderr[-500:]}\n(app log: {app_log})"
|
|
1267
|
+
|
|
1268
|
+
# msprof 在 app 崩溃时仍返回 0,必须主动检测,否则只能看到误导性的
|
|
1269
|
+
# "no task_time csv found"
|
|
1270
|
+
app_crash = _extract_app_crash(result.stdout, result.stderr) or warmup_crash
|
|
1271
|
+
if app_crash:
|
|
1272
|
+
return None, f"profiled app crashed: {app_crash} (app log: {app_log})"
|
|
1273
|
+
|
|
1274
|
+
prof_dirs = sorted(Path(output_dir).glob("PROF_*"))
|
|
1275
|
+
if not prof_dirs:
|
|
1276
|
+
return None, f"no PROF directory found (app log: {app_log})"
|
|
1277
|
+
return str(prof_dirs[-1]), None
|
|
1278
|
+
|
|
1279
|
+
|
|
1280
|
+
def _extract_compute_row(r: dict):
|
|
1281
|
+
"""从 op_summary 行提取计算算子的 (duration, op_name)。
|
|
1282
|
+
|
|
1283
|
+
非计算行、非法值或非正耗时返回 None。
|
|
1284
|
+
"""
|
|
1285
|
+
task_type = r.get("Task Type", "")
|
|
1286
|
+
if "AI_CORE" not in task_type and "AIV" not in task_type and "MIX" not in task_type:
|
|
1287
|
+
return None
|
|
1288
|
+
try:
|
|
1289
|
+
duration = float(r.get("Task Duration(us)", 0) or 0)
|
|
1290
|
+
except ValueError:
|
|
1291
|
+
return None
|
|
1292
|
+
if duration <= 0:
|
|
1293
|
+
return None
|
|
1294
|
+
return duration, r.get("Op Name", "unknown")
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
def _parse_msprof_duration(prof_group_dir: str):
|
|
1298
|
+
csv_pattern = os.path.join(prof_group_dir, "PROF_*/PROF_*/mindstudio_profiler_output/op_summary_*.csv")
|
|
1299
|
+
csv_files = sorted(glob.glob(csv_pattern))
|
|
1300
|
+
if not csv_files:
|
|
1301
|
+
return None, None, "no op_summary csv found"
|
|
1302
|
+
|
|
1303
|
+
try:
|
|
1304
|
+
with open(csv_files[0], "r", encoding="utf-8", errors="replace") as f:
|
|
1305
|
+
reader = csv.DictReader(f)
|
|
1306
|
+
rows = list(reader)
|
|
1307
|
+
except Exception as e:
|
|
1308
|
+
return None, None, f"read csv error: {e}"
|
|
1309
|
+
|
|
1310
|
+
if not rows:
|
|
1311
|
+
return None, None, "empty csv"
|
|
1312
|
+
|
|
1313
|
+
# 汇总所有实际计算算子的 Task Duration;参考实现可能包含多个 PyTorch native kernel,
|
|
1314
|
+
# AscendC 实现也可能拆分为多个 kernel,因此采用累加而非取最大。
|
|
1315
|
+
compute_rows = [cr for cr in (_extract_compute_row(r) for r in rows) if cr is not None]
|
|
1316
|
+
|
|
1317
|
+
if compute_rows:
|
|
1318
|
+
total_duration = sum(d for d, _ in compute_rows)
|
|
1319
|
+
op_name = compute_rows[0][1] if len(compute_rows) == 1 else "multiple_kernels"
|
|
1320
|
+
return total_duration, op_name, None
|
|
1321
|
+
|
|
1322
|
+
return None, None, "no compute rows found"
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
_META_KERNEL_TYPES = ("PROFILING_ENABLE", "PROFILING_DISABLE", "TASK_TIMEOUT_SET", "")
|
|
1326
|
+
|
|
1327
|
+
|
|
1328
|
+
def _split_task_time_runs(rows: List[Dict[str, str]], n_runs: int):
|
|
1329
|
+
"""把 task_time.csv 的 kernel 行按「重复的 kernel 序列」拆成 n_runs 次 run。
|
|
1330
|
+
|
|
1331
|
+
采集窗口内包含 warmup + repeats 次迭代,每次迭代发射完全相同的 kernel 序列。
|
|
1332
|
+
按 task_start 排序后,总行数应能被 n_runs 整除,且每个分块的 kernel_name
|
|
1333
|
+
序列必须逐位相同 —— 否则说明迭代次数与预期不符,返回 None 由调用方回退。
|
|
1334
|
+
|
|
1335
|
+
Returns: list[list[float]] 每个 run 的 kernel 耗时列表,或 None。
|
|
1336
|
+
"""
|
|
1337
|
+
kernels = []
|
|
1338
|
+
for r in rows:
|
|
1339
|
+
if r.get("kernel_type", "") in _META_KERNEL_TYPES:
|
|
1340
|
+
continue
|
|
1341
|
+
try:
|
|
1342
|
+
dur = float(r.get("task_time(us)", "") or 0)
|
|
1343
|
+
start = float((r.get("task_start(us)", "") or "0").strip())
|
|
1344
|
+
except ValueError:
|
|
1345
|
+
continue
|
|
1346
|
+
if dur <= 0:
|
|
1347
|
+
continue
|
|
1348
|
+
kernels.append((start, r.get("kernel_name", "unknown"), dur))
|
|
1349
|
+
|
|
1350
|
+
if not kernels or n_runs < 1 or len(kernels) % n_runs:
|
|
1351
|
+
return None
|
|
1352
|
+
kernels.sort(key=lambda x: x[0])
|
|
1353
|
+
|
|
1354
|
+
n = len(kernels) // n_runs
|
|
1355
|
+
runs, seq = [], [k[1] for k in kernels[:n]]
|
|
1356
|
+
for i in range(n_runs):
|
|
1357
|
+
chunk = kernels[i * n:(i + 1) * n]
|
|
1358
|
+
if [k[1] for k in chunk] != seq:
|
|
1359
|
+
return None
|
|
1360
|
+
runs.append([k[2] for k in chunk])
|
|
1361
|
+
return runs
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
def _parse_msprof_duration_quick(prof_group_dir: str, warmup: int = 0, repeats: int = 1):
|
|
1365
|
+
"""快速模式解析:从 PROF 目录中查找 task_time.csv 并提取时间。
|
|
1366
|
+
|
|
1367
|
+
快速模式只跑 1 轮(不采集 7 个 aic-metrics),因此没有 op_summary_*.csv。
|
|
1368
|
+
|
|
1369
|
+
采集窗口内包含 warmup + repeats 次 in-process 迭代(与 torch_npu profiler 的
|
|
1370
|
+
warmup/active 语义一致)。这里按 kernel 序列把它们拆开,**只对后 repeats 次
|
|
1371
|
+
(active)求平均**,丢弃 warmup 次 —— 避免首次迭代的冷启动污染测量值。
|
|
1372
|
+
若拆分失败(行数不匹配等),回退为按时间排序后的位置分片,同样丢弃 warmup 份。
|
|
1373
|
+
|
|
1374
|
+
兼容两种目录结构:
|
|
1375
|
+
- 无 --aic-metrics: PROF_*/mindstudio_profiler_output/task_time_*.csv
|
|
1376
|
+
- 有 --aic-metrics: PROF_*/PROF_PipeUtilization/mindstudio_profiler_output/task_time_*.csv
|
|
1377
|
+
"""
|
|
1378
|
+
task_time_patterns = [
|
|
1379
|
+
os.path.join(prof_group_dir, "mindstudio_profiler_output", "task_time_*.csv"),
|
|
1380
|
+
os.path.join(prof_group_dir, "PROF_*", "mindstudio_profiler_output", "task_time_*.csv"),
|
|
1381
|
+
]
|
|
1382
|
+
for pattern in task_time_patterns:
|
|
1383
|
+
task_time_files = sorted(glob.glob(pattern))
|
|
1384
|
+
if not task_time_files:
|
|
1385
|
+
continue
|
|
1386
|
+
try:
|
|
1387
|
+
with open(task_time_files[0], "r", encoding="utf-8", errors="replace") as f:
|
|
1388
|
+
rows = list(csv.DictReader(f))
|
|
1389
|
+
|
|
1390
|
+
# 优先:按 run 拆分,只取 active(后 repeats 次)的均值
|
|
1391
|
+
runs = _split_task_time_runs(rows, warmup + repeats)
|
|
1392
|
+
if runs is not None:
|
|
1393
|
+
active = runs[warmup:] if warmup < len(runs) else runs
|
|
1394
|
+
per_run = [sum(x) for x in active]
|
|
1395
|
+
return (sum(per_run) / len(per_run)), "multiple_kernels", None
|
|
1396
|
+
|
|
1397
|
+
# 回退路径:run 拆分失败(kernel 名称序列不一致等),位置分片
|
|
1398
|
+
kernels = _collect_kernels(rows)
|
|
1399
|
+
result = _split_kernels_by_position(kernels, warmup, repeats)
|
|
1400
|
+
if result is None:
|
|
1401
|
+
continue
|
|
1402
|
+
kernel_names = list({k[1] for k in kernels})
|
|
1403
|
+
kernel_name = kernel_names[0] if len(kernel_names) == 1 else "multiple_kernels"
|
|
1404
|
+
return result, kernel_name, None
|
|
1405
|
+
except Exception as e:
|
|
1406
|
+
LOGGER.debug("Failed to parse %s: %s", task_time_files[0], e)
|
|
1407
|
+
|
|
1408
|
+
return None, None, "no task_time or api_statistic csv found"
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
def _collect_kernels(rows):
|
|
1412
|
+
"""从 task_time 行中收集有效 kernel:过滤元数据 kernel、空/非法/非正耗时。"""
|
|
1413
|
+
kernels = []
|
|
1414
|
+
for r in rows:
|
|
1415
|
+
kernel_type = r.get("kernel_type", "")
|
|
1416
|
+
task_time = r.get("task_time(us)", "")
|
|
1417
|
+
if kernel_type in _META_KERNEL_TYPES or not task_time:
|
|
1418
|
+
continue
|
|
1419
|
+
try:
|
|
1420
|
+
dur = float(task_time)
|
|
1421
|
+
start = float((r.get("task_start(us)", "") or "0").strip())
|
|
1422
|
+
except ValueError:
|
|
1423
|
+
continue
|
|
1424
|
+
if dur <= 0:
|
|
1425
|
+
continue
|
|
1426
|
+
kernels.append((start, r.get("kernel_name", "unknown"), dur))
|
|
1427
|
+
return kernels
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
def _split_kernels_by_position(kernels, warmup: int, repeats: int):
|
|
1431
|
+
"""按时间排序后做位置分片,丢弃前 warmup 份,返回单次迭代估算耗时。
|
|
1432
|
+
|
|
1433
|
+
行数可整除时按位置精确分片;不可整除时按比例估算。kernels 为空返回 None。
|
|
1434
|
+
"""
|
|
1435
|
+
if not kernels:
|
|
1436
|
+
return None
|
|
1437
|
+
kernels.sort(key=lambda x: x[0])
|
|
1438
|
+
total = sum(d for _, _, d in kernels)
|
|
1439
|
+
n_total = warmup + repeats
|
|
1440
|
+
if n_total <= 0:
|
|
1441
|
+
n_total = 1
|
|
1442
|
+
n_kernels = len(kernels)
|
|
1443
|
+
|
|
1444
|
+
if n_kernels % n_total == 0:
|
|
1445
|
+
# 行数可整除:按位置精确分片,丢弃前 warmup 份
|
|
1446
|
+
k_per = n_kernels // n_total
|
|
1447
|
+
active_kernels = kernels[warmup * k_per:]
|
|
1448
|
+
return sum(d for _, _, d in active_kernels) / max(1, repeats)
|
|
1449
|
+
|
|
1450
|
+
# 行数不可整除:按比例估算,丢弃时间轴上前 warmup/n_total 的部分
|
|
1451
|
+
split_idx = max(0, int(n_kernels * warmup / n_total))
|
|
1452
|
+
active_kernels = kernels[split_idx:]
|
|
1453
|
+
if not active_kernels:
|
|
1454
|
+
return total / n_total
|
|
1455
|
+
# 按 active kernel 数占总 kernel 数的比例折算单次迭代耗时
|
|
1456
|
+
active_total = sum(d for _, _, d in active_kernels)
|
|
1457
|
+
return active_total / (len(active_kernels) / (n_kernels / n_total))
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
def pick_idle_npu(default=0):
|
|
1461
|
+
try:
|
|
1462
|
+
p = subprocess.run(["/usr/local/bin/npu-smi", "info"], capture_output=True, text=True, timeout=10)
|
|
1463
|
+
if p.returncode != 0:
|
|
1464
|
+
return default
|
|
1465
|
+
except Exception:
|
|
1466
|
+
return default
|
|
1467
|
+
|
|
1468
|
+
devices = {}
|
|
1469
|
+
cur = None
|
|
1470
|
+
head_re = re.compile(r"^\|\s+(\d+)\s+\S+\s+\|\s+\w+\s+\|")
|
|
1471
|
+
bus_re = re.compile(
|
|
1472
|
+
r"^\|\s+\d+\s+\|\s+[0-9A-Fa-f:.]+\s+\|\s+(\d+)\s+(\d+)\s*/\s*(\d+)(?:\s+(\d+)\s*/\s*(\d+))?"
|
|
1473
|
+
)
|
|
1474
|
+
for line in p.stdout.splitlines():
|
|
1475
|
+
m2 = bus_re.match(line)
|
|
1476
|
+
if m2 and cur is not None:
|
|
1477
|
+
aicore = int(m2.group(1))
|
|
1478
|
+
mem_used = int(m2.group(2))
|
|
1479
|
+
mem_total = max(int(m2.group(3)), 1)
|
|
1480
|
+
hbm_used = int(m2.group(4)) if m2.group(4) else 0
|
|
1481
|
+
hbm_total = max(int(m2.group(5)), 1) if m2.group(5) else 1
|
|
1482
|
+
mem_ratio = max(mem_used / mem_total, hbm_used / hbm_total)
|
|
1483
|
+
devices[cur] = (aicore, mem_ratio)
|
|
1484
|
+
cur = None
|
|
1485
|
+
continue
|
|
1486
|
+
m1 = head_re.match(line)
|
|
1487
|
+
if m1:
|
|
1488
|
+
cur = int(m1.group(1))
|
|
1489
|
+
|
|
1490
|
+
if not devices:
|
|
1491
|
+
return default
|
|
1492
|
+
best_id, _ = min(devices.items(), key=lambda kv: (kv[1][0], kv[1][1]))
|
|
1493
|
+
return best_id
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
def _add_compare_header(lines, report):
|
|
1497
|
+
"""Add the header section to the compare markdown report."""
|
|
1498
|
+
lines.append("# 性能评估结果")
|
|
1499
|
+
lines.append("")
|
|
1500
|
+
lines.append(f"- **Operator**: {report['task']}")
|
|
1501
|
+
lines.append(f"- **Device**: npu:{report['device_id']} (source={report['device_select_source']})")
|
|
1502
|
+
lines.append(f"- **Warmup**: {report['warmup']}")
|
|
1503
|
+
lines.append(f"- **Repeats**: {report['repeats']}")
|
|
1504
|
+
lines.append(f"- **Seed**: {report['seed']}")
|
|
1505
|
+
lines.append(f"- **Timing method**: {report['timing_method']}")
|
|
1506
|
+
lines.append("")
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
def _add_per_case_table(lines, report):
|
|
1510
|
+
"""Add the per-case comparison table."""
|
|
1511
|
+
if not report.get("per_case"):
|
|
1512
|
+
return
|
|
1513
|
+
lines.append("## 性能对比")
|
|
1514
|
+
lines.append("")
|
|
1515
|
+
lines.append("| Case | Shape | DType | 自定义算子(us) | 标杆(us) | 加速比 |")
|
|
1516
|
+
lines.append("| ---- | ----- | ----- | ------------- | -------- | -------------- |")
|
|
1517
|
+
for case in report["per_case"]:
|
|
1518
|
+
shape = case.get("shape", "?")
|
|
1519
|
+
dtype = case.get("dtype", "?")
|
|
1520
|
+
ref = case.get("ref_us")
|
|
1521
|
+
asc = case.get("asc_us")
|
|
1522
|
+
sp = case.get("speedup")
|
|
1523
|
+
ref_str = f"{ref:.2f}" if ref is not None else "N/A"
|
|
1524
|
+
asc_str = f"{asc:.2f}" if asc is not None else "N/A"
|
|
1525
|
+
sp_str = f"{sp:.3f}" if sp is not None else "N/A"
|
|
1526
|
+
lines.append(f"| {case['case']} | {shape} | {dtype} | {asc_str} | {ref_str} | {sp_str} |")
|
|
1527
|
+
lines.append("")
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
def _add_summary_section(lines, report):
|
|
1531
|
+
"""Add the summary and dtype tables."""
|
|
1532
|
+
has_speedup = report.get("geomean_speedup") is not None
|
|
1533
|
+
has_timing = (report.get("mean_ref_us") is not None
|
|
1534
|
+
or report.get("mean_asc_us") is not None)
|
|
1535
|
+
if not has_speedup and not has_timing:
|
|
1536
|
+
return
|
|
1537
|
+
lines.append("## 全量汇总")
|
|
1538
|
+
lines.append("")
|
|
1539
|
+
lines.append("| 指标 | 值 |")
|
|
1540
|
+
lines.append("| ---- | -- |")
|
|
1541
|
+
lines.append(f"| 用例数 | {report['n_cases_total']} |")
|
|
1542
|
+
if has_speedup:
|
|
1543
|
+
lines.append(f"| 平均加速比(>1 表示自定义算子更快) | {report['mean_speedup']:.3f} |")
|
|
1544
|
+
else:
|
|
1545
|
+
lines.append("| 平均加速比 | N/A(--impl 单边采集或无双侧有效 case) |")
|
|
1546
|
+
if report.get("geomean_ref_us") is not None:
|
|
1547
|
+
lines.append(f"| 标杆几何平均耗时 (us) | {report['geomean_ref_us']:.2f} |")
|
|
1548
|
+
if report.get("geomean_asc_us") is not None:
|
|
1549
|
+
lines.append(f"| 自定义算子几何平均耗时 (us) | {report['geomean_asc_us']:.2f} |")
|
|
1550
|
+
if has_speedup:
|
|
1551
|
+
better = sum(1 for c in report.get('per_case', []) if c.get('speedup') and c['speedup'] > 1)
|
|
1552
|
+
worse = sum(1 for c in report.get('per_case', []) if c.get('speedup') and c['speedup'] < 1)
|
|
1553
|
+
lines.append(f"| 自定义算子更优(比值>1) | {better} |")
|
|
1554
|
+
lines.append(f"| 标杆更优(比值<1) | {worse} |")
|
|
1555
|
+
lines.append("")
|
|
1556
|
+
|
|
1557
|
+
dtype_groups = {}
|
|
1558
|
+
for case in report.get("per_case", []):
|
|
1559
|
+
dtype = case.get("dtype", "?")
|
|
1560
|
+
sp = case.get("speedup")
|
|
1561
|
+
if sp is not None:
|
|
1562
|
+
dtype_groups.setdefault(dtype, []).append(sp)
|
|
1563
|
+
if dtype_groups:
|
|
1564
|
+
lines.append("### 按数据类型汇总")
|
|
1565
|
+
lines.append("")
|
|
1566
|
+
lines.append("| DType | 用例数 | 平均加速比 | 自定义算子更优 | 标杆更优 |")
|
|
1567
|
+
lines.append("| ----- | ------ | ------------------- | ------------- | -------- |")
|
|
1568
|
+
for dtype, sps in sorted(dtype_groups.items()):
|
|
1569
|
+
mean_sp = statistics.mean(sps)
|
|
1570
|
+
better = sum(1 for sp in sps if sp > 1)
|
|
1571
|
+
worse = sum(1 for sp in sps if sp < 1)
|
|
1572
|
+
lines.append(f"| {dtype} | {len(sps)} | {mean_sp:.3f} | {better} | {worse} |")
|
|
1573
|
+
lines.append("")
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
def _add_analysis_sections(lines, report):
|
|
1577
|
+
"""Add the short analysis and deep bottleneck analysis sections."""
|
|
1578
|
+
lines.append("## 简短分析")
|
|
1579
|
+
lines.append("")
|
|
1580
|
+
if report.get("mean_speedup") is not None:
|
|
1581
|
+
if report["mean_speedup"] > 1:
|
|
1582
|
+
lines.append(f"- 平均加速比 {report['mean_speedup']:.3f} 大于 1,自定义算子整体有优势。")
|
|
1583
|
+
else:
|
|
1584
|
+
lines.append(f"- 平均加速比 {report['mean_speedup']:.3f} 小于 1,标杆路径整体更优。")
|
|
1585
|
+
lines.append("- 详细瓶颈分析见 msprof 归档目录(op_summary_*.csv + summary.txt)。")
|
|
1586
|
+
lines.append("")
|
|
1587
|
+
|
|
1588
|
+
lines.append("## 深度瓶颈分析")
|
|
1589
|
+
lines.append("")
|
|
1590
|
+
lines.append(
|
|
1591
|
+
"如需进一步分析性能瓶颈(各流水线利用率、核间负载均衡、主 Bound 判定),"
|
|
1592
|
+
"可运行:"
|
|
1593
|
+
)
|
|
1594
|
+
lines.append("```bash")
|
|
1595
|
+
lines.append(
|
|
1596
|
+
f"python3 ${{SKILL_PATH}}/scripts/msprof_perf_summary.py "
|
|
1597
|
+
f"{report.get('prof_group_dir', './PROF_GROUP_*')} {report['task']}"
|
|
1598
|
+
)
|
|
1599
|
+
lines.append("```")
|
|
1600
|
+
lines.append("")
|
|
1601
|
+
lines.append("或参考 `ops-profiling/references/optimization_quickref.md` 获取优化建议。")
|
|
1602
|
+
lines.append("")
|
|
1603
|
+
|
|
1604
|
+
|
|
1605
|
+
def _report_compare_to_markdown(report: Dict[str, Any]) -> str:
|
|
1606
|
+
lines = []
|
|
1607
|
+
_add_compare_header(lines, report)
|
|
1608
|
+
_add_per_case_table(lines, report)
|
|
1609
|
+
_add_summary_section(lines, report)
|
|
1610
|
+
_add_analysis_sections(lines, report)
|
|
1611
|
+
return "\n".join(lines)
|
|
1612
|
+
|
|
1613
|
+
|
|
1614
|
+
def _report_compare_to_text(report: Dict[str, Any]) -> str:
|
|
1615
|
+
lines = []
|
|
1616
|
+
lines.append("=" * 100)
|
|
1617
|
+
lines.append(f"Kernel-level Performance (msprof): {report['task']} "
|
|
1618
|
+
f"(warmup={report['warmup']}, repeats={report['repeats']}, seed={report['seed']})")
|
|
1619
|
+
lines.append("=" * 100)
|
|
1620
|
+
lines.append(f"{'Case':<5} {'Shape':<35} {'dtype':<10} {'Ref(us)':>12} {'Asc(us)':>12} {'Speedup':>10}")
|
|
1621
|
+
lines.append("-" * 100)
|
|
1622
|
+
|
|
1623
|
+
for case in report.get("per_case", []):
|
|
1624
|
+
shape = case.get("shape", "?")
|
|
1625
|
+
dtype = case.get("dtype", "?")
|
|
1626
|
+
ref_us = case.get("ref_us")
|
|
1627
|
+
asc_us = case.get("asc_us")
|
|
1628
|
+
sp = case.get("speedup")
|
|
1629
|
+
if ref_us is not None and asc_us is not None and sp is not None:
|
|
1630
|
+
lines.append(f"{case['case']:<5} {shape:<35} {dtype:<10} {ref_us:>12.2f} {asc_us:>12.2f} {sp:>9.3f}x")
|
|
1631
|
+
else:
|
|
1632
|
+
ref_str = f"{ref_us:.2f}" if ref_us is not None else "N/A"
|
|
1633
|
+
asc_str = f"{asc_us:.2f}" if asc_us is not None else "N/A"
|
|
1634
|
+
ref_err = case.get("ref_error", "")
|
|
1635
|
+
asc_err = case.get("asc_error", "")
|
|
1636
|
+
lines.append(f"{case['case']:<5} {shape:<35} {dtype:<10} "
|
|
1637
|
+
f"{ref_str:>12} {asc_str:>12} "
|
|
1638
|
+
f"{'N/A':>10} (ref_err={ref_err}, asc_err={asc_err})")
|
|
1639
|
+
|
|
1640
|
+
lines.append("-" * 100)
|
|
1641
|
+
if report.get("geomean_speedup") is not None:
|
|
1642
|
+
lines.append("--- Speedup ---")
|
|
1643
|
+
lines.append(f" Geomean : {report['geomean_speedup']:.2f}x ← 主指标")
|
|
1644
|
+
lines.append(f" Mean : {report['mean_speedup']:.2f}x")
|
|
1645
|
+
lines.append(f" Median : {report['median_speedup']:.2f}x")
|
|
1646
|
+
lines.append(f" Min/Max : {report['min_speedup']:.2f}x / {report['max_speedup']:.2f}x")
|
|
1647
|
+
lines.append(f" Valid : {report['n_cases_valid']}/{report['n_cases_total']}")
|
|
1648
|
+
# 单边采集(--impl ref/asc)时只渲染已测到的一侧,未测的一侧不出现
|
|
1649
|
+
if report.get("mean_ref_us") is not None:
|
|
1650
|
+
lines.append("--- Task Duration (us) ---")
|
|
1651
|
+
lines.append(
|
|
1652
|
+
f" Ref mean/median/geomean/total : {report['mean_ref_us']:.2f} / "
|
|
1653
|
+
f"{report['median_ref_us']:.2f} / {report['geomean_ref_us']:.2f} / "
|
|
1654
|
+
f"{report['total_ref_us']:.2f}"
|
|
1655
|
+
)
|
|
1656
|
+
if report.get("mean_asc_us") is not None:
|
|
1657
|
+
lines.append(
|
|
1658
|
+
f" Asc mean/median/geomean/total : {report['mean_asc_us']:.2f} / "
|
|
1659
|
+
f"{report['median_asc_us']:.2f} / {report['geomean_asc_us']:.2f} / "
|
|
1660
|
+
f"{report['total_asc_us']:.2f}"
|
|
1661
|
+
)
|
|
1662
|
+
if report.get("total_speedup") is not None:
|
|
1663
|
+
lines.append(f" Total speedup (Σref/Σasc) : {report['total_speedup']:.2f}x")
|
|
1664
|
+
lines.append("=" * 100)
|
|
1665
|
+
|
|
1666
|
+
return "\n".join(lines)
|
|
1667
|
+
|
|
1668
|
+
|
|
1669
|
+
def _select_device_id(args):
|
|
1670
|
+
"""Select NPU device from CLI arg, env var, or auto-detect."""
|
|
1671
|
+
if args.device is not None:
|
|
1672
|
+
return args.device, "cli"
|
|
1673
|
+
if os.environ.get("ASCEND_RT_VISIBLE_DEVICES"):
|
|
1674
|
+
return int(os.environ["ASCEND_RT_VISIBLE_DEVICES"].split(",")[0]), "env"
|
|
1675
|
+
return pick_idle_npu(default=0), "auto"
|
|
1676
|
+
|
|
1677
|
+
|
|
1678
|
+
@dataclass
|
|
1679
|
+
class _MeasureInput:
|
|
1680
|
+
"""封装 _measure_one_impl 的测量参数。
|
|
1681
|
+
|
|
1682
|
+
Args:
|
|
1683
|
+
out_dir: 算子输出目录(Path)
|
|
1684
|
+
case_idx: case 索引号
|
|
1685
|
+
impl: 实现类型,\"reference\" 或 \"ascendc\"
|
|
1686
|
+
args: argparse.Namespace(需含 retry, seed, warmup 属性)
|
|
1687
|
+
device_id: NPU 设备 ID
|
|
1688
|
+
jsonl_case: JSONL case 字典,可选
|
|
1689
|
+
"""
|
|
1690
|
+
out_dir: Path
|
|
1691
|
+
case_idx: int
|
|
1692
|
+
impl: str
|
|
1693
|
+
args: argparse.Namespace
|
|
1694
|
+
device_id: int
|
|
1695
|
+
jsonl_case: Optional[Dict[str, Any]] = None
|
|
1696
|
+
|
|
1697
|
+
|
|
1698
|
+
def _measure_one_impl(mi: _MeasureInput):
|
|
1699
|
+
"""Measure one implementation (reference/ascendc) with retries.
|
|
1700
|
+
|
|
1701
|
+
Returns (duration_us, error, prof_dir).
|
|
1702
|
+
"""
|
|
1703
|
+
prof_dir = None
|
|
1704
|
+
impl_abbr = "ref" if mi.impl == "reference" else "asc"
|
|
1705
|
+
for _ in range(1 + mi.args.retry):
|
|
1706
|
+
wrapper = _generate_wrapper_script(_WrapperConfig(
|
|
1707
|
+
mi.out_dir, mi.case_idx, mi.impl, mi.args.seed, mi.device_id,
|
|
1708
|
+
mi.args.warmup, mi.jsonl_case))
|
|
1709
|
+
tmpdir = f"/tmp/msprof_{impl_abbr}_{mi.out_dir.name}_c{mi.case_idx}"
|
|
1710
|
+
prof_dir, err = _run_msprof_standard(wrapper, tmpdir, mi.device_id, mi.args.warmup)
|
|
1711
|
+
if prof_dir:
|
|
1712
|
+
duration, _op_name, parse_err = _parse_msprof_duration(prof_dir)
|
|
1713
|
+
if duration is not None:
|
|
1714
|
+
return duration, None, prof_dir
|
|
1715
|
+
err = f"{parse_err} (app log: {tmpdir}/app_output.log)"
|
|
1716
|
+
time.sleep(0.5)
|
|
1717
|
+
return None, err, prof_dir
|
|
1718
|
+
|
|
1719
|
+
|
|
1720
|
+
def _measure_one_impl_quick(mi: _MeasureInput):
|
|
1721
|
+
"""快速模式:Measure one implementation with retries and repeats.
|
|
1722
|
+
|
|
1723
|
+
--retry 用于解析失败重试。
|
|
1724
|
+
|
|
1725
|
+
与 torch_npu profiler 对齐的口径:wrapper 在**同一个被采集的进程内**先跑
|
|
1726
|
+
--warmup 次预热迭代、再跑 --repeats 次计时迭代,msprof 一把全采;解析时按
|
|
1727
|
+
kernel 序列拆分成 (warmup + repeats) 次 run,只对后 repeats 次求平均。
|
|
1728
|
+
|
|
1729
|
+
旧实现把 warmup 放在 msprof 外部的独立进程里执行,对被采集的那个进程毫无
|
|
1730
|
+
预热作用,导致采到的必然是冷 run(首个 kernel 被放大 ~47%)。--ext-warmup
|
|
1731
|
+
保留了旧行为,默认关闭。
|
|
1732
|
+
|
|
1733
|
+
Returns (duration_us, error, prof_dir).
|
|
1734
|
+
"""
|
|
1735
|
+
prof_dir = None
|
|
1736
|
+
impl_abbr = "ref" if mi.impl == "reference" else "asc"
|
|
1737
|
+
repeats = max(1, getattr(mi.args, "repeats", 1))
|
|
1738
|
+
warmup = max(0, getattr(mi.args, "warmup", 0))
|
|
1739
|
+
ext_warmup = max(0, getattr(mi.args, "ext_warmup", 0))
|
|
1740
|
+
|
|
1741
|
+
for _ in range(1 + mi.args.retry):
|
|
1742
|
+
wrapper = _generate_wrapper_script(_WrapperConfig(
|
|
1743
|
+
mi.out_dir, mi.case_idx, mi.impl, mi.args.seed, mi.device_id,
|
|
1744
|
+
warmup, mi.jsonl_case, repeats))
|
|
1745
|
+
tag = getattr(mi.args, "prof_tag", None)
|
|
1746
|
+
if tag:
|
|
1747
|
+
if not _PROF_TAG_RE.match(tag):
|
|
1748
|
+
raise ValueError(
|
|
1749
|
+
f"--prof-tag 只允许 [A-Za-z0-9_.-]+,收到 {tag!r};"
|
|
1750
|
+
f"该值会拼进临时目录名并在随后被 rmtree 清理,禁止路径分隔符")
|
|
1751
|
+
tag_suffix = f"_{tag}"
|
|
1752
|
+
else:
|
|
1753
|
+
tag_suffix = ""
|
|
1754
|
+
tmpdir = (f"/tmp/msprof_quick_{impl_abbr}_{mi.out_dir.name}_c{mi.case_idx}"
|
|
1755
|
+
+ tag_suffix)
|
|
1756
|
+
_cleanup_prof_dirs(tmpdir)
|
|
1757
|
+
prof_dir, err = _run_msprof_quick(wrapper, tmpdir, mi.device_id, ext_warmup)
|
|
1758
|
+
if err and "timed out" in err:
|
|
1759
|
+
# A wedged device wedges every case; fail the whole profiling run
|
|
1760
|
+
# fast instead of grinding through all remaining cases. The O5
|
|
1761
|
+
# infra retry (with backoff) is the recovery.
|
|
1762
|
+
raise RuntimeError(err)
|
|
1763
|
+
if not prof_dir:
|
|
1764
|
+
continue
|
|
1765
|
+
|
|
1766
|
+
duration, _op_name, parse_err = _parse_msprof_duration_quick(
|
|
1767
|
+
prof_dir, warmup, repeats)
|
|
1768
|
+
if duration is None:
|
|
1769
|
+
err = f"{parse_err} (app log: {tmpdir}/app_output.log)"
|
|
1770
|
+
continue
|
|
1771
|
+
|
|
1772
|
+
return duration, None, prof_dir
|
|
1773
|
+
|
|
1774
|
+
return None, err, prof_dir
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
@dataclass
|
|
1778
|
+
class _CompareSummaryInput:
|
|
1779
|
+
"""封装 _compute_compare_summary 的汇总计算参数。
|
|
1780
|
+
|
|
1781
|
+
Args:
|
|
1782
|
+
out_dir: 算子输出目录(Path)
|
|
1783
|
+
rows: 逐 case 的测量结果列表
|
|
1784
|
+
speedups: 有效 speedup 值列表
|
|
1785
|
+
ref_times: 参考实现耗时列表(us)
|
|
1786
|
+
asc_times: AscendC 实现耗时列表(us)
|
|
1787
|
+
n_cases: case 总数
|
|
1788
|
+
args: argparse.Namespace(需含 warmup, repeats, seed 属性)
|
|
1789
|
+
device_id: NPU 设备 ID
|
|
1790
|
+
device_src: 设备来源描述(cli/env/auto)
|
|
1791
|
+
"""
|
|
1792
|
+
out_dir: Path
|
|
1793
|
+
rows: list
|
|
1794
|
+
speedups: list
|
|
1795
|
+
ref_times: list
|
|
1796
|
+
asc_times: list
|
|
1797
|
+
n_cases: int
|
|
1798
|
+
args: argparse.Namespace
|
|
1799
|
+
device_id: int
|
|
1800
|
+
device_src: str
|
|
1801
|
+
|
|
1802
|
+
|
|
1803
|
+
def _compute_compare_summary(csi: _CompareSummaryInput):
|
|
1804
|
+
"""Compute the summary statistics dict for compare mode."""
|
|
1805
|
+
speedup_stats = _compute_speedup_stats(csi.speedups)
|
|
1806
|
+
timing_stats = _compute_timing_stats(csi.ref_times, csi.asc_times)
|
|
1807
|
+
return {
|
|
1808
|
+
"task": csi.out_dir.name,
|
|
1809
|
+
"task_dir": str(csi.out_dir),
|
|
1810
|
+
"n_cases_total": csi.n_cases,
|
|
1811
|
+
**speedup_stats,
|
|
1812
|
+
**timing_stats,
|
|
1813
|
+
"warmup": csi.args.warmup,
|
|
1814
|
+
"repeats": csi.args.repeats,
|
|
1815
|
+
"seed": csi.args.seed,
|
|
1816
|
+
"device_id": csi.device_id,
|
|
1817
|
+
"device_select_source": csi.device_src,
|
|
1818
|
+
"timing_method": "msprof.op_summary.Task_Duration",
|
|
1819
|
+
"per_case": csi.rows,
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
def _compute_speedup_stats(speedups: list) -> dict:
|
|
1824
|
+
"""Compute speedup statistics from a list of speedup values.
|
|
1825
|
+
|
|
1826
|
+
Returns a dict with n_cases_valid and geomean/mean/median/min/max speedup.
|
|
1827
|
+
"""
|
|
1828
|
+
if not speedups:
|
|
1829
|
+
return {
|
|
1830
|
+
"n_cases_valid": 0,
|
|
1831
|
+
"geomean_speedup": None,
|
|
1832
|
+
"mean_speedup": None,
|
|
1833
|
+
"median_speedup": None,
|
|
1834
|
+
"min_speedup": None,
|
|
1835
|
+
"max_speedup": None,
|
|
1836
|
+
}
|
|
1837
|
+
return {
|
|
1838
|
+
"n_cases_valid": len(speedups),
|
|
1839
|
+
"geomean_speedup": statistics.geometric_mean(speedups),
|
|
1840
|
+
"mean_speedup": statistics.mean(speedups),
|
|
1841
|
+
"median_speedup": statistics.median(speedups),
|
|
1842
|
+
"min_speedup": min(speedups),
|
|
1843
|
+
"max_speedup": max(speedups),
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
def _compute_timing_stats(ref_times: list, asc_times: list) -> dict:
|
|
1848
|
+
"""Compute timing statistics for reference and AscendC implementations.
|
|
1849
|
+
|
|
1850
|
+
Returns a dict with mean/median/geomean/total for ref and asc, plus total_speedup.
|
|
1851
|
+
"""
|
|
1852
|
+
if ref_times:
|
|
1853
|
+
ref_stats = {
|
|
1854
|
+
"mean_ref_us": statistics.mean(ref_times),
|
|
1855
|
+
"median_ref_us": statistics.median(ref_times),
|
|
1856
|
+
"geomean_ref_us": statistics.geometric_mean(ref_times),
|
|
1857
|
+
"total_ref_us": sum(ref_times),
|
|
1858
|
+
}
|
|
1859
|
+
else:
|
|
1860
|
+
ref_stats = {"mean_ref_us": None, "median_ref_us": None,
|
|
1861
|
+
"geomean_ref_us": None, "total_ref_us": None}
|
|
1862
|
+
|
|
1863
|
+
if asc_times:
|
|
1864
|
+
asc_stats = {
|
|
1865
|
+
"mean_asc_us": statistics.mean(asc_times),
|
|
1866
|
+
"median_asc_us": statistics.median(asc_times),
|
|
1867
|
+
"geomean_asc_us": statistics.geometric_mean(asc_times),
|
|
1868
|
+
"total_asc_us": sum(asc_times),
|
|
1869
|
+
}
|
|
1870
|
+
else:
|
|
1871
|
+
asc_stats = {"mean_asc_us": None, "median_asc_us": None,
|
|
1872
|
+
"geomean_asc_us": None, "total_asc_us": None}
|
|
1873
|
+
|
|
1874
|
+
total_speedup = None
|
|
1875
|
+
if ref_times and asc_times:
|
|
1876
|
+
asc_sum = sum(asc_times)
|
|
1877
|
+
if asc_sum > 0:
|
|
1878
|
+
total_speedup = sum(ref_times) / asc_sum
|
|
1879
|
+
|
|
1880
|
+
return {**ref_stats, **asc_stats, "total_speedup": total_speedup}
|
|
1881
|
+
|
|
1882
|
+
|
|
1883
|
+
def _log_and_save_compare_reports(summary, out_dir, speedups, n_cases):
|
|
1884
|
+
"""Log summary results and save JSON/log/Markdown reports."""
|
|
1885
|
+
LOGGER.info("-" * 100)
|
|
1886
|
+
if speedups:
|
|
1887
|
+
LOGGER.info("--- Speedup ---")
|
|
1888
|
+
LOGGER.info(f" Geomean : {summary['geomean_speedup']:.2f}x ← 主指标")
|
|
1889
|
+
LOGGER.info(f" Mean : {summary['mean_speedup']:.2f}x")
|
|
1890
|
+
LOGGER.info(f" Median : {summary['median_speedup']:.2f}x")
|
|
1891
|
+
LOGGER.info(f" Min/Max : {summary['min_speedup']:.2f}x / {summary['max_speedup']:.2f}x")
|
|
1892
|
+
LOGGER.info(f" Valid : {len(speedups)}/{n_cases}")
|
|
1893
|
+
else:
|
|
1894
|
+
LOGGER.info("--- Speedup ---")
|
|
1895
|
+
LOGGER.info(" (N/A: 无双侧均有效的 case —— --impl 单边采集或双侧测量失败)")
|
|
1896
|
+
# 单边采集(--impl ref/asc)时只渲染已测到的一侧,未测的一侧不出现
|
|
1897
|
+
if summary.get("mean_ref_us") is not None:
|
|
1898
|
+
LOGGER.info("--- Task Duration (us) ---")
|
|
1899
|
+
LOGGER.info(
|
|
1900
|
+
f" Ref mean/median/geomean/total : {summary['mean_ref_us']:.2f} / "
|
|
1901
|
+
f"{summary['median_ref_us']:.2f} / {summary['geomean_ref_us']:.2f} / "
|
|
1902
|
+
f"{summary['total_ref_us']:.2f}"
|
|
1903
|
+
)
|
|
1904
|
+
if summary.get("mean_asc_us") is not None:
|
|
1905
|
+
LOGGER.info(
|
|
1906
|
+
f" Asc mean/median/geomean/total : {summary['mean_asc_us']:.2f} / "
|
|
1907
|
+
f"{summary['median_asc_us']:.2f} / {summary['geomean_asc_us']:.2f} / "
|
|
1908
|
+
f"{summary['total_asc_us']:.2f}"
|
|
1909
|
+
)
|
|
1910
|
+
if summary.get("total_speedup") is not None:
|
|
1911
|
+
LOGGER.info(f" Total speedup (Σref/Σasc) : {summary['total_speedup']:.2f}x")
|
|
1912
|
+
LOGGER.info("=" * 100)
|
|
1913
|
+
|
|
1914
|
+
# 保存 JSON 报告
|
|
1915
|
+
json_path = out_dir / "performance.json"
|
|
1916
|
+
with open(json_path, "w", encoding="utf-8") as f:
|
|
1917
|
+
json.dump(summary, f, indent=2, ensure_ascii=False)
|
|
1918
|
+
LOGGER.info(f"\n[INFO] JSON report saved to: {json_path}")
|
|
1919
|
+
|
|
1920
|
+
# 保存打屏日志
|
|
1921
|
+
log_path = out_dir / "performance.log"
|
|
1922
|
+
with open(log_path, "w", encoding="utf-8") as f:
|
|
1923
|
+
f.write(_report_compare_to_text(summary))
|
|
1924
|
+
LOGGER.info(f"[INFO] Console report saved to: {log_path}")
|
|
1925
|
+
|
|
1926
|
+
# 保存 Markdown 报告
|
|
1927
|
+
md_path = out_dir / "perf_report.md"
|
|
1928
|
+
md = _report_compare_to_markdown(summary)
|
|
1929
|
+
with open(md_path, "w", encoding="utf-8") as f:
|
|
1930
|
+
f.write(md)
|
|
1931
|
+
LOGGER.info(f"[INFO] Markdown report saved to: {md_path}")
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
def _load_compare_cases(out_dir):
|
|
1935
|
+
"""Load test cases from jsonl or json files in the output directory."""
|
|
1936
|
+
cases, case_source = _load_cases_jsonl(out_dir)
|
|
1937
|
+
if not cases:
|
|
1938
|
+
cases, case_source = _load_cases_json(out_dir)
|
|
1939
|
+
return cases, case_source
|
|
1940
|
+
|
|
1941
|
+
|
|
1942
|
+
def _log_compare_header(out_dir, args):
|
|
1943
|
+
"""Log the compare mode header."""
|
|
1944
|
+
LOGGER.info("=" * 100)
|
|
1945
|
+
LOGGER.info(f"Kernel-level Performance (msprof): {out_dir.name} "
|
|
1946
|
+
f"(warmup={args.warmup}, repeats={args.repeats}, seed={args.seed})")
|
|
1947
|
+
LOGGER.info("=" * 100)
|
|
1948
|
+
LOGGER.info(f"{'Case':<5} {'Shape':<35} {'dtype':<10} {'Ref(us)':>12} {'Asc(us)':>12} {'Speedup':>10}")
|
|
1949
|
+
LOGGER.info("-" * 100)
|
|
1950
|
+
|
|
1951
|
+
|
|
1952
|
+
_PROF_TAG_RE = re.compile(r"^[A-Za-z0-9_.-]+$")
|
|
1953
|
+
# 与 _measure_one_impl* 中硬编码的 /tmp/msprof_* 前缀保持一致;
|
|
1954
|
+
# 不用 tempfile.gettempdir(),避免 TMPDIR 环境变量改写导致误拒清理。
|
|
1955
|
+
_TMP_ROOT = os.path.realpath("/tmp")
|
|
1956
|
+
|
|
1957
|
+
|
|
1958
|
+
def _cleanup_prof_dirs(*dirs):
|
|
1959
|
+
"""Remove profiling directories if they exist.
|
|
1960
|
+
|
|
1961
|
+
防御:删除前先 realpath 解析,确认目标位于临时目录根下且不是根本身,
|
|
1962
|
+
才允许删除。prof_tag 等用户输入会拼进目录名,防止路径逃逸导致误删。
|
|
1963
|
+
"""
|
|
1964
|
+
for d in dirs:
|
|
1965
|
+
if not d:
|
|
1966
|
+
continue
|
|
1967
|
+
real = os.path.realpath(d)
|
|
1968
|
+
if real == _TMP_ROOT or os.path.commonpath([real, _TMP_ROOT]) != _TMP_ROOT:
|
|
1969
|
+
LOGGER.warning("Refusing to remove %s: not under %s", real, _TMP_ROOT)
|
|
1970
|
+
continue
|
|
1971
|
+
if os.path.isdir(real):
|
|
1972
|
+
shutil.rmtree(real, ignore_errors=True)
|
|
1973
|
+
|
|
1974
|
+
|
|
1975
|
+
@dataclass
|
|
1976
|
+
class _LoopAccumulator:
|
|
1977
|
+
"""对比/快速模式共用的逐 case 统计累积器。
|
|
1978
|
+
|
|
1979
|
+
Args:
|
|
1980
|
+
args: argparse.Namespace(需含 keep_prof 属性)
|
|
1981
|
+
rows: 逐 case 的测量结果列表
|
|
1982
|
+
speedups: 有效 speedup 值列表
|
|
1983
|
+
ref_times: 参考实现耗时列表(us)
|
|
1984
|
+
asc_times: AscendC 实现耗时列表(us)
|
|
1985
|
+
|
|
1986
|
+
record() 统一完成双侧耗时累计、speedup 统计、日志输出、rows 登记与
|
|
1987
|
+
PROF 目录清理,对比/快速两个循环共用同一份逻辑。
|
|
1988
|
+
"""
|
|
1989
|
+
args: argparse.Namespace
|
|
1990
|
+
rows: List[Dict[str, Any]] = field(default_factory=list)
|
|
1991
|
+
speedups: List[float] = field(default_factory=list)
|
|
1992
|
+
ref_times: List[float] = field(default_factory=list)
|
|
1993
|
+
asc_times: List[float] = field(default_factory=list)
|
|
1994
|
+
|
|
1995
|
+
def record(self, idx, shape, dtype, ref_result, asc_result):
|
|
1996
|
+
"""累计单个 case 的测量结果。
|
|
1997
|
+
|
|
1998
|
+
ref_result/asc_result 为 _measure_one_impl(_quick) 返回的
|
|
1999
|
+
(duration_us, error, prof_dir) 三元组。
|
|
2000
|
+
|
|
2001
|
+
单侧失败或 --impl 单边采集时,仍累计已测到的一侧耗时,生成单边汇总;
|
|
2002
|
+
speedup 仅在双侧都有效时统计。
|
|
2003
|
+
"""
|
|
2004
|
+
ref_us, ref_err, ref_prof_dir = ref_result
|
|
2005
|
+
asc_us, asc_err, asc_prof_dir = asc_result
|
|
2006
|
+
|
|
2007
|
+
if ref_us is not None:
|
|
2008
|
+
self.ref_times.append(ref_us)
|
|
2009
|
+
if asc_us is not None and asc_us > 0:
|
|
2010
|
+
self.asc_times.append(asc_us)
|
|
2011
|
+
if ref_us is not None and asc_us is not None and asc_us > 0:
|
|
2012
|
+
sp = ref_us / asc_us
|
|
2013
|
+
self.speedups.append(sp)
|
|
2014
|
+
LOGGER.info(f"{idx:<5} {shape:<35} {dtype:<10} {ref_us:>12.2f} {asc_us:>12.2f} {sp:>9.3f}x")
|
|
2015
|
+
else:
|
|
2016
|
+
LOGGER.info(f"{idx:<5} {shape:<35} {dtype:<10} "
|
|
2017
|
+
f"{'N/A' if ref_us is None else f'{ref_us:.2f}':>12} "
|
|
2018
|
+
f"{'N/A' if asc_us is None else f'{asc_us:.2f}':>12} "
|
|
2019
|
+
f"{'N/A':>10} (ref_err={ref_err}, asc_err={asc_err})")
|
|
2020
|
+
|
|
2021
|
+
self.rows.append({
|
|
2022
|
+
"case": idx, "shape": shape, "dtype": dtype,
|
|
2023
|
+
"ref_us": ref_us, "asc_us": asc_us,
|
|
2024
|
+
"speedup": (ref_us / asc_us) if (ref_us and asc_us and asc_us > 0) else None,
|
|
2025
|
+
"ref_error": ref_err,
|
|
2026
|
+
"asc_error": asc_err,
|
|
2027
|
+
"ref_prof_dir": ref_prof_dir,
|
|
2028
|
+
"asc_prof_dir": asc_prof_dir,
|
|
2029
|
+
})
|
|
2030
|
+
|
|
2031
|
+
if not self.args.keep_prof:
|
|
2032
|
+
_cleanup_prof_dirs(ref_prof_dir, asc_prof_dir)
|
|
2033
|
+
|
|
2034
|
+
|
|
2035
|
+
def _run_compare_loop(out_dir, cases, n_cases, args, device_id):
|
|
2036
|
+
"""Run the measurement loop over all cases. Returns rows and stats."""
|
|
2037
|
+
acc = _LoopAccumulator(args)
|
|
2038
|
+
|
|
2039
|
+
for idx in range(n_cases):
|
|
2040
|
+
shape, dtype = _extract_shape_dtype_from_jsonl(cases[idx]) if cases else ("?", "?")
|
|
2041
|
+
jsonl_case = cases[idx] if cases else None
|
|
2042
|
+
|
|
2043
|
+
if _case_has_empty_tensor(jsonl_case):
|
|
2044
|
+
LOGGER.info(f"{idx:<5} {shape:<35} {dtype:<10} "
|
|
2045
|
+
f"{'--':>12} {'--':>12} "
|
|
2046
|
+
f"{'skip':>10} (empty tensor)")
|
|
2047
|
+
acc.rows.append({
|
|
2048
|
+
"case": idx, "shape": shape, "dtype": dtype,
|
|
2049
|
+
"ref_us": None, "asc_us": None, "speedup": None,
|
|
2050
|
+
"ref_error": None, "asc_error": None,
|
|
2051
|
+
"skipped": "empty_tensor",
|
|
2052
|
+
})
|
|
2053
|
+
continue
|
|
2054
|
+
|
|
2055
|
+
ref_mi = _MeasureInput(out_dir, idx, "reference", args, device_id, jsonl_case)
|
|
2056
|
+
asc_mi = _MeasureInput(out_dir, idx, "ascendc", args, device_id, jsonl_case)
|
|
2057
|
+
ref_result = _measure_one_impl(ref_mi)
|
|
2058
|
+
asc_result = _measure_one_impl(asc_mi)
|
|
2059
|
+
|
|
2060
|
+
acc.record(idx, shape, dtype, ref_result, asc_result)
|
|
2061
|
+
|
|
2062
|
+
return acc.rows, acc.speedups, acc.ref_times, acc.asc_times
|
|
2063
|
+
|
|
2064
|
+
|
|
2065
|
+
def _run_quick_loop(out_dir, cases, n_cases, args, device_id):
|
|
2066
|
+
"""快速模式:Run the measurement loop over all cases (只跑 1 轮 msprof).
|
|
2067
|
+
|
|
2068
|
+
Returns rows and stats.
|
|
2069
|
+
"""
|
|
2070
|
+
acc = _LoopAccumulator(args)
|
|
2071
|
+
|
|
2072
|
+
sel = getattr(args, "cases", None)
|
|
2073
|
+
if sel:
|
|
2074
|
+
idx_list = [int(x) for x in str(sel).split(",") if x.strip() != ""]
|
|
2075
|
+
else:
|
|
2076
|
+
idx_list = list(range(n_cases))
|
|
2077
|
+
|
|
2078
|
+
for idx in idx_list:
|
|
2079
|
+
shape, dtype = _extract_shape_dtype_from_jsonl(cases[idx]) if cases else ("?", "?")
|
|
2080
|
+
jsonl_case = cases[idx] if cases else None
|
|
2081
|
+
|
|
2082
|
+
if _case_has_empty_tensor(jsonl_case):
|
|
2083
|
+
LOGGER.info(f"{idx:<5} {shape:<35} {dtype:<10} "
|
|
2084
|
+
f"{'--':>12} {'--':>12} "
|
|
2085
|
+
f"{'skip':>10} (empty tensor)")
|
|
2086
|
+
acc.rows.append({
|
|
2087
|
+
"case": idx, "shape": shape, "dtype": dtype,
|
|
2088
|
+
"ref_us": None, "asc_us": None, "speedup": None,
|
|
2089
|
+
"ref_error": None, "asc_error": None,
|
|
2090
|
+
"skipped": "empty_tensor",
|
|
2091
|
+
})
|
|
2092
|
+
continue
|
|
2093
|
+
|
|
2094
|
+
# 按 --impl 选择实现;单侧失败或单边采集时仍累计已测到的一侧耗时。
|
|
2095
|
+
which = getattr(args, "impl", "both")
|
|
2096
|
+
if which in ("both", "ref"):
|
|
2097
|
+
ref_mi = _MeasureInput(out_dir, idx, "reference", args, device_id, jsonl_case)
|
|
2098
|
+
ref_result = _measure_one_impl_quick(ref_mi)
|
|
2099
|
+
else:
|
|
2100
|
+
ref_result = (None, "skipped (--impl)", None)
|
|
2101
|
+
if which in ("both", "asc"):
|
|
2102
|
+
asc_mi = _MeasureInput(out_dir, idx, "ascendc", args, device_id, jsonl_case)
|
|
2103
|
+
asc_result = _measure_one_impl_quick(asc_mi)
|
|
2104
|
+
else:
|
|
2105
|
+
asc_result = (None, "skipped (--impl)", None)
|
|
2106
|
+
|
|
2107
|
+
acc.record(idx, shape, dtype, ref_result, asc_result)
|
|
2108
|
+
|
|
2109
|
+
return acc.rows, acc.speedups, acc.ref_times, acc.asc_times
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
def run_compare_mode(args):
|
|
2113
|
+
"""执行对比模式:model.py vs model_new_ascendc.py"""
|
|
2114
|
+
out_dir = Path(args.output_dir).resolve()
|
|
2115
|
+
|
|
2116
|
+
device_id, device_src = _select_device_id(args)
|
|
2117
|
+
LOGGER.info(f"[INFO] Using NPU device {device_id} (source={device_src})")
|
|
2118
|
+
|
|
2119
|
+
cases, case_source = _load_compare_cases(out_dir)
|
|
2120
|
+
n_cases = len(cases)
|
|
2121
|
+
if case_source:
|
|
2122
|
+
LOGGER.info(f"[INFO] Loaded {n_cases} cases from {case_source}")
|
|
2123
|
+
|
|
2124
|
+
_log_compare_header(out_dir, args)
|
|
2125
|
+
rows, speedups, ref_times, asc_times = _run_compare_loop(
|
|
2126
|
+
out_dir, cases, n_cases, args, device_id)
|
|
2127
|
+
|
|
2128
|
+
csi = _CompareSummaryInput(
|
|
2129
|
+
out_dir, rows, speedups, ref_times, asc_times, n_cases, args, device_id, device_src)
|
|
2130
|
+
summary = _compute_compare_summary(csi)
|
|
2131
|
+
_log_and_save_compare_reports(summary, out_dir, speedups, n_cases)
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
def run_quick_mode(args):
|
|
2135
|
+
"""执行快速模式:model.py vs model_new_ascendc.py(只跑 1 轮 msprof,不采集 7 个 metrics)"""
|
|
2136
|
+
out_dir = Path(args.output_dir).resolve()
|
|
2137
|
+
|
|
2138
|
+
device_id, device_src = _select_device_id(args)
|
|
2139
|
+
LOGGER.info(f"[INFO] Using NPU device {device_id} (source={device_src})")
|
|
2140
|
+
LOGGER.info("[INFO] Quick mode: 1-round profiling (no aic-metrics)")
|
|
2141
|
+
|
|
2142
|
+
cases, case_source = _load_compare_cases(out_dir)
|
|
2143
|
+
n_cases = len(cases)
|
|
2144
|
+
if case_source:
|
|
2145
|
+
LOGGER.info(f"[INFO] Loaded {n_cases} cases from {case_source}")
|
|
2146
|
+
|
|
2147
|
+
max_cases = getattr(args, "max_cases", 0)
|
|
2148
|
+
if max_cases and max_cases < n_cases:
|
|
2149
|
+
n_cases = max_cases
|
|
2150
|
+
LOGGER.info(f"[INFO] --max-cases: limiting to first {n_cases} cases")
|
|
2151
|
+
|
|
2152
|
+
LOGGER.info(f"[INFO] in-process warmup={args.warmup}, timed repeats={args.repeats}, "
|
|
2153
|
+
f"ext-warmup={getattr(args, 'ext_warmup', 0)}, impl={getattr(args, 'impl', 'both')}")
|
|
2154
|
+
_log_compare_header(out_dir, args)
|
|
2155
|
+
rows, speedups, ref_times, asc_times = _run_quick_loop(
|
|
2156
|
+
out_dir, cases, n_cases, args, device_id)
|
|
2157
|
+
|
|
2158
|
+
csi = _CompareSummaryInput(
|
|
2159
|
+
out_dir, rows, speedups, ref_times, asc_times, n_cases, args, device_id, device_src)
|
|
2160
|
+
summary = _compute_compare_summary(csi)
|
|
2161
|
+
summary["timing_method"] = "msprof.quick.Task_Duration"
|
|
2162
|
+
summary["profiling_mode"] = "quick"
|
|
2163
|
+
_log_and_save_compare_reports(summary, out_dir, speedups, n_cases)
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
# ============================================================================
|
|
2167
|
+
# 批量模式:扫描多个算子目录,汇总报告
|
|
2168
|
+
# ============================================================================
|
|
2169
|
+
|
|
2170
|
+
def _is_valid_table_row(line: str) -> bool:
|
|
2171
|
+
return line.startswith('|') and 'Level' not in line and '---' not in line and len(line) > 5
|
|
2172
|
+
|
|
2173
|
+
|
|
2174
|
+
def _extract_trace_table_rows(trace_file_path: str) -> List[str]:
|
|
2175
|
+
if not os.path.exists(trace_file_path):
|
|
2176
|
+
return []
|
|
2177
|
+
try:
|
|
2178
|
+
with open(trace_file_path, 'r', encoding='utf-8') as f:
|
|
2179
|
+
content = f.read()
|
|
2180
|
+
except Exception:
|
|
2181
|
+
return []
|
|
2182
|
+
start_idx = content.find('## 汇总表报告')
|
|
2183
|
+
if start_idx == -1:
|
|
2184
|
+
return []
|
|
2185
|
+
section_content = content[start_idx:]
|
|
2186
|
+
lines = section_content.split('\n')
|
|
2187
|
+
valid_rows = []
|
|
2188
|
+
for line in lines:
|
|
2189
|
+
line = line.strip()
|
|
2190
|
+
if _is_valid_table_row(line):
|
|
2191
|
+
valid_rows.append(line)
|
|
2192
|
+
return valid_rows
|
|
2193
|
+
|
|
2194
|
+
|
|
2195
|
+
def _load_performance_json(op_dir: Path) -> Optional[Dict[str, Any]]:
|
|
2196
|
+
perf_json = op_dir / "performance.json"
|
|
2197
|
+
if perf_json.exists():
|
|
2198
|
+
try:
|
|
2199
|
+
with open(perf_json, "r", encoding="utf-8") as f:
|
|
2200
|
+
return json.load(f)
|
|
2201
|
+
except Exception as e:
|
|
2202
|
+
LOGGER.warning("Failed to load performance.json from %s: %s", op_dir, e)
|
|
2203
|
+
return None
|
|
2204
|
+
|
|
2205
|
+
|
|
2206
|
+
def _build_batch_md_summary_table(op_results):
|
|
2207
|
+
"""Build the batch summary table markdown lines."""
|
|
2208
|
+
md_lines = []
|
|
2209
|
+
if op_results:
|
|
2210
|
+
md_lines.append("## 性能汇总")
|
|
2211
|
+
md_lines.append("")
|
|
2212
|
+
md_lines.append(
|
|
2213
|
+
"| 算子名称 | 用例数 | 有效用例 | 几何平均加速比 | 平均加速比 | 状态 |"
|
|
2214
|
+
)
|
|
2215
|
+
md_lines.append("| -------- | ------ | -------- | -------------- | ---------- | ---- |")
|
|
2216
|
+
for op in op_results:
|
|
2217
|
+
data = op["data"]
|
|
2218
|
+
name = op["name"]
|
|
2219
|
+
n_total = data.get("n_cases_total", 0)
|
|
2220
|
+
n_valid = data.get("n_cases_valid", 0)
|
|
2221
|
+
geo = data.get("geomean_speedup")
|
|
2222
|
+
mean = data.get("mean_speedup")
|
|
2223
|
+
geo_str = f"{geo:.3f}" if geo is not None else "N/A"
|
|
2224
|
+
mean_str = f"{mean:.3f}" if mean is not None else "N/A"
|
|
2225
|
+
status = "✅" if geo is not None and geo > 1 else "⚠️" if geo is not None else "❌"
|
|
2226
|
+
md_lines.append(f"| {name} | {n_total} | {n_valid} | {geo_str} | {mean_str} | {status} |")
|
|
2227
|
+
md_lines.append("")
|
|
2228
|
+
return md_lines
|
|
2229
|
+
|
|
2230
|
+
|
|
2231
|
+
def _build_batch_md_per_op_details(op_results):
|
|
2232
|
+
"""Build per-operator detail tables in markdown."""
|
|
2233
|
+
md_lines = []
|
|
2234
|
+
for op in op_results:
|
|
2235
|
+
data = op["data"]
|
|
2236
|
+
name = op["name"]
|
|
2237
|
+
md_lines.append(f"## {name}")
|
|
2238
|
+
md_lines.append("")
|
|
2239
|
+
if data.get("per_case"):
|
|
2240
|
+
md_lines.append("| Case | Shape | DType | 自定义算子(us) | 标杆(us) | 加速比 |")
|
|
2241
|
+
md_lines.append("| ---- | ----- | ----- | ------------- | -------- | -------------- |")
|
|
2242
|
+
for case in data["per_case"]:
|
|
2243
|
+
shape = case.get("shape", "?")
|
|
2244
|
+
dtype = case.get("dtype", "?")
|
|
2245
|
+
ref = case.get("ref_us")
|
|
2246
|
+
asc = case.get("asc_us")
|
|
2247
|
+
sp = case.get("speedup")
|
|
2248
|
+
ref_str = f"{ref:.2f}" if ref is not None else "N/A"
|
|
2249
|
+
asc_str = f"{asc:.2f}" if asc is not None else "N/A"
|
|
2250
|
+
sp_str = f"{sp:.3f}" if sp is not None else "N/A"
|
|
2251
|
+
md_lines.append(f"| {case['case']} | {shape} | {dtype} | {asc_str} | {ref_str} | {sp_str} |")
|
|
2252
|
+
md_lines.append("")
|
|
2253
|
+
return md_lines
|
|
2254
|
+
|
|
2255
|
+
|
|
2256
|
+
def _build_batch_md_trace_section(trace_rows):
|
|
2257
|
+
"""Build trace table section in markdown if rows exist."""
|
|
2258
|
+
if not trace_rows:
|
|
2259
|
+
return []
|
|
2260
|
+
md_lines = [
|
|
2261
|
+
"## Trace 汇总表",
|
|
2262
|
+
"",
|
|
2263
|
+
("| Level | Problem ID | 算子名称 | 算子类型 | 编译通过 | 精度正确 | "
|
|
2264
|
+
"PyTorch 参考延迟 | 生成AscendC代码延迟 | 加速比 | 最终状态 | "
|
|
2265
|
+
"精度正确 | 性能0.6x pytorch | 性能0.8x pytorch |"),
|
|
2266
|
+
"| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |",
|
|
2267
|
+
]
|
|
2268
|
+
md_lines.extend(trace_rows)
|
|
2269
|
+
md_lines.append("")
|
|
2270
|
+
return md_lines
|
|
2271
|
+
|
|
2272
|
+
|
|
2273
|
+
def _generate_batch_md_report(args, op_results, trace_rows, base_dir):
|
|
2274
|
+
"""Generate and save the batch Markdown report."""
|
|
2275
|
+
md_lines = []
|
|
2276
|
+
md_lines.append("# 📊 算子批量性能汇总报告")
|
|
2277
|
+
md_lines.append("")
|
|
2278
|
+
md_lines.append(f"- **扫描目录**: {base_dir}")
|
|
2279
|
+
md_lines.append(f"- **算子总数**: {len(op_results)}")
|
|
2280
|
+
md_lines.append(f"- **生成时间**: {time.strftime('%Y-%m-%d %H:%M:%S')}")
|
|
2281
|
+
md_lines.append("")
|
|
2282
|
+
|
|
2283
|
+
md_lines.extend(_build_batch_md_summary_table(op_results))
|
|
2284
|
+
md_lines.extend(_build_batch_md_per_op_details(op_results))
|
|
2285
|
+
md_lines.extend(_build_batch_md_trace_section(trace_rows))
|
|
2286
|
+
|
|
2287
|
+
md_path = Path(args.output_md)
|
|
2288
|
+
md_path.parent.mkdir(parents=True, exist_ok=True)
|
|
2289
|
+
with open(md_path, "w", encoding="utf-8") as f:
|
|
2290
|
+
f.write("\n".join(md_lines))
|
|
2291
|
+
LOGGER.info("Batch markdown report saved to: %s", md_path)
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
def _generate_batch_json_report(args, op_results, base_dir):
|
|
2295
|
+
"""Generate and save the batch JSON summary."""
|
|
2296
|
+
batch_summary = {
|
|
2297
|
+
"base_dir": str(base_dir),
|
|
2298
|
+
"n_operators": len(op_results),
|
|
2299
|
+
"operators": [
|
|
2300
|
+
{
|
|
2301
|
+
"name": op["name"],
|
|
2302
|
+
"n_cases_total": op["data"].get("n_cases_total", 0),
|
|
2303
|
+
"n_cases_valid": op["data"].get("n_cases_valid", 0),
|
|
2304
|
+
"geomean_speedup": op["data"].get("geomean_speedup"),
|
|
2305
|
+
"mean_speedup": op["data"].get("mean_speedup"),
|
|
2306
|
+
"mean_ref_us": op["data"].get("mean_ref_us"),
|
|
2307
|
+
"mean_asc_us": op["data"].get("mean_asc_us"),
|
|
2308
|
+
}
|
|
2309
|
+
for op in op_results
|
|
2310
|
+
],
|
|
2311
|
+
"generated_at": time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
2312
|
+
}
|
|
2313
|
+
json_path = Path(args.output_json)
|
|
2314
|
+
json_path.parent.mkdir(parents=True, exist_ok=True)
|
|
2315
|
+
with open(json_path, "w", encoding="utf-8") as f:
|
|
2316
|
+
json.dump(batch_summary, f, indent=2, ensure_ascii=False)
|
|
2317
|
+
LOGGER.info("Batch JSON summary saved to: %s", json_path)
|
|
2318
|
+
|
|
2319
|
+
|
|
2320
|
+
def run_batch_mode(args):
|
|
2321
|
+
"""执行批量模式:扫描 base_dir 下所有子目录,汇总性能报告。"""
|
|
2322
|
+
base_dir = Path(args.batch).resolve()
|
|
2323
|
+
|
|
2324
|
+
if not base_dir.is_dir():
|
|
2325
|
+
raise ValueError("'%s' is not a directory." % base_dir)
|
|
2326
|
+
|
|
2327
|
+
# 收集所有子目录的 performance.json
|
|
2328
|
+
op_results = []
|
|
2329
|
+
for subdir in sorted(base_dir.iterdir()):
|
|
2330
|
+
if not subdir.is_dir():
|
|
2331
|
+
continue
|
|
2332
|
+
perf_data = _load_performance_json(subdir)
|
|
2333
|
+
if perf_data:
|
|
2334
|
+
op_results.append({
|
|
2335
|
+
"name": subdir.name,
|
|
2336
|
+
"data": perf_data,
|
|
2337
|
+
"dir": subdir,
|
|
2338
|
+
})
|
|
2339
|
+
|
|
2340
|
+
# 同时收集 trace.md 中的表格行(兼容旧 batch_report.py 功能)
|
|
2341
|
+
trace_rows = []
|
|
2342
|
+
for subdir in sorted(base_dir.iterdir()):
|
|
2343
|
+
if not subdir.is_dir():
|
|
2344
|
+
continue
|
|
2345
|
+
trace_file = subdir / "trace.md"
|
|
2346
|
+
if trace_file.exists():
|
|
2347
|
+
rows = _extract_trace_table_rows(str(trace_file))
|
|
2348
|
+
trace_rows.extend(rows)
|
|
2349
|
+
|
|
2350
|
+
LOGGER.info("Found %d operators with performance.json in %s", len(op_results), base_dir)
|
|
2351
|
+
|
|
2352
|
+
if args.output_md:
|
|
2353
|
+
_generate_batch_md_report(args, op_results, trace_rows, base_dir)
|
|
2354
|
+
|
|
2355
|
+
if args.output_json:
|
|
2356
|
+
_generate_batch_json_report(args, op_results, base_dir)
|
|
2357
|
+
|
|
2358
|
+
|
|
2359
|
+
# ============================================================================
|
|
2360
|
+
# 主入口
|
|
2361
|
+
# ============================================================================
|
|
2362
|
+
|
|
2363
|
+
def _run_standard_mode(args):
|
|
2364
|
+
"""Execute standard mode: parse PROF_GROUP and generate summary."""
|
|
2365
|
+
group_dir = os.path.abspath(args.prof_group_dir)
|
|
2366
|
+
ops_dir = os.path.abspath(args.ops_dir)
|
|
2367
|
+
|
|
2368
|
+
if not os.path.isdir(group_dir):
|
|
2369
|
+
raise ValueError("'%s' is not a directory." % group_dir)
|
|
2370
|
+
if not os.path.isdir(ops_dir):
|
|
2371
|
+
raise ValueError("'%s' is not a directory." % ops_dir)
|
|
2372
|
+
|
|
2373
|
+
merged = merge_metric_rows(group_dir, args.op_name)
|
|
2374
|
+
if not merged.get("Op Name"):
|
|
2375
|
+
raise ValueError("no op_summary_*.csv rows discovered under %s" % group_dir)
|
|
2376
|
+
|
|
2377
|
+
perf_dir = os.path.join(ops_dir, "docs", "perf")
|
|
2378
|
+
round_dir = os.path.join(perf_dir, args.round_name) if args.round_name else find_next_round(perf_dir)
|
|
2379
|
+
|
|
2380
|
+
copied = archive_csvs(group_dir, round_dir)
|
|
2381
|
+
pc_csv = archive_per_core_csv(group_dir, round_dir)
|
|
2382
|
+
if pc_csv:
|
|
2383
|
+
copied.append(os.path.basename(pc_csv))
|
|
2384
|
+
LOGGER.info("Archived %d CSV files to: %s", len(copied), round_dir)
|
|
2385
|
+
|
|
2386
|
+
summary = generate_summary(merged, round_dir, group_dir)
|
|
2387
|
+
summary_path = os.path.join(round_dir, "summary.txt")
|
|
2388
|
+
with open(summary_path, "w", encoding="utf-8") as f:
|
|
2389
|
+
f.write(summary)
|
|
2390
|
+
|
|
2391
|
+
LOGGER.info("Summary written to: %s", summary_path)
|
|
2392
|
+
LOGGER.info("\n%s", summary)
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
def _build_arg_parser():
|
|
2396
|
+
"""构建命令行参数解析器(标准/对比/批量三种模式)。"""
|
|
2397
|
+
parser = argparse.ArgumentParser(description="msprof 解析 & 归档 & 对比测试脚本(统一入口)")
|
|
2398
|
+
|
|
2399
|
+
# 标准模式参数
|
|
2400
|
+
parser.add_argument("prof_group_dir", nargs="?", help="PROF_GROUP_<timestamp> directory")
|
|
2401
|
+
parser.add_argument("ops_dir", nargs="?", help="Operator directory")
|
|
2402
|
+
parser.add_argument("--op-name", default=None, help="Exact Op Name to pick in op_summary.csv")
|
|
2403
|
+
parser.add_argument("--round-name", default=None, help="Override round directory name")
|
|
2404
|
+
|
|
2405
|
+
# 对比模式参数
|
|
2406
|
+
parser.add_argument("--compare", action="store_true", help="启用对比模式(8 轮采集:7 metrics + sample)")
|
|
2407
|
+
parser.add_argument("--quick", action="store_true", help="启用快速模式(1 轮采集:只获取 kernel 时间,不采集 7 个 aic-metrics)")
|
|
2408
|
+
parser.add_argument("--output-dir", dest="output_dir", help="算子输出目录(对比模式/快速模式)")
|
|
2409
|
+
parser.add_argument("--warmup", type=int, default=3,
|
|
2410
|
+
help="quick 模式:被采集进程内的预热迭代次数(解析时丢弃)")
|
|
2411
|
+
parser.add_argument("--repeats", type=int, default=1,
|
|
2412
|
+
help="quick 模式:被采集进程内的计时迭代次数(解析时取均值)")
|
|
2413
|
+
parser.add_argument("--ext-warmup", dest="ext_warmup", type=int, default=0,
|
|
2414
|
+
help="旧行为:在 msprof 外部另起进程预热的次数(对被采集进程无预热效果,默认 0)")
|
|
2415
|
+
parser.add_argument("--impl", choices=["both", "ref", "asc"], default="both",
|
|
2416
|
+
help="quick 模式只采集指定实现(ref=参考实现,asc=AscendC 实现)")
|
|
2417
|
+
parser.add_argument("--max-cases", dest="max_cases", type=int, default=0,
|
|
2418
|
+
help="quick 模式只跑前 N 个 case(0=全部,用于冒烟测试)")
|
|
2419
|
+
parser.add_argument("--cases", default=None,
|
|
2420
|
+
help="quick 模式只跑指定 case 下标,逗号分隔,如 0,4,9,18(优先于 --max-cases)")
|
|
2421
|
+
parser.add_argument("--prof-tag", dest="prof_tag", default=None,
|
|
2422
|
+
help="PROF 临时目录后缀,用于同一 case 多次独立采集互不覆盖")
|
|
2423
|
+
parser.add_argument("--seed", type=int, default=0, help="随机种子")
|
|
2424
|
+
parser.add_argument("--retry", type=int, default=2, help="单 case 解析失败重试次数")
|
|
2425
|
+
parser.add_argument("--device", type=int, default=None, help="NPU 设备 id")
|
|
2426
|
+
parser.add_argument("--keep-prof", action="store_true", help="保留 msprof 原始 PROF 目录")
|
|
2427
|
+
|
|
2428
|
+
# 批量模式参数
|
|
2429
|
+
parser.add_argument("--batch", metavar="BASE_DIR", help="启用批量模式,指定根目录")
|
|
2430
|
+
parser.add_argument("--output-md", help="批量模式 Markdown 输出路径")
|
|
2431
|
+
parser.add_argument("--output-json", help="批量模式 JSON 输出路径")
|
|
2432
|
+
return parser
|
|
2433
|
+
|
|
2434
|
+
|
|
2435
|
+
def _run_or_exit(run_fn, args) -> int:
|
|
2436
|
+
"""执行模式函数,ValueError(参数/输入不合法)时打日志并返回退出码 1。"""
|
|
2437
|
+
try:
|
|
2438
|
+
run_fn(args)
|
|
2439
|
+
except ValueError as e:
|
|
2440
|
+
LOGGER.error("%s", e)
|
|
2441
|
+
return 1
|
|
2442
|
+
return 0
|
|
2443
|
+
|
|
2444
|
+
|
|
2445
|
+
def main() -> int:
|
|
2446
|
+
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
|
2447
|
+
parser = _build_arg_parser()
|
|
2448
|
+
args = parser.parse_args()
|
|
2449
|
+
|
|
2450
|
+
# 模式路由
|
|
2451
|
+
if args.compare:
|
|
2452
|
+
if not args.output_dir:
|
|
2453
|
+
parser.error("--compare 模式必须指定 --output-dir")
|
|
2454
|
+
run_compare_mode(args)
|
|
2455
|
+
return 0
|
|
2456
|
+
if args.quick:
|
|
2457
|
+
if not args.output_dir:
|
|
2458
|
+
parser.error("--quick 模式必须指定 --output-dir")
|
|
2459
|
+
run_quick_mode(args)
|
|
2460
|
+
return 0
|
|
2461
|
+
if args.batch:
|
|
2462
|
+
return _run_or_exit(run_batch_mode, args)
|
|
2463
|
+
if not args.prof_group_dir or not args.ops_dir:
|
|
2464
|
+
parser.error("标准模式需要 prof_group_dir 和 ops_dir 参数")
|
|
2465
|
+
return _run_or_exit(_run_standard_mode, args)
|
|
2466
|
+
|
|
2467
|
+
|
|
2468
|
+
if __name__ == "__main__":
|
|
2469
|
+
sys.exit(main())
|