Skip to content
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

Speed up CI runtime #3189

Merged
merged 7 commits into from
Jan 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Speedup DeformConvTester (#3191)
* Separating unrelated checks to avoid unnecessary repetition.

* Add cache on get_fn_args().
  • Loading branch information
datumbox authored Dec 18, 2020
commit e96bc8da5c10b6646106030624255298cf61ed80
6 changes: 5 additions & 1 deletion test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np

import torch
from functools import lru_cache
from torch import Tensor
from torch.autograd import gradcheck
from torch.nn.modules.utils import _pair
Expand Down Expand Up @@ -496,6 +497,7 @@ def expected_fn(self, x, weight, offset, mask, bias, stride=1, padding=0, dilati
out += bias.view(1, n_out_channels, 1, 1)
return out

@lru_cache(maxsize=None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deciding on caching random data is not that simple IMO. There are pros/cons of that...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree there are pros/cons. Note that this is something we do on tests only and seems to help us speed-wise. I don't have a strong opinion about keeping it if it causes issues.

def get_fn_args(self, device, contiguous, batch_sz, dtype):
n_in_channels = 6
n_out_channels = 2
Expand Down Expand Up @@ -614,9 +616,11 @@ def script_func_no_mask(x_, offset_, weight_, bias_, stride_, pad_, dilation_):
gradcheck(lambda z, off, wei, bi: script_func_no_mask(z, off, wei, bi, stride, padding, dilation),
(x, offset, weight, bias), nondet_tol=1e-5)

@unittest.skipIf(not torch.cuda.is_available(), "CUDA unavailable")
def test_compare_cpu_cuda_grads(self):
# Test from https://github.com/pytorch/vision/issues/2598
# Run on CUDA only
if "cuda" in device.type:
for contiguous in [False, True]:
# compare grads computed on CUDA with grads computed on CPU
true_cpu_grads = None

Expand Down