Skip to content

Commit

Permalink
Fix random calculation error in test_sum_on_device1 (#994)
Browse files Browse the repository at this point in the history
Fix random calculation error in test_sum_on_device1 by adding device
switch logic.
  • Loading branch information
xytintel authored Oct 22, 2024
1 parent 88b029e commit b4a760c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions test/regressions/test_operation_on_device_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class TestOperationOnDevice1(TestCase):
def test_sum_on_device1(self, dtype=torch.float):
if torch.xpu.device_count() >= 2:
a = torch.randn(2, 3, device=torch.device('xpu:1'))
torch.xpu.set_device(1)
res = a.sum()
ref = a.cpu().sum()
self.assertEqual(ref, res)

0 comments on commit b4a760c

Please sign in to comment.