Skip to content

Adds dtypes decorators to and allows helper methods in device generic test classes#26375

Closed
mruberry wants to merge 4 commits intomasterfrom
generic_device_dtypes
Closed

Adds dtypes decorators to and allows helper methods in device generic test classes#26375
mruberry wants to merge 4 commits intomasterfrom
generic_device_dtypes

Conversation

@mruberry
Copy link
Copy Markdown
Collaborator

@mruberry mruberry commented Sep 17, 2019

  • Adds @dtypes, @dtypesIfCPU, and @dtypesIfCUDA decorators.
  • Eliminates the need for nontest members to be defined in an inherited base.
  • Updates one test to use the decorators and updates TestTorchDeviceType with helpers.

This PR appears to be hanging the ROCm build, which is not entirely surprising. See #26394, which demonstrates that the ROCm build can be hung by commenting out a Python test that was never run on ROCm.

@gchanan - what type list, if any, do you want to expose? I imagine most test suites will define their own lists like today. SCALAR_TYPES, QUANTIZED_TYPES, and ALL_TYPES seem reasonable to me. DOCUMENTED_TENSOR_TYPES will be removed, of course.

@mruberry mruberry changed the title [WIP] Adds dtypes decorators to and allows helper methods in device generic test classes Adds dtypes decorators to and allows helper methods in device generic test classes Sep 18, 2019
@mruberry mruberry requested a review from gchanan September 18, 2019 05:46
Comment thread test/common_device_type.py
Comment thread test/common_device_type.py Outdated
Comment thread test/common_device_type.py Outdated
Comment thread test/common_device_type.py Outdated
@mruberry mruberry requested a review from gchanan September 18, 2019 20:46
@mruberry
Copy link
Copy Markdown
Collaborator Author

@pytorchbot rebase this please.

Comment thread test/test_torch.py
doubles, sz, lambda input, out: torch.pow(42, input, out=out))

def test_erfinv(self, device):
@dtypesIfCUDA(torch.half, torch.float, torch.double)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it is probably common enough in the future to have a function that returns a device-specific list for these cases.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

getCUDAFloatTypes()?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

getFloatTypes('cuda') :).

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@mruberry mruberry deleted the generic_device_dtypes branch September 18, 2019 22:43
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@mruberry merged this pull request in 248d585.

laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
… test classes (pytorch#26375)

Summary:
- Adds dtypes, dtypesIfCPU, and dtypesIfCUDA decorators.
- Eliminates the need for nontest members to be defined in an inherited base.
- Updates one test to use the decorators and updates TestTorchDeviceType with helpers.

This PR appears to be hanging the ROCm build, which is not entirely surprising. See pytorch#26394, which demonstrates that the ROCm build can be hung by commenting out a Python test that was never run on ROCm.

gchanan - what type list, if any, do you want to expose? I imagine most test suites will define their own lists like today. SCALAR_TYPES, QUANTIZED_TYPES, and ALL_TYPES seem reasonable to me. DOCUMENTED_TENSOR_TYPES will be removed, of course.
Pull Request resolved: pytorch#26375

Test Plan: Edit is to tests themselves.

Differential Revision: D17462294

Pulled By: mruberry

fbshipit-source-id: f8259ec66709749b1bf8077efc737676af901436
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants