بنقرة واحدة
akg-pr
基于当前分支与目标分支的 diff,自动生成符合 AKG 项目规范的 PR 描述文件。 生成的 .md 和 .json 文件写入 .tmp/pr/,经规范校验后供用户确认和提交。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
基于当前分支与目标分支的 diff,自动生成符合 AKG 项目规范的 PR 描述文件。 生成的 .md 和 .json 文件写入 .tmp/pr/,经规范校验后供用户确认和提交。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
矩阵乘法矩阵乘法 A[M, K] @ B[K, N] = C[M, N]中,大K维度矩阵乘法(K>>M,N)优化:针对M/N较小但K极大(如M=N=256,K=131072)的场景,Split-K切分K维度并行化、Workspace+Reduce替代全局同步,实现显著性能提升
Triton Ascend hard API restrictions and forbidden syntax. MUST-follow rules that apply to every kernel: forbidden control flow (return/break/continue/lambda/while), tensor slice/index restrictions, scalar conversion rules, BLOCK_SIZE upper bound. Violating any of these produces a compile or runtime error on Ascend.
Triton Ascend 性能优化通用策略: BLOCK_SIZE 选择 (1024-2048 for elementwise, must be <65536), grid configuration (use VEC_CORE_NUM / CUBE_CORE_NUM, 2D/3D grid for matmul / conv / reduce, 1D grid + inner loop for elementwise / pointwise), 256B alignment for memory transfers, autotune block-size patterns, fp16 / fp32 precision conversion. Bind via keywords like matmul, elementwise, reduce, block_size, grid, autotune, alignment, fp16, fp32, tile, interleaved-loop, cube-core, vec-core.
通过 adaptive_search 或 evolve 搜索式 workflow 生成优化算子。 后台 silent mode 执行,轮询监控进度。
适用于归约(reduce)类算子和含归约子步骤的复合算子(如归一化)的优化指南。典型算子包括:sum, mean, max, min, prod, argmax, argmin, cumsum, cumprod, softmax, logsoftmax, layernorm, rmsnorm, groupnorm, instancenorm, batchnorm, l1norm, l2norm, frobeniusnorm, var, std, average_pooling, sum_pooling 等。特别重要:当归约维度不是最后一维(如 dim=1 归约 shape=[B,F,D1,D2]),需要正确处理多维索引和两阶段归约。包含 PyTorch normalized_shape 多轴归一化语义说明。不适用于纯逐元素运算或矩阵乘法。如果算子是损失函数(先逐元素计算再全局归约),应选择 elementwise-reduce-fused 指南。
CPU C++ 算子核心概念、标准结构模式、KernelBench 代码规范和内嵌扩展方法
| name | akg-pr |
| description | 基于当前分支与目标分支的 diff,自动生成符合 AKG 项目规范的 PR 描述文件。 生成的 .md 和 .json 文件写入 .tmp/pr/,经规范校验后供用户确认和提交。 |
| argument-hint | 可选:TARGET_BRANCH(目标分支,默认 master)。 可选:REMOTE(远程名,默认自动检测)。 示例:/akg-pr /akg-pr origin/br_agents |
$AKG_AGENTS_DIR/.tmp/pr/,禁止写入其他位置。[AKG_AGENTS] 前缀,格式:[AKG_AGENTS] <kind>: <概要描述>。[ -z "$VAR" ] 判断。Step 1 确定分支与远程信息(自动)
Step 2 收集差异数据(自动)
Step 3 生成 PR 描述文件(自动)
Step 4 规范校验(自动)
Step 5 展示结果 + 用户决策(一次交互)
Step 6 执行 API 提交(仅当用户选择"提交"时,不再二次确认)
执行以下命令收集 git 上下文:
git rev-parse --abbrev-ref HEAD
git remote -v
git config --get branch.$(git rev-parse --abbrev-ref HEAD).remote
参数解析规则(解析 $ARGUMENTS):
/(如 origin/master):
git remote 获取列表/ 前部分在 remote 列表中 → 该部分为 REMOTE,/ 后为 TARGET_BRANCH/ 前部分不在 remote 列表中 → 整体作为 TARGET_BRANCH 使用(可能是 用户名/分支名 格式的 ref)master远程名优先级:用户指定 > tracking remote > origin > origin_gitcode > 第一个
平台与仓库(⚠️ 必须从 git remote -v 的 URL 提取,禁止从用户输入的分支名推断):
gitcode.com / gitee.com / github.comowner/repo(去掉 .git 后缀)🛑 当前分支 == 目标分支 → 报错终止。
git diff <target_branch>...HEAD --stat
git log <target_branch>..HEAD --oneline --no-merges
git diff <target_branch>...HEAD
git status --short
⚠️ 无差异 → 报错终止。 ⚠️ 有未提交变更 → 提醒但继续。
| 字段 | 推断逻辑 |
|---|---|
kind | 从 commit message 关键词推断:fix/bug → bug,feat/add/support → feature,其他 → task |
title | [AKG_AGENTS] <kind>: <概要描述>。单 commit 时可直接用 message 加前缀 |
fixes | 从 commit message 提取 Fixes #N、Close #N,未检测到时写 N/A,不要编造。关联 Issue 时必须使用完整 URL:Fixes https://gitcode.com/mindspore/akg/issues/399 |
description | AI 总结:做了什么、为什么做、怎么做的 |
reviewer_notes | 重点变更、潜在风险、需要特别关注的文件 |
文件名:pr_<branch>_<YYYYMMDD_HHmmss>.md
必须使用以下模板格式:
**What type of PR is this?**
/kind <bug|task|feature>
**What does this PR do / why do we need it**:
<AI 生成的描述>
**Which issue(s) this PR fixes**:
Fixes #<issue_url>(如有,无则写 N/A,必须使用完整 URL 而不是数字编号)
**Special notes for your reviewers**:
<AI 生成的审查要点>
---
### 变更概览
<git diff --stat 输出>
### 关键变更说明
<按模块/目录分组的变更说明>
文件名:pr_<branch>_<YYYYMMDD_HHmmss>.json
{
"version": "1.0",
"type": "pr",
"source_branch": "<当前分支>",
"target_branch": "<目标分支>",
"remote": "<远程名>",
"platform": "<gitcode|gitee|github>",
"repo": "<owner/repo>",
"title": "[AKG_AGENTS] <kind>: <概要描述>",
"kind": "<bug|task|feature>",
"fixes": ["#123"],
"labels": ["kind/<kind>"],
"reviewers": [],
"generated_at": "<ISO 8601 时间戳>",
"body_file": "<对应的 .md 文件名>",
"validation": { "passed": null, "errors": [], "warnings": [] }
}
mkdir -p $AKG_AGENTS_DIR/.tmp/pr
python $AKG_AGENTS_DIR/.opencode/skills/akg-pr/scripts/validate_pr.py $AKG_AGENTS_DIR/.tmp/pr/<json_file>
校验规则(脚本已实现):
| 规则 ID | 描述 | 级别 |
|---|---|---|
| PR-000 | title 必须以 [AKG_AGENTS] 开头 | error |
| PR-001 | /kind 必须存在且为 bug/task/feature | error |
| PR-002 | PR 描述至少 20 字 | error |
| PR-003 | bug fix PR 必须关联 issue(Fixes #) | error |
| PR-004 | 不应有 merge commit | warning |
| PR-006 | title 建议符合 conventional 格式 | warning |
校验结果回填到 .json 的 validation 字段。
一次性展示所有信息,让用户做一次决策:
PR 预览
字段 值 标题 [AKG_AGENTS] feature: 添加 xxx类型 /kind feature分支 <source_branch>→<remote>/<target_branch>仓库 <owner>/<repo>(<平台名>)关联 Issue Fixes #123 / N/A 校验结果:<逐条列出>
文件:
- 描述文件:
.tmp/pr/pr_<branch>_<ts>.md- 元数据文件:
.tmp/pr/pr_<branch>_<ts>.json请选择:
- 提交 — 通过 API 提交到 <平台名>
- 仅保存 — 只保留本地文件
- 修改 — 请说明要改什么
- 放弃
处理逻辑:
⛔ 禁止使用 echo $TOKEN 或 echo "${TOKEN:?}" 打印 Token 值。
# GitCode
if [ -z "$GITCODE_TOKEN" ]; then echo "GITCODE_TOKEN 未设置"; exit 1; fi
echo "GITCODE_TOKEN 已设置"
# Gitee
if [ -z "$GITEE_TOKEN" ]; then echo "GITEE_TOKEN 未设置"; exit 1; fi
echo "GITEE_TOKEN 已设置"
# GitHub
gh auth status
Token 未设置时提示:
GitCode:登录 GitCode → 右上角头像 → 个人设置 → 访问令牌 → 新建访问令牌(勾选 api 权限)
export GITCODE_TOKEN="你的token"文档:https://docs.gitcode.com/docs/help/home/user_center/security_management/user_patGitee:设置 → 私人令牌 → 生成新令牌(勾选 pull_requests 权限)
export GITEE_TOKEN="你的token"GitHub:
gh auth login
重要:title、body 等内容在 Step 3 生成时已存在于上下文中,无需重新读取文件,直接使用即可。
owner 和 repo 必须使用 Step 1 从 git remote -v 提取的值,禁止从用户输入推断。
GitCode(platform == "gitcode"):
使用完整路径 /repos/<owner>/<repo>/pulls,JSON 格式提交。
curl -s -X POST "https://api.gitcode.com/api/v5/repos/<owner>/<repo>/pulls?access_token=$GITCODE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "<title>",
"head": "<source_branch>",
"base": "<target_branch>",
"body": "<body>"
}'
| 参数 | 必填 | 位置 | 说明 |
|---|---|---|---|
access_token | ✅ | query | Token 环境变量 |
owner | ✅ | URL path | 从 git remote -v 的 URL 提取 |
repo | ✅ | URL path | 从 git remote -v 的 URL 提取 |
title | ✅ | JSON body | Step 3 生成的标题 |
head | ✅ | JSON body | 当前分支名 |
base | ✅ | JSON body | 目标分支名 |
body | ❌ | JSON body | Step 3 生成的 PR 正文 |
Gitee(platform == "gitee"):
curl -s -X POST "https://gitee.com/api/v5/repos/<owner>/<repo>/pulls" \
-H "Content-Type: application/json" \
-d '{
"access_token": "'"$GITEE_TOKEN"'",
"title": "<title>",
"head": "<source_branch>",
"base": "<target_branch>",
"body": "<body>"
}'
GitHub(platform == "github"):
gh pr create --title "<title>" --body-file $AKG_AGENTS_DIR/.tmp/pr/<file>.md \
--base <target_branch> --head <source_branch>
html_url)→ 展示 PR 链接403 → URL 中 owner/repo 不正确,检查 git remote -v401 → Token 无效或过期422 → 分支未 push 或 PR 已存在