Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added mul and multiply to PyTorch fronend #5357

Merged
merged 3 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ivy/functional/frontends/torch/pointwise_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,10 @@ def clip(input, min=None, max=None, *, out=None):
if max is None:
return ivy.maximum(input, min, out=out)
return ivy.clip(input, min, max, out=out)


def mul(input, other, *, out=None):
return ivy.multiply(input, other, out=out)


multiply = mul
33 changes: 33 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 @@ -1432,3 +1432,36 @@ def test_torch_clip(
max=max,
out=None,
)


# mul
@handle_cmd_line_args
@given(
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("numeric"),
num_arrays=2,
min_value=-1e04,
max_value=1e04,
allow_inf=False,
),
num_positional_args=helpers.num_positional_args(
fn_name="functional.frontends.torch.mul"
),
)
def test_torch_mul(
dtype_and_x, as_variable, with_out, num_positional_args, native_array, fw
):
input_dtype, x = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
as_variable_flags=as_variable,
with_out=with_out,
num_positional_args=num_positional_args,
native_array_flags=native_array,
frontend="torch",
fn_tree="mul",
rtol=1e-03,
input=x[0],
other=x[1],
out=None,
)