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 17, 2023
1 parent 0b71cb0 commit 2066fbd
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 @@ -320,3 +320,30 @@ def zero(self: T) -> T:
def exponential(self: T, pairs: set[tuple[str, str]], _: typing.Any = None) -> T:
"Compat Interface: Get the exponential tensor of this tensor."
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 2066fbd

Please sign in to comment.