Skip to contents

Matrix multiplication of two arrays. You can also use the %*% operator. Supports batched matrix multiplication when inputs have more than 2 dimensions.

Usage

nv_matmul(lhs, rhs)

Arguments

lhs, rhs

(arrayish)
Arrays with at least 2 dimensions. Operands are promoted to a common data type.

Value

arrayish

Shapes

  • lhs: (b1, ..., bk, m, n)

  • rhs: (b1, ..., bk, n, p)

  • output: (b1, ..., bk, m, p)

See also

prim_dot_general() for the underlying primitive.

Examples

x <- nv_array(matrix(1:6, nrow = 2))
y <- nv_array(matrix(1:6, nrow = 3))
x %*% y
#> AnvlArray
#>  22 49
#>  28 64
#> [ CPUi32{2,2} ]