Skip to content

Commit

Permalink
feat: add erfc to torch.Tensor frontend (#26991)
Browse files Browse the repository at this point in the history
Co-authored-by: Sam-Armstrong <samuel_e_armstrong@yahoo.co.uk>
  • Loading branch information
G544 and Sam-Armstrong authored Jul 11, 2024
1 parent 59027b0 commit 1ef9b84
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,17 @@ def erf_(self, *, out=None):
{"2.2 and below": {"cpu": ("float32", "float64")}},
"torch",
)
def erfc_(self, *, out=None):
def erfc(self, *, out=None):
return torch_frontend.erfc(self, out=out)

@with_supported_device_and_dtypes(
{"2.2 and below": {"cpu": ("float32", "float64")}},
"torch",
)
def erfc_(self, *, out=None):
self.ivy_array = self.erfc(out=out).ivy_array
return self

def new_zeros(
self,
*args,
Expand Down
37 changes: 37 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 @@ -6536,6 +6536,43 @@ def test_torch_erfinv_(
)


# erfc
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="torch.tensor",
method_name="erfc",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
),
)
def test_torch_tensor_erfc(
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,
rtol_=1e-2,
atol_=1e-2,
)


# exp
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down

0 comments on commit 1ef9b84

Please sign in to comment.