Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding isfinite and isinf torch frontend #3752

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ivy/functional/frontends/torch/comparison_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,11 @@ def isclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False):


isclose.unsupported_dtypes = ("float16",)


def isfinite(input):
return ivy.isfinite(input)


def isinf(input):
return ivy.isinf(input)
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,75 @@ def test_torch_isclose(
atol=1e-08,
equal_nan=equal_nan,
)


# isifinite
@handle_cmd_line_args
@given(
dtype_and_input=helpers.dtype_and_values(
available_dtypes=tuple(
set(ivy_np.valid_numeric_dtypes).intersection(
set(ivy_torch.valid_numeric_dtypes)
),
),
allow_inf=True,
),
num_positional_args=helpers.num_positional_args(
fn_name="ivy.functional.frontends.torch.isfinite"
),
)
def test_torch_isfinite(
dtype_and_input,
as_variable,
num_positional_args,
native_array,
fw,
):
input_dtype, input = dtype_and_input
helpers.test_frontend_function(
input_dtypes=input_dtype,
as_variable_flags=as_variable,
with_out=False,
num_positional_args=num_positional_args,
native_array_flags=native_array,
fw=fw,
frontend="torch",
fn_tree="isfinite",
input=np.asarray(input, dtype=input_dtype),
)


# isinf
@handle_cmd_line_args
@given(
dtype_and_input=helpers.dtype_and_values(
available_dtypes=tuple(
set(ivy_np.valid_numeric_dtypes).intersection(
set(ivy_torch.valid_numeric_dtypes)
),
),
allow_inf=True,
),
num_positional_args=helpers.num_positional_args(
fn_name="ivy.functional.frontends.torch.isinf"
),
)
def test_torch_isinf(
dtype_and_input,
as_variable,
num_positional_args,
native_array,
fw,
):
input_dtype, input = dtype_and_input
helpers.test_frontend_function(
input_dtypes=input_dtype,
as_variable_flags=as_variable,
with_out=False,
num_positional_args=num_positional_args,
native_array_flags=native_array,
fw=fw,
frontend="torch",
fn_tree="isinf",
input=np.asarray(input, dtype=input_dtype),
)