mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
hijack torch.linalg.cholesky()
This commit is contained in:
+10
-1
@@ -245,7 +245,7 @@ if sys.platform == "win32":
|
||||
|
||||
cholesky_ex_gpu = torch.linalg.cholesky_ex
|
||||
@wraps(cholesky_ex_gpu)
|
||||
def cholesky_ex(A: torch.Tensor, upper=False, check_errors=False, out=None) -> torch.Tensor:
|
||||
def cholesky_ex(A: torch.Tensor, upper=False, check_errors=False, out=None) -> torch.return_types.linalg_cholesky_ex:
|
||||
if A.device.type != 'cpu':
|
||||
return cholesky_ex_gpu(A, upper=upper, check_errors=check_errors, out=out)
|
||||
|
||||
@@ -269,6 +269,15 @@ if sys.platform == "win32":
|
||||
return torch.return_types.linalg_cholesky_ex((L, torch.tensor(0, dtype=torch.int32, device='cpu')), {})
|
||||
torch.linalg.cholesky_ex = cholesky_ex
|
||||
|
||||
cholesky_gpu = torch.linalg.cholesky
|
||||
@wraps(cholesky_gpu)
|
||||
def cholesky(A: torch.Tensor, upper=False, out=None) -> torch.Tensor:
|
||||
if A.device.type != 'cpu':
|
||||
return cholesky_gpu(A, upper=upper, out=out)
|
||||
L, _ = torch.linalg.cholesky_ex(A, upper=upper, out=out)
|
||||
return L
|
||||
torch.linalg.cholesky = cholesky
|
||||
|
||||
is_wsl: bool = False
|
||||
else:
|
||||
def get_agents() -> List[Agent]:
|
||||
|
||||
Reference in New Issue
Block a user