MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / linalg_inv

Function linalg_inv

monai/transforms/utils_pytorch_numpy_unification.py:450–458  ·  view source on GitHub ↗

`torch.linalg.inv` with equivalent implementation for numpy. Args: x: array/tensor.

(x: NdarrayTensor)

Source from the content-addressed store, hash-verified

448
449
450def linalg_inv(x: NdarrayTensor) -> NdarrayTensor:
451 """`torch.linalg.inv` with equivalent implementation for numpy.
452
453 Args:
454 x: array/tensor.
455 """
456 if isinstance(x, torch.Tensor) and hasattr(torch, "inverse"): # pytorch 1.7.0
457 return torch.inverse(x) # type: ignore
458 return torch.linalg.inv(x) if isinstance(x, torch.Tensor) else np.linalg.inv(x) # type: ignore
459
460
461def max(x: NdarrayTensor, dim: int | tuple | None = None, **kwargs) -> NdarrayTensor:

Callers 5

_compute_final_affineMethod · 0.90
transform_coordinatesMethod · 0.90
inverse_transformMethod · 0.90
inverseMethod · 0.90
inverseMethod · 0.90

Calls 1

inverseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…