[Testing] Make test_add_complex3 run on different devices (#151732)

By constructing tensor on that device, because it does not call `self.common` but rather executes test directly.

Otherwise `test_add_complex3_mps` will test CPU inductor, rather than MPS one

Pull Request resolved: https://github.com/pytorch/pytorch/pull/151732
Approved by: https://github.com/dcci
This commit is contained in:
Nikita Shulga 2025-04-19 14:29:13 +00:00 committed by PyTorch MergeBot
parent 483e61bfec
commit ed511cd537

View File

@ -1369,7 +1369,11 @@ class CommonTemplate:
b = torch.add(args[0], args[0])
return (a, b)
x = torch.randn(41, dtype=torch.complex64)
# Complex are not supported on MacOS-13
if self.device == "mps" and MACOS_VERSION < 14.0:
raise unittest.SkipTest("No complex on MacOS13")
x = torch.randn(41, dtype=torch.complex64, device=self.device)
y = x.clone()
# should not inplace write to the input
fn(x)