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

transformations: Convert memref to ptrdialect #3383

Merged
merged 3 commits into from
Nov 3, 2024

Conversation

mamanain
Copy link
Collaborator

@mamanain mamanain commented Nov 3, 2024

Introducing lowering of some memref operations to a ptr dialect. This will be used to translate riscv compilation to ptr dialect in the future (this is the second pr in the series).

Copy link

codecov bot commented Nov 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.13%. Comparing base (3b668fb) to head (990dcd5).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3383   +/-   ##
=======================================
  Coverage   90.13%   90.13%           
=======================================
  Files         451      452    +1     
  Lines       56868    56951   +83     
  Branches     5459     5467    +8     
=======================================
+ Hits        51256    51331   +75     
- Misses       4167     4173    +6     
- Partials     1445     1447    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mamanain mamanain self-assigned this Nov 3, 2024
)
]

if len(list(indices)) == 0:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if len(list(indices)) == 0:
if not indices:

Copy link
Member

Choose a reason for hiding this comment

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

It looks like the indices passed below are actually a Collection, so this should be possible, and would avoid an extra list construction

def apply(self, ctx: MLContext, op: builtin.ModuleOp) -> None:
the_one_pass = PatternRewriteWalker(
GreedyRewritePatternApplier([ConvertStoreOp(), ConvertLoadOp()]),
apply_recursively=False,
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary?

Copy link
Member

Choose a reason for hiding this comment

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

Similarly for the other options below

Copy link
Member

@superlopuh superlopuh left a comment

Choose a reason for hiding this comment

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

Could you please add some doc strings to the helpers? LGTM otherwise

from xdsl.utils.exceptions import DiagnosticException


# I think we also need to pass the adress width.
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it computed below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, forgot to delete this comment from a previous version

@mamanain mamanain merged commit 152aa06 into xdslproject:main Nov 3, 2024
14 checks passed
@mamanain mamanain deleted the ptr-dialect-part2 branch November 3, 2024 10:44
@superlopuh superlopuh added the transformations Changes or adds a transformatio label Nov 3, 2024
case builtin.StridedLayoutAttr():
strides = memref_type.layout.get_strides()
case _:
raise DiagnosticException(f"Unsupported layout type {memref_type.layout}")
Copy link
Member

Choose a reason for hiding this comment

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

Oh I forgot about this, could you please add a small PR with a test that catches this diagnostic exception?

EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
Introducing lowering of some memref operations to a ptr dialect. This
will be used to translate riscv compilation to ptr dialect in the future
(this is the second pr in the series).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transformations Changes or adds a transformatio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants