-
Notifications
You must be signed in to change notification settings - Fork 49
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
Conversation
|
||
return recorded_shifts | ||
trace_stencil = TraceShifts.trace_stencil |
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.
Why is it also a classmethod?
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.
To allow subclassing.
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.
Did you just make this up or do you have a use-case in mind?
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.
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.
instance = cls() | ||
instance.visit(node) | ||
ctx = instance.initialize_context(args) | ||
instance.visit(im.call(stencil)(*args), ctx=ctx) |
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.
This pattern looks a bit weird as initialization is done in 2 steps. Maybe you can disentangle a bit more?
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 cleaned it up a bit, but still not great. I would leave it as is for now.
if isinstance(stencil, ir.Lambda): | ||
assert num_args is None or num_args == len(stencil.params) | ||
num_args = len(stencil.params) |
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.
what's special with lambdas? what else can it be?
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.
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 |
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.
Did you just make this up or do you have a use-case in mind?
The pass now only operates on stencils instead of
StencilClosure
s using the newly introduced functiontrace_stencil
.