Skip to content

Commit

Permalink
feat: added broadcast_tensors funtion for torch frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishticode committed Feb 13, 2024
1 parent 2f1d92d commit 902cf55
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ivy/functional/frontends/torch/tensor_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back


@to_ivy_arrays_and_back
def broadcast_tensors(*tensors):
return ivy.broadcast_arrays(*tensors)


@to_ivy_arrays_and_back
def is_complex(input):
return ivy.is_complex_dtype(input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,40 @@
)


# broadcast_tensors
@handle_frontend_test(
fn_tree="torch.broadcast_tensors",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
min_num_dims=1,
num_arrays=2,
),
)
def test_torch_broadcast_tensors(
*,
dtype_and_x,
on_device,
fn_tree,
frontend,
test_flags,
backend_fw,
):
input_dtype, x = dtype_and_x
kw = {}
for i, array in enumerate(x):
kw[f"x{i}"] = array
test_flags.num_positional_args = len(kw)
helpers.test_frontend_function(
input_dtypes=input_dtype,
backend_to_test=backend_fw,
on_device=on_device,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
**kw,
)


@handle_frontend_test(
fn_tree="torch.is_complex",
dtype_and_x=helpers.dtype_and_values(
Expand Down

0 comments on commit 902cf55

Please sign in to comment.