megengine.functional.matinv#

matinv(inp)[source]#

Computes the inverse of a batch of matrices; input must has shape […, n, n].

Parameters:

inp (Tensor) – input tensor.

Return type:

Tensor

Returns:

output tensor.

Examples

>>> import numpy as np
>>> data = Tensor([[1.0, 0.0], [1.0, 1.0]])
>>> out = F.matinv(data)
>>> out.numpy()
array([[ 1.,  0.],
       [-1.,  1.]], dtype=float32)