-
Notifications
You must be signed in to change notification settings - Fork 85
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
core: (affine) Add functions dealing with dimensions to AffineMap and AffineExpr #4007
core: (affine) Add functions dealing with dimensions to AffineMap and AffineExpr #4007
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4007 +/- ##
=======================================
Coverage 90.19% 90.19%
=======================================
Files 458 458
Lines 58319 58341 +22
Branches 5688 5692 +4
=======================================
+ Hits 52598 52619 +21
Misses 4331 4331
- Partials 1390 1391 +1 ☔ View full report in Codecov by Sentry. |
Do you know what MLIR does here? We should probably mimic their beaviour. |
Both |
xdsl/ir/affine/affine_map.py
Outdated
|
||
return result | ||
|
||
def unused_dims(self) -> set[int]: |
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.
Am I right in understanding that neither unused_dims nor the bit vector version are used in your other PR? Are we sure we need these helpers?
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.
Actually it seems like none of these helpers are used?
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.
I just updated that PR, have a look now. I removed some verification that wasn't ready yet because of the changes that needed to be done to the VectorType
xdsl/ir/affine/affine_map.py
Outdated
result: set[int] = set() | ||
|
||
for expr in self.results: | ||
result = result.union(expr.used_dims()) | ||
|
||
return result |
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.
Set construction feels expensive enough to me to only want to do it once:
result: set[int] = set() | |
for expr in self.results: | |
result = result.union(expr.used_dims()) | |
return result | |
return {expr.position for res_expr in self.results for expr in res_expr.dfs() if isinstance(expr, AffineDimExpr)} |
xdsl/ir/affine/affine_map.py
Outdated
used_dims = self.used_dims() | ||
return tuple( | ||
True if position in used_dims else False | ||
for position in range(self.num_dims) | ||
) |
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.
Same here, let's avoid the set construction
used_dims = self.used_dims() | |
return tuple( | |
True if position in used_dims else False | |
for position in range(self.num_dims) | |
) | |
used_dims = [False] * self.num_dims | |
for res_expr in self.results: | |
for expr in res_expr.dfs(): | |
if isinstance(expr, AffineDimExpr): | |
used_dims[expr.position] = True | |
return tuple(used_dims) |
Thank you! |
Add a couple of utility functions to AffineMap and AffineExpr that deal with dimensions.
Cherry picked from #3650, prerequisite for implementing
vector.transfer_read
andvector.transfer_write
ops