Draft
Conversation
c155f41 to
dfaaeed
Compare
221de48 to
b9edcae
Compare
majosm
reviewed
Mar 19, 2024
Collaborator
majosm
left a comment
There was a problem hiding this comment.
This looks familiar. 🙂 I added something almost exactly the same in my concatenation changes.
Added a couple of suggestions here.
pytato/analysis/__init__.py
Outdated
| # {{{ NodeTypeCountMapper | ||
|
|
||
| @optimize_mapper(drop_args=True, drop_kwargs=True, inline_get_cache_key=True) | ||
| class NodeTypeCountMapper(CachedWalkMapper): |
Collaborator
There was a problem hiding this comment.
Could maybe just modify NodeCountMapper to do this and then have get_num_nodes return sum(ncm.counts.values())? Saves some duplication.
pytato/analysis/__init__.py
Outdated
| self.counts[type(expr)] += 1 | ||
|
|
||
|
|
||
| def get_num_node_types(outputs: Union[Array, DictOfNamedArrays]) -> Dict[Type, int]: |
Collaborator
There was a problem hiding this comment.
get_num_node_types is a little confusing (sounds like it would return the number of distinct types in the DAG). I used get_node_counts in mine, which isn't much better... get_node_type_counts? 🤷♂️
Author
There was a problem hiding this comment.
Agreed. get_node_type_counts seems like the clear choice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an analysis util to count nodes of each type.
cc: @matthiasdiener