Skip to content

Commit

Permalink
feat: Added signbit function for torch frontend (ivy-llc#10713)
Browse files Browse the repository at this point in the history
Co-authored-by: nathzi1505 <[email protected]>
  • Loading branch information
codesankalp and p3jitnath authored Feb 26, 2023
1 parent 469c9e9 commit 13d03bc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ivy/functional/frontends/torch/pointwise_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,8 @@ def sigmoid(input, *, out=None):
@to_ivy_arrays_and_back
def lerp(input, end, weight, *, out=None):
return ivy.add(input, ivy.multiply(weight, ivy.subtract(end, input)), out=out)


@to_ivy_arrays_and_back
def signbit(input, *, out=None):
return ivy.signbit(input, out=out)
26 changes: 26 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2115,3 +2115,29 @@ def test_torch_lerp(
end=end,
weight=weight,
)


# signbit
@handle_frontend_test(
fn_tree="torch.signbit",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("numeric"),
),
)
def test_torch_signbit(
*,
dtype_and_x,
on_device,
fn_tree,
frontend,
test_flags,
):
input_dtype, x = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
input=x[0],
)

0 comments on commit 13d03bc

Please sign in to comment.