Skip to contents

Unlike %*%, mlx_matmul() accepts arrays with more than two dimensions. The last two axes are matrix axes; preceding axes broadcast. One-dimensional operands are promoted to row/column matrices and the added axes are removed from the result, following MLX semantics. Scalars are not supported.

Usage

mlx_matmul(x, y)

Arguments

x

An mlx array, or an R array/matrix/vector that will be converted via as_mlx().

y

A second array, with the same accepted types as x.

Value

An mlx array. Two vectors produce a scalar inner product.

See also

Examples

x <- mlx_ones(c(2, 3, 4))
w <- mlx_ones(c(4, 5))
mlx_shape(mlx_matmul(x, w)) # 2 3 5
#> [1] 2 3 5