Skip to content

Commit 13e6f70

Browse files
committed
Adding generate_bindgen_rs.sh and Readme
1 parent 3ceac86 commit 13e6f70

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

tensorflow-sys-runtime/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# tensorflow-sys-runtime [![Version][version-icon]][version-page]
2+
3+
The crate provides runtime bindings to [TensorFlow][tensorflow]. Using runtime bindings allows you to avoid
4+
pulling in additional package dependencies into your project. Users will need to call tensorflow::library::load()
5+
before any other calls so that the linking is completed before use.
6+
7+
## NOTE
8+
This crate is meant to be used by [Rust language bindings for Tensorflow][crates-tf]. It is not meant to be used on it's own.
9+
10+
## Requirements
11+
12+
To use these bindings you must have the Tensorflow C libraries installed. See [install steps][tensorflow-setup]
13+
for detailed instructions.
14+
15+
[tensorflow]: https://www.tensorflow.org
16+
[tensorflow-setup]: https://www.tensorflow.org/install/lang_c
17+
[crates-tf]: https://crates.io/crates/tensorflow
18+
[version-icon]: https://img.shields.io/crates/v/tensorflow-sys-runtime.svg
19+
[version-page]: https://crates.io/crates/tensorflow-sys-runtime
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
if ! which bindgen > /dev/null; then
4+
echo "ERROR: Please install 'bindgen' using cargo:"
5+
echo " cargo install bindgen"
6+
echo "See https://github.com/servo/rust-bindgen for more information."
7+
exit 1
8+
fi
9+
10+
include_dir="$HOME/git/tensorflow"
11+
12+
bindgen_options_runtime_functions="--allowlist-function TF_.+ --blocklist-type .+ --size_t-is-usize --default-enum-style=rust --generate-inline-functions"
13+
cmd="bindgen ${bindgen_options_runtime_functions} ${include_dir}/tensorflow/c/c_api.h --output src/runtime_linking/c_api.rs -- -I ${include_dir}"
14+
echo ${cmd}
15+
${cmd}
16+
17+
bindgen_options_runtime_types="--allowlist-type TF_.+ --blocklist-function .+ --size_t-is-usize --default-enum-style=rust --generate-inline-functions"
18+
cmd="bindgen ${bindgen_options_runtime_types} ${include_dir}/tensorflow/c/c_api.h --output src/runtime_linking/types.rs -- -I ${include_dir}"
19+
echo ${cmd}
20+
${cmd}
21+
22+
echo "link! {\n$(cat src/runtime_linking/c_api.rs)" > src/runtime_linking/c_api.rs
23+
echo } >> src/runtime_linking/c_api.rs

0 commit comments

Comments
 (0)