Skip to content

Commit

Permalink
Torch frontend lerp (ivy-llc#10690)
Browse files Browse the repository at this point in the history
Co-authored-by: Fotios Spyridakos <[email protected]>
  • Loading branch information
aparna2071 and fspyridakos authored Feb 22, 2023
1 parent 49ed853 commit c5403e7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ivy/functional/frontends/torch/pointwise_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,9 @@ def hypot(input, other, *, out=None):
@to_ivy_arrays_and_back
def sigmoid(input, *, out=None):
return ivy.sigmoid(input, out=out)


@with_unsupported_dtypes({"1.11.0 and below": ("float16", "bfloat16")}, "torch")
@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)
34 changes: 34 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 @@ -2081,3 +2081,37 @@ def test_torch_sigmoid(
on_device=on_device,
input=x[0],
)


# lerp
@handle_frontend_test(
fn_tree="torch.lerp",
dtype_and_input=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
num_arrays=3,
shared_dtype=True,
large_abs_safety_factor=2.5,
small_abs_safety_factor=2.5,
safety_factor_scale="log",
),
)
def test_torch_lerp(
*,
dtype_and_input,
frontend,
test_flags,
fn_tree,
on_device,
):
input_dtype, inputs = dtype_and_input
start, end, weight = inputs
helpers.test_frontend_function(
input_dtypes=input_dtype,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
input=start,
end=end,
weight=weight,
)

0 comments on commit c5403e7

Please sign in to comment.