#tensorflow #protobuf #serde #config

tensorflow_proto

Rust structs for Tensorflow Protocol buffers

3 releases (breaking)

0.3.0 Jan 11, 2021
0.2.0 Aug 8, 2020
0.1.0 Aug 8, 2020

#2365 in Encoding

Download history 308/week @ 2024-03-29 239/week @ 2024-04-05 240/week @ 2024-04-12 257/week @ 2024-04-19 175/week @ 2024-04-26 149/week @ 2024-05-03 224/week @ 2024-05-10 452/week @ 2024-05-17 278/week @ 2024-05-24 204/week @ 2024-05-31 341/week @ 2024-06-07 123/week @ 2024-06-14 220/week @ 2024-06-21 323/week @ 2024-06-28 169/week @ 2024-07-05 146/week @ 2024-07-12

885 downloads per month

Custom license

140KB
177 lines

tensorflow_proto

Continuous Integration Crates.io docs.rs

tensorflow_proto is a crate that uses prost-build to generate Rust structs to be used in serialization/deserialization of protocol buffers wherever Tensorflow uses them.

In particular, this is useful in the tensorflow/rust library when calling SessionOptions::set_config to configure Tensorflow.

Note: This crate is tested against tensorflow 1.15.2 and 2.0.0.

Usage

Default Features

Add

tensorflow_proto = "0.3.0"

to your Cargo.toml.

Serde Support

Serde support can be enabled using the "serde-derive" feature:

tensorflow_proto = { version = "0.3.0", features = ["serde-derive"] }

This will add a #[derive(serde::Serialize, serde::Deserialize)] 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<u8> for every struct generated by prost:

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.

Dependencies

~2–4MB
~68K SLoC