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

Simplify and organize test_ops. #1551

Merged
merged 3 commits into from
Nov 6, 2019
Merged

Conversation

pedrofreire
Copy link
Contributor

@pedrofreire pedrofreire commented Nov 4, 2019

For #1528, We perform the following:

  • Simplify the functions slow_roi_pooling, slow_ps_roi_pooling, slow_ps_roi_align and bilinear_interpolate (including finding and removing a semi-bug in slow_ps_roi_pooling, which used bin_w instead of bin_h);
  • Write a slow_roi_align function, that was missing;
  • Create a base class testing all combinations of forward/backward, cpu/cuda, contiguous/non-contiguous;
  • Organize all testing inside the base class with _test_forward and _test_backward (which can be easily overriden if a parciular op needs something different); an op class then only needs to implement fn, get_script_fn, and expected_fn.

A few points:

  • We are using the same inputs for all tests, and not trying a diverse set of inputs in the domain of a given operation. One improvement would be to test more diverse inputs, and to personalize the inputs for some ops (e.g. different inputs for pooling ops and align ops).
  • Running all tests is quite slow (~1 min only for CPU tests), so that can possibly be improved.

@pedrofreire pedrofreire changed the title Simlify and organize test_ops. Simplify and organize test_ops. Nov 4, 2019
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

This looks much better, thanks a lot for the improvements @pedrofreire !

I only have minor comments which are not merge-blocking, and which can be fixed in a follow-up PR.

Tests seem to be failing on TravisCI though due to OOM on the gradcheck.

While we will be moving away from TravisCI soonish, we still rely on it for some signal, so it would be good to have it fixed.
Can you maybe reduce the input size for gradient computation to fix this OOM?

@fmassa
Copy link
Member

fmassa commented Nov 4, 2019

Link for failed tests on TravisCI: https://travis-ci.org/pytorch/vision/builds/607174087?utm_source=github_status&utm_medium=notification

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

There is a lint error, apart from that the other test failure seems to be unrelated.

Thanks!

@codecov-io
Copy link

codecov-io commented Nov 4, 2019

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1551   +/-   ##
=======================================
  Coverage   65.48%   65.48%           
=======================================
  Files          90       90           
  Lines        7080     7080           
  Branches     1077     1077           
=======================================
  Hits         4636     4636           
  Misses       2135     2135           
  Partials      309      309

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 4897402...765b891. Read the comment docs.

@fmassa
Copy link
Member

fmassa commented Nov 5, 2019

@pedrofreire this PR uncovered a small inconsistency with nms which I'll be resolving today, after which I'll be merging your PR.

@fmassa
Copy link
Member

fmassa commented Nov 5, 2019

@pedrofreire #1556 has been merged, so if you rebase your PR on top of master all tests should pass.

Pedro Freire added 3 commits November 6, 2019 09:11
We perform the following:

- Simplify the functions slow_roi_pooling, slow_ps_roi_pooling, slow_ps_roi_align and bilinear_interpolate (including finding and removing a semi-bug in slow_ps_roi_pooling, which used bin_w instead of bin_h);
- Wrote a slow_roi_align function, that was missing;
- Create a base class testing all combinations of forward/backward, cpu/cuda, contiguous/non-contiguous;
- Organize all testing inside the base class with _test_forward and _test_backward (which can be easily overriden if a parciular op needs something different); an Op class then only needs to implement fn, get_script_fn, and expected_fn.

A few points:
- We are using the same inputs for all tests, and not trying all possible inputs in the domain of a given operation. One improvement would be to test more diverse inputs, and to personalize the inputs for some ops (e.g. different inputs for pooling ops and align ops).
- Running all tests is quite slow (~1 min only for CPU tests), so that can possibly be improved.
gradcheck can be quite costly, and it was causing OOM errors and making
the tests slow. By reducing the size of the input, the test speed is
down to 3 seconds for the CPU tests.

Other points:
- We remove an unused namedtuple;
- We inherit from object for better Python 2 compatibility;
- We remove a hardcoded pool_size from the TorchScript functions, and
add it as a parameter instead.
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Awesome, thanks a lot!

@fmassa fmassa merged commit af225a8 into pytorch:master Nov 6, 2019
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