-
Notifications
You must be signed in to change notification settings - Fork 74
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
dialects: (builtin) add CompileTimeFixedBitwidthType #3599
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3599 +/- ##
==========================================
+ Coverage 90.38% 90.41% +0.02%
==========================================
Files 469 471 +2
Lines 59075 59151 +76
Branches 5615 5611 -4
==========================================
+ Hits 53397 53482 +85
+ Misses 4232 4225 -7
+ Partials 1446 1444 -2 ☔ View full report in Codecov by Sentry. |
IndexType is not FixedBitwidth, since its bitwidth is target-dependent |
We need an adjustment to the hierarchy, where we need to distinguish between packability, and bitwidth fixed at compile-time vs runtime |
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.
Probably worth checking with @math-fehr on this also, but my understanding is that we're missing a type that says that the bitwidth is fixed during compilation time but it may differ from the bitwidth at runtime until lowered to target-dependent code.
I had considered it to be because even if it is target-dependent, it will always have a fixed bitwidth. The fact that we don't know the actual bitwidth seems like a separate problem. I'm not too sure about this though. Just a bit confused as how to proceed because I want to pack indextype variables, and in #3581 we decided to combine the fixedbitwidth and structpackable type. I think @math-fehr mentioned somewhere that even though indextype is not known, it is assured to be |
Looks good to me, but what is the practical use of the |
Because we need to distinguish between things that can go in DenseArrayBase and DenseIntOrFPElementsAttr, and in general for bitwidth computation of things that reside in memory on the target |
I updated things to your suggestions, let me know what you think! |
xdsl/dialects/builtin.py
Outdated
class CompileTimeFixedBitwidthType(TypeAttribute, ABC): | ||
""" | ||
A type attribute whose runtime bitwidth is fixed, but may be target-dependent. | ||
""" | ||
|
||
name = "abstract.compile_time_fixed_bitwidth_type" | ||
|
||
|
||
class FixedBitwidthType(CompileTimeFixedBitwidthType, ABC): |
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.
How do you feel about putting an abstract property here?
Maybe actually not packed-dependent name, like compile_time_size
?
class CompileTimeFixedBitwidthType(TypeAttribute, ABC): | |
""" | |
A type attribute whose runtime bitwidth is fixed, but may be target-dependent. | |
""" | |
name = "abstract.compile_time_fixed_bitwidth_type" | |
class FixedBitwidthType(CompileTimeFixedBitwidthType, ABC): | |
class CompileTimeFixedBitwidthType(TypeAttribute, ABC): | |
""" | |
A type attribute whose runtime bitwidth is fixed, but may be target-dependent. | |
""" | |
name = "abstract.compile_time_fixed_bitwidth_type" | |
@property | |
@abstractmethod | |
def packed_size(self) -> int: | |
""" | |
Contiguous memory footprint of packed value in bytes. | |
""" | |
raise NotImplementedError() | |
class FixedBitwidthType(CompileTimeFixedBitwidthType, ABC): |
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.
yep, this makes sense!
Yeah, you should always be able to pack an |
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.
Thank you!
This PR adds the
CompileTimeFixedBitwidthType
to represent values that have a fixed bitwidth and are thus packable, but the bitwidth may not be known until compile time.The new dependency graph now looks like the following: https://is.gd/q5N7Dx