Skip to content

Commit

Permalink
added instance method isfinite to pytorch tensor (pytorch frontend) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
VeraChristina committed Aug 28, 2023
1 parent d58265d commit 645ec20
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions ivy/functional/backends/tensorflow/elementwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ def greater_equal(
return tf.math.greater_equal(x1, x2)


@with_unsupported_dtypes({"2.13.0 and below": ("bool",)}, backend_version)
def isfinite(
x: Union[tf.Tensor, tf.Variable],
/,
Expand Down
3 changes: 3 additions & 0 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,9 @@ def fix_(self):
self.ivy_array = self.fix().ivy_array
return self

def isfinite(self):
return torch_frontend.isfinite(self._ivy_array)

def isinf(self):
return torch_frontend.isinf(self._ivy_array)

Expand Down
33 changes: 33 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10019,6 +10019,39 @@ def test_torch_tensor_norm(
)


# isfinite
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="torch.tensor",
method_name="isfinite",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
),
)
def test_torch_tensor_isfinite(
dtype_and_x,
frontend_method_data,
init_flags,
method_flags,
frontend,
on_device,
backend_fw,
):
input_dtype, x = dtype_and_x
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
backend_to_test=backend_fw,
init_all_as_kwargs_np={"data": x[0]},
method_input_dtypes=input_dtype,
method_all_as_kwargs_np={},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
on_device=on_device,
)


# isinf
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down

0 comments on commit 645ec20

Please sign in to comment.