candle icon indicating copy to clipboard operation
candle copied to clipboard

Is there a way to zero-copy `tch-rs::Tensor` as `candle_core::Tensor`?

Open Jonarod opened this issue 1 year ago • 2 comments
trafficstars

I am working on some project that started as tch-rs, and would like to know if there is any way to convert a tch-rs::Tensor as a candle_core::Tensor? preferably zero-copy?

Jonarod avatar Mar 15 '24 00:03 Jonarod

I don't think there is anything no-copy possible at the moment, you would have to extract the whole content of the tch tensor and then create a new candle tensor with Tensor::from_vec.

LaurentMazare avatar Mar 16 '24 21:03 LaurentMazare

Thank you for taking the time to reply.

Yeah that's what I thought... I did try to extract everything one by one, but honestly it was much faster to save the tch::Tensor to disk first and then load the candle_core::Tensor using mmap. But I was wondering if I there was another more "graceful" and efficient solution.

Jonarod avatar Mar 16 '24 23:03 Jonarod