Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "submodules/tensorflow"]
path = submodules/tensorflow
url = https://github.com/tensorflow/tensorflow.git
url = https://github.com/tensorflow/tflite-micro
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ordered-float = { version = "~2.0.0", default-features = false }

[build-dependencies]
cc = { version = "~1.0.61", features = ["parallel"] }
bindgen = "0.55.1"
bindgen = "0.59.2"
cpp_build = "0.5.5"
glob = "0.3.0"
fs_extra = "~1.2.0"
Expand Down
27 changes: 14 additions & 13 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ fn cc_tensorflow_library() {
.file(tflite.join("lite/core/api/flatbuffer_conversions.cc"))
.file(tflite.join("lite/core/api/op_resolver.cc"))
.file(tflite.join("lite/core/api/tensor_utils.cc"))
.file(tflite.join("lite/schema/schema_utils.cc"))
.file(tflite.join("lite/kernels/internal/quantization_util.cc"))
.file(tflite.join("lite/kernels/kernel_util.cc"));

Expand Down Expand Up @@ -383,7 +384,7 @@ fn bindgen_tflite_types() {

let bindings = bindgen_cross_builder()
.expect("Error setting up bindgen for cross compiling")
.whitelist_recursively(true)
.allowlist_recursively(true)
.prepend_enum_name(false)
.impl_debug(true)
.with_codegen_config(CodegenConfig::TYPES)
Expand All @@ -394,22 +395,22 @@ fn bindgen_tflite_types() {
.use_core()
.ctypes_prefix("cty")
// Types
.whitelist_type("tflite::MicroErrorReporter")
.allowlist_type("tflite::MicroErrorReporter")
.opaque_type("tflite::MicroErrorReporter")
.whitelist_type("tflite::Model")
.allowlist_type("tflite::Model")
.opaque_type("tflite::Model")
.whitelist_type("tflite::MicroInterpreter")
.allowlist_type("tflite::MicroInterpreter")
.opaque_type("tflite::MicroInterpreter")
.whitelist_type("tflite::ops::micro::AllOpsResolver")
.opaque_type("tflite::ops::micro::AllOpsResolver")
.whitelist_type("TfLiteTensor")
.whitelist_type("FrontendState")
.whitelist_type("FrontendConfig")
.whitelist_type("FrontendOutput")
.allowlist_type("tflite::AllOpsResolver")
.opaque_type("tflite::AllOpsResolver")
.allowlist_type("TfLiteTensor")
.allowlist_type("FrontendState")
.allowlist_type("FrontendConfig")
.allowlist_type("FrontendOutput")
// Types - blacklist
.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,
})
Expand Down
2 changes: 1 addition & 1 deletion csrc/tflite_wrapper.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "tensorflow/lite/micro/kernels/micro_ops.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/micro/kernels/all_ops_resolver.h"
#include "tensorflow/lite/micro/all_ops_resolver.h"

#include "tensorflow/lite/experimental/microfrontend/lib/frontend.h"
#include "tensorflow/lite/experimental/microfrontend/lib/frontend_util.h"
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ pub enum Status {
Ok,
Error,
DelegateError,
ApplicationError,
DelegateDataNotFoundError,
DelegateDataWriteError,
DelegateDataReadError,
UnresolvedOps
}
impl From<bindings::TfLiteStatus> for Status {
fn from(status: bindings::TfLiteStatus) -> Self {
Expand All @@ -180,6 +185,11 @@ impl From<bindings::TfLiteStatus> for Status {
bindings::TfLiteStatus::kTfLiteOk => Ok,
bindings::TfLiteStatus::kTfLiteError => Error,
bindings::TfLiteStatus::kTfLiteDelegateError => DelegateError,
bindings::TfLiteStatus::kTfLiteApplicationError => ApplicationError,
bindings::TfLiteStatus::kTfLiteDelegateDataNotFound => DelegateDataNotFoundError,
bindings::TfLiteStatus::kTfLiteDelegateDataWriteError => DelegateDataWriteError,
bindings::TfLiteStatus::kTfLiteDelegateDataReadError => DelegateDataReadError,
bindings::TfLiteStatus::kTfLiteUnresolvedOps => UnresolvedOps,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/micro_interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ cpp! {{
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/testing/micro_test.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/version.h"
// #include "tensorflow/lite/version.h"
}}

static mut ERROR_REPORTER: MaybeUninit<MicroErrorReporter> =
Expand Down
8 changes: 4 additions & 4 deletions src/micro_op_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use core::fmt;

cpp! {{
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
#include "tensorflow/lite/micro/kernels/all_ops_resolver.h"
#include "tensorflow/lite/micro/all_ops_resolver.h"
}}

// AllOpsResolver has the same memory representation as
Expand All @@ -18,7 +18,7 @@ cpp! {{
//
// Thus we can cast between the two types.

type OpResolverT = tflite::ops::micro::AllOpsResolver;
type OpResolverT = tflite::AllOpsResolver;

/// Marker trait for types that have the memory representation of a
/// `OpResolver`
Expand Down Expand Up @@ -61,9 +61,9 @@ impl AllOpResolver {
// The C++ compiler fills in the MicroMutableOpResolver with the
// operators enumerated in AllOpsResolver
let micro_op_resolver = unsafe {
cpp!([] -> OpResolverT as "tflite::ops::micro::AllOpsResolver" {
cpp!([] -> OpResolverT as "tflite::AllOpsResolver" {
// All ops
tflite::ops::micro::AllOpsResolver resolver;
tflite::AllOpsResolver resolver;

return resolver;
})
Expand Down
Loading