Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for 0-copy tensors #207

Open
colinator opened this issue Oct 8, 2024 · 3 comments
Open

Support for 0-copy tensors #207

colinator opened this issue Oct 8, 2024 · 3 comments

Comments

@colinator
Copy link

Would it be possible to add support for tensor serialization/deserialization? i.e. things like xtensor or eigen? Ideally these would have a '0-copy' ability - you could deserialize the memory directly into the tensor... or maybe just a '0-copy bytestring'? Do byte strings work that way now? Then tensor support could be grafted independently then... right?

@liuzicheng1987
Copy link
Contributor

@colinator , is is possible to serialize and deserialize bytestrings using this library for formats that support this (msgpack, flexbuffers, CBOR, BSON):

https://github.com/getml/reflect-cpp/blob/main/docs/bytestring.md

You could just implement your own custom parser for your tensors:

https://github.com/getml/reflect-cpp/blob/main/docs/custom_parser.md

In this case you would use using ReflType = rfl::Bytestring and then implement the to and from methods that would load the byte string from and to your tensors.

@colinator
Copy link
Author

Thanks! I will give it a try.

@colinator
Copy link
Author

Now I'm not so sure that byte strings (or deserialization/serialization in general) works with '0-copy'. Meaning, if I have some data 'in hand' from the network, for example - a sequence of bytes that represents a flex-buffer-encoded thing, I want to get a structure such that accessing a variable (or calling a function to get something) from the structure points into the flex buffer-encoded data, without copying the data. In this way I can get true '0-copy': I can turn some bytes from the network, for example, into a 'live' struct with no copying. Maybe I'm missing how to do it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants