ATen icon indicating copy to clipboard operation
ATen copied to clipboard

Tensor serialization

Open jgehring opened this issue 6 years ago • 3 comments

What's a good way to serialize and de-serialize a Tensor to a vector<char> or iostream?

jgehring avatar Nov 12 '17 21:11 jgehring

You can get a T* data pointer using t.data() (you have to know what the type of the tensor is at the call site) and then, assuming it's contiguous, read out t.numel() elements. This won't include the metadata though; we don't currently have any facilities for that.

ezyang avatar Nov 13 '17 00:11 ezyang

I see; I rolled something on my own for now but it would be nice to have a more principled solution in ATen itself, taking into account backends, shared storage, views etc. Do you have any immediate plans to add something like this?

jgehring avatar Nov 13 '17 15:11 jgehring

What about deserialization?

themightyoarfish avatar Jul 20 '18 13:07 themightyoarfish