Skip to content

Add integer compatibility for selected PTO index operands#411

Open
zhangstevenunity wants to merge 3 commits intomainfrom
codex/index-compat-inputs
Open

Add integer compatibility for selected PTO index operands#411
zhangstevenunity wants to merge 3 commits intomainfrom
codex/index-compat-inputs

Conversation

@zhangstevenunity
Copy link
Copy Markdown
Collaborator

Summary

  • allow selected PTO ops to accept i64 or index operands for pointer/view-related indices
  • allow selected tile ops to accept u32-compatible or index operands for valid-shape and tile element indexing
  • preserve existing textual syntax by default and bridge compatible integer operands back to index where lowering still requires it

Details

  • add IndexOrI64 and IndexOrU32 operand constraints in ODS
  • add custom asm parsing/printing for ops whose old syntax omitted operand types so old IR stays valid while non-index operands can still be printed and parsed
  • relax verifiers for textract/tinsert and add uniform compatible-type checks for grouped operands
  • update PTOViewToMemref lowering to cast compatible integer operands back to index before feeding memref.dim, bind_tile, and pointer_cast

Validation

  • built ptoas and ptobc successfully in WSL against the updated workspace sources

@reedhecre
Copy link
Copy Markdown

reedhecre commented Apr 1, 2026

Codex Review

该评论由 review 机器人自动更新。

  • PR: Add integer compatibility for selected PTO index operands #411 Add integer compatibility for selected PTO index operands
  • Author: zhangstevenunity
  • Base/Head: main / codex/index-compat-inputs
  • Head SHA: 099eb18109ae
  • Trigger: PR 有新提交
  • Generated At: 2026-04-01T09:31:56Z
  • Previous Head SHA: 9314fbac10b5
  • Status: completed

Summary

发现 3 个问题:TInsertOp::verify 引入了编译错误,且 tinsert/alloc_tile addr 的 i32 兼容路径仍不完整。

Findings

  1. P1 `TInsertOp::verify` 当前代码无法通过编译 lib/PTO/IR/PTO.cpp:3846

这里新加的 readConstIndex lambda 明确声明返回 bool,但失败分支却返回了 std::nullopt;同时下面的 verifyIndexOperands / verifyStaticBounds 还在继续调用已经不存在的 getConstIndex(Value) 版本。lib/PTO/IR/PTO.cpp 因此会直接编译失败,属于 CI/build blocker。

  1. P2 `tinsert` 的 verifier 仍然拒绝 i32 索引,与 ODS/功能宣称不一致 lib/PTO/IR/PTO.cpp:3848

PR 已把 TInsertOpindexRow/indexCol 放宽到 IndexOrI32,但这里的 verifyIndexOperands() 仍然硬编码要求两个操作数都是 index。结果是 tile_buf 形式的 pto.tinsert 传入 i32 仍会在 verifier 阶段报错,和这次“selected PTO index operands 支持整数”的目标不一致。新增测试只覆盖了 memref 旁路路径,所以没有把这个问题测出来。

  1. P2 `alloc_tile addr=...` 路径会把 i32 valid dims 降成不合法的内部 IR lib/PTO/Transforms/PTOViewToMemref.cpp:631

这一分支前面已经计算了 bindVRow/bindVCol = ensureIndex(...),但真正创建 BindTileOp 时又回退成了原始的 vRow/vColBindTileOp 在 ODS 里仍然是 Optional<Index>,所以 alloc_tile addr=..., valid_row=%i32, valid_col=%i32 会生成违反内部类型约束的 IR;一旦开启 verifier,或者后续 rewrite 依赖这些约束,就会在这条新兼容路径上失败。

@zhangstevenunity
Copy link
Copy Markdown
Collaborator Author

/run all

@reedhecre
Copy link
Copy Markdown

A3 板测失败

日志尾部

onst {
      |   ^~~~
/tmp/ptoas-board-monitor/runs/20260401_170403_manual_pr411/repo/lib/PTO/Transforms/PTOToEmitC.cpp: At global scope:
/tmp/ptoas-board-monitor/runs/20260401_170403_manual_pr411/repo/lib/PTO/Transforms/PTOToEmitC.cpp:5933:20: warning: ‘std::string maskPatternTok(mlir::pto::MaskPatternAttr)’ defined but not used [-Wunused-function]
 5933 | static std::string maskPatternTok(mlir::pto::MaskPatternAttr a) {
      |                    ^~~~~~~~~~~~~~
/tmp/ptoas-board-monitor/runs/20260401_170403_manual_pr411/repo/lib/PTO/Transforms/PTOToEmitC.cpp:3815:20: warning: ‘std::string getPipeName(mlir::pto::PIPE)’ defined but not used [-Wunused-function]
 3815 | static std::string getPipeName(pto::PIPE pipe) {
      |                    ^~~~~~~~~~~
/tmp/ptoas-board-monitor/runs/20260401_170403_manual_pr411/repo/lib/PTO/Transforms/PTOToEmitC.cpp:2505:13: warning: ‘Role inferSubviewRole(mlir::memref::SubViewOp)’ defined but not used [-Wunused-function]
 2505 | static Role inferSubviewRole(memref::SubViewOp sv) {
      |             ^~~~~~~~~~~~~~~~
/tmp/ptoas-board-monitor/runs/20260401_170403_manual_pr411/repo/lib/PTO/Transforms/PTOToEmitC.cpp:2365:13: warning: ‘void inferTileMNK(mlir::func::FuncOp, int&, int&, int&)’ defined but not used [-Wunused-function]
 2365 | static void inferTileMNK(func::FuncOp f, int &M, int &N, int &K) {
      |             ^~~~~~~~~~~~
/tmp/ptoas-board-monitor/runs/20260401_170403_manual_pr411/repo/lib/PTO/Transforms/PTOToEmitC.cpp:2352:19: warning: ‘KernelKind inferKernelKind(mlir::func::FuncOp)’ defined but not used [-Wunused-function]
 2352 | static KernelKind inferKernelKind(func::FuncOp f) {
      |                   ^~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
===== END STAGE build-ptoas rc=1 @ 2026-04-01 17:04:50 =====

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants