Skip to content

Commit

Permalink
added add function to PyTorch frontend, with corresponding unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
djl11 committed Jun 26, 2022
1 parent 4c595c8 commit 2624e99
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ivy/functional/frontends/torch/pointwise_ops.py
@@ -1,7 +1,16 @@
# global
import ivy


def add(input, other, *, alpha=1, out=None):
return ivy.add(input, other*alpha, out=out)


add.unsupported_dtypes = ('float16',)


def tan(input, *, out=None):
return ivy.tan(input, out=out)


tan.unsupported_dtypes = ('float16',)
38 changes: 38 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_pointwise_ops.py
Expand Up @@ -8,6 +8,44 @@
import ivy.functional.backends.torch as ivy_torch


# add
@given(
dtype_and_x=helpers.dtype_and_values(
tuple(set(ivy_np.valid_float_dtypes).intersection(
set(ivy_torch.valid_float_dtypes))), 2),
alpha=st.floats(),
as_variable=st.booleans(),
with_out=st.booleans(),
num_positional_args=helpers.num_positional_args(
fn_name="functional.frontends.torch.add"),
native_array=st.booleans(),
)
def test_torch_add(
dtype_and_x,
alpha,
as_variable,
with_out,
num_positional_args,
native_array,
fw,
):
input_dtype, x = dtype_and_x
helpers.test_frontend_function(
input_dtype,
as_variable,
with_out,
num_positional_args,
native_array,
fw,
"torch",
"add",
input=np.asarray(x[0], dtype=input_dtype[0]),
other=np.asarray(x[1], dtype=input_dtype[1]),
alpha=alpha,
out=None,
)


# tan
@given(
dtype_and_x=helpers.dtype_and_values(
Expand Down

0 comments on commit 2624e99

Please sign in to comment.