-
-
Couldn't load subscription status.
- Fork 657
Explore fixing test issues for older pytorch versions #3434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,7 +37,7 @@ def fid_score( | |||||||||||||
| diff = mu1 - mu2 | ||||||||||||||
|
|
||||||||||||||
| # Product might be almost singular | ||||||||||||||
| covmean, _ = scipy.linalg.sqrtm(sigma1.mm(sigma2), disp=False) | ||||||||||||||
| covmean, _ = scipy.linalg.sqrtm(sigma1.mm(sigma2).numpy(), disp=False) | ||||||||||||||
| # Numerical error might give slight imaginary component | ||||||||||||||
| if np.iscomplexobj(covmean): | ||||||||||||||
| if not np.allclose(np.diagonal(covmean).imag, 0, atol=1e-3): | ||||||||||||||
|
|
@@ -48,7 +48,7 @@ def fid_score( | |||||||||||||
| tr_covmean = np.trace(covmean) | ||||||||||||||
|
|
||||||||||||||
| if not np.isfinite(covmean).all(): | ||||||||||||||
| tr_covmean = np.sum(np.sqrt(((np.diag(sigma1) * eps) * (np.diag(sigma2) * eps)) / (eps * eps))) | ||||||||||||||
| tr_covmean = np.sum(np.sqrt(((np.diag(sigma1.numpy()) * eps) * (np.diag(sigma2.numpy()) * eps)) / (eps * eps))) | ||||||||||||||
|
|
||||||||||||||
| return float(diff.dot(diff).item() + torch.trace(sigma1) + torch.trace(sigma2) - 2 * tr_covmean) | ||||||||||||||
|
Comment on lines
+51
to
53
|
||||||||||||||
| tr_covmean = np.sum(np.sqrt(((np.diag(sigma1.numpy()) * eps) * (np.diag(sigma2.numpy()) * eps)) / (eps * eps))) | |
| return float(diff.dot(diff).item() + torch.trace(sigma1) + torch.trace(sigma2) - 2 * tr_covmean) | |
| tr_covmean = np.sum(np.sqrt(((np.diag(sigma1) * eps) * (np.diag(sigma2) * eps)) / (eps * eps))) | |
| return float(diff.dot(diff).item() + torch.trace(torch.tensor(sigma1)) + torch.trace(torch.tensor(sigma2)) - 2 * tr_covmean) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -872,7 +872,7 @@ def test__compute_recall_and_precision(available_device): | |
| def test_compute(sample): | ||
| device = idist.device() | ||
|
|
||
| if device == torch.device("mps"): | ||
| if device.type == "mps": | ||
| pytest.skip("Due to MPS backend out of memory") | ||
|
|
||
| # [email protected], [email protected], [email protected], AP-S, AP-M, AP-L, AR-1, AR-10, AR-100, AR-S, AR-M, AR-L | ||
|
|
@@ -932,7 +932,7 @@ def test_integration(sample): | |
| bs = 3 | ||
|
|
||
| device = idist.device() | ||
| if device == torch.device("mps"): | ||
| if device.type == "mps": | ||
| pytest.skip("Due to MPS backend out of memory") | ||
|
|
||
| def update(engine, i): | ||
|
|
@@ -1003,7 +1003,7 @@ def test_distrib_update_compute(distributed, sample): | |
|
|
||
| device = idist.device() | ||
|
|
||
| if device == torch.device("mps"): | ||
| if device.type == "mps": | ||
| pytest.skip("Due to MPS backend out of memory") | ||
|
|
||
| metric_device = "cpu" if device.type == "xla" else device | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converting the tensor to numpy adds an unnecessary GPU-to-CPU transfer. Consider checking if the input tensors are on GPU and handle the conversion more efficiently, or use PyTorch native operations if available.