`torch.linalg.inv` with equivalent implementation for numpy. Args: x: array/tensor.
(x: NdarrayTensor)
| 448 | |
| 449 | |
| 450 | def 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 | |
| 461 | def max(x: NdarrayTensor, dim: int | tuple | None = None, **kwargs) -> NdarrayTensor: |
no test coverage detected
searching dependent graphs…