cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
326 stars 92 forks source link

[IRBuilder] Fix FP to Index cast #498

Closed zzzDavid closed 1 year ago

zzzDavid commented 1 year ago

This PR fixes an issue with FP to Index type cast op.

Building arith.fptoui for fp -> index cast fails at MLIR verification with message:

arith.fptoui result #0 must be signless-fixed-width-integer-like, but got index

The solution is to cast FP to UI first, then use arith.index_cast to cast UI to Index.

zzzDavid commented 1 year ago

Wait to merge PR: https://github.com/cornell-zhang/heterocl/pull/499 so CI test can run

zzzDavid commented 1 year ago

Yes, that makes sense. Let me add that checking

zzzDavid commented 1 year ago

Added type checking for indices, and update tests: added two FP-as-index cases that are expected to fail.