https://github.com/cpcloud/tensorflow_proto
Rusty protobufs for Tensorflow
https://github.com/cpcloud/tensorflow_proto
Last synced: 10 months ago
JSON representation
Rusty protobufs for Tensorflow
- Host: GitHub
- URL: https://github.com/cpcloud/tensorflow_proto
- Owner: cpcloud
- License: mit
- Created: 2020-08-05T17:22:14.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-11T20:04:18.000Z (over 5 years ago)
- Last Synced: 2025-08-14T03:23:54.644Z (10 months ago)
- Language: Rust
- Size: 222 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `tensorflow_proto`
[](https://github.com/cpcloud/tensorflow_proto/actions?query=branch%3Amaster+event%3Apush+workflow%3A%22Continuous+Integration%22)
[](https://crates.io/crates/tensorflow_proto)
[](https://docs.rs/crate/tensorflow_proto)
`tensorflow_proto` is a crate that uses `prost-build` to generate Rust
`struct`s to be used in serialization/deserialization of protocol buffers
wherever Tensorflow uses them.
In particular, this is useful in the
[`tensorflow/rust`](https://github.com/tensorflow/rust) library when calling
[`SessionOptions::set_config`](https://tensorflow.github.io/rust/tensorflow/struct.SessionOptions.html#method.set_config)
to configure Tensorflow.
**Note**: **This crate is tested against tensorflow 1.15.2 and 2.0.0.**
# Usage
## Default Features
Add
```toml
tensorflow_proto = "0.3.0"
```
to your `Cargo.toml`.
## Serde Support
Serde support can be enabled using the `"serde-derive"` feature:
```toml
tensorflow_proto = { version = "0.3.0", features = ["serde-derive"] }
```
This will add a [`#[derive(serde::Serialize,
serde::Deserialize)]`](https://serde.rs/derive.html) to every generated
`struct`.
You must also depend on `serde` as well.
## Easy conversion to bytes
Finally, you can enable code generation for an implementation of `std::convert::TryFrom`
that encodes a message into a `Vec` for every `struct` generated by prost:
```toml
tensorflow_proto = { version = "0.3.0", features = ["convert"] }
```
## Use custom Tensorflow `*.proto` sources
To use a different version of Tensorflow protocol buffer sources, define
`TENSORFLOW_PROTO_SOURCE` to be the root of a Tensorflow source tree.