Skip to content

Added available_device in test_classification_report (#3335) #3342

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

Merged
merged 5 commits into from
Mar 23, 2025

Conversation

HyeSungP
Copy link
Contributor

@HyeSungP HyeSungP commented Mar 11, 2025

Fixes #3335
Related #3335 (as we should not close the issue with this PR as it does not address all the tasks)

Description:

  • Added test_compute_multiclass and test_compute_multilabel to automatically use the available_device fixture in test_classification_report.py.

* Added test_compute_multiclass and test_compute_multilabel to automatically use the available_device fixture in pytest.
Copy link
Collaborator

@vfdev-5 vfdev-5 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @HyeSungP !
This test suite looks a bit particular and we need to rework it a bit. I left a comment.

@@ -159,6 +159,158 @@ def update(engine, i):
_test(metric_device, 2, ["0", "1", "2", "3", "4", "5", "6"])


@pytest.mark.parametrize("n_times", range(5))
def test_compute_multiclass(n_times, available_device):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's refactor _test_integration_multiclass test such that we could call it in usual and distributed configs. It is not good to copy-paste the code. Same for the second test method.

Copy link
Contributor Author

@HyeSungP HyeSungP Mar 11, 2025

Choose a reason for hiding this comment

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

@vfdev-5 Thank you for your advice! So, should I refactor _test_integration_multiclass and _test_integration_multilabel to extract the common logic and make it reusable for both the usual and distributed configurations?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, we should extract the common code that could be used with 1) the new test you have written with available_device and 2) distributed test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vfdev-5 Hello! I have made a new commit. Could you check it for me?

HyeSungP and others added 2 commits March 13, 2025 13:53
* Added `_test_multiclass` and `_test_multilabel`

* Updated `_test_integration_multiclass` and `_test_integration_multilabel`

* Updated `test_compute_multiclass` and `test_compute_multilabel`
@HyeSungP
Copy link
Contributor Author

Hi @vfdev-5, sorry for the reminder, but I just wanted to kindly check if you had a chance to review my recent commit regarding the refactored tests. Let me know if there’s anything I should improve or revise!

Copy link
Collaborator

@vfdev-5 vfdev-5 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @HyeSungP !
Sorry for delay on reviewing the PR!

@vfdev-5 vfdev-5 enabled auto-merge (squash) March 23, 2025 20:11
@vfdev-5 vfdev-5 merged commit 0f365e7 into pytorch:master Mar 23, 2025
13 of 14 checks passed
@HyeSungP HyeSungP deleted the test_classification_report branch March 26, 2025 13:52
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.

Improve metrics tests
2 participants