Skip to contents

Matrix multiplication of two tensors. 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

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

Value

tensorish

Shapes

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

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

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

See also

nvl_dot_general() for the underlying primitive.

Examples

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