Skip to content

Commit 45e543d

Browse files
erwei-xilinxclaude
andcommitted
[multi-gpu] Phase 1: fix negative-rank verifier check
The previous commit (888bcaa) added a `>= 0` verifier on src_rank / dst_rank, but used `getSrcRank()` / `getDstRank()` — those return `std::optional<uint64_t>` (a TableGen quirk for `OptionalAttr<I64Attr>`), so `*sr < 0` on the unsigned value is always false and the check never fired. The two new verifier-negative tests in air_memcpy_invalid.mlir silently regressed. Switch to the typed `getSrcRankAttr()` / `getDstRankAttr()` accessors which return `IntegerAttr`, then call `.getInt()` for a real `int64_t`. The check now fires on negative values; both negative-rank tests pass under `lit -sv ../../mlir/test/Dialect/AIR` (21/21). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 44d743d commit 45e543d

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

mlir/lib/Dialect/AIR/IR/AIRDialect.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,13 +2823,20 @@ LogicalResult air::DmaMemcpyNdOp::verify() {
28232823
return emitOpError("src_rank/dst_rank attributes require an enclosing "
28242824
"air.rank scope");
28252825

2826-
// Rank indices are non-negative.
2827-
if (auto sr = getSrcRank())
2828-
if (*sr < 0)
2829-
return emitOpError() << "src_rank must be >= 0, got " << *sr;
2830-
if (auto dr = getDstRank())
2831-
if (*dr < 0)
2832-
return emitOpError() << "dst_rank must be >= 0, got " << *dr;
2826+
// Rank indices are non-negative. Use the typed *Attr accessor instead
2827+
// of the generated getSrcRank()/getDstRank() (those return uint64_t
2828+
// for OptionalAttr<I64Attr>, so a comparison against 0 is meaningless
2829+
// for negative values stored as i64).
2830+
if (auto srAttr = getSrcRankAttr()) {
2831+
int64_t sr = srAttr.getInt();
2832+
if (sr < 0)
2833+
return emitOpError() << "src_rank must be >= 0, got " << sr;
2834+
}
2835+
if (auto drAttr = getDstRankAttr()) {
2836+
int64_t dr = drAttr.getInt();
2837+
if (dr < 0)
2838+
return emitOpError() << "dst_rank must be >= 0, got " << dr;
2839+
}
28332840

28342841
auto requireSymmetricAlloc = [&](Value v, StringRef side) -> LogicalResult {
28352842
auto alloc = v.getDefiningOp<memref::AllocOp>();

0 commit comments

Comments
 (0)