Skip to content
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

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

JosseVanDelm
Copy link
Collaborator

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

@JosseVanDelm JosseVanDelm added enhancement New feature or request dialects Changes on the dialects labels Jun 18, 2024
@JosseVanDelm JosseVanDelm self-assigned this Jun 18, 2024
Copy link
Collaborator

@AntonLydike AntonLydike left a 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!

Comment on lines +527 to +530
@staticmethod
def from_source_memref(
source: SSAValue | Operation, source_type: MemRefType[Attribute]
):
Copy link
Collaborator

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

Copy link
Collaborator Author

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?

Copy link
Collaborator

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?

Copy link
Collaborator

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?

Copy link
Collaborator

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?

Copy link
Collaborator

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

Comment on lines 543 to 546
return ExtractStridedMetaDataOp.build(
operands=[source], result_types=[*return_type]
)

Copy link
Collaborator

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])

Copy link
Collaborator

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

Comment on lines 540 to 541
strides_type = [IndexType() for _ in source_shape]
sizes_type = [IndexType() for _ in source_shape]
Copy link
Collaborator

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^^

Copy link

codecov bot commented Jun 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.91%. Comparing base (ec32ac5) to head (a30c44b).

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.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@PapyChacal PapyChacal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@JosseVanDelm JosseVanDelm merged commit e25b55a into main Jun 18, 2024
9 checks passed
@JosseVanDelm JosseVanDelm deleted the Josse/add-memref-extract-metadata-op branch June 18, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialects Changes on the dialects enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants