-
Notifications
You must be signed in to change notification settings - Fork 16
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 PytatoKeyBuilder, persistent_dict test #459
Open
matthiasdiener
wants to merge
29
commits into
main
Choose a base branch
from
PytatoKeyBuilder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+126
−1
Open
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
38e4332
add PytatoKeyBuilder
matthiasdiener 4dd3250
mypy fixes
matthiasdiener 970e7bb
support TaggableCLArray, Subscript
matthiasdiener 95dec09
CL Array, function
matthiasdiener 2ac10ee
add prim.Variable
matthiasdiener 62a13ae
fixes to ndarray, pymb expressions
matthiasdiener b8e04bf
flake8
matthiasdiener ad9aa28
improve test
matthiasdiener 60d8e41
add full invocation test
matthiasdiener 9d45e65
lint fixes
matthiasdiener 08be380
add missing pymbolic expressions
matthiasdiener 058f6f9
flake8
matthiasdiener 352bab6
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener 0360e21
remove update_for_function (now handled directly by pytools)
matthiasdiener 8e3277c
Merge remote-tracking branch 'refs/remotes/origin/PytatoKeyBuilder' i…
matthiasdiener b1aaa97
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener 16516ec
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener 454f273
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener 993dfe4
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener 82a5f25
lint
matthiasdiener dc53746
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener 97df5d7
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener 93abdc1
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener b35d841
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener 70a6887
add typecheck, remove pymbolic handling
matthiasdiener 4f9f95f
lint
matthiasdiener cffda36
pylint
matthiasdiener 47a31d6
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener 57908b1
Merge branch 'main' into PytatoKeyBuilder
matthiasdiener File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
|
||
from typing import TYPE_CHECKING, Any, Mapping | ||
|
||
from loopy.tools import LoopyKeyBuilder | ||
from pymbolic.mapper.optimize import optimize_mapper | ||
from pytools import memoize_method | ||
|
||
|
@@ -564,4 +565,47 @@ def get_num_call_sites(outputs: Array | DictOfNamedArrays) -> int: | |
|
||
# }}} | ||
|
||
|
||
# {{{ PytatoKeyBuilder | ||
|
||
class PytatoKeyBuilder(LoopyKeyBuilder): | ||
"""A custom :class:`pytools.persistent_dict.KeyBuilder` subclass | ||
for objects within :mod:`pytato`. | ||
""" | ||
|
||
def update_for_ndarray(self, key_hash: Any, key: Any) -> None: | ||
self.rec(key_hash, key.data.tobytes()) | ||
|
||
def update_for_TaggableCLArray(self, key_hash: Any, key: Any) -> None: | ||
self.rec(key_hash, key.get()) | ||
|
||
def update_for_Array(self, key_hash: Any, key: Any) -> None: | ||
# CL Array | ||
self.rec(key_hash, key.get()) | ||
|
||
update_for_BitwiseAnd = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_BitwiseNot = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_BitwiseOr = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_BitwiseXor = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Call = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_CallWithKwargs = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Comparison = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_If = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_FloorDiv = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_LeftShift = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_LogicalAnd = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_LogicalNot = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_LogicalOr = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Lookup = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Power = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Product = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Quotient = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Remainder = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_RightShift = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Subscript = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Sum = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
update_for_Variable = LoopyKeyBuilder.update_for_pymbolic_expression # noqa: N815 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All this can go now that inducer/pymbolic#125 is in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed in 70a6887 |
||
|
||
# }}} | ||
|
||
# vim: fdm=marker |
This file contains 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
Oops, something went wrong.
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.
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.
Could you use an
isinstance
check to make sure that this only hashes the intended types?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.
Added in 70a6887