ATen
ATen copied to clipboard
Tensor serialization
What's a good way to serialize and de-serialize a Tensor to a vector<char>
or iostream?
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.
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?
What about deserialization?