Skip to content

Commit

Permalink
Test that broadcast doesn't copy when dst and src devices are the same (
Browse files Browse the repository at this point in the history
pytorch#8803)

* test that broadcast doesn't copy when dst and src devices are the same

* only test if input is cuda
  • Loading branch information
ssnl committed Jun 22, 2018
1 parent 46bff5d commit 12904ed
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ def _test_broadcast(self, input):
for i, t in enumerate(result):
self.assertEqual(t.get_device(), i)
self.assertEqual(t, input)
if input.is_cuda and input.get_device() == i:
self.assertEqual(t.data_ptr(), input.data_ptr())

def test_broadcast_cpu(self):
self._test_broadcast(torch.randn(5, 5))
Expand Down

0 comments on commit 12904ed

Please sign in to comment.