Skip to content

Commit

Permalink
add random placeholder.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzhangxyz committed Nov 18, 2023
1 parent 8e1484a commit b245cdd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tat/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,30 @@ def exponential(self: T, pairs: set[tuple[str, str]], step: int | None = None) -
"Compat Interface: Get the exponential tensor of this tensor."
# pylint: disable=unused-argument
return origin_exponential(self, pairs)


# Random utility


class CompatRandom:
"""
Fake module for compat random utility in TAT.
"""

def __init__(self: CompatRandom) -> None:
pass

def uniform_int(self: CompatRandom, low: int, high: int) -> typing.Callable[[], int]:
return staticmethod(lambda: 0)

def uniform_real(self: CompatRandom, low: float, high: float) -> typing.Callable[[], float]:
return staticmethod(lambda: 0.0)

def normal(self: CompatRandom, mean: float, stddev: float) -> typing.Callable[[], float]:
return staticmethod(lambda: 0.0)

def seed(self: CompatRandom, new_seed: int) -> None:
pass


random = CompatRandom()

0 comments on commit b245cdd

Please sign in to comment.