Skip to contents

Computes beta * input + alpha * (mat1 %*% mat2) in a single MLX kernel. All operands are promoted to a common dtype/device prior to evaluation.

Usage

mlx_addmm(input, mat1, mat2, alpha = 1, beta = 1)

Arguments

input

Matrix-like object providing the additive term.

mat1

Left matrix operand.

mat2

Right matrix operand.

alpha, beta

Numeric scalars controlling the fused linear combination.

Value

An mlx matrix with the same shape as input.

See also

Examples

if (FALSE) { # \dontrun{
input <- as_mlx(diag(3))
mat1 <- as_mlx(matrix(rnorm(9), 3, 3))
mat2 <- as_mlx(matrix(rnorm(9), 3, 3))
mlx_addmm(input, mat1, mat2, alpha = 0.5, beta = 2)
} # }