Skip to content

Add PDL constraint function ktdf.is_precision - #145

Closed
msdataei wants to merge 1 commit into
torch-spyre:mainfrom
msdataei:msd_linalg_gen_precision
Closed

Add PDL constraint function ktdf.is_precision#145
msdataei wants to merge 1 commit into
torch-spyre:mainfrom
msdataei:msd_linalg_gen_precision

Conversation

@msdataei

@msdataei msdataei commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a new PDL constraint function, ktdf.is_precision, usable in device pattern rules to gate matches on the element precision of a linalg.generic op's output (fp16, fp32, or bf16).
  • Register the constraint in PatternCache alongside the existing ktdf.is_reduction_kind / ktdf.is_inner_dim_reduction constraints.

Details

ktdfIsPrecision inspects the first output of a linalg.generic op, resolves its element type (unwrapping MemRefType/ShapedType as needed), and compares it against a caller-supplied expected_prec string attribute. It fails the match if:

  • the matched op is not a linalg.generic,
  • the second operand isn't a string attribute,
  • the op has no outputs, or
  • the element type isn't one of f16/f32/bf16.

Signed-off-by: Masoud Ataei <Masoud.Ataei.Jaliseh@ibm.com>
@msdataei

msdataei commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Upstream changes are in PR#4682

@vswagath1989

Copy link
Copy Markdown
Collaborator

@msdataei - In discussion with @acgatea1 , I have already have a PR to enable this: #143

@msdataei msdataei closed this Sep 8, 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