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

feat[next]: Prepare TraceShift pass for GTIR #1592

Merged
merged 8 commits into from
Sep 17, 2024

Conversation

tehrengruber
Copy link
Contributor

@tehrengruber tehrengruber commented Jul 28, 2024

The pass now only operates on stencils instead of StencilClosures using the newly introduced function trace_stencil.

@tehrengruber tehrengruber changed the title feat[next]: Support for itir.Program in TraceShift feat[next]: Prepare TraceShift pass for GTIR Jul 28, 2024

return recorded_shifts
trace_stencil = TraceShifts.trace_stencil
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it also a classmethod?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To allow subclassing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you just make this up or do you have a use-case in mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To stick to your wording: I made this up. I can change it if you like, I can also make up unlikely cases where this might be useful.

Comment on lines 353 to 355
instance = cls()
instance.visit(node)
ctx = instance.initialize_context(args)
instance.visit(im.call(stencil)(*args), ctx=ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

This pattern looks a bit weird as initialization is done in 2 steps. Maybe you can disentangle a bit more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cleaned it up a bit, but still not great. I would leave it as is for now.

Comment on lines +341 to +343
if isinstance(stencil, ir.Lambda):
assert num_args is None or num_args == len(stencil.params)
num_args = len(stencil.params)
Copy link
Contributor

Choose a reason for hiding this comment

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

what's special with lambdas? what else can it be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For lambdas we can deduce the number of arguments and the num_args parameter is optional. This is essentially a convenience feature for testing. I've added a comment.


return recorded_shifts
trace_stencil = TraceShifts.trace_stencil
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you just make this up or do you have a use-case in mind?

@tehrengruber tehrengruber merged commit c8822c0 into GridTools:main Sep 17, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants