Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
boncheolgu committed Jun 26, 2023
1 parent 8dd5e56 commit 0769751
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["tensorflow", "tflite", "bindings"]
license = "MIT/Apache-2.0"
repository = "https://github.com/boncheolgu/tflite-rs"
readme = "README.md"
edition = "2018"
edition = "2021"
documentation = "https://docs.rs/crate/tflite"

# filter in only necessary files
Expand Down Expand Up @@ -41,17 +41,17 @@ include = [
]

[dependencies]
cpp = "0.5.5"
libc = "0.2.77"
cpp = "0.5.7"
libc = "0.2.139"
maybe-owned = "0.3.4"
thiserror = "1.0.20"
thiserror = "1.0.38"

[build-dependencies]
bart = { version = "0.1.6", optional = true }
bart_derive = { version = "0.1.6", optional = true }
bindgen = "0.55.1"
cpp_build = "0.5.5"
fs_extra = { version = "1.2.0", optional = true }
bindgen = "0.65.1"
cpp_build = "0.5.7"
fs_extra = { version = "1.3.0", optional = true }

[features]
build = ["fs_extra"]
Expand Down
58 changes: 29 additions & 29 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ fn prepare_tensorflow_library() {
// so a cached version that doesn't match expectations isn't used
let binary_changing_features = binary_changing_features();
let tf_lib_name =
Path::new(&out_dir).join(format!("libtensorflow-lite{}.a", binary_changing_features,));
Path::new(&out_dir).join(format!("libtensorflow-lite{binary_changing_features}.a"));
let os = env::var("CARGO_CFG_TARGET_OS").expect("Unable to get TARGET_OS");
if !tf_lib_name.exists() {
println!("Building tflite");
let start = Instant::now();
let mut make = std::process::Command::new("make");
if let Ok(prefix) = env::var("TARGET_TOOLCHAIN_PREFIX") {
make.arg(format!("TARGET_TOOLCHAIN_PREFIX={}", prefix));
make.arg(format!("TARGET_TOOLCHAIN_PREFIX={prefix}"));
} else {
let target_triple = env::var("TARGET").unwrap();
let host_triple = env::var("HOST").unwrap();
Expand Down Expand Up @@ -136,21 +136,21 @@ fn prepare_tensorflow_library() {
("EXTRA_CFLAGS", None),
("EXTRA_CXXFLAGS", None),
] {
let env_var = format!("TFLITE_RS_MAKE_{}", make_var);
println!("cargo:rerun-if-env-changed={}", env_var);
let env_var = format!("TFLITE_RS_MAKE_{make_var}");
println!("cargo:rerun-if-env-changed={env_var}");

match env::var(&env_var) {
Ok(result) => {
make.arg(format!("{}={}", make_var, result));
make.arg(format!("{make_var}={result}"));
}
Err(VarError::NotPresent) => {
// Try and set some reasonable default values
if let Some(result) = default {
make.arg(format!("{}={}", make_var, result));
make.arg(format!("{make_var}={result}"));
}
}
Err(VarError::NotUnicode(_)) => {
panic!("Provided a non-unicode value for {}", env_var)
panic!("Provided a non-unicode value for {env_var}")
}
}
}
Expand All @@ -162,7 +162,7 @@ fn prepare_tensorflow_library() {
make.arg("micro");
}
make.current_dir(make_dir);
eprintln!("make command = {:?} in dir {:?}", make, make_dir);
eprintln!("make command = {make:?} in dir {make_dir:?}");
if !make.status().expect("failed to run make command").success() {
panic!("Failed to build tensorflow");
}
Expand All @@ -179,8 +179,8 @@ fn prepare_tensorflow_library() {

println!("Building tflite from source took {:?}", start.elapsed());
}
println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=tensorflow-lite{}", binary_changing_features);
println!("cargo:rustc-link-search=native={out_dir}");
println!("cargo:rustc-link-lib=static=tensorflow-lite{binary_changing_features}");
}
#[cfg(not(feature = "build"))]
{
Expand Down Expand Up @@ -212,7 +212,7 @@ fn import_tflite_types() {
let submodules = submodules();
let submodules_str = submodules.to_string_lossy();
let bindings = Builder::default()
.whitelist_recursively(true)
.allowlist_recursively(true)
.prepend_enum_name(false)
.impl_debug(true)
.with_codegen_config(CodegenConfig::TYPES)
Expand All @@ -221,32 +221,32 @@ fn import_tflite_types() {
.derive_default(true)
.size_t_is_usize(true)
// for model APIs
.whitelist_type("tflite::ModelT")
.whitelist_type(".+OptionsT")
.blacklist_type(".+_TableType")
.allowlist_type("tflite::ModelT")
.allowlist_type(".+OptionsT")
.blocklist_type(".+_TableType")
// for interpreter
.whitelist_type("tflite::FlatBufferModel")
.allowlist_type("tflite::FlatBufferModel")
.opaque_type("tflite::FlatBufferModel")
.whitelist_type("tflite::InterpreterBuilder")
.allowlist_type("tflite::InterpreterBuilder")
.opaque_type("tflite::InterpreterBuilder")
.whitelist_type("tflite::Interpreter")
.allowlist_type("tflite::Interpreter")
.opaque_type("tflite::Interpreter")
.whitelist_type("tflite::ops::builtin::BuiltinOpResolver")
.allowlist_type("tflite::ops::builtin::BuiltinOpResolver")
.opaque_type("tflite::ops::builtin::BuiltinOpResolver")
.whitelist_type("tflite::OpResolver")
.allowlist_type("tflite::OpResolver")
.opaque_type("tflite::OpResolver")
.whitelist_type("TfLiteTensor")
.allowlist_type("TfLiteTensor")
.opaque_type("std::string")
.opaque_type("flatbuffers::NativeTable")
.blacklist_type("std")
.blacklist_type("tflite::Interpreter_TfLiteDelegatePtr")
.blacklist_type("tflite::Interpreter_State")
.blocklist_type("std")
.blocklist_type("tflite::Interpreter_TfLiteDelegatePtr")
.blocklist_type("tflite::Interpreter_State")
.default_enum_style(EnumVariation::Rust { non_exhaustive: false })
.derive_partialeq(true)
.derive_eq(true)
.header("csrc/tflite_wrapper.hpp")
.clang_arg(format!("-I{}/tensorflow", submodules_str))
.clang_arg(format!("-I{}/downloads/flatbuffers/include", submodules_str))
.clang_arg(format!("-I{submodules_str}/tensorflow"))
.clang_arg(format!("-I{submodules_str}/downloads/flatbuffers/include"))
.clang_arg("-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK")
.clang_arg("-DFLATBUFFERS_POLYMORPHIC_NATIVETABLE")
.clang_arg("-x")
Expand Down Expand Up @@ -283,11 +283,11 @@ fn import_stl_types() {

let bindings = Builder::default()
.enable_cxx_namespaces()
.whitelist_type("std::string")
.allowlist_type("std::string")
.opaque_type("std::string")
.whitelist_type("rust::.+")
.allowlist_type("rust::.+")
.opaque_type("rust::.+")
.blacklist_type("std")
.blocklist_type("std")
.header("csrc/stl_wrapper.hpp")
.layout_tests(false)
.derive_partialeq(true)
Expand All @@ -296,7 +296,7 @@ fn import_stl_types() {
.clang_arg("c++")
.clang_arg("-std=c++14")
.clang_arg("-fms-extensions")
.rustfmt_bindings(false)
.formatter(Formatter::Rustfmt)
.generate()
.expect("Unable to generate STL bindings");

Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ where
interpreter->SetNumThreads(threads);
})
};
println!("Set num threads to {}", threads);
println!("Set num threads to {threads}");
}

/// Read only access to list of inputs.
Expand Down
8 changes: 4 additions & 4 deletions src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,19 +461,19 @@ mod tests {
println!("{:?}", subgraph.outputs);

for operator in &subgraph.operators {
println!("{:?}", operator);
println!("{operator:?}");
}

for tensor in &subgraph.tensors {
println!("{:?}", tensor);
println!("{tensor:?}");
}

for buffer in &model.buffers {
println!("{:?}", buffer);
println!("{buffer:?}");
}

for operator_code in &model.operator_codes {
println!("{:?}", operator_code);
println!("{operator_code:?}");
}
model.to_buffer()
};
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn test_mnist(model: &FlatBufferModel) -> Result<()> {
let output: &[u8] = interpreter.tensor_data(output_index)?;
let guess = output.iter().enumerate().max_by(|x, y| x.1.cmp(y.1)).unwrap().0;

println!("{}: {:?}", i, output);
println!("{i}: {output:?}");
assert_eq!(i, guess);
}
Ok(())
Expand Down

0 comments on commit 0769751

Please sign in to comment.