torch.linalg.solve_ex#
- torch.linalg.solve_ex(A, B, *, left=True, check_errors=False, out=None)#
A version of
solve()
that does not perform error checks unlesscheck_errors
= True. It also returns theinfo
tensor returned by LAPACK’s getrf.注意
当输入在 CUDA 设备上时,此函数仅在
check_errors
= True 时进行同步。警告
此函数是“实验性的”,未来 PyTorch 版本中可能会发生变化。
- 参数
A (Tensor) – 形状为 (*, n, n) 的张量,其中 * 是零个或多个批次维度。
- 关键字参数
left (bool, optional) – whether to solve the system or . Default: True.
check_errors (bool, optional) – controls whether to check the content of
infos
and raise an error if it is non-zero. Default: False.out (tuple, optional) – tuple of two tensors to write the output to. Ignored if None. Default: None.
- 返回
A named tuple (result, info).
示例
>>> A = torch.randn(3, 3) >>> Ainv, info = torch.linalg.solve_ex(A) >>> torch.dist(torch.linalg.inv(A), Ainv) tensor(0.) >>> info tensor(0, dtype=torch.int32)