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

Introduce common utility for defining test matrix for device/dtype #616

Merged
merged 4 commits into from May 8, 2020

Conversation

mthrok
Copy link
Collaborator

@mthrok mthrok commented May 7, 2020

To work on #613, I added a helper function which simplifies the logic to generate test suites for different device, which also extends it to dtype.
As a result, torchscript consistency test is performed on (cpu, cuda) x (float32, float64) matrix. (float64 is newly added)

  1. This revealed that some transforms (Resample) is not compatible with float64, which is fixed in this PR.
  2. Interestingly lfilter does not yield consistent result among Python and torchscript only when float64.
    I looked at it but do not have an immediate fix so I marked them as expected to fail.

@mthrok mthrok force-pushed the test-dtype-device branch 2 times, most recently from aa39d2f to d7256e6 Compare May 7, 2020 21:25
@mthrok mthrok changed the title [WIP] Introduce common utility for defining test matrix for device/dtype Introduce common utility for defining test matrix for device/dtype May 7, 2020
@mthrok mthrok requested a review from vincentqb May 7, 2020 21:33
@mthrok mthrok marked this pull request as ready for review May 7, 2020 21:33
@codecov
Copy link

codecov bot commented May 7, 2020

Codecov Report

Merging #616 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #616   +/-   ##
=======================================
  Coverage   88.99%   89.00%           
=======================================
  Files          21       21           
  Lines        2254     2255    +1     
=======================================
+ Hits         2006     2007    +1     
  Misses        248      248           
Impacted Files Coverage Δ
torchaudio/compliance/kaldi.py 95.97% <100.00%> (+0.01%) ⬆️

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 7a0d419...ff4fc6a. Read the comment docs.

Copy link
Contributor

@vincentqb vincentqb left a comment

Choose a reason for hiding this comment

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

LGTM


if __name__ == '__main__':
unittest.main()
common_utils.define_test_suites(globals(), [Functional, Transforms])
Copy link
Contributor

Choose a reason for hiding this comment

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

alright, looks like pytorch is passing globals()

@@ -33,25 +30,12 @@ def test_clamp(self):
b_coeffs = torch.tensor([1, 0], dtype=self.dtype, device=self.device)
a_coeffs = torch.tensor([1, -0.95], dtype=self.dtype, device=self.device)
output_signal = F.lfilter(input_signal, a_coeffs, b_coeffs, clamp=True)
self.assertTrue(output_signal.max() <= 1)
assert output_signal.max() <= 1
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: changing self.assertTrue to assert? oh that's because the class isn't inheriting from unittest. I see.



if __name__ == '__main__':
unittest.main()
Copy link
Contributor

Choose a reason for hiding this comment

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

removing unittest is good to me.

@vincentqb vincentqb merged commit 00d3820 into pytorch:master May 8, 2020
@cpuhrsch
Copy link
Contributor

cpuhrsch commented May 8, 2020

I'm really not a fan of not inheriting from PyTorch's unittest class. Sure we can argue that some designs such as overwriting self.assertEqual aren't perfect, but the entire system relies on it and we should comply with whatever the core library defines as "equal". Otherwise we stand to fail to test for new developments such as type upcasting or new Tensor properties.

@mthrok mthrok deleted the test-dtype-device branch May 8, 2020 18:39
@mthrok
Copy link
Collaborator Author

mthrok commented May 8, 2020

I'm really not a fan of not inheriting from PyTorch's unittest class. Sure we can argue that some designs such as overwriting self.assertEqual aren't perfect, but the entire system relies on it and we should comply with whatever the core library defines as "equal". Otherwise we stand to fail to test for new developments such as type upcasting or new Tensor properties.

offline discussion: I will look into this.

@mthrok mthrok mentioned this pull request May 8, 2020
@vincentqb
Copy link
Contributor

I'm really not a fan of not inheriting from PyTorch's unittest class.

I agree. I suggest we revert the PR, and redo each item separately.

@mthrok -- Can you elaborate on the action items you have discussed?

@mthrok
Copy link
Collaborator Author

mthrok commented May 11, 2020

I'm really not a fan of not inheriting from PyTorch's unittest class.

I agree. I suggest we revert the PR, and redo each item separately.

Reverting this will adds more work for the same outcome so I would not.
Things I am working on

  • Replace pytest framework with unittest
  • Replace torch.assert_allclose with assertEqual from PyTorch''s test framework.

@vincentqb vincentqb mentioned this pull request Jun 3, 2020
2 tasks
mthrok pushed a commit to mthrok/audio that referenced this pull request Feb 26, 2021
Enabling tensor index from random_split
mpc001 pushed a commit to mpc001/audio that referenced this pull request Aug 4, 2023
The authors had renamed the paper to 'Auto-Encoding Variational Bayes'. This is more familiar to the current research community. I have just renamed the README to its current title, which matches their ICLR 2013 version.
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.

None yet

3 participants