acrotensor icon indicating copy to clipboard operation
acrotensor copied to clipboard

GPU-only Tensors

Open Linux-cpp-lisp opened this issue 4 years ago • 2 comments

Hi all,

I'm considering trying to integrate acrotensor with PyTorch to use it in a model. It looks like it should be fairly trivial to create an acro::Tensor that references the GPU memory of some_pytorch_tensor.contiguous(); the only issue is Tensor.cpp:L192:

if (ddata != nullptr) {
      ACROBATIC_ASSERT(hdata != nullptr, "Acrotensor does not currently support GPU only tensors.");

It seems to me reading the rest of Tensor.cpp that this isn't actually true — it seems like as long as you never try to move the Tensor back to host it should be fine — but I was hoping to confirm this.

If anyone has previously tried to integrate this with PyTorch or has any thoughts on that, I'd also be grateful to hear them.

Thanks for your work on this library!

Linux-cpp-lisp avatar May 31 '21 18:05 Linux-cpp-lisp

I obviously haven't looked at this in quite a while and had no idea folks were looking at it. I believe that should work as long as you don't call anything that needs the data on the host. Did you end up giving it a try?

acfisher avatar Mar 28 '24 23:03 acfisher

Hi @acfisher ,

It's also been a long time since I looked at this, but I did implement PyTorch bindings at one point, which I think worked fine with regard to this issue. The code is here if you are interested: https://github.com/Linux-cpp-lisp/acrotensor/tree/pytorch.

Linux-cpp-lisp avatar Mar 29 '24 13:03 Linux-cpp-lisp