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

Add test for large batches in DeformConv2d #2040

Merged
merged 4 commits into from
Apr 2, 2020

Conversation

fmassa
Copy link
Member

@fmassa fmassa commented Apr 1, 2020

Follow-up for #2027

@fmassa fmassa force-pushed the test-large-batch-deform-conv2d branch from 793d7bd to 6e6c2da Compare April 1, 2020 15:00
@codecov-io
Copy link

Codecov Report

Merging #2040 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2040   +/-   ##
======================================
  Coverage    0.48%   0.48%           
======================================
  Files          92      92           
  Lines        7411    7411           
  Branches     1128    1128           
======================================
  Hits           36      36           
  Misses       7362    7362           
  Partials       13      13

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2f085b...b5aa349. Read the comment docs.

@fmassa fmassa force-pushed the test-large-batch-deform-conv2d branch from b5aa349 to 252e063 Compare April 2, 2020 13:42
@@ -454,7 +454,7 @@ def expected_fn(self, x, weight, offset, bias, stride=1, padding=0, dilation=1):
return out

def get_fn_args(self, device, contiguous):
batch_sz = 1
batch_sz = 33
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not test both batch_sz 1, 33 and some larger value (in case that magic number changes)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would like to change this test to be faster actually -- in it's current state it is the slowest test in torchvision (takes 30s to run). Ideally, I would like to only do gradcheck on a smaller tensor, but still check for correctness in the large-tensor case. My plan was to open an issue to improve this in the future

{n_in_channels * weight_w * weight_h, n_parallel_imgs * out_h * out_w},
input.options());

// Separate into blocks
grad_input = grad_input.view(
grad_input = grad_input.reshape(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this changing from view to reshape?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are many changes like that which are mostly artifacts of when I was debugging ongoing issues, and although most of them are not needed per se, I think it's a better practice now to use reshape instead of view, as it works with non-contiguous tensors.

Basically, using reshape here will probably not change anything to the current code-path, but I think it's safer

Copy link
Contributor

Choose a reason for hiding this comment

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

It's safer, but it can also incur unexpected memory operations

Copy link
Member Author

Choose a reason for hiding this comment

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

totally agree, but if we want to support non-contiguous tensors in this function, we would need to call .contiguous() before anyway, so this becomes a no-op

@fmassa fmassa merged commit ccd797d into pytorch:master Apr 2, 2020
@fmassa fmassa deleted the test-large-batch-deform-conv2d branch April 2, 2020 18:03
@fmassa
Copy link
Member Author

fmassa commented Apr 2, 2020

Thanks for the review Christian!

fmassa added a commit to fmassa/vision-1 that referenced this pull request Jul 8, 2020
* Add test for large batches in DeformConv2d

* Clean-up and (try) fix DeformConv2d

* Simplifications and bugfixes

* Try fix CUDA now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants