CV-CUDA icon indicating copy to clipboard operation
CV-CUDA copied to clipboard

[FEATURE]libtorch interface

Open nan2088 opened this issue 3 years ago • 4 comments

At this moment, CudaBuffer can be converted to torch.Tensor through __cuda_array_interface__. However, sometimes we have to use libtorch(at::Tensor/torch::Tensor). Is it possible to make a libtorch interface for nvcv::Tensor/ITensor ?

nan2088 avatar Jan 10 '23 05:01 nan2088

To have DLPack support for C++ API would be great, like

 DLManagedTensor* fromNvcvTensor(const nvcv::Tensor& src) ;
...

An example is from pytorch:

https://github.com/Tabrizian/pytorch/blob/5c5f53ef6645016794b2e0c9a267ccb095995ea5/aten/src/ATen/DLConvertor.cpp#L244

nan2088 avatar Dec 15 '23 03:12 nan2088

At this moment, CudaBuffer can be converted to torch.Tensor through __cuda_array_interface__. However, sometimes we have to use libtorch(at::Tensor/torch::Tensor). Is it possible to make a libtorch interface for nvcv::Tensor/ITensor ?

I'm having the same problem now, how did you solve it? Thanks!

SongDabao avatar Jan 30 '24 07:01 SongDabao

At this moment, CudaBuffer can be converted to torch.Tensor through __cuda_array_interface__. However, sometimes we have to use libtorch(at::Tensor/torch::Tensor). Is it possible to make a libtorch interface for nvcv::Tensor/ITensor ?

I'm having the same problem now, how did you solve it? Thanks!

I wrote a libtorch interface here toNvcvTensor and fromNvcvTensor , for Tensor2NvTensor and NvTensor2Tensor backends

nan2088 avatar Jan 30 '24 07:01 nan2088

@dlesage-nvidia @pmikolajczyk

shiremathNV avatar Feb 02 '24 00:02 shiremathNV