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

C/Other Languages: Support serialization and deserialization of Tensors #6003

Closed
asimshankar opened this issue Dec 1, 2016 · 8 comments
Closed
Assignees
Labels
type:feature Feature requests

Comments

@asimshankar
Copy link
Contributor

In C++ and Python, Tensors can be serialized into a TensorProto using functions like Tensor::AsProtoTensorContents and make_tensor_proto

This is particularly useful when communicating tensors across process boundaries such as PredictRequest RPCs to a TensorFlow Model Server

Filing this to track any changes to the C API and language bindings.

Interested parties: @asimshankar @jhseu @nfiedel @josh11b

@asimshankar asimshankar self-assigned this Dec 1, 2016
benoitsteiner pushed a commit to benoitsteiner/tensorflow that referenced this issue Dec 3, 2016
The current implementation has limitations, in particular
it does not support string tensors. But the same API
will be sufficient when that limitation has been
addressed.

See also tensorflow#6003. The API added here can be used to
fill in the tensor_contents field of a TensorProto
protocol buffer.
Change: 140760816
@aselle aselle added type:feature Feature requests and removed enhancement labels Feb 9, 2017
@yifeif
Copy link
Contributor

yifeif commented Jun 16, 2017

@asimshankar, saw "Go: API functions to serialize/deserialize Tensors" was added with #6137. Are we expecting further update on this issue?

@asimshankar
Copy link
Contributor Author

Nobody is actively working on this, this was more of a tracking bug. I think it's fine to close this for now (and re-open if and when the need is more urgent). The "need" would be to save/load tensors directly (as opposed to using things like the Restore operations or a SavedModel loader).

@samsends
Copy link
Contributor

@asimshankar, could we reopen this? Tensor se/de operations in C would be extremely useful for multi-language interoperability.

@asimshankar
Copy link
Contributor Author

@sbsends : Happy to reopen it, but would love to hear what specifically you're interested in. Could you elaborate on what you're trying to do and the problems being run into?

@samsends
Copy link
Contributor

samsends commented Dec 17, 2018

@asimshankar, we are interested in passing TensorProto's directly between languages. E.g. generating a packed TensorProto in Python and sending them over the wire to a program running in Golang. This is possible using Pythons implementation of make_proto and then building a custom handler in Golang to parse the TensorProto's contents/type/dim's. The tensor contents can be read using ReadTensor, but this only supports numeric data types. IMHO, it would be significantly cleaner (and less error prone) to handle ser/de in a standardized way across all client libraries using the C API.

Edit: grammar fix

@samsends
Copy link
Contributor

@asimshankar, would you consider giving feedback on our stab at building a standard for transporting tensors across applications/languages? The goal is to support many frameworks and act as an intermediary between application specific protocols. What can we do to increase the likelihood of gaining TensorFlow support?

https://github.com/tensortask/ttp

@lyschoening
Copy link

@asimshankar Would it we possible to reopen this? In our case, we would like to serialize/deserialize tensors to communicate with Tensorflow Serving from Go. We can not use the Go library as it does not handle serialization of string tensors.

@blepfo
Copy link

blepfo commented Jul 10, 2020

Seconding the above comment -- I ran into this issue trying to use to Go API tf.ReadTensor() only to discover that DT_STRING is not supported.

In the meantime is there an easy workaround for parsing string TensorProto into Go tf.Tensor?

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

No branches or pull requests

6 participants