Skip to content

Commit

Permalink
(hotifx) Seed types should be cacheable (#1623)
Browse files Browse the repository at this point in the history
  • Loading branch information
adodge authored Mar 3, 2023
1 parent 13e0319 commit e6c7f0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/src/nodes/node_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def _args_to_key(args) -> Tuple:
key.append(tuple(arg.shape))
key.append(arg.dtype.str)
key.append(hashlib.sha256(arg.tobytes()).digest())
elif hasattr(arg, "cache_key_func"):
key.append(arg.__class__.__name__)
key.append(arg.cache_key_func())
else:
raise RuntimeError(f"Unexpected argument type {arg.__class__.__name__}")
return tuple(key)
Expand Down
3 changes: 3 additions & 0 deletions backend/src/nodes/utils/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ def to_u32(self) -> int:
Returns the value of the seed as a 32bit unsigned integer.
"""
return self.to_range(0, _U32_MAX - 1)

def cache_key_func(self):
return self.value

0 comments on commit e6c7f0b

Please sign in to comment.