三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

CANN/cannbot-skills CUDA迁移规则模式

CANN/cannbot-skills CUDA迁移规则模式

Rule Schema

【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体,本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills

grammar_rules.yamlandconstraint_rules.yamlare the source of truth for syntax-rewrite rules and migration constraint rules.

The Markdown files remain human-readable browse views:

  • grammar.md
  • constraints.md

Update the YAML files first. Keep the Markdown views aligned afterward.

grammar_rules.yaml

Usegrammar_rules.yamlto record syntax-level rewrite rules for CUDA source code that must be adjusted for Ascend C SIMT.

Record Structure

- rule_id: assert-header pattern: assert category: debug status: required action: include_header cuda_form: assert(...) ascend_form: '#include "utils/debug/asc_assert.h"' note: Add the Ascend SIMT assert header when assert is used. source: - reference/grammar.md reviewed_by: human reviewed_at: "2026-04-06"

Field Definitions

  • rule_id

    • Required.
    • Unique identifier for the rule.
    • Use lowercase letters, digits, and hyphens.
  • pattern

    • Required.
    • The CUDA syntax pattern or construct this rule applies to.
  • category

    • Required.
    • Suggested values:
      • debug
      • memory-space
      • header
      • syntax
  • status

    • Required.
    • One of:
      • required: a fixed rule that must be applied
      • rewrite-required: syntax must be transformed
      • conditional: only applies in specific situations
      • unknown: rule not fully confirmed yet
  • action

    • Required.
    • One of:
      • include_header
      • syntax_replace
      • check_docs
      • manual_review
  • cuda_form

    • Required, may be empty.
    • Short representation of the CUDA-side form.
  • ascend_form

    • Required, may be empty.
    • Short representation of the Ascend-side form.
  • note

    • Required, may be empty.
    • Brief explanation of the rule or its scope.
  • source

    • Required.
    • List of references that justify the rule.
  • reviewed_by

    • Required, may be empty.
    • human,agent, or a more specific reviewer label.
  • reviewed_at

    • Required, may be empty.
    • ISO date string.

Maintenance Rules

  • Add a new rule when the syntax transformation is reusable across operators.
  • Do not encode one-off operator-specific hacks as global syntax rules.
  • If the rewrite rule is uncertain, keepstatus: unknownorstatus: conditional.
  • Prefer shortcuda_formandascend_formexamples over long code blocks.

constraint_rules.yaml

Useconstraint_rules.yamlto record unsupported or restricted features in the current migration model.

Record Structure

- rule_id: cooperative-groups feature: Cooperative Groups category: execution-model status: unsupported action: stop_and_report workaround: "" note: No workaround in the current migration model. source: - reference/constraints.md reviewed_by: human reviewed_at: "2026-04-06"

Field Definitions

  • rule_id

    • Required.
    • Unique identifier for the constraint rule.
    • Use lowercase letters, digits, and hyphens.
  • feature

    • Required.
    • Human-readable name of the constrained feature.
  • category

    • Required.
    • Suggested values:
      • graphics
      • execution-model
      • memory-model
      • performance-model
      • compilation
      • data-type
      • build
  • status

    • Required.
    • One of:
      • unsupported: the feature has no direct migration support in the current model; useactionto distinguish blocking features from removable unsupported subpaths
      • restricted: only usable with a workaround or limitation
      • conditional: support depends on context or extra confirmation
      • unknown: not fully investigated yet
  • action

    • Required.
    • One of:
      • stop_and_report: the selected migration path cannot continue
      • remove_and_record: remove or exclude the unsupported source subpath, record the exclusion, and continue only if supported behavior remains
      • manual_implementation
      • check_docs
      • manual_review
  • workaround

    • Required, may be empty.
    • The accepted workaround when one exists.
  • note

    • Required, may be empty.
    • Brief explanation of the constraint.
  • source

    • Required.
    • List of references that justify the rule.
  • reviewed_by

    • Required, may be empty.
    • human,agent, or a more specific reviewer label.
  • reviewed_at

    • Required, may be empty.
    • ISO date string.

Maintenance Rules

  • Useunsupportedonly when the feature itself has no direct migration support in the current migration model.
  • Useaction: stop_and_reportfor blocking unsupported features that prevent the selected migration path from continuing.
  • Useaction: remove_and_recordfor unsupported subpaths that may be removed or excluded while preserving supported source-visible behavior.
  • Userestrictedwhen a workaround exists but carries limits or extra migration work.
  • If the rule still needs confirmation, useconditionalorunknown; do not overstate support.
  • Keep workarounds short in YAML and move long explanations to Markdown if needed.

General Update Workflow

When a human or agent updates rule references:

  1. Update the relevant YAML file first.
  2. Keeprule_idstable once introduced.
  3. Add or revisesource,note, andreviewed_at.
  4. Sync the Markdown browse view if the rule meaning changed.

【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体,本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

← 返回列表