@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,1931 @@
|
|
|
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
|
+
公共工具函数模块
|
|
13
|
+
|
|
14
|
+
功能:
|
|
15
|
+
1. dtype字符串映射与规范化
|
|
16
|
+
2. dtype可转换性计算
|
|
17
|
+
3. dtype可推导组合计算
|
|
18
|
+
4. dtype推导计算
|
|
19
|
+
5. Shape broadcast关系计算
|
|
20
|
+
6. Shape broadcast结果计算
|
|
21
|
+
7. 随机Shape生成(基于对数分段)
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from typing import List, Set, Optional, Union, Tuple
|
|
25
|
+
import itertools
|
|
26
|
+
import random
|
|
27
|
+
import math
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# ==================== dtype 映射定义 ====================
|
|
31
|
+
|
|
32
|
+
# dtype 标准名称到各种别名的映射
|
|
33
|
+
DTYPE_ALIASES: dict = {
|
|
34
|
+
"float32": ["float32", "float", "acl_float", "FLOAT", "FLOAT32", "f32"],
|
|
35
|
+
"float16": ["float16", "acl_float16", "FLOAT16", "FP16", "fp16", "half", "f16"],
|
|
36
|
+
"bfloat16": ["bfloat16", "acl_bf16", "BF16", "bf16", "ACL_BF16"],
|
|
37
|
+
"float64": ["float64", "double", "acl_double", "DOUBLE", "FLOAT64", "f64"],
|
|
38
|
+
"int8": ["int8", "acl_int8", "INT8", "i8", "s8"],
|
|
39
|
+
"uint8": ["uint8", "acl_uint8", "UINT8", "u8"],
|
|
40
|
+
"int16": ["int16", "acl_int16", "INT16", "i16", "s16"],
|
|
41
|
+
"uint16": ["uint16", "acl_uint16", "UINT16", "u16"],
|
|
42
|
+
"int32": ["int32", "acl_int32", "INT32", "i32", "s32"],
|
|
43
|
+
"uint32": ["uint32", "acl_uint32", "UINT32", "u32"],
|
|
44
|
+
"int64": ["int64", "acl_int64", "INT64", "i64", "s64"],
|
|
45
|
+
"uint64": ["uint64", "acl_uint64", "UINT64", "u64"],
|
|
46
|
+
"bool": ["bool", "acl_bool", "BOOL", "boolean"],
|
|
47
|
+
"complex32": ["complex32", "acl_complex32", "COMPLEX32", "c32"],
|
|
48
|
+
"complex64": ["complex64", "acl_complex64", "COMPLEX64", "c64"],
|
|
49
|
+
"complex128": ["complex128", "acl_complex128", "COMPLEX128", "c128"],
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# 反向映射:别名 -> 标准名称
|
|
53
|
+
_ALIAS_TO_STANDARD: dict = {}
|
|
54
|
+
_STANDARD_DTYPES: set = set()
|
|
55
|
+
|
|
56
|
+
for standard, aliases in DTYPE_ALIASES.items():
|
|
57
|
+
_STANDARD_DTYPES.add(standard)
|
|
58
|
+
for alias in aliases:
|
|
59
|
+
_ALIAS_TO_STANDARD[alias.lower()] = standard
|
|
60
|
+
_ALIAS_TO_STANDARD[alias] = standard
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def normalize_dtype(dtype_str: Optional[Union[str, int]]) -> Optional[str]:
|
|
64
|
+
"""
|
|
65
|
+
将dtype字符串映射为标准名称
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
dtype_str: dtype字符串,可以是各种格式
|
|
69
|
+
- "FLOAT" / "float" / "FLOAT32" / "float32" -> "float32"
|
|
70
|
+
- "FLOAT16" / "float16" / "FP16" -> "float16"
|
|
71
|
+
- "INT32" / "int32" -> "int32"
|
|
72
|
+
...
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
标准化的dtype名称,如果无法识别则返回 None
|
|
76
|
+
|
|
77
|
+
Examples:
|
|
78
|
+
>>> normalize_dtype("FLOAT")
|
|
79
|
+
'float32'
|
|
80
|
+
>>> normalize_dtype("float16")
|
|
81
|
+
'float16'
|
|
82
|
+
>>> normalize_dtype("INT32")
|
|
83
|
+
'int32'
|
|
84
|
+
>>> normalize_dtype("unknown")
|
|
85
|
+
None
|
|
86
|
+
"""
|
|
87
|
+
if dtype_str is None:
|
|
88
|
+
return None
|
|
89
|
+
|
|
90
|
+
if isinstance(dtype_str, int):
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
dtype_str = str(dtype_str).strip()
|
|
94
|
+
|
|
95
|
+
result = _ALIAS_TO_STANDARD.get(dtype_str)
|
|
96
|
+
if result:
|
|
97
|
+
return result
|
|
98
|
+
|
|
99
|
+
return _ALIAS_TO_STANDARD.get(dtype_str.lower())
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def normalize_dtype_list(dtype_list: List[str]) -> List[str]:
|
|
103
|
+
"""
|
|
104
|
+
批量规范化dtype列表
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
dtype_list: dtype字符串列表
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
规范化后的dtype列表(过滤掉无法识别的)
|
|
111
|
+
|
|
112
|
+
Examples:
|
|
113
|
+
>>> normalize_dtype_list(["FLOAT", "FLOAT16", "INT32"])
|
|
114
|
+
['float32', 'float16', 'int32']
|
|
115
|
+
"""
|
|
116
|
+
result: List[str] = []
|
|
117
|
+
for dtype_str in dtype_list:
|
|
118
|
+
normalized = normalize_dtype(dtype_str)
|
|
119
|
+
if normalized is not None:
|
|
120
|
+
result.append(normalized)
|
|
121
|
+
return result
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# ==================== dtype 类型分类 ====================
|
|
125
|
+
|
|
126
|
+
# 整数类型集合(标准名称)
|
|
127
|
+
INTEGER_DTYPES: Set[str] = {
|
|
128
|
+
"int8",
|
|
129
|
+
"uint8",
|
|
130
|
+
"int16",
|
|
131
|
+
"uint16",
|
|
132
|
+
"int32",
|
|
133
|
+
"uint32",
|
|
134
|
+
"int64",
|
|
135
|
+
"uint64",
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# 浮点类型集合(标准名称)
|
|
139
|
+
FLOAT_DTYPES: Set[str] = {"float16", "float32", "float64", "bfloat16"}
|
|
140
|
+
|
|
141
|
+
# 复数类型集合(标准名称)
|
|
142
|
+
COMPLEX_DTYPES: Set[str] = {"complex32", "complex64", "complex128"}
|
|
143
|
+
|
|
144
|
+
# BOOL类型
|
|
145
|
+
BOOL_DTYPE: str = "bool"
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def get_dtype_category(dtype: Optional[str]) -> Optional[str]:
|
|
149
|
+
"""
|
|
150
|
+
获取dtype的类型分类
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
dtype: dtype字符串(可以是各种格式,会自动规范化)
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
类型分类: "integer", "float", "complex", "bool" 或 None
|
|
157
|
+
"""
|
|
158
|
+
if dtype is None:
|
|
159
|
+
return None
|
|
160
|
+
|
|
161
|
+
normalized = normalize_dtype(dtype)
|
|
162
|
+
if normalized is None:
|
|
163
|
+
return None
|
|
164
|
+
|
|
165
|
+
if normalized in INTEGER_DTYPES:
|
|
166
|
+
return "integer"
|
|
167
|
+
elif normalized in FLOAT_DTYPES:
|
|
168
|
+
return "float"
|
|
169
|
+
elif normalized in COMPLEX_DTYPES:
|
|
170
|
+
return "complex"
|
|
171
|
+
elif normalized == BOOL_DTYPE:
|
|
172
|
+
return "bool"
|
|
173
|
+
|
|
174
|
+
return None
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
# ==================== dtype 可转换性计算 ====================
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def get_convertible_source_dtypes(
|
|
181
|
+
target_dtype: str, source_dtypes: List[str]
|
|
182
|
+
) -> List[str]:
|
|
183
|
+
"""
|
|
184
|
+
根据 dtype 可转换规则,从原始 dtype 列表中筛选出可转换为目标 dtype 的列表
|
|
185
|
+
|
|
186
|
+
可转换规则(参考:互转换关系.md):
|
|
187
|
+
1. 整数类型间可以转换,也支持往浮点、复数类型转换
|
|
188
|
+
2. 浮点类型间可以转换,也支持往复数类型转换
|
|
189
|
+
3. 复数类型间可以转换
|
|
190
|
+
4. BOOL支持往整数、浮点、复数类型转换
|
|
191
|
+
5. 其他场景不支持转换
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
target_dtype: 目标 dtype(需要转换到的类型)
|
|
195
|
+
source_dtypes: 原始支持的 dtype 列表
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
原始 dtype 列表中可转换为目标 dtype 的子列表
|
|
199
|
+
|
|
200
|
+
Examples:
|
|
201
|
+
>>> get_convertible_source_dtypes("float32", ["float32", "float16", "int32", "bool"])
|
|
202
|
+
['float32', 'float16', 'int32', 'bool']
|
|
203
|
+
|
|
204
|
+
>>> get_convertible_source_dtypes("float32", ["float16", "int32", "int64", "complex64"])
|
|
205
|
+
['float16', 'int32', 'int64']
|
|
206
|
+
|
|
207
|
+
>>> get_convertible_source_dtypes("int32", ["float32", "int8", "uint8", "bool"])
|
|
208
|
+
['int8', 'uint8', 'bool']
|
|
209
|
+
|
|
210
|
+
>>> get_convertible_source_dtypes("complex64", ["float16", "float32", "int32", "bool"])
|
|
211
|
+
['float16', 'float32', 'int32', 'bool']
|
|
212
|
+
|
|
213
|
+
>>> get_convertible_source_dtypes("bool", ["int32", "float32", "bool"])
|
|
214
|
+
['bool']
|
|
215
|
+
"""
|
|
216
|
+
target_normalized = normalize_dtype(target_dtype)
|
|
217
|
+
if target_normalized is None:
|
|
218
|
+
return []
|
|
219
|
+
|
|
220
|
+
normalized_sources = normalize_dtype_list(source_dtypes)
|
|
221
|
+
|
|
222
|
+
target_category = get_dtype_category(target_normalized)
|
|
223
|
+
if target_category is None:
|
|
224
|
+
return []
|
|
225
|
+
|
|
226
|
+
convertible: List[str] = []
|
|
227
|
+
|
|
228
|
+
for source_dtype in normalized_sources:
|
|
229
|
+
source_category = get_dtype_category(source_dtype)
|
|
230
|
+
|
|
231
|
+
if source_category is None:
|
|
232
|
+
continue
|
|
233
|
+
|
|
234
|
+
if _can_convert(
|
|
235
|
+
source_category, source_dtype, target_category, target_normalized
|
|
236
|
+
):
|
|
237
|
+
convertible.append(source_dtype)
|
|
238
|
+
|
|
239
|
+
return convertible
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def _can_convert(
|
|
243
|
+
source_category: str, source_dtype: str, target_category: str, target_dtype: str
|
|
244
|
+
) -> bool:
|
|
245
|
+
"""
|
|
246
|
+
判断源 dtype 是否可以转换到目标 dtype
|
|
247
|
+
|
|
248
|
+
Args:
|
|
249
|
+
source_category: 源 dtype 的类型分类
|
|
250
|
+
source_dtype: 源 dtype(已规范化)
|
|
251
|
+
target_category: 目标 dtype 的类型分类
|
|
252
|
+
target_dtype: 目标 dtype(已规范化)
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
是否可以转换
|
|
256
|
+
"""
|
|
257
|
+
if source_dtype == target_dtype:
|
|
258
|
+
return True
|
|
259
|
+
|
|
260
|
+
# 目标是整数:可以从整数、BOOL转换
|
|
261
|
+
if target_category == "integer":
|
|
262
|
+
return source_category in ("integer", "bool")
|
|
263
|
+
|
|
264
|
+
# 目标是浮点:可以从整数、浮点、BOOL转换
|
|
265
|
+
if target_category == "float":
|
|
266
|
+
return source_category in ("integer", "float", "bool")
|
|
267
|
+
|
|
268
|
+
# 目标是复数:可以从整数、浮点、复数、BOOL转换
|
|
269
|
+
if target_category == "complex":
|
|
270
|
+
return source_category in ("integer", "float", "complex", "bool")
|
|
271
|
+
|
|
272
|
+
# 目标是BOOL:只能从BOOL转换(BOOL不接收其他类型的转换)
|
|
273
|
+
if target_category == "bool":
|
|
274
|
+
return source_category == "bool"
|
|
275
|
+
|
|
276
|
+
return False
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def can_convert_dtype(source_dtype: str, target_dtype: str) -> bool:
|
|
280
|
+
"""
|
|
281
|
+
判断单个 dtype 是否可以转换到目标 dtype
|
|
282
|
+
|
|
283
|
+
Args:
|
|
284
|
+
source_dtype: 源 dtype
|
|
285
|
+
target_dtype: 目标 dtype
|
|
286
|
+
|
|
287
|
+
Returns:
|
|
288
|
+
是否可以转换
|
|
289
|
+
|
|
290
|
+
Examples:
|
|
291
|
+
>>> can_convert_dtype("int32", "float32")
|
|
292
|
+
True
|
|
293
|
+
>>> can_convert_dtype("float32", "int32")
|
|
294
|
+
False
|
|
295
|
+
>>> can_convert_dtype("bool", "float32")
|
|
296
|
+
True
|
|
297
|
+
>>> can_convert_dtype("float32", "bool")
|
|
298
|
+
False
|
|
299
|
+
"""
|
|
300
|
+
source_normalized = normalize_dtype(source_dtype)
|
|
301
|
+
target_normalized = normalize_dtype(target_dtype)
|
|
302
|
+
|
|
303
|
+
if source_normalized is None or target_normalized is None:
|
|
304
|
+
return False
|
|
305
|
+
|
|
306
|
+
source_category = get_dtype_category(source_normalized)
|
|
307
|
+
target_category = get_dtype_category(target_normalized)
|
|
308
|
+
|
|
309
|
+
if source_category is None or target_category is None:
|
|
310
|
+
return False
|
|
311
|
+
|
|
312
|
+
return _can_convert(
|
|
313
|
+
source_category, source_normalized, target_category, target_normalized
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
# ==================== dtype 推导相关 ====================
|
|
318
|
+
|
|
319
|
+
# dtype推导表(参考:互推导关系.md)
|
|
320
|
+
# 格式: (dtype1, dtype2) -> result_dtype
|
|
321
|
+
# None 表示不能推导
|
|
322
|
+
# 表格行/列顺序: f32, f16, f64, bf16, s8, u8, s16, u16, s32, u32, s64, u64, bool, c32, c64, c128
|
|
323
|
+
DTYPE_INFER_TABLE: dict = {
|
|
324
|
+
# f32 行
|
|
325
|
+
("float32", "float32"): "float32",
|
|
326
|
+
("float32", "float16"): "float32",
|
|
327
|
+
("float32", "float64"): "float64",
|
|
328
|
+
("float32", "bfloat16"): "float32",
|
|
329
|
+
("float32", "int8"): "float32",
|
|
330
|
+
("float32", "uint8"): "float32",
|
|
331
|
+
("float32", "int16"): "float32",
|
|
332
|
+
("float32", "uint16"): None,
|
|
333
|
+
("float32", "int32"): "float32",
|
|
334
|
+
("float32", "uint32"): None,
|
|
335
|
+
("float32", "int64"): "float32",
|
|
336
|
+
("float32", "uint64"): None,
|
|
337
|
+
("float32", "bool"): "float32",
|
|
338
|
+
("float32", "complex32"): "complex64",
|
|
339
|
+
("float32", "complex64"): "complex64",
|
|
340
|
+
("float32", "complex128"): "complex128",
|
|
341
|
+
# f16 行
|
|
342
|
+
("float16", "float32"): "float32",
|
|
343
|
+
("float16", "float16"): "float16",
|
|
344
|
+
("float16", "float64"): "float64",
|
|
345
|
+
("float16", "bfloat16"): "float32",
|
|
346
|
+
("float16", "int8"): "float16",
|
|
347
|
+
("float16", "uint8"): "float16",
|
|
348
|
+
("float16", "int16"): "float16",
|
|
349
|
+
("float16", "uint16"): None,
|
|
350
|
+
("float16", "int32"): "float16",
|
|
351
|
+
("float16", "uint32"): None,
|
|
352
|
+
("float16", "int64"): "float16",
|
|
353
|
+
("float16", "uint64"): None,
|
|
354
|
+
("float16", "bool"): "float16",
|
|
355
|
+
("float16", "complex32"): "complex32",
|
|
356
|
+
("float16", "complex64"): "complex64",
|
|
357
|
+
("float16", "complex128"): "complex128",
|
|
358
|
+
# f64 行
|
|
359
|
+
("float64", "float32"): "float64",
|
|
360
|
+
("float64", "float16"): "float64",
|
|
361
|
+
("float64", "float64"): "float64",
|
|
362
|
+
("float64", "bfloat16"): "float64",
|
|
363
|
+
("float64", "int8"): "float64",
|
|
364
|
+
("float64", "uint8"): "float64",
|
|
365
|
+
("float64", "int16"): "float64",
|
|
366
|
+
("float64", "uint16"): None,
|
|
367
|
+
("float64", "int32"): "float64",
|
|
368
|
+
("float64", "uint32"): None,
|
|
369
|
+
("float64", "int64"): "float64",
|
|
370
|
+
("float64", "uint64"): None,
|
|
371
|
+
("float64", "bool"): "float64",
|
|
372
|
+
("float64", "complex32"): "complex128",
|
|
373
|
+
("float64", "complex64"): "complex128",
|
|
374
|
+
("float64", "complex128"): "complex128",
|
|
375
|
+
# bf16 行
|
|
376
|
+
("bfloat16", "float32"): "float32",
|
|
377
|
+
("bfloat16", "float16"): "float32",
|
|
378
|
+
("bfloat16", "float64"): "float64",
|
|
379
|
+
("bfloat16", "bfloat16"): "bfloat16",
|
|
380
|
+
("bfloat16", "int8"): "bfloat16",
|
|
381
|
+
("bfloat16", "uint8"): "bfloat16",
|
|
382
|
+
("bfloat16", "int16"): "bfloat16",
|
|
383
|
+
("bfloat16", "uint16"): None,
|
|
384
|
+
("bfloat16", "int32"): "bfloat16",
|
|
385
|
+
("bfloat16", "uint32"): None,
|
|
386
|
+
("bfloat16", "int64"): "bfloat16",
|
|
387
|
+
("bfloat16", "uint64"): None,
|
|
388
|
+
("bfloat16", "bool"): "bfloat16",
|
|
389
|
+
("bfloat16", "complex32"): "complex32",
|
|
390
|
+
("bfloat16", "complex64"): "complex64",
|
|
391
|
+
("bfloat16", "complex128"): "complex128",
|
|
392
|
+
# s8 行
|
|
393
|
+
("int8", "float32"): "float32",
|
|
394
|
+
("int8", "float16"): "float16",
|
|
395
|
+
("int8", "float64"): "float64",
|
|
396
|
+
("int8", "bfloat16"): "bfloat16",
|
|
397
|
+
("int8", "int8"): "int8",
|
|
398
|
+
("int8", "uint8"): "int16",
|
|
399
|
+
("int8", "int16"): "int16",
|
|
400
|
+
("int8", "uint16"): None,
|
|
401
|
+
("int8", "int32"): "int32",
|
|
402
|
+
("int8", "uint32"): None,
|
|
403
|
+
("int8", "int64"): "int64",
|
|
404
|
+
("int8", "uint64"): None,
|
|
405
|
+
("int8", "bool"): "int8",
|
|
406
|
+
("int8", "complex32"): "complex32",
|
|
407
|
+
("int8", "complex64"): "complex64",
|
|
408
|
+
("int8", "complex128"): "complex128",
|
|
409
|
+
# u8 行
|
|
410
|
+
("uint8", "float32"): "float32",
|
|
411
|
+
("uint8", "float16"): "float16",
|
|
412
|
+
("uint8", "float64"): "float64",
|
|
413
|
+
("uint8", "bfloat16"): "bfloat16",
|
|
414
|
+
("uint8", "int8"): "int16",
|
|
415
|
+
("uint8", "uint8"): "uint8",
|
|
416
|
+
("uint8", "int16"): "int16",
|
|
417
|
+
("uint8", "uint16"): None,
|
|
418
|
+
("uint8", "int32"): "int32",
|
|
419
|
+
("uint8", "uint32"): None,
|
|
420
|
+
("uint8", "int64"): "int64",
|
|
421
|
+
("uint8", "uint64"): None,
|
|
422
|
+
("uint8", "bool"): "uint8",
|
|
423
|
+
("uint8", "complex32"): "complex32",
|
|
424
|
+
("uint8", "complex64"): "complex64",
|
|
425
|
+
("uint8", "complex128"): "complex128",
|
|
426
|
+
# s16 行
|
|
427
|
+
("int16", "float32"): "float32",
|
|
428
|
+
("int16", "float16"): "float16",
|
|
429
|
+
("int16", "float64"): "float64",
|
|
430
|
+
("int16", "bfloat16"): "bfloat16",
|
|
431
|
+
("int16", "int8"): "int16",
|
|
432
|
+
("int16", "uint8"): "int16",
|
|
433
|
+
("int16", "int16"): "int16",
|
|
434
|
+
("int16", "uint16"): None,
|
|
435
|
+
("int16", "int32"): "int32",
|
|
436
|
+
("int16", "uint32"): None,
|
|
437
|
+
("int16", "int64"): "int64",
|
|
438
|
+
("int16", "uint64"): None,
|
|
439
|
+
("int16", "bool"): "int16",
|
|
440
|
+
("int16", "complex32"): "complex32",
|
|
441
|
+
("int16", "complex64"): "complex64",
|
|
442
|
+
("int16", "complex128"): "complex128",
|
|
443
|
+
# u16 行
|
|
444
|
+
("uint16", "float32"): None,
|
|
445
|
+
("uint16", "float16"): None,
|
|
446
|
+
("uint16", "float64"): None,
|
|
447
|
+
("uint16", "bfloat16"): None,
|
|
448
|
+
("uint16", "int8"): None,
|
|
449
|
+
("uint16", "uint8"): None,
|
|
450
|
+
("uint16", "int16"): None,
|
|
451
|
+
("uint16", "uint16"): "uint16",
|
|
452
|
+
("uint16", "int32"): None,
|
|
453
|
+
("uint16", "uint32"): None,
|
|
454
|
+
("uint16", "int64"): None,
|
|
455
|
+
("uint16", "uint64"): None,
|
|
456
|
+
("uint16", "bool"): None,
|
|
457
|
+
("uint16", "complex32"): None,
|
|
458
|
+
("uint16", "complex64"): None,
|
|
459
|
+
("uint16", "complex128"): None,
|
|
460
|
+
# s32 行
|
|
461
|
+
("int32", "float32"): "float32",
|
|
462
|
+
("int32", "float16"): "float16",
|
|
463
|
+
("int32", "float64"): "float64",
|
|
464
|
+
("int32", "bfloat16"): "bfloat16",
|
|
465
|
+
("int32", "int8"): "int32",
|
|
466
|
+
("int32", "uint8"): "int32",
|
|
467
|
+
("int32", "int16"): "int32",
|
|
468
|
+
("int32", "uint16"): None,
|
|
469
|
+
("int32", "int32"): "int32",
|
|
470
|
+
("int32", "uint32"): None,
|
|
471
|
+
("int32", "int64"): "int64",
|
|
472
|
+
("int32", "uint64"): None,
|
|
473
|
+
("int32", "bool"): "int32",
|
|
474
|
+
("int32", "complex32"): "complex32",
|
|
475
|
+
("int32", "complex64"): "complex64",
|
|
476
|
+
("int32", "complex128"): "complex128",
|
|
477
|
+
# u32 行
|
|
478
|
+
("uint32", "float32"): None,
|
|
479
|
+
("uint32", "float16"): None,
|
|
480
|
+
("uint32", "float64"): None,
|
|
481
|
+
("uint32", "bfloat16"): None,
|
|
482
|
+
("uint32", "int8"): None,
|
|
483
|
+
("uint32", "uint8"): None,
|
|
484
|
+
("uint32", "int16"): None,
|
|
485
|
+
("uint32", "uint16"): None,
|
|
486
|
+
("uint32", "int32"): None,
|
|
487
|
+
("uint32", "uint32"): "uint32",
|
|
488
|
+
("uint32", "int64"): None,
|
|
489
|
+
("uint32", "uint64"): None,
|
|
490
|
+
("uint32", "bool"): None,
|
|
491
|
+
("uint32", "complex32"): None,
|
|
492
|
+
("uint32", "complex64"): None,
|
|
493
|
+
("uint32", "complex128"): None,
|
|
494
|
+
# s64 行
|
|
495
|
+
("int64", "float32"): "float32",
|
|
496
|
+
("int64", "float16"): "float16",
|
|
497
|
+
("int64", "float64"): "float64",
|
|
498
|
+
("int64", "bfloat16"): "bfloat16",
|
|
499
|
+
("int64", "int8"): "int64",
|
|
500
|
+
("int64", "uint8"): "int64",
|
|
501
|
+
("int64", "int16"): "int64",
|
|
502
|
+
("int64", "uint16"): None,
|
|
503
|
+
("int64", "int32"): "int64",
|
|
504
|
+
("int64", "uint32"): None,
|
|
505
|
+
("int64", "int64"): "int64",
|
|
506
|
+
("int64", "uint64"): None,
|
|
507
|
+
("int64", "bool"): "int64",
|
|
508
|
+
("int64", "complex32"): "complex32",
|
|
509
|
+
("int64", "complex64"): "complex64",
|
|
510
|
+
("int64", "complex128"): "complex128",
|
|
511
|
+
# u64 行
|
|
512
|
+
("uint64", "float32"): None,
|
|
513
|
+
("uint64", "float16"): None,
|
|
514
|
+
("uint64", "float64"): None,
|
|
515
|
+
("uint64", "bfloat16"): None,
|
|
516
|
+
("uint64", "int8"): None,
|
|
517
|
+
("uint64", "uint8"): None,
|
|
518
|
+
("uint64", "int16"): None,
|
|
519
|
+
("uint64", "uint16"): None,
|
|
520
|
+
("uint64", "int32"): None,
|
|
521
|
+
("uint64", "uint32"): None,
|
|
522
|
+
("uint64", "int64"): None,
|
|
523
|
+
("uint64", "uint64"): "uint64",
|
|
524
|
+
("uint64", "bool"): None,
|
|
525
|
+
("uint64", "complex32"): None,
|
|
526
|
+
("uint64", "complex64"): None,
|
|
527
|
+
("uint64", "complex128"): None,
|
|
528
|
+
# bool 行
|
|
529
|
+
("bool", "float32"): "float32",
|
|
530
|
+
("bool", "float16"): "float16",
|
|
531
|
+
("bool", "float64"): "float64",
|
|
532
|
+
("bool", "bfloat16"): "bfloat16",
|
|
533
|
+
("bool", "int8"): "int8",
|
|
534
|
+
("bool", "uint8"): "uint8",
|
|
535
|
+
("bool", "int16"): "int16",
|
|
536
|
+
("bool", "uint16"): None,
|
|
537
|
+
("bool", "int32"): "int32",
|
|
538
|
+
("bool", "uint32"): None,
|
|
539
|
+
("bool", "int64"): "int64",
|
|
540
|
+
("bool", "uint64"): None,
|
|
541
|
+
("bool", "bool"): "bool",
|
|
542
|
+
("bool", "complex32"): "complex32",
|
|
543
|
+
("bool", "complex64"): "complex64",
|
|
544
|
+
("bool", "complex128"): "complex128",
|
|
545
|
+
# c32 行
|
|
546
|
+
("complex32", "float32"): "complex64",
|
|
547
|
+
("complex32", "float16"): "complex32",
|
|
548
|
+
("complex32", "float64"): "complex128",
|
|
549
|
+
("complex32", "bfloat16"): "complex32",
|
|
550
|
+
("complex32", "int8"): "complex32",
|
|
551
|
+
("complex32", "uint8"): "complex32",
|
|
552
|
+
("complex32", "int16"): "complex32",
|
|
553
|
+
("complex32", "uint16"): None,
|
|
554
|
+
("complex32", "int32"): "complex32",
|
|
555
|
+
("complex32", "uint32"): None,
|
|
556
|
+
("complex32", "int64"): "complex32",
|
|
557
|
+
("complex32", "uint64"): None,
|
|
558
|
+
("complex32", "bool"): "complex32",
|
|
559
|
+
("complex32", "complex32"): "complex32",
|
|
560
|
+
("complex32", "complex64"): "complex64",
|
|
561
|
+
("complex32", "complex128"): "complex128",
|
|
562
|
+
# c64 行
|
|
563
|
+
("complex64", "float32"): "complex64",
|
|
564
|
+
("complex64", "float16"): "complex64",
|
|
565
|
+
("complex64", "float64"): "complex128",
|
|
566
|
+
("complex64", "bfloat16"): "complex64",
|
|
567
|
+
("complex64", "int8"): "complex64",
|
|
568
|
+
("complex64", "uint8"): "complex64",
|
|
569
|
+
("complex64", "int16"): "complex64",
|
|
570
|
+
("complex64", "uint16"): None,
|
|
571
|
+
("complex64", "int32"): "complex64",
|
|
572
|
+
("complex64", "uint32"): None,
|
|
573
|
+
("complex64", "int64"): "complex64",
|
|
574
|
+
("complex64", "uint64"): None,
|
|
575
|
+
("complex64", "bool"): "complex64",
|
|
576
|
+
("complex64", "complex32"): "complex64",
|
|
577
|
+
("complex64", "complex64"): "complex64",
|
|
578
|
+
("complex64", "complex128"): "complex128",
|
|
579
|
+
# c128 行
|
|
580
|
+
("complex128", "float32"): "complex128",
|
|
581
|
+
("complex128", "float16"): "complex128",
|
|
582
|
+
("complex128", "float64"): "complex128",
|
|
583
|
+
("complex128", "bfloat16"): "complex128",
|
|
584
|
+
("complex128", "int8"): "complex128",
|
|
585
|
+
("complex128", "uint8"): "complex128",
|
|
586
|
+
("complex128", "int16"): "complex128",
|
|
587
|
+
("complex128", "uint16"): None,
|
|
588
|
+
("complex128", "int32"): "complex128",
|
|
589
|
+
("complex128", "uint32"): None,
|
|
590
|
+
("complex128", "int64"): "complex128",
|
|
591
|
+
("complex128", "uint64"): None,
|
|
592
|
+
("complex128", "bool"): "complex128",
|
|
593
|
+
("complex128", "complex32"): "complex128",
|
|
594
|
+
("complex128", "complex64"): "complex128",
|
|
595
|
+
("complex128", "complex128"): "complex128",
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
def infer_two_dtypes(dtype1: str, dtype2: str) -> Optional[str]:
|
|
600
|
+
"""
|
|
601
|
+
根据两个dtype推导结果dtype(基于推导表)
|
|
602
|
+
|
|
603
|
+
Args:
|
|
604
|
+
dtype1: 第一个dtype
|
|
605
|
+
dtype2: 第二个dtype
|
|
606
|
+
|
|
607
|
+
Returns:
|
|
608
|
+
推导后的dtype,如果不能推导则返回None
|
|
609
|
+
|
|
610
|
+
Examples:
|
|
611
|
+
>>> infer_two_dtypes("float16", "float32")
|
|
612
|
+
'float32'
|
|
613
|
+
>>> infer_two_dtypes("float16", "bfloat16")
|
|
614
|
+
'float32'
|
|
615
|
+
>>> infer_two_dtypes("float32", "uint16")
|
|
616
|
+
None
|
|
617
|
+
"""
|
|
618
|
+
d1 = normalize_dtype(dtype1)
|
|
619
|
+
d2 = normalize_dtype(dtype2)
|
|
620
|
+
|
|
621
|
+
if d1 is None or d2 is None:
|
|
622
|
+
return None
|
|
623
|
+
|
|
624
|
+
if d1 == d2:
|
|
625
|
+
return d1
|
|
626
|
+
|
|
627
|
+
result = DTYPE_INFER_TABLE.get((d1, d2))
|
|
628
|
+
return result
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
def infer_dtypes(dtype_list: List[str]) -> Optional[str]:
|
|
632
|
+
"""
|
|
633
|
+
根据dtype列表计算推导后的dtype
|
|
634
|
+
多个dtype依次两两推导,得到最终结果
|
|
635
|
+
|
|
636
|
+
Args:
|
|
637
|
+
dtype_list: dtype列表
|
|
638
|
+
|
|
639
|
+
Returns:
|
|
640
|
+
推导后的dtype,如果无法推导则返回None
|
|
641
|
+
|
|
642
|
+
Examples:
|
|
643
|
+
>>> infer_dtypes(["float16", "float32"])
|
|
644
|
+
'float32'
|
|
645
|
+
>>> infer_dtypes(["float16", "float16", "float32"])
|
|
646
|
+
'float32'
|
|
647
|
+
>>> infer_dtypes(["float16", "bfloat16"])
|
|
648
|
+
'float32'
|
|
649
|
+
>>> infer_dtypes(["float16", "uint16"])
|
|
650
|
+
None
|
|
651
|
+
"""
|
|
652
|
+
if not dtype_list:
|
|
653
|
+
return None
|
|
654
|
+
|
|
655
|
+
normalized_list = normalize_dtype_list(dtype_list)
|
|
656
|
+
if not normalized_list:
|
|
657
|
+
return None
|
|
658
|
+
|
|
659
|
+
if len(normalized_list) == 1:
|
|
660
|
+
return normalized_list[0]
|
|
661
|
+
|
|
662
|
+
result = normalized_list[0]
|
|
663
|
+
for i in range(1, len(normalized_list)):
|
|
664
|
+
result = infer_two_dtypes(result, normalized_list[i])
|
|
665
|
+
if result is None:
|
|
666
|
+
return None
|
|
667
|
+
|
|
668
|
+
return result
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
def get_inferable_dtype_combinations(
|
|
672
|
+
tensor_dtype_lists: List[List[str]],
|
|
673
|
+
) -> List[List[str]]:
|
|
674
|
+
"""
|
|
675
|
+
根据多个tensor支持的dtype列表,计算所有支持推导的有效dtype组合
|
|
676
|
+
|
|
677
|
+
Args:
|
|
678
|
+
tensor_dtype_lists: 多个tensor参数各自支持的dtype列表
|
|
679
|
+
例如: [["float16", "float32", "bfloat16"],
|
|
680
|
+
["float16", "float32", "bfloat16"],
|
|
681
|
+
["float16", "float32", "bfloat16"]]
|
|
682
|
+
|
|
683
|
+
Returns:
|
|
684
|
+
所有有效的dtype组合列表(每个组合中的dtype可以相互推导)
|
|
685
|
+
例如: [["float16", "float16", "float16"],
|
|
686
|
+
["float16", "float16", "float32"],
|
|
687
|
+
["float16", "float16", "bfloat16"],
|
|
688
|
+
...]
|
|
689
|
+
|
|
690
|
+
Examples:
|
|
691
|
+
>>> dtypes1 = ["float16", "float32", "bfloat16"]
|
|
692
|
+
>>> dtypes2 = ["float16", "float32", "bfloat16"]
|
|
693
|
+
>>> result = get_inferable_dtype_combinations([dtypes1, dtypes2])
|
|
694
|
+
>>> len(result) > 0
|
|
695
|
+
True
|
|
696
|
+
>>> # 验证每个组合都可以推导
|
|
697
|
+
>>> all(infer_dtypes(combo) is not None for combo in result)
|
|
698
|
+
True
|
|
699
|
+
"""
|
|
700
|
+
if not tensor_dtype_lists:
|
|
701
|
+
return []
|
|
702
|
+
|
|
703
|
+
if len(tensor_dtype_lists) == 1:
|
|
704
|
+
normalized = normalize_dtype_list(tensor_dtype_lists[0])
|
|
705
|
+
return [[d] for d in normalized]
|
|
706
|
+
|
|
707
|
+
# 规范化所有dtype列表
|
|
708
|
+
normalized_lists = []
|
|
709
|
+
for dtype_list in tensor_dtype_lists:
|
|
710
|
+
normalized = normalize_dtype_list(dtype_list)
|
|
711
|
+
if not normalized:
|
|
712
|
+
return []
|
|
713
|
+
normalized_lists.append(normalized)
|
|
714
|
+
|
|
715
|
+
# 生成所有可能的组合
|
|
716
|
+
all_combinations = list(itertools.product(*normalized_lists))
|
|
717
|
+
|
|
718
|
+
# 筛选可以推导的组合
|
|
719
|
+
valid_combinations = []
|
|
720
|
+
for combo in all_combinations:
|
|
721
|
+
if infer_dtypes(list(combo)) is not None:
|
|
722
|
+
valid_combinations.append(list(combo))
|
|
723
|
+
|
|
724
|
+
return valid_combinations
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
def infer_dtype(dtype1: Optional[str], dtype2: Optional[str] = None) -> Optional[str]:
|
|
728
|
+
"""
|
|
729
|
+
类型推导:根据输入 dtype 推导结果 dtype
|
|
730
|
+
(兼容旧接口,推荐使用 infer_dtypes 或 infer_two_dtypes)
|
|
731
|
+
|
|
732
|
+
Args:
|
|
733
|
+
dtype1: 第一个输入的 dtype
|
|
734
|
+
dtype2: 第二个输入的 dtype(可选)
|
|
735
|
+
|
|
736
|
+
Returns:
|
|
737
|
+
推导后的 dtype
|
|
738
|
+
|
|
739
|
+
Examples:
|
|
740
|
+
>>> infer_dtype("float16", "float32")
|
|
741
|
+
'float32'
|
|
742
|
+
>>> infer_dtype("float16")
|
|
743
|
+
'float16'
|
|
744
|
+
"""
|
|
745
|
+
normalized_dtype1 = normalize_dtype(dtype1)
|
|
746
|
+
|
|
747
|
+
if normalized_dtype1 is None:
|
|
748
|
+
return None
|
|
749
|
+
|
|
750
|
+
if dtype2 is None:
|
|
751
|
+
return normalized_dtype1
|
|
752
|
+
|
|
753
|
+
return infer_two_dtypes(normalized_dtype1, dtype2)
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
# ==================== 辅助函数 ====================
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
def get_all_supported_dtypes() -> List[str]:
|
|
760
|
+
"""获取所有支持的 dtype 列表"""
|
|
761
|
+
return list(_STANDARD_DTYPES)
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
def is_valid_dtype(dtype: Optional[str]) -> bool:
|
|
765
|
+
"""检查 dtype 是否有效"""
|
|
766
|
+
return normalize_dtype(dtype) is not None
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
def dtype_to_acl_format(dtype: Optional[str]) -> Optional[str]:
|
|
770
|
+
"""
|
|
771
|
+
将标准 dtype 名称转换为 ACL 格式
|
|
772
|
+
|
|
773
|
+
Args:
|
|
774
|
+
dtype: 标准 dtype 名称
|
|
775
|
+
|
|
776
|
+
Returns:
|
|
777
|
+
ACL 格式的 dtype 名称
|
|
778
|
+
|
|
779
|
+
Examples:
|
|
780
|
+
>>> dtype_to_acl_format("float32")
|
|
781
|
+
'ACL_FLOAT'
|
|
782
|
+
>>> dtype_to_acl_format("float16")
|
|
783
|
+
'ACL_FLOAT16'
|
|
784
|
+
>>> dtype_to_acl_format("int32")
|
|
785
|
+
'ACL_INT32'
|
|
786
|
+
"""
|
|
787
|
+
normalized = normalize_dtype(dtype)
|
|
788
|
+
if normalized is None:
|
|
789
|
+
return None
|
|
790
|
+
|
|
791
|
+
acl_map: dict = {
|
|
792
|
+
"float32": "ACL_FLOAT",
|
|
793
|
+
"float16": "ACL_FLOAT16",
|
|
794
|
+
"float64": "ACL_DOUBLE",
|
|
795
|
+
"bfloat16": "ACL_BF16",
|
|
796
|
+
"int8": "ACL_INT8",
|
|
797
|
+
"uint8": "ACL_UINT8",
|
|
798
|
+
"int16": "ACL_INT16",
|
|
799
|
+
"uint16": "ACL_UINT16",
|
|
800
|
+
"int32": "ACL_INT32",
|
|
801
|
+
"uint32": "ACL_UINT32",
|
|
802
|
+
"int64": "ACL_INT64",
|
|
803
|
+
"uint64": "ACL_UINT64",
|
|
804
|
+
"bool": "ACL_BOOL",
|
|
805
|
+
"complex32": "ACL_COMPLEX32",
|
|
806
|
+
"complex64": "ACL_COMPLEX64",
|
|
807
|
+
"complex128": "ACL_COMPLEX128",
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
return acl_map.get(normalized)
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
# ==================== Shape 相关函数 ====================
|
|
814
|
+
|
|
815
|
+
# 常量定义
|
|
816
|
+
MAX_SHAPE_PRODUCT = 2 * 1024 * 1024 * 1024 # 2G
|
|
817
|
+
MAX_DIM_VALUE = 2 * 1024 * 1024 * 1024 # 单轴最大值2G
|
|
818
|
+
MIN_DIM_VALUE = 1
|
|
819
|
+
MAX_DIMENSIONS = 8 # 最大维度数
|
|
820
|
+
NUM_LOG_SEGMENTS = 500 # 对数分段数量
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
def _calculate_shape_product(shape: List[int]) -> int:
|
|
824
|
+
"""计算shape的乘积"""
|
|
825
|
+
product = 1
|
|
826
|
+
for dim in shape:
|
|
827
|
+
product *= dim
|
|
828
|
+
if product > MAX_SHAPE_PRODUCT:
|
|
829
|
+
return MAX_SHAPE_PRODUCT + 1
|
|
830
|
+
return product
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
def generate_random_shape(
|
|
834
|
+
dimensions: int, num_segments: int = NUM_LOG_SEGMENTS, seed: Optional[int] = None
|
|
835
|
+
) -> List[int]:
|
|
836
|
+
"""
|
|
837
|
+
根据输入维度生成随机shape
|
|
838
|
+
|
|
839
|
+
生成策略:
|
|
840
|
+
1. 将shape乘积范围[1, 2G]按对数划分成num_segments段
|
|
841
|
+
2. 随机选择一个分段,在该分段内随机生成目标乘积
|
|
842
|
+
3. 将目标乘积分解到各个维度,确保维度值分布合理
|
|
843
|
+
|
|
844
|
+
约束:
|
|
845
|
+
- shape乘积 <= 2G
|
|
846
|
+
- 单轴取值范围 [1, 2G]
|
|
847
|
+
- 维度数 <= 8
|
|
848
|
+
|
|
849
|
+
Args:
|
|
850
|
+
dimensions: shape的维度数(1-8)
|
|
851
|
+
num_segments: 对数分段数量,默认500
|
|
852
|
+
seed: 随机种子(可选)
|
|
853
|
+
|
|
854
|
+
Returns:
|
|
855
|
+
随机生成的shape列表
|
|
856
|
+
|
|
857
|
+
Examples:
|
|
858
|
+
>>> shape = generate_random_shape(3, seed=42)
|
|
859
|
+
>>> len(shape)
|
|
860
|
+
3
|
|
861
|
+
>>> _calculate_shape_product(shape) <= MAX_SHAPE_PRODUCT
|
|
862
|
+
True
|
|
863
|
+
"""
|
|
864
|
+
if seed is not None:
|
|
865
|
+
random.seed(seed)
|
|
866
|
+
|
|
867
|
+
# 参数校验
|
|
868
|
+
if not isinstance(dimensions, int) or dimensions <= 0 or dimensions > MAX_DIMENSIONS:
|
|
869
|
+
corrected = max(1, min(abs(int(dimensions)) if isinstance(dimensions, (int, float)) else 1, MAX_DIMENSIONS))
|
|
870
|
+
dimensions = corrected
|
|
871
|
+
else:
|
|
872
|
+
dimensions = max(1, min(dimensions, MAX_DIMENSIONS))
|
|
873
|
+
|
|
874
|
+
# 特殊情况:1维shape直接随机生成
|
|
875
|
+
if dimensions == 1:
|
|
876
|
+
# 直接在对数范围内随机
|
|
877
|
+
log_min = 0 # log(1) = 0
|
|
878
|
+
log_max = math.log2(MAX_SHAPE_PRODUCT)
|
|
879
|
+
log_val = random.uniform(log_min, log_max)
|
|
880
|
+
return [max(1, int(2**log_val))]
|
|
881
|
+
|
|
882
|
+
# Step 1: 按对数划分段,随机选择一个分段
|
|
883
|
+
log_min = 0 # log(1) = 0
|
|
884
|
+
log_max = math.log2(MAX_SHAPE_PRODUCT)
|
|
885
|
+
|
|
886
|
+
# 计算每段的对数范围
|
|
887
|
+
log_segment_size = (log_max - log_min) / num_segments
|
|
888
|
+
|
|
889
|
+
# 随机选择一个分段
|
|
890
|
+
segment_idx = random.randint(0, num_segments - 1)
|
|
891
|
+
segment_log_min = log_min + segment_idx * log_segment_size
|
|
892
|
+
segment_log_max = segment_log_min + log_segment_size
|
|
893
|
+
|
|
894
|
+
# 在分段内随机选择目标乘积的对数值
|
|
895
|
+
target_log = random.uniform(segment_log_min, segment_log_max)
|
|
896
|
+
target_product = int(2**target_log)
|
|
897
|
+
|
|
898
|
+
# 确保目标乘积至少能分配到各个维度(每个维度至少为1)
|
|
899
|
+
target_product = max(dimensions, target_product)
|
|
900
|
+
target_product = min(target_product, MAX_SHAPE_PRODUCT)
|
|
901
|
+
|
|
902
|
+
# Step 2: 将目标乘积分解到各个维度
|
|
903
|
+
shape = _decompose_product_to_shape(target_product, dimensions)
|
|
904
|
+
|
|
905
|
+
return shape
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
def _decompose_product_to_shape(target_product: int, dimensions: int) -> List[int]:
|
|
909
|
+
"""
|
|
910
|
+
将目标乘积分解为指定维度的shape
|
|
911
|
+
|
|
912
|
+
分解策略:
|
|
913
|
+
1. 使用对数均匀分布来分配各维度的值
|
|
914
|
+
2. 先生成各维度的对数值,然后转换为实际值
|
|
915
|
+
3. 调整使乘积精确匹配目标值
|
|
916
|
+
|
|
917
|
+
Args:
|
|
918
|
+
target_product: 目标乘积
|
|
919
|
+
dimensions: 维度数
|
|
920
|
+
|
|
921
|
+
Returns:
|
|
922
|
+
分解后的shape列表
|
|
923
|
+
"""
|
|
924
|
+
if dimensions == 1:
|
|
925
|
+
return [target_product]
|
|
926
|
+
|
|
927
|
+
# 策略:使用随机分解
|
|
928
|
+
# 1. 随机生成各个维度的"权重"
|
|
929
|
+
# 2. 根据权重分配乘积
|
|
930
|
+
|
|
931
|
+
shape = []
|
|
932
|
+
|
|
933
|
+
# 方法1:逐步分解法
|
|
934
|
+
remaining_product = target_product
|
|
935
|
+
remaining_dims = dimensions
|
|
936
|
+
|
|
937
|
+
for i in range(dimensions - 1):
|
|
938
|
+
# 计算当前维度的最大可能值
|
|
939
|
+
# 确保剩余乘积至少能分配给剩余维度(每维至少为1)
|
|
940
|
+
max_for_this_dim = remaining_product // (remaining_dims)
|
|
941
|
+
|
|
942
|
+
if max_for_this_dim <= 1:
|
|
943
|
+
shape.append(1)
|
|
944
|
+
remaining_dims -= 1
|
|
945
|
+
continue
|
|
946
|
+
|
|
947
|
+
# 使用对数均匀分布来选择当前维度的值
|
|
948
|
+
# 这样可以产生更多样化的维度值分布
|
|
949
|
+
log_min = 0 # log(1) = 0
|
|
950
|
+
log_max = math.log2(max_for_this_dim)
|
|
951
|
+
|
|
952
|
+
# 在对数空间均匀采样
|
|
953
|
+
log_val = random.uniform(log_min, log_max)
|
|
954
|
+
dim_value = max(1, min(max_for_this_dim, int(2**log_val)))
|
|
955
|
+
|
|
956
|
+
shape.append(dim_value)
|
|
957
|
+
remaining_product //= dim_value
|
|
958
|
+
remaining_dims -= 1
|
|
959
|
+
|
|
960
|
+
# 最后一个维度取剩余值
|
|
961
|
+
shape.append(max(1, remaining_product))
|
|
962
|
+
|
|
963
|
+
# 微调:如果乘积不匹配,调整最后一个维度
|
|
964
|
+
actual_product = 1
|
|
965
|
+
for d in shape[:-1]:
|
|
966
|
+
actual_product *= d
|
|
967
|
+
|
|
968
|
+
if actual_product > 0:
|
|
969
|
+
last_dim = target_product // actual_product
|
|
970
|
+
shape[-1] = max(1, last_dim)
|
|
971
|
+
|
|
972
|
+
# 确保单轴值不超过最大值
|
|
973
|
+
shape = [min(d, MAX_DIM_VALUE) for d in shape]
|
|
974
|
+
|
|
975
|
+
return shape
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
def generate_random_shapes(
|
|
979
|
+
dimensions: int,
|
|
980
|
+
count: int = 10,
|
|
981
|
+
num_segments: int = NUM_LOG_SEGMENTS,
|
|
982
|
+
seed: Optional[int] = None,
|
|
983
|
+
) -> List[List[int]]:
|
|
984
|
+
"""
|
|
985
|
+
批量生成随机shape
|
|
986
|
+
|
|
987
|
+
Args:
|
|
988
|
+
dimensions: shape的维度数
|
|
989
|
+
count: 需要生成的shape数量
|
|
990
|
+
num_segments: 对数分段数量
|
|
991
|
+
seed: 随机种子
|
|
992
|
+
|
|
993
|
+
Returns:
|
|
994
|
+
随机shape列表
|
|
995
|
+
|
|
996
|
+
Examples:
|
|
997
|
+
>>> shapes = generate_random_shapes(3, count=5, seed=42)
|
|
998
|
+
>>> len(shapes)
|
|
999
|
+
5
|
|
1000
|
+
>>> all(len(s) == 3 for s in shapes)
|
|
1001
|
+
True
|
|
1002
|
+
"""
|
|
1003
|
+
if seed is not None:
|
|
1004
|
+
random.seed(seed)
|
|
1005
|
+
|
|
1006
|
+
shapes = []
|
|
1007
|
+
for _ in range(count):
|
|
1008
|
+
shape = generate_random_shape(dimensions, num_segments)
|
|
1009
|
+
shapes.append(shape)
|
|
1010
|
+
|
|
1011
|
+
return shapes
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
def generate_diverse_random_shapes(
|
|
1015
|
+
dimensions_list: List[int],
|
|
1016
|
+
count_per_dim: int = 5,
|
|
1017
|
+
num_segments: int = NUM_LOG_SEGMENTS,
|
|
1018
|
+
seed: Optional[int] = None,
|
|
1019
|
+
) -> List[List[int]]:
|
|
1020
|
+
"""
|
|
1021
|
+
为多个维度生成多样化的随机shape
|
|
1022
|
+
|
|
1023
|
+
Args:
|
|
1024
|
+
dimensions_list: 维度数列表,如[1, 2, 3, 4]
|
|
1025
|
+
count_per_dim: 每个维度生成的shape数量
|
|
1026
|
+
num_segments: 对数分段数量
|
|
1027
|
+
seed: 随机种子
|
|
1028
|
+
|
|
1029
|
+
Returns:
|
|
1030
|
+
随机shape列表
|
|
1031
|
+
|
|
1032
|
+
Examples:
|
|
1033
|
+
>>> shapes = generate_diverse_random_shapes([1, 2, 3], count_per_dim=2, seed=42)
|
|
1034
|
+
>>> len(shapes)
|
|
1035
|
+
6
|
|
1036
|
+
"""
|
|
1037
|
+
if seed is not None:
|
|
1038
|
+
random.seed(seed)
|
|
1039
|
+
|
|
1040
|
+
all_shapes = []
|
|
1041
|
+
for dims in dimensions_list:
|
|
1042
|
+
shapes = generate_random_shapes(dims, count_per_dim, num_segments)
|
|
1043
|
+
all_shapes.extend(shapes)
|
|
1044
|
+
|
|
1045
|
+
return all_shapes
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
def generate_random_value_by_dtype(
|
|
1049
|
+
dtype: str,
|
|
1050
|
+
value_range: Optional[List[Union[int, float]]] = None,
|
|
1051
|
+
seed: Optional[int] = None
|
|
1052
|
+
) -> Union[int, float, bool]:
|
|
1053
|
+
"""
|
|
1054
|
+
按照数据类型和取值区间生成随机数
|
|
1055
|
+
|
|
1056
|
+
Args:
|
|
1057
|
+
dtype: 数据类型(如 "float32", "int32", "bool" 等)
|
|
1058
|
+
value_range: 取值区间 [min, max],如果为None则使用dtype的默认范围
|
|
1059
|
+
seed: 随机种子(可选)
|
|
1060
|
+
|
|
1061
|
+
Returns:
|
|
1062
|
+
根据数据类型生成的随机值
|
|
1063
|
+
|
|
1064
|
+
Examples:
|
|
1065
|
+
>>> generate_random_value_by_dtype("int32", [0, 100], seed=42)
|
|
1066
|
+
82
|
|
1067
|
+
>>> generate_random_value_by_dtype("float32", [0.0, 1.0], seed=42)
|
|
1068
|
+
0.6394267984578837
|
|
1069
|
+
>>> generate_random_value_by_dtype("bool", seed=42)
|
|
1070
|
+
False
|
|
1071
|
+
"""
|
|
1072
|
+
if seed is not None:
|
|
1073
|
+
random.seed(seed)
|
|
1074
|
+
|
|
1075
|
+
normalized = normalize_dtype(dtype)
|
|
1076
|
+
if normalized is None:
|
|
1077
|
+
raise ValueError(f"Unsupported dtype: {dtype}")
|
|
1078
|
+
|
|
1079
|
+
dtype_ranges = {
|
|
1080
|
+
"int8": (-128, 127),
|
|
1081
|
+
"uint8": (0, 255),
|
|
1082
|
+
"int16": (-32768, 32767),
|
|
1083
|
+
"uint16": (0, 65535),
|
|
1084
|
+
"int32": (-2147483648, 2147483647),
|
|
1085
|
+
"uint32": (0, 4294967295),
|
|
1086
|
+
"int64": (-9223372036854775808, 9223372036854775807),
|
|
1087
|
+
"uint64": (0, 18446744073709551615),
|
|
1088
|
+
"float16": (-65504.0, 65504.0),
|
|
1089
|
+
"float32": (-3.4028235e38, 3.4028235e38),
|
|
1090
|
+
"float64": (-1.7976931348623157e308, 1.7976931348623157e308),
|
|
1091
|
+
"bfloat16": (-3.3895313892515355e38, 3.3895313892515355e38),
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
if normalized == "bool":
|
|
1095
|
+
if value_range is not None and len(value_range) == 2:
|
|
1096
|
+
min_val, max_val = value_range[0], value_range[1]
|
|
1097
|
+
if min_val == max_val:
|
|
1098
|
+
return bool(min_val)
|
|
1099
|
+
return random.choice([True, False])
|
|
1100
|
+
return random.choice([True, False])
|
|
1101
|
+
|
|
1102
|
+
if value_range is None or len(value_range) != 2:
|
|
1103
|
+
value_range = dtype_ranges.get(normalized, (0, 100))
|
|
1104
|
+
|
|
1105
|
+
min_val, max_val = value_range[0], value_range[1]
|
|
1106
|
+
|
|
1107
|
+
def _parse_special_value(v):
|
|
1108
|
+
if isinstance(v, str):
|
|
1109
|
+
v_lower = v.lower().strip()
|
|
1110
|
+
if v_lower == 'inf' or v_lower == '+inf':
|
|
1111
|
+
return float('inf')
|
|
1112
|
+
elif v_lower == '-inf':
|
|
1113
|
+
return float('-inf')
|
|
1114
|
+
elif v_lower == 'nan':
|
|
1115
|
+
return float('nan')
|
|
1116
|
+
elif v_lower == '+0':
|
|
1117
|
+
return 0.0
|
|
1118
|
+
elif v_lower == '-0':
|
|
1119
|
+
return -0.0
|
|
1120
|
+
return v
|
|
1121
|
+
|
|
1122
|
+
min_val = _parse_special_value(min_val)
|
|
1123
|
+
max_val = _parse_special_value(max_val)
|
|
1124
|
+
|
|
1125
|
+
if min_val == max_val:
|
|
1126
|
+
if isinstance(min_val, float) and (min_val != min_val):
|
|
1127
|
+
return float('nan')
|
|
1128
|
+
if normalized in INTEGER_DTYPES:
|
|
1129
|
+
return int(min_val)
|
|
1130
|
+
return float(min_val)
|
|
1131
|
+
|
|
1132
|
+
if normalized in INTEGER_DTYPES:
|
|
1133
|
+
return random.randint(int(min_val), int(max_val))
|
|
1134
|
+
elif normalized in FLOAT_DTYPES:
|
|
1135
|
+
return random.uniform(float(min_val), float(max_val))
|
|
1136
|
+
elif normalized in COMPLEX_DTYPES:
|
|
1137
|
+
real = random.uniform(float(min_val), float(max_val))
|
|
1138
|
+
imag = random.uniform(float(min_val), float(max_val))
|
|
1139
|
+
return f"({real}+{imag}j)"
|
|
1140
|
+
else:
|
|
1141
|
+
return random.uniform(float(min_val), float(max_val))
|
|
1142
|
+
|
|
1143
|
+
|
|
1144
|
+
def _can_broadcast_single_dim(source_dim: int, target_dim: int) -> bool:
|
|
1145
|
+
"""
|
|
1146
|
+
判断单个维度是否可以broadcast
|
|
1147
|
+
|
|
1148
|
+
规则:source_dim == target_dim 或 source_dim == 1
|
|
1149
|
+
"""
|
|
1150
|
+
return source_dim == target_dim or source_dim == 1
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
def can_broadcast_to(source_shape: List[int], target_shape: List[int]) -> bool:
|
|
1154
|
+
"""
|
|
1155
|
+
判断source_shape是否可以broadcast到target_shape
|
|
1156
|
+
|
|
1157
|
+
Broadcast规则:
|
|
1158
|
+
1. 从后往前对齐维度
|
|
1159
|
+
2. 每个维度必须相等,或者source维度为1
|
|
1160
|
+
3. source维度数可以少于target
|
|
1161
|
+
|
|
1162
|
+
Args:
|
|
1163
|
+
source_shape: 源shape
|
|
1164
|
+
target_shape: 目标shape
|
|
1165
|
+
|
|
1166
|
+
Returns:
|
|
1167
|
+
是否可以broadcast
|
|
1168
|
+
|
|
1169
|
+
Examples:
|
|
1170
|
+
>>> can_broadcast_to([1, 3], [2, 3])
|
|
1171
|
+
True
|
|
1172
|
+
>>> can_broadcast_to([3], [2, 3])
|
|
1173
|
+
True
|
|
1174
|
+
>>> can_broadcast_to([2, 3], [2, 3])
|
|
1175
|
+
True
|
|
1176
|
+
>>> can_broadcast_to([2, 4], [2, 3])
|
|
1177
|
+
False
|
|
1178
|
+
"""
|
|
1179
|
+
source_rev = list(reversed(source_shape))
|
|
1180
|
+
target_rev = list(reversed(target_shape))
|
|
1181
|
+
|
|
1182
|
+
for i in range(max(len(source_rev), len(target_rev))):
|
|
1183
|
+
if i >= len(source_rev):
|
|
1184
|
+
continue
|
|
1185
|
+
if i >= len(target_rev):
|
|
1186
|
+
return False
|
|
1187
|
+
|
|
1188
|
+
s = source_rev[i]
|
|
1189
|
+
t = target_rev[i]
|
|
1190
|
+
|
|
1191
|
+
if not _can_broadcast_single_dim(s, t):
|
|
1192
|
+
return False
|
|
1193
|
+
|
|
1194
|
+
return True
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
def get_broadcast_result(shapes: List[List[int]]) -> Optional[List[int]]:
|
|
1198
|
+
"""
|
|
1199
|
+
根据多个shape计算broadcast后的结果shape
|
|
1200
|
+
|
|
1201
|
+
Broadcast规则:
|
|
1202
|
+
1. 从后往前对齐维度
|
|
1203
|
+
2. 每个维度取最大值
|
|
1204
|
+
3. 如果某个维度不兼容(都不为1且不相等),返回None
|
|
1205
|
+
|
|
1206
|
+
Args:
|
|
1207
|
+
shapes: shape列表
|
|
1208
|
+
|
|
1209
|
+
Returns:
|
|
1210
|
+
broadcast后的shape,如果不兼容则返回None
|
|
1211
|
+
|
|
1212
|
+
Examples:
|
|
1213
|
+
>>> get_broadcast_result([[1, 3], [2, 3]])
|
|
1214
|
+
[2, 3]
|
|
1215
|
+
>>> get_broadcast_result([[3], [2, 3]])
|
|
1216
|
+
[2, 3]
|
|
1217
|
+
>>> get_broadcast_result([[2, 1], [1, 3]])
|
|
1218
|
+
[2, 3]
|
|
1219
|
+
>>> get_broadcast_result([[2, 3], [3, 4]])
|
|
1220
|
+
None
|
|
1221
|
+
"""
|
|
1222
|
+
if not shapes:
|
|
1223
|
+
return None
|
|
1224
|
+
|
|
1225
|
+
if len(shapes) == 1:
|
|
1226
|
+
return shapes[0]
|
|
1227
|
+
|
|
1228
|
+
# 找到最大维度数
|
|
1229
|
+
max_dims = max(len(s) for s in shapes)
|
|
1230
|
+
|
|
1231
|
+
result = []
|
|
1232
|
+
|
|
1233
|
+
for i in range(max_dims):
|
|
1234
|
+
dim_values = []
|
|
1235
|
+
for shape in shapes:
|
|
1236
|
+
idx = len(shape) - 1 - i
|
|
1237
|
+
if idx >= 0:
|
|
1238
|
+
dim_values.append(shape[idx])
|
|
1239
|
+
|
|
1240
|
+
# 检查兼容性并取最大值
|
|
1241
|
+
max_dim = 1
|
|
1242
|
+
for d in dim_values:
|
|
1243
|
+
if d != 1:
|
|
1244
|
+
if max_dim != 1 and max_dim != d:
|
|
1245
|
+
return None
|
|
1246
|
+
max_dim = max(max_dim, d)
|
|
1247
|
+
|
|
1248
|
+
result.append(max_dim)
|
|
1249
|
+
|
|
1250
|
+
return list(reversed(result))
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
# def generate_broadcast_shapes(
|
|
1254
|
+
# source_shape: List[int], num_shapes: int = 5, seed: Optional[int] = None
|
|
1255
|
+
# ) -> List[List[int]]:
|
|
1256
|
+
# """
|
|
1257
|
+
# 根据输入shape生成满足broadcast关系的shape列表
|
|
1258
|
+
|
|
1259
|
+
# Broadcast规则:从后往前对齐维度,每个维度必须相等或其中一方为1。
|
|
1260
|
+
|
|
1261
|
+
# 生成的shape包含以下场景(生成的shape与source_shape满足双向broadcast关系之一):
|
|
1262
|
+
|
|
1263
|
+
# | 场景 | 说明 | 示例source | 生成的shape | broadcast方向 |
|
|
1264
|
+
# |------|------|-----------|-------------|---------------|
|
|
1265
|
+
# | 相等 | 与输入shape完全相等 | [2,3,4] | [2,3,4] | 双向相等 |
|
|
1266
|
+
# | 维度少 | 维度数小于source,某些轴为1 | [2,3,4] | [4], [3,4], [1,4] | 生成→source |
|
|
1267
|
+
# | 维度多 | 维度数大于source | [2,3,4] | [6,2,3,4] | source→生成 |
|
|
1268
|
+
# | 维度相等 | 某些轴设为1 | [2,3,4] | [1,3,4], [2,1,4] | 生成→source |
|
|
1269
|
+
# | 扩展1轴 | source中为1的轴变非1 | [1,3,1] | [2,3,4], [5,3,8] | source→生成 |
|
|
1270
|
+
|
|
1271
|
+
# 约束:
|
|
1272
|
+
# - shape乘积小于2G
|
|
1273
|
+
# - 单轴取值范围1~2G
|
|
1274
|
+
# - 最大维度数8
|
|
1275
|
+
|
|
1276
|
+
# Args:
|
|
1277
|
+
# source_shape: 输入shape
|
|
1278
|
+
# num_shapes: 需要生成的shape数量
|
|
1279
|
+
# seed: 随机种子(可选)
|
|
1280
|
+
|
|
1281
|
+
# Returns:
|
|
1282
|
+
# 满足broadcast关系的shape列表
|
|
1283
|
+
|
|
1284
|
+
# Examples:
|
|
1285
|
+
# >>> # 无1轴的source
|
|
1286
|
+
# >>> shapes = generate_broadcast_shapes([2, 3, 4], num_shapes=5, seed=42)
|
|
1287
|
+
# >>> for s in shapes:
|
|
1288
|
+
# ... assert can_broadcast_to(s, [2,3,4]) or can_broadcast_to([2,3,4], s)
|
|
1289
|
+
|
|
1290
|
+
# >>> # 包含1轴的source
|
|
1291
|
+
# >>> shapes = generate_broadcast_shapes([1, 3, 1], num_shapes=5, seed=42)
|
|
1292
|
+
# >>> for s in shapes:
|
|
1293
|
+
# ... assert can_broadcast_to(s, [1,3,1]) or can_broadcast_to([1,3,1], s)
|
|
1294
|
+
# """
|
|
1295
|
+
# if seed is not None:
|
|
1296
|
+
# random.seed(seed)
|
|
1297
|
+
|
|
1298
|
+
# result = []
|
|
1299
|
+
# source_dims = len(source_shape)
|
|
1300
|
+
|
|
1301
|
+
# # 辅助函数:验证shape是否满足乘积约束
|
|
1302
|
+
# def _validate_shape(shape: List[int]) -> Optional[List[int]]:
|
|
1303
|
+
# product = _calculate_shape_product(shape)
|
|
1304
|
+
# if product <= MAX_SHAPE_PRODUCT:
|
|
1305
|
+
# return shape
|
|
1306
|
+
# return None
|
|
1307
|
+
|
|
1308
|
+
# # 场景1: 与输入shape相等
|
|
1309
|
+
# result.append(list(source_shape))
|
|
1310
|
+
|
|
1311
|
+
# # 场景2: 维度比输入shape少(这些shape可以broadcast到source_shape)
|
|
1312
|
+
# if source_dims > 1:
|
|
1313
|
+
# for target_dims in range(1, source_dims):
|
|
1314
|
+
# shape = []
|
|
1315
|
+
# ones_count = random.randint(0, target_dims)
|
|
1316
|
+
# ones_positions = set(
|
|
1317
|
+
# random.sample(range(target_dims), min(ones_count, target_dims))
|
|
1318
|
+
# )
|
|
1319
|
+
|
|
1320
|
+
# for i in range(target_dims):
|
|
1321
|
+
# source_idx = source_dims - target_dims + i
|
|
1322
|
+
# if i in ones_positions:
|
|
1323
|
+
# shape.append(1)
|
|
1324
|
+
# else:
|
|
1325
|
+
# shape.append(source_shape[source_idx])
|
|
1326
|
+
|
|
1327
|
+
# validated = _validate_shape(shape)
|
|
1328
|
+
# if validated and validated not in result:
|
|
1329
|
+
# result.append(validated)
|
|
1330
|
+
|
|
1331
|
+
# # 场景3: 维度比输入shape多(source_shape可以broadcast到这些shape)
|
|
1332
|
+
# for extra_dims in range(1, min(4, MAX_DIMENSIONS - source_dims + 1)):
|
|
1333
|
+
# target_dims = source_dims + extra_dims
|
|
1334
|
+
# if target_dims > MAX_DIMENSIONS:
|
|
1335
|
+
# break
|
|
1336
|
+
|
|
1337
|
+
# shape = []
|
|
1338
|
+
# # 前面添加额外维度(这些维度决定source_shape broadcast后的形状)
|
|
1339
|
+
# for i in range(extra_dims):
|
|
1340
|
+
# if random.random() < 0.3:
|
|
1341
|
+
# shape.append(1)
|
|
1342
|
+
# else:
|
|
1343
|
+
# shape.append(random.randint(2, 8))
|
|
1344
|
+
|
|
1345
|
+
# # 添加原始维度
|
|
1346
|
+
# shape.extend(source_shape)
|
|
1347
|
+
|
|
1348
|
+
# validated = _validate_shape(shape)
|
|
1349
|
+
# if validated and validated not in result:
|
|
1350
|
+
# result.append(validated)
|
|
1351
|
+
|
|
1352
|
+
# # 场景4: 维度相等,某些轴为1(这些shape可以broadcast到source_shape)
|
|
1353
|
+
# for _ in range(3):
|
|
1354
|
+
# ones_count = random.randint(1, max(1, source_dims))
|
|
1355
|
+
# ones_positions = set(
|
|
1356
|
+
# random.sample(range(source_dims), min(ones_count, source_dims))
|
|
1357
|
+
# )
|
|
1358
|
+
|
|
1359
|
+
# shape = []
|
|
1360
|
+
# for i in range(source_dims):
|
|
1361
|
+
# if i in ones_positions:
|
|
1362
|
+
# shape.append(1)
|
|
1363
|
+
# else:
|
|
1364
|
+
# shape.append(source_shape[i])
|
|
1365
|
+
|
|
1366
|
+
# validated = _validate_shape(shape)
|
|
1367
|
+
# if validated and validated not in result:
|
|
1368
|
+
# result.append(validated)
|
|
1369
|
+
|
|
1370
|
+
# # 场景5: 输入shape中轴包含1时,将1轴扩展为非1
|
|
1371
|
+
# # 这些shape可以让source_shape broadcast到
|
|
1372
|
+
# ones_in_source = [i for i, d in enumerate(source_shape) if d == 1]
|
|
1373
|
+
# if ones_in_source:
|
|
1374
|
+
# for _ in range(3):
|
|
1375
|
+
# shape = list(source_shape)
|
|
1376
|
+
# for idx in ones_in_source:
|
|
1377
|
+
# if random.random() < 0.7:
|
|
1378
|
+
# shape[idx] = random.randint(2, 16)
|
|
1379
|
+
|
|
1380
|
+
# validated = _validate_shape(shape)
|
|
1381
|
+
# if validated and validated not in result:
|
|
1382
|
+
# result.append(validated)
|
|
1383
|
+
|
|
1384
|
+
# # 补充随机形状以满足数量要求
|
|
1385
|
+
# attempts = 0
|
|
1386
|
+
# while len(result) < num_shapes and attempts < num_shapes * 10:
|
|
1387
|
+
# attempts += 1
|
|
1388
|
+
|
|
1389
|
+
# # 随机选择一种场景
|
|
1390
|
+
# scenario = random.choice(
|
|
1391
|
+
# ["fewer_dims", "more_dims", "equal_dims", "expand_ones"]
|
|
1392
|
+
# )
|
|
1393
|
+
|
|
1394
|
+
# shape = None
|
|
1395
|
+
|
|
1396
|
+
# if scenario == "fewer_dims" and source_dims > 1:
|
|
1397
|
+
# # 维度少,可以broadcast到source
|
|
1398
|
+
# target_dims = random.randint(1, source_dims - 1)
|
|
1399
|
+
# shape = []
|
|
1400
|
+
# for i in range(target_dims):
|
|
1401
|
+
# source_idx = source_dims - target_dims + i
|
|
1402
|
+
# if random.random() < 0.5:
|
|
1403
|
+
# shape.append(1)
|
|
1404
|
+
# else:
|
|
1405
|
+
# shape.append(source_shape[source_idx])
|
|
1406
|
+
|
|
1407
|
+
# elif scenario == "more_dims":
|
|
1408
|
+
# # 维度多,source可以broadcast到它
|
|
1409
|
+
# extra_dims = random.randint(1, min(4, MAX_DIMENSIONS - source_dims))
|
|
1410
|
+
# shape = []
|
|
1411
|
+
# for _ in range(extra_dims):
|
|
1412
|
+
# shape.append(1 if random.random() < 0.3 else random.randint(2, 8))
|
|
1413
|
+
# shape.extend(source_shape)
|
|
1414
|
+
|
|
1415
|
+
# elif scenario == "equal_dims":
|
|
1416
|
+
# # 维度相等,某些轴为1(可以broadcast到source)
|
|
1417
|
+
# shape = []
|
|
1418
|
+
# for i in range(source_dims):
|
|
1419
|
+
# if random.random() < 0.3 and source_shape[i] != 1:
|
|
1420
|
+
# shape.append(1)
|
|
1421
|
+
# else:
|
|
1422
|
+
# shape.append(source_shape[i])
|
|
1423
|
+
|
|
1424
|
+
# else: # expand_ones
|
|
1425
|
+
# # 只有当source有1轴时才执行
|
|
1426
|
+
# if ones_in_source:
|
|
1427
|
+
# shape = list(source_shape)
|
|
1428
|
+
# for idx in ones_in_source:
|
|
1429
|
+
# if random.random() < 0.5:
|
|
1430
|
+
# shape[idx] = random.randint(2, 16)
|
|
1431
|
+
# else:
|
|
1432
|
+
# # 没有1轴时,跳过这个场景
|
|
1433
|
+
# continue
|
|
1434
|
+
|
|
1435
|
+
# if shape:
|
|
1436
|
+
# validated = _validate_shape(shape)
|
|
1437
|
+
# if validated and validated not in result:
|
|
1438
|
+
# # 最终验证:确保满足broadcast关系
|
|
1439
|
+
# if can_broadcast_to(validated, source_shape) or can_broadcast_to(
|
|
1440
|
+
# source_shape, validated
|
|
1441
|
+
# ):
|
|
1442
|
+
# result.append(validated)
|
|
1443
|
+
|
|
1444
|
+
# return result[:num_shapes]
|
|
1445
|
+
|
|
1446
|
+
def generate_broadcast_shapes(
|
|
1447
|
+
source_shape: List[int], seed: Optional[int] = None
|
|
1448
|
+
) -> List[int]:
|
|
1449
|
+
"""
|
|
1450
|
+
根据输入shape生成满足broadcast关系的shape
|
|
1451
|
+
|
|
1452
|
+
Broadcast规则:从后往前对齐维度,每个维度必须相等或其中一方为1。
|
|
1453
|
+
|
|
1454
|
+
Broadcast场景(生成的shape与source_shape满足双向broadcast关系之一):
|
|
1455
|
+
| 场景 | 说明 | 示例source | 生成的shape | broadcast方向 |
|
|
1456
|
+
|------|------|-----------|-------------|---------------|
|
|
1457
|
+
| 相等 | 与输入shape完全相等 | [2,3,4] | [2,3,4] | 双向相等 |
|
|
1458
|
+
| 维度少 | 维度数小于source,某些轴为1 | [2,3,4] | [4], [3,4], [1,4] | 生成→source |
|
|
1459
|
+
| 维度多 | 维度数大于source | [2,3,4] | [6,2,3,4] | source→生成 |
|
|
1460
|
+
| 维度相等 | 某些轴设为1 | [2,3,4] | [1,3,4], [2,1,4] | 生成→source |
|
|
1461
|
+
| 扩展1轴 | source中为1的轴变非1 | [1,3,1] | [2,3,4], [5,3,8] | source→生成 |
|
|
1462
|
+
|
|
1463
|
+
约束:
|
|
1464
|
+
- shape乘积小于2G
|
|
1465
|
+
- 单轴取值范围1~2G
|
|
1466
|
+
- 最大维度数8
|
|
1467
|
+
|
|
1468
|
+
Args:
|
|
1469
|
+
source_shape: 输入shape
|
|
1470
|
+
seed: 随机种子(可选)
|
|
1471
|
+
|
|
1472
|
+
Returns:
|
|
1473
|
+
满足broadcast关系的shape,从5种场景种随机选择一个场景生成并返回
|
|
1474
|
+
"""
|
|
1475
|
+
# 1. 初始化随机种子
|
|
1476
|
+
if seed is not None:
|
|
1477
|
+
random.seed(seed)
|
|
1478
|
+
|
|
1479
|
+
# 2. 校验输入合法性
|
|
1480
|
+
if not isinstance(source_shape, list) or not all(isinstance(x, int) and x >= 1 for x in source_shape):
|
|
1481
|
+
raise ValueError("source_shape必须是由正整数组成的列表")
|
|
1482
|
+
if len(source_shape) > MAX_DIMENSIONS:
|
|
1483
|
+
raise ValueError(f"source_shape维度数不能超过{MAX_DIMENSIONS}")
|
|
1484
|
+
|
|
1485
|
+
# 3. 核心辅助函数:校验两个shape是否满足broadcast规则
|
|
1486
|
+
def is_broadcast_compatible(shape1: List[int], shape2: List[int]) -> bool:
|
|
1487
|
+
"""检查shape1和shape2是否满足广播规则"""
|
|
1488
|
+
# 从后往前对齐维度
|
|
1489
|
+
for dim1, dim2 in zip(reversed(shape1), reversed(shape2)):
|
|
1490
|
+
if dim1 != dim2 and dim1 != 1 and dim2 != 1:
|
|
1491
|
+
return False
|
|
1492
|
+
return True
|
|
1493
|
+
|
|
1494
|
+
# 4. 辅助函数:计算shape乘积
|
|
1495
|
+
def product(shape: List[int]) -> int:
|
|
1496
|
+
if not shape:
|
|
1497
|
+
return 1
|
|
1498
|
+
prod = 1
|
|
1499
|
+
for val in shape:
|
|
1500
|
+
prod *= val
|
|
1501
|
+
if prod > MAX_SHAPE_PRODUCT:
|
|
1502
|
+
break
|
|
1503
|
+
return prod
|
|
1504
|
+
|
|
1505
|
+
# 5. 辅助函数:校验生成的shape是否满足所有约束(含广播兼容性)
|
|
1506
|
+
def is_valid(shape: List[int]) -> bool:
|
|
1507
|
+
# 约束1:维度数≤8
|
|
1508
|
+
if len(shape) > MAX_DIMENSIONS:
|
|
1509
|
+
return False
|
|
1510
|
+
# 约束2:单轴取值1~2G
|
|
1511
|
+
if any(val < MIN_DIM_VALUE or val > MAX_DIM_VALUE for val in shape):
|
|
1512
|
+
return False
|
|
1513
|
+
# 约束3:乘积<2G
|
|
1514
|
+
if product(shape) >= MAX_SHAPE_PRODUCT:
|
|
1515
|
+
return False
|
|
1516
|
+
# 约束4:必须与source_shape满足广播规则
|
|
1517
|
+
if not is_broadcast_compatible(shape, source_shape):
|
|
1518
|
+
return False
|
|
1519
|
+
return True
|
|
1520
|
+
|
|
1521
|
+
# 6. 定义5种场景的生成函数(全场景边界修复)
|
|
1522
|
+
def _scene_equal() -> List[int]:
|
|
1523
|
+
"""场景1:与source_shape完全相等"""
|
|
1524
|
+
return source_shape.copy()
|
|
1525
|
+
|
|
1526
|
+
def _scene_less_dims() -> List[int]:
|
|
1527
|
+
"""场景2:维度数小于source,从后往前对齐,可选轴设为1"""
|
|
1528
|
+
source_dim = len(source_shape)
|
|
1529
|
+
# 边界:source_dim=1时,无法生成更少维度,返回[1](兼容广播)
|
|
1530
|
+
if source_dim == 1:
|
|
1531
|
+
return [1]
|
|
1532
|
+
# 随机选择生成的维度数(1 ~ source_dim-1)
|
|
1533
|
+
gen_dim = random.randint(1, source_dim - 1)
|
|
1534
|
+
# 从source_shape末尾取gen_dim个维度,随机将部分轴设为1
|
|
1535
|
+
gen_shape = source_shape[-gen_dim:].copy()
|
|
1536
|
+
# 随机选择0~gen_dim个轴设为1
|
|
1537
|
+
axes_to_1 = random.sample(range(gen_dim), k=random.randint(0, gen_dim))
|
|
1538
|
+
for idx in axes_to_1:
|
|
1539
|
+
gen_shape[idx] = 1
|
|
1540
|
+
return gen_shape
|
|
1541
|
+
|
|
1542
|
+
def _scene_more_dims() -> List[int]:
|
|
1543
|
+
"""场景3:维度数大于source(但不超过8),前面新增随机正整数轴(边界修复)"""
|
|
1544
|
+
source_dim = len(source_shape)
|
|
1545
|
+
# 边界:source_dim已达MAX_DIMENSIONS,无法生成更多维度,返回场景1结果
|
|
1546
|
+
if source_dim >= MAX_DIMENSIONS:
|
|
1547
|
+
return _scene_equal()
|
|
1548
|
+
# 随机选择生成的维度数(source_dim+1 ~ MAX_DIMENSIONS)
|
|
1549
|
+
gen_dim = random.randint(source_dim + 1, MAX_DIMENSIONS)
|
|
1550
|
+
# 前面新增的轴取1~MAX_DIM_VALUE之间的随机正整数(保证乘积<2G)
|
|
1551
|
+
prefix_dims = []
|
|
1552
|
+
remaining_product = MAX_SHAPE_PRODUCT // (product(source_shape) if source_shape else 1)
|
|
1553
|
+
for _ in range(gen_dim - source_dim):
|
|
1554
|
+
# 确保新增轴的取值不超过剩余乘积上限
|
|
1555
|
+
max_val = min(MAX_DIM_VALUE, remaining_product)
|
|
1556
|
+
val = random.randint(1, max_val)
|
|
1557
|
+
prefix_dims.append(val)
|
|
1558
|
+
remaining_product = max(1, remaining_product // val)
|
|
1559
|
+
# 拼接前缀轴和source_shape
|
|
1560
|
+
gen_shape = prefix_dims + source_shape.copy()
|
|
1561
|
+
return gen_shape
|
|
1562
|
+
|
|
1563
|
+
def _scene_same_dims() -> List[int]:
|
|
1564
|
+
"""场景4:维度数与source相等,随机将部分轴设为1"""
|
|
1565
|
+
gen_shape = source_shape.copy()
|
|
1566
|
+
# 至少选择1个轴设为1(避免与场景1重复)
|
|
1567
|
+
axes_to_1 = random.sample(range(len(gen_shape)), k=random.randint(1, len(gen_shape)))
|
|
1568
|
+
for idx in axes_to_1:
|
|
1569
|
+
gen_shape[idx] = 1
|
|
1570
|
+
return gen_shape
|
|
1571
|
+
|
|
1572
|
+
def _scene_expand_1d() -> List[int]:
|
|
1573
|
+
"""场景5:source中为1的轴替换为非1的随机正整数(保证广播兼容)"""
|
|
1574
|
+
# 先检查source_shape是否有1的轴,无则跳过该场景(避免生成不兼容shape)
|
|
1575
|
+
one_axes = [idx for idx, val in enumerate(source_shape) if val == 1]
|
|
1576
|
+
if not one_axes:
|
|
1577
|
+
# 无1轴时,场景5无法生成兼容shape,返回场景1的结果(兜底)
|
|
1578
|
+
return _scene_equal()
|
|
1579
|
+
|
|
1580
|
+
gen_shape = source_shape.copy()
|
|
1581
|
+
# 将所有1的轴替换为非1的随机正整数(保证乘积<2G + 广播兼容)
|
|
1582
|
+
remaining_product = MAX_SHAPE_PRODUCT // (product([v for v in gen_shape if v != 1]) if gen_shape else 1)
|
|
1583
|
+
for idx in one_axes:
|
|
1584
|
+
max_val = min(MAX_DIM_VALUE, remaining_product)
|
|
1585
|
+
# 确保替换后的值>1且<=max_val
|
|
1586
|
+
val = random.randint(2, max_val) if max_val >= 2 else 2
|
|
1587
|
+
gen_shape[idx] = val
|
|
1588
|
+
remaining_product = max(1, remaining_product // val)
|
|
1589
|
+
return gen_shape
|
|
1590
|
+
|
|
1591
|
+
# 7. 过滤不可用场景(避免选择无法生成的场景)
|
|
1592
|
+
source_dim = len(source_shape)
|
|
1593
|
+
available_scenes = []
|
|
1594
|
+
# 场景1:始终可用
|
|
1595
|
+
available_scenes.append(_scene_equal)
|
|
1596
|
+
# 场景2:source_dim>1时可用
|
|
1597
|
+
if source_dim > 1:
|
|
1598
|
+
available_scenes.append(_scene_less_dims)
|
|
1599
|
+
# 场景3:source_dim<MAX_DIMENSIONS时可用
|
|
1600
|
+
if source_dim < MAX_DIMENSIONS:
|
|
1601
|
+
available_scenes.append(_scene_more_dims)
|
|
1602
|
+
# 场景4:始终可用
|
|
1603
|
+
available_scenes.append(_scene_same_dims)
|
|
1604
|
+
# 场景5:source有1轴时可用
|
|
1605
|
+
if any(val == 1 for val in source_shape):
|
|
1606
|
+
available_scenes.append(_scene_expand_1d)
|
|
1607
|
+
|
|
1608
|
+
# 8. 随机选择可用场景生成shape,若不满足约束则重试
|
|
1609
|
+
max_retries = 1000 # 最大重试次数,避免死循环
|
|
1610
|
+
retries = 0
|
|
1611
|
+
gen_shape = []
|
|
1612
|
+
|
|
1613
|
+
while retries < max_retries:
|
|
1614
|
+
# 随机选择一个可用场景
|
|
1615
|
+
selected_scene = random.choice(available_scenes)
|
|
1616
|
+
gen_shape = selected_scene()
|
|
1617
|
+
# 校验约束(含广播兼容性)
|
|
1618
|
+
if is_valid(gen_shape):
|
|
1619
|
+
break
|
|
1620
|
+
retries += 1
|
|
1621
|
+
|
|
1622
|
+
if retries >= max_retries:
|
|
1623
|
+
raise RuntimeError("超出最大重试次数,无法生成满足约束的shape")
|
|
1624
|
+
|
|
1625
|
+
return gen_shape
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
def get_broadcastable_shapes(
|
|
1629
|
+
target_shape: List[int], num_shapes: int = 10, seed: Optional[int] = None
|
|
1630
|
+
) -> List[List[int]]:
|
|
1631
|
+
"""
|
|
1632
|
+
根据目标shape获取可单向推导(broadcast)至目标shape的shape列表
|
|
1633
|
+
|
|
1634
|
+
这是generate_broadcast_shapes的语义化封装,返回所有可以broadcast到target_shape的shape
|
|
1635
|
+
|
|
1636
|
+
Args:
|
|
1637
|
+
target_shape: 目标shape
|
|
1638
|
+
num_shapes: 需要生成的shape数量
|
|
1639
|
+
seed: 随机种子(可选)
|
|
1640
|
+
|
|
1641
|
+
Returns:
|
|
1642
|
+
可以broadcast到target_shape的shape列表
|
|
1643
|
+
|
|
1644
|
+
Examples:
|
|
1645
|
+
>>> shapes = get_broadcastable_shapes([2, 3, 4], num_shapes=5)
|
|
1646
|
+
>>> all(can_broadcast_to(s, [2, 3, 4]) for s in shapes)
|
|
1647
|
+
True
|
|
1648
|
+
"""
|
|
1649
|
+
return generate_broadcast_shapes(target_shape, num_shapes, seed)
|
|
1650
|
+
|
|
1651
|
+
|
|
1652
|
+
def generate_unidirectional_broadcast_shapes(
|
|
1653
|
+
shape1: List[int], seed: Optional[int] = None
|
|
1654
|
+
) -> List[int]:
|
|
1655
|
+
"""
|
|
1656
|
+
根据目标shape1获取可推导(broadcast)至目标shape1的shape2(仅保证shape2→shape1可广播)
|
|
1657
|
+
|
|
1658
|
+
Broadcast规则:从后往前对齐维度,每个维度必须相等或其中一方为1。
|
|
1659
|
+
|
|
1660
|
+
Broadcast场景:
|
|
1661
|
+
| 场景 | 说明 | 示例source | 生成的shape |
|
|
1662
|
+
|------|------|-----------|-------------|
|
|
1663
|
+
| 相等 | 与输入shape完全相等 | [2,3,4] | [2,3,4] |
|
|
1664
|
+
| 维度少 | 维度数小于source,某些轴为1 | [2,3,4] | [4], [3,4], [1,4] |
|
|
1665
|
+
| 维度相等 | 某些轴设为1 | [2,3,4] | [1,3,4], [2,1,4] | 生成→source |
|
|
1666
|
+
|
|
1667
|
+
约束:
|
|
1668
|
+
- shape乘积小于2G
|
|
1669
|
+
- 单轴取值范围1~2G
|
|
1670
|
+
- 最大维度数8
|
|
1671
|
+
|
|
1672
|
+
返回 :
|
|
1673
|
+
- 仅保证shape2能broadcast至shape1(无需限制shape1反向广播)
|
|
1674
|
+
|
|
1675
|
+
Args:
|
|
1676
|
+
shape1: 目标广播形状
|
|
1677
|
+
seed: 随机种子
|
|
1678
|
+
|
|
1679
|
+
Returns:
|
|
1680
|
+
满足广播规则+约束的shape2
|
|
1681
|
+
"""
|
|
1682
|
+
# 1. 初始化随机种子
|
|
1683
|
+
if seed is not None:
|
|
1684
|
+
random.seed(seed)
|
|
1685
|
+
|
|
1686
|
+
# 2. 输入合法性校验
|
|
1687
|
+
if not isinstance(shape1, list) or not all(isinstance(x, int) and x >= 1 for x in shape1):
|
|
1688
|
+
raise ValueError("shape1必须是由正整数组成的列表")
|
|
1689
|
+
if len(shape1) > MAX_DIMENSIONS:
|
|
1690
|
+
raise ValueError(f"shape1维度数不能超过{MAX_DIMENSIONS}")
|
|
1691
|
+
|
|
1692
|
+
# 3. 核心辅助函数:判断a是否能广播到b(标准广播规则)
|
|
1693
|
+
def can_broadcast(a: List[int], b: List[int]) -> bool:
|
|
1694
|
+
"""检查a是否能广播到b(按numpy/pytorch广播规则)"""
|
|
1695
|
+
max_dim = max(len(a), len(b))
|
|
1696
|
+
# 补1对齐维度数
|
|
1697
|
+
a_padded = [1] * (max_dim - len(a)) + a
|
|
1698
|
+
b_padded = [1] * (max_dim - len(b)) + b
|
|
1699
|
+
|
|
1700
|
+
# 逐维校验:相等 或 其中一方为1
|
|
1701
|
+
for dim_a, dim_b in zip(a_padded, b_padded):
|
|
1702
|
+
if dim_a != dim_b and dim_a != 1 and dim_b != 1:
|
|
1703
|
+
return False
|
|
1704
|
+
return True
|
|
1705
|
+
|
|
1706
|
+
# 4. 辅助函数:计算shape乘积(用于约束校验)
|
|
1707
|
+
def calc_product(shape: List[int]) -> int:
|
|
1708
|
+
prod = 1
|
|
1709
|
+
for val in shape:
|
|
1710
|
+
prod *= val
|
|
1711
|
+
if prod > MAX_SHAPE_PRODUCT:
|
|
1712
|
+
break
|
|
1713
|
+
return prod
|
|
1714
|
+
|
|
1715
|
+
# 5. 辅助函数:校验shape是否满足所有约束
|
|
1716
|
+
def is_valid_shape(shape: List[int]) -> bool:
|
|
1717
|
+
# 约束1:维度数≤8
|
|
1718
|
+
if len(shape) > MAX_DIMENSIONS:
|
|
1719
|
+
return False
|
|
1720
|
+
# 约束2:单轴取值1~2G
|
|
1721
|
+
if any(val < MIN_DIM_VALUE or val > MAX_DIM_VALUE for val in shape):
|
|
1722
|
+
return False
|
|
1723
|
+
# 约束3:乘积<2G
|
|
1724
|
+
if calc_product(shape) >= MAX_SHAPE_PRODUCT:
|
|
1725
|
+
return False
|
|
1726
|
+
return True
|
|
1727
|
+
|
|
1728
|
+
# 6. 定义3种广播场景的生成函数
|
|
1729
|
+
def _scene_equal() -> List[int]:
|
|
1730
|
+
"""场景1:与shape1完全相等"""
|
|
1731
|
+
return shape1.copy()
|
|
1732
|
+
|
|
1733
|
+
def _scene_less_dims() -> List[int]:
|
|
1734
|
+
"""场景2:维度数小于shape1,从后往前对齐,可选轴设为1"""
|
|
1735
|
+
shape1_dim = len(shape1)
|
|
1736
|
+
# 1维时特殊处理:返回[1](唯一合法的少维度值)
|
|
1737
|
+
if shape1_dim == 1:
|
|
1738
|
+
return [1]
|
|
1739
|
+
# 多维时随机选择维度数(1 ~ shape1_dim-1)
|
|
1740
|
+
gen_dim = random.randint(1, shape1_dim - 1)
|
|
1741
|
+
# 从shape1末尾取gen_dim个维度,随机将部分轴设为1
|
|
1742
|
+
gen_shape = shape1[-gen_dim:].copy()
|
|
1743
|
+
# 随机选择0~gen_dim个轴设为1
|
|
1744
|
+
axes_to_1 = random.sample(range(gen_dim), k=random.randint(0, gen_dim))
|
|
1745
|
+
for idx in axes_to_1:
|
|
1746
|
+
gen_shape[idx] = 1
|
|
1747
|
+
return gen_shape
|
|
1748
|
+
|
|
1749
|
+
def _scene_same_dims() -> List[int]:
|
|
1750
|
+
"""场景3:维度数与shape1相等,随机将部分轴设为1"""
|
|
1751
|
+
gen_shape = shape1.copy()
|
|
1752
|
+
# 随机选择1~所有轴设为1(至少1个,避免与场景1重复)
|
|
1753
|
+
axes_to_1 = random.sample(range(len(gen_shape)), k=random.randint(1, len(gen_shape)))
|
|
1754
|
+
for idx in axes_to_1:
|
|
1755
|
+
gen_shape[idx] = 1
|
|
1756
|
+
return gen_shape
|
|
1757
|
+
|
|
1758
|
+
# 7. 随机选择场景生成shape2,直到满足所有约束+广播规则
|
|
1759
|
+
scenes = [_scene_equal, _scene_less_dims, _scene_same_dims]
|
|
1760
|
+
max_retries = 1000 # 最大重试次数,避免死循环
|
|
1761
|
+
retries = 0
|
|
1762
|
+
shape2 = []
|
|
1763
|
+
|
|
1764
|
+
while retries < max_retries:
|
|
1765
|
+
# 随机选择一个场景
|
|
1766
|
+
selected_scene = random.choice(scenes)
|
|
1767
|
+
shape2 = selected_scene()
|
|
1768
|
+
# 校验:约束合法 + shape2能广播到shape1
|
|
1769
|
+
if is_valid_shape(shape2) and can_broadcast(shape2, shape1):
|
|
1770
|
+
break
|
|
1771
|
+
retries += 1
|
|
1772
|
+
|
|
1773
|
+
if retries >= max_retries:
|
|
1774
|
+
raise RuntimeError("超出最大重试次数,无法生成满足约束的广播shape2")
|
|
1775
|
+
|
|
1776
|
+
return shape2
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
# ==================== 随机Shape生成测试 ====================
|
|
1780
|
+
|
|
1781
|
+
|
|
1782
|
+
def _test_random_shape_generation():
|
|
1783
|
+
"""测试随机shape生成功能"""
|
|
1784
|
+
print("\n" + "=" * 60)
|
|
1785
|
+
print("随机Shape生成功能测试")
|
|
1786
|
+
print("=" * 60)
|
|
1787
|
+
|
|
1788
|
+
# 测试1: 基本功能测试
|
|
1789
|
+
print("\n1. 基本功能测试:")
|
|
1790
|
+
for dims in [1, 2, 3, 4, 5]:
|
|
1791
|
+
shape = generate_random_shape(dims, seed=42)
|
|
1792
|
+
product = _calculate_shape_product(shape)
|
|
1793
|
+
valid = product <= MAX_SHAPE_PRODUCT and len(shape) == dims
|
|
1794
|
+
status = "✓" if valid else "✗"
|
|
1795
|
+
print(
|
|
1796
|
+
f" {status} 维度{dims}: {shape}, 乘积={product:,}, <2G: {product <= MAX_SHAPE_PRODUCT}"
|
|
1797
|
+
)
|
|
1798
|
+
|
|
1799
|
+
# 测试2: 对数分段覆盖测试
|
|
1800
|
+
print("\n2. 对数分段覆盖测试 (生成100个shape,分析乘积分布):")
|
|
1801
|
+
shapes = generate_random_shapes(3, count=100, seed=42)
|
|
1802
|
+
products = [_calculate_shape_product(s) for s in shapes]
|
|
1803
|
+
|
|
1804
|
+
# 按数量级分组统计
|
|
1805
|
+
ranges = [
|
|
1806
|
+
(1, 100, "<100"),
|
|
1807
|
+
(100, 1000, "100-1K"),
|
|
1808
|
+
(1000, 10000, "1K-10K"),
|
|
1809
|
+
(10000, 100000, "10K-100K"),
|
|
1810
|
+
(100000, 1000000, "100K-1M"),
|
|
1811
|
+
(1000000, 10000000, "1M-10M"),
|
|
1812
|
+
(10000000, 100000000, "10M-100M"),
|
|
1813
|
+
(100000000, MAX_SHAPE_PRODUCT, ">100M"),
|
|
1814
|
+
]
|
|
1815
|
+
|
|
1816
|
+
for min_val, max_val, label in ranges:
|
|
1817
|
+
count = sum(1 for p in products if min_val <= p < max_val)
|
|
1818
|
+
if count > 0:
|
|
1819
|
+
print(f" {label}: {count}个")
|
|
1820
|
+
|
|
1821
|
+
# 测试3: 维度值分布测试
|
|
1822
|
+
print("\n3. 维度值分布测试 (100个3维shape):")
|
|
1823
|
+
all_dims = []
|
|
1824
|
+
for s in shapes:
|
|
1825
|
+
all_dims.extend(s)
|
|
1826
|
+
|
|
1827
|
+
dim_ranges = [
|
|
1828
|
+
(1, 1, "1"),
|
|
1829
|
+
(2, 10, "2-10"),
|
|
1830
|
+
(11, 100, "11-100"),
|
|
1831
|
+
(101, 1000, "101-1K"),
|
|
1832
|
+
(1001, 10000, "1K-10K"),
|
|
1833
|
+
(10001, MAX_DIM_VALUE, ">10K"),
|
|
1834
|
+
]
|
|
1835
|
+
|
|
1836
|
+
for min_val, max_val, label in dim_ranges:
|
|
1837
|
+
count = sum(1 for d in all_dims if min_val <= d <= max_val)
|
|
1838
|
+
pct = count / len(all_dims) * 100
|
|
1839
|
+
if count > 0:
|
|
1840
|
+
print(f" 维度值{label}: {count}个 ({pct:.1f}%)")
|
|
1841
|
+
|
|
1842
|
+
# 测试4: 边界情况测试
|
|
1843
|
+
print("\n4. 边界情况测试:")
|
|
1844
|
+
# 测试1维
|
|
1845
|
+
shape = generate_random_shape(1, seed=42)
|
|
1846
|
+
print(f" 1维shape: {shape}, 乘积={_calculate_shape_product(shape)}")
|
|
1847
|
+
|
|
1848
|
+
# 测试8维
|
|
1849
|
+
shape = generate_random_shape(8, seed=42)
|
|
1850
|
+
print(f" 8维shape: {shape}, 乘积={_calculate_shape_product(shape)}")
|
|
1851
|
+
|
|
1852
|
+
# 测试5: 多样化shape生成
|
|
1853
|
+
print("\n5. 多样化shape生成测试:")
|
|
1854
|
+
shapes = generate_diverse_random_shapes([1, 2, 3, 4], count_per_dim=3, seed=42)
|
|
1855
|
+
for i, s in enumerate(shapes, 1):
|
|
1856
|
+
product = _calculate_shape_product(s)
|
|
1857
|
+
print(f" {i}. {s} (乘积: {product:,})")
|
|
1858
|
+
|
|
1859
|
+
# 测试6: 验证所有shape满足约束
|
|
1860
|
+
print("\n6. 约束验证测试 (1000个随机shape):")
|
|
1861
|
+
all_valid = True
|
|
1862
|
+
violations = []
|
|
1863
|
+
|
|
1864
|
+
for dims in range(1, 9):
|
|
1865
|
+
for _ in range(125): # 总共1000个
|
|
1866
|
+
shape = generate_random_shape(dims)
|
|
1867
|
+
product = _calculate_shape_product(shape)
|
|
1868
|
+
|
|
1869
|
+
if product > MAX_SHAPE_PRODUCT:
|
|
1870
|
+
violations.append(("乘积超限", shape, product))
|
|
1871
|
+
all_valid = False
|
|
1872
|
+
|
|
1873
|
+
if len(shape) != dims:
|
|
1874
|
+
violations.append(("维度不匹配", shape, dims))
|
|
1875
|
+
all_valid = False
|
|
1876
|
+
|
|
1877
|
+
for d in shape:
|
|
1878
|
+
if d < 1 or d > MAX_DIM_VALUE:
|
|
1879
|
+
violations.append(("维度值超限", shape, d))
|
|
1880
|
+
all_valid = False
|
|
1881
|
+
|
|
1882
|
+
if all_valid:
|
|
1883
|
+
print(" ✓ 所有1000个shape都满足约束条件")
|
|
1884
|
+
else:
|
|
1885
|
+
print(f" ✗ 发现{len(violations)}个违规:")
|
|
1886
|
+
for v in violations[:5]:
|
|
1887
|
+
print(f" {v}")
|
|
1888
|
+
|
|
1889
|
+
# 测试7: 对数分段均匀性测试
|
|
1890
|
+
print("\n7. 对数分段均匀性测试 (500分段,每段采样1次):")
|
|
1891
|
+
segment_counts = [0] * 10 # 将500段分成10组统计
|
|
1892
|
+
|
|
1893
|
+
for _ in range(500):
|
|
1894
|
+
shape = generate_random_shape(3)
|
|
1895
|
+
product = _calculate_shape_product(shape)
|
|
1896
|
+
log_product = math.log2(max(1, product))
|
|
1897
|
+
log_max = math.log2(MAX_SHAPE_PRODUCT)
|
|
1898
|
+
|
|
1899
|
+
# 确定落在哪个组
|
|
1900
|
+
group = int(log_product / log_max * 10)
|
|
1901
|
+
group = min(9, group)
|
|
1902
|
+
segment_counts[group] += 1
|
|
1903
|
+
|
|
1904
|
+
print(" 各对数区间的shape数量分布:")
|
|
1905
|
+
for i, count in enumerate(segment_counts):
|
|
1906
|
+
log_start = i * math.log2(MAX_SHAPE_PRODUCT) / 10
|
|
1907
|
+
log_end = (i + 1) * math.log2(MAX_SHAPE_PRODUCT) / 10
|
|
1908
|
+
val_start = int(2**log_start)
|
|
1909
|
+
val_end = int(2**log_end)
|
|
1910
|
+
bar = "█" * (count // 5)
|
|
1911
|
+
print(f" [{val_start:>10,} - {val_end:>10,}]: {count:3d} {bar}")
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
if __name__ == "__main__":
|
|
1915
|
+
# 运行所有测试
|
|
1916
|
+
print("=" * 60)
|
|
1917
|
+
print("Utils 模块功能测试")
|
|
1918
|
+
print("=" * 60)
|
|
1919
|
+
|
|
1920
|
+
# dtype相关测试
|
|
1921
|
+
print("\n" + "=" * 60)
|
|
1922
|
+
print("dtype 映射测试")
|
|
1923
|
+
print("=" * 60)
|
|
1924
|
+
|
|
1925
|
+
test_cases = ["FLOAT", "float", "FLOAT32", "float16", "FP16", "INT32", "BOOL"]
|
|
1926
|
+
for tc in test_cases:
|
|
1927
|
+
result = normalize_dtype(tc)
|
|
1928
|
+
print(f"normalize_dtype('{tc}') = '{result}'")
|
|
1929
|
+
|
|
1930
|
+
# 随机shape生成测试
|
|
1931
|
+
_test_random_shape_generation()
|