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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message on wrong device #1056

Merged
merged 15 commits into from Jun 7, 2022

Conversation

SkafteNicki
Copy link
Member

@SkafteNicki SkafteNicki commented May 31, 2022

What does this PR do?

Fixes #1055, #1047, #917 (And probably a lot more)
Common mistake by users is not moving the metric object to the same device as the input. I think this already pretty clear from the documentation (and the fact that metrics are just nn.Module which also needs to be moved) but users keep making it. This is a proposed solution that can hopefully catch this mistake.

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 馃檭

@SkafteNicki SkafteNicki added the enhancement New feature or request label May 31, 2022
@SkafteNicki SkafteNicki added this to the v0.10 milestone May 31, 2022
@codecov
Copy link

codecov bot commented May 31, 2022

Codecov Report

Merging #1056 (86633e0) into master (1cc90c6) will decrease coverage by 0%.
The diff coverage is 83%.

@@          Coverage Diff           @@
##           master   #1056   +/-   ##
======================================
- Coverage      95%     95%   -0%     
======================================
  Files         181     181           
  Lines        8046    8051    +5     
======================================
- Hits         7615    7614    -1     
- Misses        431     437    +6     

torchmetrics/metric.py Outdated Show resolved Hide resolved
torchmetrics/metric.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready label Jun 1, 2022
@Borda Borda enabled auto-merge (squash) June 2, 2022 11:09
@carmocca carmocca disabled auto-merge June 3, 2022 16:08
torchmetrics/metric.py Outdated Show resolved Hide resolved
torchmetrics/metric.py Outdated Show resolved Hide resolved
@mergify mergify bot removed the ready label Jun 6, 2022
@Borda Borda enabled auto-merge (squash) June 6, 2022 12:28
@mergify mergify bot added the ready label Jun 6, 2022
@mergify mergify bot added the has conflicts label Jun 7, 2022
@mergify mergify bot removed the has conflicts label Jun 7, 2022
@Borda Borda requested a review from justusschock June 7, 2022 09:14
@Borda Borda modified the milestones: v0.10, v0.9 Jun 7, 2022
torchmetrics/metric.py Outdated Show resolved Hide resolved
@mergify mergify bot added the has conflicts label Jun 7, 2022
@mergify mergify bot removed the has conflicts label Jun 7, 2022
@Borda Borda merged commit 9e26cae into master Jun 7, 2022
@Borda Borda deleted the feature/better_error_on_wrong_device branch June 7, 2022 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PearsonCorrCoef throws device error when tensors are on cuda device
6 participants