-
Notifications
You must be signed in to change notification settings - Fork 83
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: Add memref.extract_strided_metadata op #2748
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.
Nice work, just some minor stylistic comments! Structure looks solid!
@staticmethod | ||
def from_source_memref( | ||
source: SSAValue | Operation, source_type: MemRefType[Attribute] | ||
): |
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 make this an __init__
? That's what we are trying to move towards in xDSL
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.
Is this an init though? creating a bare op of this kind should not really include a source type, should it?
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 remember being torn by the very same thought on subview itself;
I propose you just do what's still done there, and @AntonLydike could file an issue or Zulip thread to discuss it independently?
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.
Hmmm, I don't know if I can follow. How else would you create this op if not from a source memref?
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.
Maybe you could clear this up by adding a docstring to the method saying exactly what it's for and what each operand does?
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.
May I ask why source
and source_type
are passed in separately? I'd expect source
to come with a type
xdsl/dialects/memref.py
Outdated
return ExtractStridedMetaDataOp.build( | ||
operands=[source], result_types=[*return_type] | ||
) | ||
|
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.
In the init you can replace this with super().__init__(operands=[source], result_types=[*return_type])
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.
Also [*return_type]
is the same as return_type
xdsl/dialects/memref.py
Outdated
strides_type = [IndexType() for _ in source_shape] | ||
sizes_type = [IndexType() for _ in source_shape] |
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.
You could write this as [IndexType()] * len(source_shape)
, but I don't know if you want to^^
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2748 +/- ##
=======================================
Coverage 89.90% 89.91%
=======================================
Files 367 367
Lines 47324 47355 +31
Branches 7231 7234 +3
=======================================
+ Hits 42549 42580 +31
Misses 3662 3662
Partials 1113 1113 ☔ View full report in Codecov by Sentry. |
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.
LGTM, thanks!
I'm adding the memref.extract_strided_metadataop because I need an op to fetch the dynamic offset created by a subview, and otherwise I can not do that.
https://mlir.llvm.org/docs/Dialects/MemRef/#memrefextract_strided_metadata-memrefextractstridedmetadataop