-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Builder] Add index
from/to Float
/Fixed
/UFixed
type casting
#242
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM
tests/test_types.py
Outdated
@@ -42,6 +43,44 @@ def kernel(a: int32) -> float32: | |||
assert mod(1) == kernel(1) | |||
|
|||
|
|||
def test_index_fixed_casting(): | |||
def test_one_cast(fixed): | |||
def kernel(a: fixed) -> float32: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where a
is used here?
# FP to Index is not supported in MLIR | ||
# (Float, Index): RuntimeError, | ||
# (Index, Float): RuntimeError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add float<->index testing?
Thanks, I fixed the init value issue in the test case, and added two test cases for float <-> index casting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
index
from/to Fixed
/UFixed
type casting (Fix #241)index
from/to Float
/Fixed
/UFixed
type casting
Description
This PR introduces expanding support for casting between
Index
,Fixed
, andUFixed
types in the Allo IR. This enhancement allows for seamless conversions between these types, which broadens the flexibility of type handling in the IR layer.Problems
Previously, the Allo IR lacked direct support for conversions between
Index
andFixed/UFixed
types, limiting the flexibility in scenarios where such conversions are needed for operations. Attempting these conversions required workarounds or was unsupported, creating friction in code requiring dynamic type handling.Proposed Solutions
Index <-> Fixed/UFixed
single-step conversions in thecast_map
withinASTTransformer
.IntToFixedOp
andFixedToIntOp
as intermediary conversions to facilitate direct type transformations.IndexCastOp
to handleIndex -> Fixed/UFixed
conversions.Examples
Here’s a snippet of the updated behavior:
Index to Fixed/UFixed Casting:
Fixed/UFixed to Index Casting:
Both conversions now produce correct IR output without errors, validating the new casting support.
Checklist
Index -> Fixed/UFixed
andFixed/UFixed -> Index
conversions