<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/numpy.py#L5092-L5114) |

Matrix product of two tensors.

#### View aliases


**Main aliases**

[`tf.keras.ops.numpy.matmul`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/matmul)

<br />

    tf.keras.ops.matmul(
        x1, x2
    )

- If both tensors are 1-dimensional, the dot product (scalar) is returned.
- If either tensor is N-D, N \> 2, it is treated as a stack of matrices residing in the last two indexes and broadcast accordingly.
- If the first tensor is 1-D, it is promoted to a matrix by prepending a 1 to its dimensions. After matrix multiplication the prepended 1 is removed.
- If the second tensor is 1-D, it is promoted to a matrix by appending a 1 to its dimensions. After matrix multiplication the appended 1 is removed.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x1` | First tensor. |
| `x2` | Second tensor. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Output tensor, matrix product of the inputs. ||

<br />