-
Notifications
You must be signed in to change notification settings - Fork 73
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
add TaggedExpression #688
base: main
Are you sure you want to change the base?
add TaggedExpression #688
Conversation
7b09146
to
fe827e4
Compare
Is this going in the direction you had in mind @inducer ? |
ae1f27a
to
e41625f
Compare
e41625f
to
9233385
Compare
loopy/statistics.py
Outdated
opmap = self.rec(expr.expr) | ||
for op in opmap.count_map: | ||
op.tags = expr.tags | ||
return opmap |
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.
Would overwrite tags of subexpressions that already have tags.
self.rec(expr.expr, expr.tags)
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 50adbc4 what you had 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.
Yes, generally.
loopy/statistics.py
Outdated
|
||
map_bitwise_xor = map_bitwise_or | ||
map_bitwise_and = map_bitwise_or | ||
|
||
def map_if(self, expr): | ||
def map_if(self, expr, *args): |
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 switch to *args
here?
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 0bbbaec, I changed all occurrences to tags
(with a default argument). Does this look reasonable?
Unsubscribing... @-mention or request review once it's ready for a look or needs attention. |
This is ready for a first look @inducer. |
loopy/statistics.py
Outdated
@@ -916,14 +931,17 @@ def __init__(self, knl, callables_table, kernel_rec, | |||
def combine(self, values): | |||
return sum(values) | |||
|
|||
def map_constant(self, expr): | |||
def map_constant(self, expr, tags=None): |
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 the pervasive tags=None
? The default risks losing the tag as you traverse. IMO, there should not be a default.
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 changed it in df7ed9b to not use a default argument anymore.
loopy/statistics.py
Outdated
else: | ||
return self.new_zero_poly_map() | ||
|
||
map_product = map_sum | ||
|
||
def map_comparison(self, expr): | ||
return self.rec(expr.left)+self.rec(expr.right) | ||
def map_comparison(self, expr, *args): |
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 have *args
instead of tags
here?
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.
These are hopefully all fixed in df7ed9b
This comment was marked as outdated.
This comment was marked as outdated.
aa4f1d7
to
dd419b0
Compare
9b12a27
to
c67eea6
Compare
8dcf1d4
to
c3b4a82
Compare
Co-authored-by: Andreas Klöckner <[email protected]>
I think this is ready for another review. |
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.
Thanks! This is quite close, only a few minor wrinkles to finish up.
count_granularity=local_mem_count_granularity, | ||
kernel_name=self.knl.name): self.one}) | ||
|
||
elif (isinstance(array, TemporaryVariable) and ( |
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.
Should this also apply to ArrayArg
? / Where do those get counted if not?
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.
Doesn't it already apply to ArrayArg
(see 2 lines below)?
loopy/statistics.py
Outdated
@property | ||
def mtype(self) -> str: | ||
from warnings import warn | ||
warn("MemAccess.mtype is deprecated and will stop working in 2024. " |
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.
Bump deadlines to 2026? (here and elsewhere)
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.
Done in 0b9d8a4
return f"Sync({self.kind}, {self.kernel_name})" | ||
# Overridden for conciseness | ||
return "Sync({}, {}, {})".format( | ||
self.sync_kind, repr(self.kernel_name), self.tags) | ||
|
||
# }}} | ||
|
||
|
||
# {{{ CounterBase | ||
|
||
class CounterBase(CombineMapper): |
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.
Likely missing type arguments.
loopy/symbolic.py
Outdated
.. attribute:: tags | ||
|
||
A :class:`frozenset` of subclasses of :class:`pytools.tag.Tag` used to | ||
provide metadata on this expression. | ||
|
||
.. attribute:: expr | ||
|
||
An expression to which :attr:`tags` are attached. | ||
""" | ||
|
||
tags: frozenset[Tag] | ||
expr: Expression |
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.
Have this use autoattribute
, move docstrings after declaration.
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.
Done in 6661eff
|
||
|
||
@dataclass(frozen=True, eq=True) | ||
class MemAccess: | ||
"""A descriptor for a type of memory access. |
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.
Move to autoattribute and in-line docstrings?
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.
Done in 6959904
|
||
# }}} | ||
|
||
|
||
# {{{ Op descriptor | ||
|
||
class Op(ImmutableRecord): | ||
class OpType(Enum): |
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.
Move to autoattribute
and in-line docstrings?
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.
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.
The semantics of tagging in connection with counting need to be explained somewhere in the documentation.
Co-authored-by: Andreas Klöckner <[email protected]>
Co-authored-by: Andreas Klöckner <[email protected]>
TODOs:
Please squash