-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for device parametrization (#6)
- Loading branch information
Showing
2 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import unittest | ||
|
||
import torch | ||
from torch.testing._internal.common_device_type import ( | ||
dtypes, | ||
instantiate_device_type_tests, | ||
onlyCPU, | ||
) | ||
from torch.testing._internal.common_utils import TestCase | ||
|
||
|
||
class TestFoo(TestCase): | ||
@onlyCPU | ||
@dtypes(torch.float16, torch.int32) | ||
# fails for float16, passes for int32 | ||
def test_bar(self, device, dtype): | ||
assert dtype == torch.int32 | ||
|
||
# passes for float16, skips for int32 | ||
@onlyCPU | ||
@dtypes(torch.float16, torch.int32) | ||
def test_baz(self, device, dtype): | ||
if dtype == torch.int32: | ||
raise unittest.SkipTest | ||
|
||
assert True | ||
|
||
|
||
instantiate_device_type_tests(TestFoo, globals()) | ||
|
||
|
||
class TestSpam(TestCase): | ||
@onlyCPU | ||
def test_ham(self, device): | ||
assert True | ||
|
||
@onlyCPU | ||
@dtypes(torch.float16) | ||
def test_eggs(self, device, dtype): | ||
assert False | ||
|
||
|
||
instantiate_device_type_tests(TestSpam, globals()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters