Skip to content

Commit

Permalink
implement update_persistent_hash for Reduce, _StatelessReductionOpera…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
matthiasdiener authored and inducer committed Jul 3, 2024
1 parent 78b43c1 commit 6ae882c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pytato/reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def __eq__(self, other: Any) -> bool:


class _StatelessReductionOperation(ReductionOperation):
def update_persistent_hash(self, key_hash: Any, key_builder: Any) -> None:
key_builder.rec(key_hash, type(self))

def __hash__(self) -> int:
return hash(type(self))

Expand Down
6 changes: 6 additions & 0 deletions pytato/scalar_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ class Reduce(ExpressionBase):
identifying half-open bounds intervals. Must be hashable.
"""

def update_persistent_hash(self, key_hash: Any, key_builder: Any) -> None:
key_builder.rec(key_hash, self.inner_expr)
key_builder.rec(key_hash, self.op)
key_builder.rec(key_hash, tuple(self.bounds.keys()))
key_builder.rec(key_hash, tuple(self.bounds.values()))

def __getinitargs__(self) -> Tuple[ScalarExpression, ReductionOperation, Any]:
return (self.inner_expr, self.op, self.bounds)

Expand Down

0 comments on commit 6ae882c

Please sign in to comment.