-
Notifications
You must be signed in to change notification settings - Fork 428
Moving runtime bindings into their own crate #382
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5b2009c
Moving runtime bindings into their own crate
brianjjones 3ceac86
Removing unused variable
brianjjones 13e6f70
Adding generate_bindgen_rs.sh and Readme
brianjjones 7613d97
Fixing some formatting
brianjjones cf5ab4f
Adding requested changes
brianjjones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "tensorflow-sys-runtime" | ||
version = "0.1.0" | ||
authors = ["Brian Jones <[email protected]>"] | ||
license = "Apache-2.0" | ||
keywords = ["TensorFlow", "runtime bindings"] | ||
description = "The package provides runtime bindings to TensorFlow." | ||
documentation = "https://tensorflow.github.io/rust" | ||
homepage = "https://github.com/tensorflow/rust" | ||
repository = "https://github.com/tensorflow/rust" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
libc = "0.2.132" | ||
lazy_static = "1.4.0" | ||
libloading = "0.7.3" | ||
cfg-if = "1.0.0" | ||
log = "0.4.17" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# tensorflow-sys-runtime [![Version][version-icon]][version-page] | ||
|
||
The crate provides runtime bindings to [TensorFlow][tensorflow]. Using runtime bindings allows you to avoid | ||
pulling in additional package dependencies into your project. Users will need to call tensorflow::library::load() | ||
before any other calls so that the linking is completed before use. | ||
|
||
## NOTE | ||
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. | ||
To use it you will need to disable the default features so you don't also include the tensorflow-sys crate. | ||
|
||
``` | ||
[dependencies] | ||
tensorflow = { version = "0.19.1", default-features = false, features = ["tensorflow_runtime_linking"]} | ||
``` | ||
|
||
## Requirements | ||
|
||
To use these bindings you must have the Tensorflow C libraries installed. See [install steps][tensorflow-setup] | ||
for detailed instructions. | ||
|
||
[tensorflow]: https://www.tensorflow.org | ||
[tensorflow-setup]: https://www.tensorflow.org/install/lang_c | ||
[crates-tf]: https://crates.io/crates/tensorflow | ||
[version-icon]: https://img.shields.io/crates/v/tensorflow-sys-runtime.svg | ||
[version-page]: https://crates.io/crates/tensorflow-sys-runtime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
|
||
if ! which bindgen > /dev/null; then | ||
echo "ERROR: Please install 'bindgen' using cargo:" | ||
echo " cargo install bindgen" | ||
echo "See https://github.com/servo/rust-bindgen for more information." | ||
exit 1 | ||
fi | ||
|
||
include_dir="$HOME/git/tensorflow" | ||
|
||
bindgen_options_runtime_functions="--allowlist-function TF_.+ --blocklist-type .+ --size_t-is-usize --default-enum-style=rust --generate-inline-functions" | ||
cmd="bindgen ${bindgen_options_runtime_functions} ${include_dir}/tensorflow/c/c_api.h --output src/runtime_linking/c_api.rs -- -I ${include_dir}" | ||
echo ${cmd} | ||
${cmd} | ||
|
||
bindgen_options_runtime_types="--allowlist-type TF_.+ --blocklist-function .+ --size_t-is-usize --default-enum-style=rust --generate-inline-functions" | ||
cmd="bindgen ${bindgen_options_runtime_types} ${include_dir}/tensorflow/c/c_api.h --output src/runtime_linking/types.rs -- -I ${include_dir}" | ||
echo ${cmd} | ||
${cmd} | ||
|
||
echo "link! {\n$(cat src/runtime_linking/c_api.rs)" > src/runtime_linking/c_api.rs | ||
echo } >> src/runtime_linking/c_api.rs | ||
1 change: 1 addition & 0 deletions
1
tensorflow-sys/src/runtime_linking/c_api.rs → tensorflow-sys-runtime/src/c_api.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
include!("runtime.rs"); | ||
link! { | ||
/* automatically generated by rust-bindgen 0.59.2 */ | ||
|
||
|
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_snake_case)] | ||
#![allow(non_upper_case_globals)] | ||
include!("c_api.rs"); | ||
include!("types.rs"); | ||
include!("finder.rs"); | ||
pub use crate::TF_AttrType::*; | ||
pub use crate::TF_Code::*; | ||
pub use crate::TF_DataType::*; | ||
|
||
pub mod library { | ||
use std::path::PathBuf; | ||
|
||
// Include the definition of `load` here. This allows hiding all of the "extra" linking-related | ||
// functions in the same place, without polluting the top-level namespace (which should only | ||
// contain foreign functions and types). | ||
#[doc(inline)] | ||
pub use super::load; | ||
|
||
pub fn find() -> Option<PathBuf> { | ||
super::find("tensorflow") | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the runtime bits should be removed from tensorflow-sys/generate_bindgen_rs.sh.