Skip to content

Commit

Permalink
Added logaddexp2 method to the PyTorch frontend (#21804)
Browse files Browse the repository at this point in the history
Co-authored-by: NripeshN <[email protected]>
  • Loading branch information
he11owthere and NripeshN authored Dec 23, 2023
1 parent b2389e0 commit 1e528f0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,11 @@ def backward(self, gradient=None, retain_graph=None, create_graph=False):
def logaddexp(self, other):
return torch_frontend.logaddexp(self, other)

@with_unsupported_dtypes({"2.1.2 and below": ("float16",)}, "torch")
def logaddexp2(self, other):
self.ivy_array = torch_frontend.logaddexp2(self, other).ivy_array
return self

def angle(self):
return torch_frontend.angle(self)

Expand Down
42 changes: 42 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 @@ -12964,6 +12964,48 @@ def test_torch_tensor_erfc_(
)


# logaddexp2
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="torch.tensor",
method_name="logaddexp2",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
num_arrays=2,
min_num_dims=1,
min_value=-100,
max_value=100,
shared_dtype=True,
),
)
def test_torch_tensor_logaddexp2(
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={
"other": x[1],
},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
on_device=on_device,
)


# positive
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down

0 comments on commit 1e528f0

Please sign in to comment.