Skip to content

Commit

Permalink
Add Matmul function for Torch Frontend (#10476)
Browse files Browse the repository at this point in the history

Co-authored-by: MahmoudAshraf97 <[email protected]>
  • Loading branch information
MuhammedAshraf2020 and MahmoudAshraf97 authored Feb 17, 2023
1 parent d63d560 commit b753ed1
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/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,9 @@ def solve(input, other, *, out=None):
@with_unsupported_dtypes({"1.11.0 and below": ("bfloat16", "float16")}, "torch")
def tensorsolve(A, B, dims=None, *, out=None):
return ivy.tensorsolve(A, B, axes=dims, out=out)


@to_ivy_arrays_and_back
@with_unsupported_dtypes({"1.11.0 and below": ("bfloat16", "float16")}, "torch")
def matmul(input, other, *, out=None):
return ivy.matmul(input, other, out=out)
34 changes: 34 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,3 +847,37 @@ def test_torch_tensorsolve(
A=A,
B=B,
)


@handle_frontend_test(
fn_tree="torch.linalg.matmul",
dtype_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
shape=(3, 3),
num_arrays=2,
shared_dtype=True,
min_value=-1e04,
max_value=1e04,
),
test_with_out=st.just(False),
)
def test_torch_matmul(
*,
dtype_x,
frontend,
fn_tree,
on_device,
test_flags,
):
input_dtype, x = dtype_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
frontend=frontend,
fn_tree=fn_tree,
on_device=on_device,
test_flags=test_flags,
input=x[0],
other=x[1],
rtol=1e-03,
atol=1e-06,
)

0 comments on commit b753ed1

Please sign in to comment.