feat: add PTO op coverage for remaining math/expand ops#408
Conversation
Codex Review该评论由 review 机器人自动更新。
Summary发现 3 个问题:新 row-expand verifier 放宽了操作数/shape 合约,A2/A3 的 tmp 版 row-expand 新 op 不能做 PTO-BC v0 编码,且 trowprod 仍缺少默认的 ptobc v0 覆盖。 Findings
lib/PTO/IR/PTO.cpp 中新的 verifyTRowExpandReduceLikeOp 通过 src0MatchesDst/src1MatchesDst 仅按 valid_shape 选择“完整 tile”操作数,并且没有再对完整输入或 tmp 调用 verifyTileBufSameShapeAndElem/verifyTileBufSameValidShape。结果是两类无效 IR 会被接受:1) 对 trowexpandexpdif 而言,src1 作为完整 tile、src0 作为按行广播向量也能通过,但 lowering 仍固定按 TROWEXPANDEXPDIF(dst, src0, src1) 发射,语义会被反转;2) 完整输入或 tmp 的静态 tile shape 与 dst 不一致时也能通过验证。这样的 IR 会一路进入 codegen,最终要么算错,要么在后端/运行时报错。
这三个新 op 在 IR 合约里都声明了 Optional tmp(见 include/PTO/IR/PTOOps.td),但 tools/ptobc/generated/ptobc_opcodes_v0.h:111-113 仍把它们登记成 operand_mode=0x00、num_operands=3 的固定三操作数 op。tools/ptobc/src/mlir_encode.cpp:429-430 会对 0x00 模式做严格 operand count 检查,所以任何合法的 A2/A3 4 操作数形式都会在 ptobc encode 阶段直接失败。因为名字已经命中 opcode 表,编码器也不会再退回 generic escape。
PR 新增了 pto.trowprod,但 tools/ptobc/generated/ptobc_opcodes_v0.h 里没有任何 pto.trowprod 条目。按照 tools/ptobc/src/mlir_encode.cpp:485-486,默认 ptobc encode 会把这种 op 当成“not in v0 opcode table”并报错,只有显式打开 PTOBC_ALLOW_GENERIC=1 才能走 generic escape。runop.sh 恰好开启了这个开关,所以 CI 不会暴露问题,但默认的 BC 兼容性仍然缺失。 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8f3b083b3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| PTODpsType:$src0, | ||
| PTODpsType:$src1, | ||
| Optional<PTODpsType>:$tmp, | ||
| PTODpsType:$dst |
There was a problem hiding this comment.
Align ptobc arity with optional tmp row-expand ops
These new row-expand ops are defined with an optional tmp operand (so A2/A3 can legally build 4-operand forms), but the v0 ptobc schema still encodes them as fixed 3-operand ops and the encoder enforces exact operand counts. As a result, valid IR such as pto.trowexpandmax/min/expdif with tmp will fail ptobc encode with an operand-count mismatch, breaking the bytecode workflow for supported A2/A3 forms.
Useful? React with 👍 / 👎.
| except subprocess.CalledProcessError: | ||
| pass | ||
| return git_output("diff-tree", "--no-commit-id", "--name-only", "--diff-filter=ACMR", "-r", head_sha) |
There was a problem hiding this comment.
Preserve full changed-file set when git diff fails
When git diff base..head fails, the fallback uses git diff-tree -r head, which only reports files from the tip commit. In shallow or partially-fetched checkouts where the base SHA is missing, this silently drops files changed in earlier commits of the push, so the license-header check can pass even though required headers are missing in skipped files.
Useful? React with 👍 / 👎.
A3 板测失败
失败用例
|
A3 板测失败详情:PR #408rsqrt
|
Summary
runop.sh --enablebcon both default arch and--pto-arch a5Validation
cmake --build build --parallel 8 --target installPTOAS_BIN=$PWD/build/tools/ptoas/ptoas PTOBC_BIN=$PWD/build/tools/ptobc/ptobc PYTHON_BIN=/Users/laoda/miniforge3/envs/ptoas-py39/bin/python PYTHONPATH=$PWD/install:/Users/laoda/llvm-workspace/llvm-project/llvm/build-shared/tools/mlir/python_packages/mlir_core bash test/samples/runop.sh --enablebc -t Fmodrunop.sh --enablebccoverage forFmods Colprod Colexpandadd Colexpandexpdif Rowprod Rowexpandmax Rowexpandmin RowexpandexpdifPTOAS_FLAGS="--pto-arch a5"