mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[dynamo][numpy] Add unsigned integer dtypes (#125717)
We should support these to whatever extent we can. They corresponding `torch.uint<w>` types are defined, so I don't see an issue with generating the various casting rules and allowing them to trace. Pull Request resolved: https://github.com/pytorch/pytorch/pull/125717 Approved by: https://github.com/lezcano
This commit is contained in:
committed by
PyTorch MergeBot
parent
4ce5322a1f
commit
879d01afcb
@ -476,13 +476,18 @@ class TestNumPyInterop(TestCase):
|
||||
self.assertTrue(r2.requires_grad)
|
||||
|
||||
@onlyCPU
|
||||
def test_parse_numpy_int(self, device):
|
||||
@skipIfTorchDynamo()
|
||||
def test_parse_numpy_int_overflow(self, device):
|
||||
# assertRaises uses a try-except which dynamo has issues with
|
||||
# Only concrete class can be given where "Type[number[_64Bit]]" is expected
|
||||
self.assertRaisesRegex(
|
||||
RuntimeError,
|
||||
"(Overflow|an integer is required)",
|
||||
lambda: torch.mean(torch.randn(1, 1), np.uint64(-1)),
|
||||
) # type: ignore[call-overload]
|
||||
|
||||
@onlyCPU
|
||||
def test_parse_numpy_int(self, device):
|
||||
# https://github.com/pytorch/pytorch/issues/29252
|
||||
for nptype in [np.int16, np.int8, np.uint8, np.int32, np.int64]:
|
||||
scalar = 3
|
||||
|
||||
Reference in New Issue
Block a user