Skip to content

Commit

Permalink
add tensorflow matmul frontend implemenation (ivy-llc#10079)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurshakuz authored Jan 30, 2023
1 parent f8cae0f commit 90315eb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ivy/functional/frontends/tensorflow/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ def eigvalsh(tensor, name=None):
return ivy.eigvalsh(tensor)


@to_ivy_arrays_and_back
def matmul(
a,
b,
transpose_a=False,
transpose_b=False,
adjoint_a=False,
adjoint_b=False,
a_is_sparse=False,
b_is_sparse=False,
output_type=None,
name=None
):
# TODO : handle conjugate when ivy supports complex numbers
return ivy.matmul(a, b, transpose_a=transpose_a, transpose_b=transpose_b)


@to_ivy_arrays_and_back
@with_unsupported_dtypes({"2.9.0 and below": ("float16", "bfloat16")}, "tensorflow")
def solve(matrix, rhs):
Expand Down
44 changes: 44 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_tensorflow/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,50 @@ def test_matrix_rank(
)


@handle_frontend_test(
fn_tree="tensorflow.linalg.matmul",
dtype_x=helpers.dtype_and_values(
available_dtypes=[
"float16",
"float32",
"float64",
"int32",
"int64",
],
shape=(3, 3),
num_arrays=2,
shared_dtype=True,
min_value=-1e04,
max_value=1e04,
),
transpose_a=st.booleans(),
transpose_b=st.booleans(),
test_with_out=st.just(False),
)
def test_matmul(
*,
dtype_x,
transpose_a,
transpose_b,
frontend,
test_flags,
fn_tree,
on_device,
):
input_dtype, x = dtype_x
helpers.test_frontend_function(
input_dtypes=input_dtype,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
a=x[0],
b=x[1],
transpose_a=transpose_a,
transpose_b=transpose_b,
)


@st.composite
def _solve_get_dtype_and_data(draw):
batch = draw(st.integers(min_value=1, max_value=5))
Expand Down

0 comments on commit 90315eb

Please sign in to comment.