Skip to content

Add test to verify models and inputs are using the expected device#443

Merged
aaronenyeshi merged 4 commits into
masterfrom
aaron-add-check-device-test
Sep 2, 2021
Merged

Add test to verify models and inputs are using the expected device#443
aaronenyeshi merged 4 commits into
masterfrom
aaron-add-check-device-test

Conversation

@aaronenyeshi
Copy link
Copy Markdown
Member

The device attribute needs to be set in three locations: the BenchmarkModel,
the nn.Module model, and the model inputs. This test will verify that
the tensors and inputs are on the expected device set in BenchmarkModel.
Also, fix a few benchmark bugs where the device is incorrectly set.

The device attribute needs to be set in three locations: the BenchmarkModel,
the nn.Module model, and the model inputs. This test will verify that
the tensors and inputs are on the expected device set in BenchmarkModel.
Also, fix a few benchmark bugs where the device is incorrectly set.
@aaronenyeshi
Copy link
Copy Markdown
Member Author

Verified this test with gpurun python test.py --verbose -k check_device and all 52 models on cpu/cuda check_device tests passed:

----------------------------------------------------------------------
Ran 104 tests in 584.110s

OK (skipped=8)

Copy link
Copy Markdown
Contributor

@xuzhao9 xuzhao9 left a comment

Choose a reason for hiding this comment

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

Overall looks good to me! Great to see the test is already capturing a few bugs!

Comment thread test.py
Comment thread torchbenchmark/models/Super_SloMo/__init__.py
Copy link
Copy Markdown

@robieta robieta left a comment

Choose a reason for hiding this comment

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

I had some nitpicks, but overall looks quite reasonable. And that fact that it's already catching bugs speaks volumes! Thanks!

Comment thread torchbenchmark/__init__.py Outdated
Comment thread torchbenchmark/__init__.py Outdated
Comment thread torchbenchmark/__init__.py Outdated
Comment thread torchbenchmark/__init__.py Outdated
Comment thread torchbenchmark/__init__.py Outdated
Comment thread torchbenchmark/__init__.py Outdated
Comment thread torchbenchmark/__init__.py
Comment thread test.py
Change Exception to RuntimeError.
Update check inputs to a recursive implementation.
Copy link
Copy Markdown

@robieta robieta left a comment

Choose a reason for hiding this comment

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

One minor nit, but overall LGTM. Thanks!

Comment thread torchbenchmark/__init__.py Outdated
@aaronenyeshi aaronenyeshi merged commit c8f21e9 into master Sep 2, 2021
xuzhao9 pushed a commit to xuzhao9/benchmark that referenced this pull request Sep 10, 2021
…ytorch#443)

* Add test to verify models and inputs are using the expected device

The device attribute needs to be set in three locations: the BenchmarkModel,
the nn.Module model, and the model inputs. This test will verify that
the tensors and inputs are on the expected device set in BenchmarkModel.
Also, fix a few benchmark bugs where the device is incorrectly set.

* Fix a bug in tts_angular benchmark not allocating inputs on expected device

* Minor improvements to check_device

Change Exception to RuntimeError.
Update check inputs to a recursive implementation.

* Fix small mistake for inputs tensor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants