-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add aten::clone and simple cases Signed-off-by: Feng Yuan <feng1.yuan@intel.com> * Fix Loops legacy code-path Signed-off-by: Feng Yuan <feng1.yuan@intel.com> --------- Signed-off-by: Feng Yuan <feng1.yuan@intel.com>
- Loading branch information
1 parent
6340065
commit 9cb104a
Showing
3 changed files
with
28 additions
and
2 deletions.
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
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
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,21 @@ | ||
import torch | ||
from torch.testing._internal.common_utils import TestCase | ||
|
||
cpu_device = torch.device("cpu") | ||
xpu_device = torch.device("xpu") | ||
|
||
|
||
class TestSimpleCopy(TestCase): | ||
def test_copy_and_clone(self, dtype=torch.float): | ||
a_cpu = torch.randn(16, 64, 28, 28) | ||
b_cpu = torch.randn(16, 64, 28, 28) | ||
a_xpu = a_cpu.to(xpu_device) | ||
b_xpu = b_cpu.to(xpu_device) | ||
# naive | ||
b_cpu.copy_(a_cpu) | ||
b_xpu.copy_(a_xpu) | ||
self.assertEqual(b_cpu, b_xpu.to(cpu_device)) | ||
# clone + permutation | ||
b_cpu = a_cpu.clone(memory_format=torch.channels_last) | ||
b_xpu = a_xpu.clone(memory_format=torch.channels_last) | ||
self.assertEqual(b_cpu, b_xpu.to(cpu_device)) |