Skip to content

[Add] pass generate skill#945

Open
fuhouyu-hw wants to merge 1 commit intotile-ai:ascendc_ptofrom
fuhouyu-hw:ascendc_pto
Open

[Add] pass generate skill#945
fuhouyu-hw wants to merge 1 commit intotile-ai:ascendc_ptofrom
fuhouyu-hw:ascendc_pto

Conversation

@fuhouyu-hw
Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions
Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run bash format.sh in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.

We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work!

🚀

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the tilelang-pass-generate skill, which automates the generation of TileLang-Ascend Pass implementation code, including C++ source, Python wrappers, and pipeline integration. It establishes a structured workflow that moves from an implementation skeleton to final code and smoke testing, while explicitly delegating unit and system testing to a separate future skill. The review feedback correctly identifies several technical inaccuracies in the provided C++ templates regarding TVM's internal APIs, specifically noting that arith::IRMutatorWithAnalyzer requires an analyzer pointer in its constructor and that PrimFunc objects are immutable, requiring a specific reconstruction pattern rather than a MutateFunc method.


| 场景 | 默认做法 |
|------|----------|
| 父类是 `IRMutatorWithAnalyzer` | 在 `Substitute` 中执行 `mutator.MutateFunc(f)`,构造函数传 `f->body` |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在 TVM 的标准实现中,arith::IRMutatorWithAnalyzer 的构造函数通常接收一个 arith::Analyzer* 指针,而不是 f->body。此外,该类及其基类 StmtExprMutator 并没有 MutateFunc 方法,通常是直接调用 operator()(stmt)。为了确保 AI Agent 生成的代码能够编译通过,建议修正此处的描述。

Suggested change
| 父类是 `IRMutatorWithAnalyzer` |`Substitute` 中执行 `mutator.MutateFunc(f)`,构造函数传 `f->body` |
| 父类是 `IRMutatorWithAnalyzer` |`Substitute` 中构造 `analyzer` 并传给 `mutator`,执行 `mutator(f->body)` |


private:
// 构造函数
{PassName}(PrimFunc f, PassContext ctx, {输入 attrs 参数});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

如前所述,如果类继承自 arith::IRMutatorWithAnalyzer,其构造函数必须接收并初始化基类的 analyzer。建议在模板中明确这一点,或者提供一个更符合 TVM 惯例的构造函数签名。

Suggested change
{PassName}(PrimFunc f, PassContext ctx, {输入 attrs 参数});
{PassName}(arith::Analyzer* analyzer, {输入 attrs 参数});

Comment on lines +103 to +104
PrimFunc new_f = mutator.MutateFunc(f); # IRMutatorWithAnalyzer
// 或 mutator.VisitStmt(f->body); # StmtExprVisitor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在 TVM 中,PrimFunc 是不可变的。变换 PrimFunc 的标准做法是变换其 body,然后构造一个新的 PrimFuncMutateFunc 并非标准 API。建议更新伪代码以反映真实的 IR 变换流程。

Suggested change
PrimFunc new_f = mutator.MutateFunc(f); # IRMutatorWithAnalyzer
// 或 mutator.VisitStmt(f->body); # StmtExprVisitor
4. 执行变换
auto new_body = mutator(f->body);
PrimFunc new_f = PrimFunc(f->params, new_body, f->ret_type, f->buffer_map, f->attrs);

@fuhouyu-hw fuhouyu-hw changed the title [Add] pass generate pass [Add] pass generate skill Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants