pytorch
0a9c9cc6 - Update DLPack to 0.4 (#55365)

Commit
3 years ago
Update DLPack to 0.4 (#55365) Summary: Fixes https://github.com/pytorch/pytorch/issues/55090 I included the header directly, but I am not sure if we should add this as a git submodule, what do you guys think? Also regarding the implementation, in ATen lanes seems not to be supported, but from CuPy complex types are exported with 2 lanes, I am not sure wether this is correct or not. However, in PyTorch this seems to be working properly, so I forgive 2 lanes for complex datatypes. TODO: add tests for complex and bfloat Easy test script against cupy ```python import cupy import torch from torch.utils.dlpack import to_dlpack from torch.utils.dlpack import from_dlpack # Create a PyTorch tensor. tx1 = torch.tensor( [2 + 1j, 3 + 2j, 4 + 3j, 5 + 4j], dtype=torch.complex128 ).cuda() # Convert it into a DLPack tensor. dx = to_dlpack(tx1) # Convert it into a CuPy array. cx = cupy.fromDlpack(dx) # Convert it back to a PyTorch tensor. tx2 = from_dlpack(cx.toDlpack()) torch.testing.assert_allclose(tx1, tx2) ``` Thanks to leofang who updated CuPy's dlpack version and his PR served me as the guide for this one. Pull Request resolved: https://github.com/pytorch/pytorch/pull/55365 Reviewed By: ngimel Differential Revision: D27724923 Pulled By: mruberry fbshipit-source-id: 481eadb882ff3dd31e7664e08e8908c60a960f66
Author
Emilio Castillo
Parents
Loading