Skip to content

[Verifier] Enforce TStore dst shape and src valid_shape consistency#466

Open
TaoTao-real wants to merge 1 commit intohw-native-sys:mainfrom
TaoTao-real:codex/issue322-tstore-verify-shape-valid
Open

[Verifier] Enforce TStore dst shape and src valid_shape consistency#466
TaoTao-real wants to merge 1 commit intohw-native-sys:mainfrom
TaoTao-real:codex/issue322-tstore-verify-shape-valid

Conversation

@TaoTao-real
Copy link
Copy Markdown
Contributor

Summary

  • Add a verifier constraint in pto.tstore to enforce destination partition shape matches source tile valid_shape on statically-known dimensions.
  • Keep dynamic dimensions permissive (only static-vs-static mismatch is rejected).
  • Add a negative regression test for shape/valid mismatch.

Motivation

Design

  • Updated TStoreOp::verify() common path in lib/PTO/IR/PTO.cpp.
  • New check runs before arch-specific dtype/address-space checks.
  • Error is dimension-specific: dst shape[i] vs src valid_shape[i].

Testing

  • ninja -C build ptoas
  • build/tools/ptoas/ptoas test/basic/tstore_verify_shape_valid_mismatch_invalid.pto -o /tmp/tstore_invalid.cpp (expect fail with verifier error)
  • build/tools/ptoas/ptoas test/basic/tquant_e2e.pto -o /tmp/tquant_e2e.cpp (expect pass)
  • build/tools/ptoas/ptoas test/basic/tcvt_e2e.pto -o /tmp/tcvt_e2e.cpp (expect pass)

Risk / Rollback

  • Risk: kernels relying on previously-accepted invalid tstore IR will now fail verifier earlier.
  • Rollback: revert this PR to restore previous permissive behavior.

Copy link
Copy Markdown

@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 explicit shape verification for the TStoreOp in the PTO dialect, ensuring that the destination tensor partition shape matches the source tile's valid shape for all statically-known dimensions. A new test case was added to validate this check. Feedback suggests making the test's error message verification more specific to ensure the reported dimension sizes are correct.

}
}

// CHECK: error: 'pto.tstore' op expects dst shape[0] to match src valid_shape[0]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The FileCheck directive is a bit too general. It would be better to check for the specific values in the error message to make the test more robust. This ensures that the verifier is not only firing but also reporting the correct expected and actual dimension sizes.

// CHECK: error: 'pto.tstore' op expects dst shape[0] to match src valid_shape[0] (32), but got 64

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.

1 participant