pytorch
9239279c - Suport tensor type for XPU (#96656)

Commit
2 years ago
Suport tensor type for XPU (#96656) # Motivate To support tensor type scenario for XPU. like CUDA: ```python >>> import torch >>> torch.rand(2,3).cuda(0).type(torch.cuda.IntTensor) tensor([[0, 0, 0], [0, 0, 0]], device='cuda:0', dtype=torch.int32) ``` without this PR: ```python >>> import torch >>> import intel_extension_for_pytorch >>> torch.rand(2,3).xpu('xpu:0').type(torch.xpu.IntTensor) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid type: 'torch.xpu.IntTensor' ``` with this PR: ```python >>> import torch >>> import intel_extension_for_pytorch >>> torch.rand(2,3).xpu('xpu:0').type(torch.xpu.IntTensor) tensor([[0, 0, 0], [0, 0, 0]], device='xpu:0', dtype=torch.int32) ``` # Solution Add allXPUTypes in type method to parse all xpu tensor type # Additional UT pass. Pull Request resolved: https://github.com/pytorch/pytorch/pull/96656 Approved by: https://github.com/albanD
Author
Committer
Parents
Loading