Skip to content

Commit

Permalink
fix (all backends)(data_type.py): added the Finfo fix to all backend …
Browse files Browse the repository at this point in the history
…implementations
  • Loading branch information
YushaArif99 committed Aug 2, 2024
1 parent 535a9f3 commit 3d3c4bc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ivy/functional/backends/jax/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ def min(self):
def smallest_normal(self):
return float(self._jnp_finfo.tiny)

def __getattribute__(self, name):
try:
# Try to get the attribute from the Finfo class
return super().__getattribute__(name)
except AttributeError:
# If the attribute doesn't exist in Finfo, try to get it from _jnp_finfo
jnp_finfo = super().__getattribute__("_jnp_finfo")
return getattr(jnp_finfo, name)


# Array API Standard #
# -------------------#
Expand Down
9 changes: 9 additions & 0 deletions ivy/functional/backends/numpy/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ def min(self):
def smallest_normal(self):
return float(self._np_finfo.tiny)

def __getattribute__(self, name):
try:
# Try to get the attribute from the Finfo class
return super().__getattribute__(name)
except AttributeError:
# If the attribute doesn't exist in Finfo, try to get it from _np_finfo
np_finfo = super().__getattribute__("_np_finfo")
return getattr(np_finfo, name)


# Array API Standard #
# -------------------#
Expand Down
9 changes: 9 additions & 0 deletions ivy/functional/backends/paddle/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ def min(self):
def smallest_normal(self):
return float(self._paddle_finfo.tiny)

def __getattribute__(self, name):
try:
# Try to get the attribute from the Finfo class
return super().__getattribute__(name)
except AttributeError:
# If the attribute doesn't exist in Finfo, try to get it from _paddle_finfo
paddle_finfo = super().__getattribute__("_paddle_finfo")
return getattr(paddle_finfo, name)


class Iinfo:
def __init__(self, paddle_iinfo: np.iinfo):
Expand Down
9 changes: 9 additions & 0 deletions ivy/functional/backends/torch/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ def min(self):
def smallest_normal(self):
return self._torch_finfo.tiny

def __getattribute__(self, name):
try:
# Try to get the attribute from the Finfo class
return super().__getattribute__(name)
except AttributeError:
# If the attribute doesn't exist in Finfo, try to get it from _torch_finfo
torch_finfo = super().__getattribute__("_torch_finfo")
return getattr(torch_finfo, name)


# Array API Standard #
# -------------------#
Expand Down

0 comments on commit 3d3c4bc

Please sign in to comment.