Skip to content
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

Move metadata, codegen and java lib into the new repo. #11

Merged
merged 1 commit into from
Jul 1, 2020
Merged
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
18 changes: 3 additions & 15 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
# TFLite Support is a toolkit that helps users to develop ML and deploy TFLite
# models onto mobile devices.

package(
default_visibility = ["//visibility:private"],
licenses = ["notice"], # Apache 2.0
)

exports_files(["LICENSE"])

package_group(
name = "users",
packages = [
"//research/kernel/softskills/...",
"//third_party/tensorflow_lite_support/...",
exports_files(
[
"LICENSE",
],
)
87 changes: 77 additions & 10 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,95 @@ http_archive(

http_archive(
name = "org_tensorflow",
strip_prefix = "tensorflow-2.2.0",
sha256 = "fd3e6580cfe2035aa80d569b76bba5f33119362907f3d77039b6bedf76172712",
sha256 = "bb8b10da8184ce747f0348ea5b0d0aaf9e9bbe63cf68363d0e1bcdb72b4d3315",
strip_prefix = "tensorflow-5d49dc5526324443931a33cc84d66c8bcae9cea2",
urls = [
"https://github.com/tensorflow/tensorflow/archive/v2.2.0.zip"
"https://github.com/tensorflow/tensorflow/archive/5d49dc5526324443931a33cc84d66c8bcae9cea2.zip", # 2020-06-13
],
)

# Configure TF.
load("@org_tensorflow//tensorflow:workspace.bzl", "tf_workspace")
# Set up dependencies. Need to do this before set up TF so that our modification
# could take effects.
load("//third_party:repo.bzl", "third_party_http_archive")

third_party_http_archive(
name = "pybind11",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/pybind/pybind11/archive/v2.4.3.tar.gz",
"https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz",
],
sha256 = "1eed57bc6863190e35637290f97a20c81cfe4d9090ac0a24f3bbf08f265eb71d",
strip_prefix = "pybind11-2.4.3",
build_file = "//third_party:pybind11.BUILD",
)

http_archive(
name = "absl_py",
sha256 = "603febc9b95a8f2979a7bdb77d2f5e4d9b30d4e0d59579f88eba67d4e4cc5462",
strip_prefix = "abseil-py-pypi-v0.9.0",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-py/archive/pypi-v0.9.0.tar.gz",
"https://github.com/abseil/abseil-py/archive/pypi-v0.9.0.tar.gz",
],
)

http_archive(
name = "com_google_absl",
build_file = "//third_party:com_google_absl.BUILD",
sha256 = "f368a8476f4e2e0eccf8a7318b98dafbe30b2600f4e3cf52636e5eb145aba06a",
strip_prefix = "abseil-cpp-df3ea785d8c30a9503321a3d35ee7d35808f190d",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
"https://github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
],
)

http_archive(
name = "six_archive",
build_file = "//third_party:six.BUILD",
sha256 = "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73",
strip_prefix = "six-1.12.0",
urls = [
"https://storage.googleapis.com/mirror.tensorflow.org/pypi.python.org/packages/source/s/six/six-1.12.0.tar.gz",
"https://pypi.python.org/packages/source/s/six/six-1.12.0.tar.gz",
],
)

load("//third_party/flatbuffers:workspace.bzl", flatbuffers = "repo")

flatbuffers()


# Set up TF.
load("@org_tensorflow//tensorflow:workspace.bzl", "tf_workspace")
tf_workspace(tf_repo_name="@org_tensorflow")

load("//third_party/tensorflow:tf_configure.bzl", "tf_configure")

tf_configure(name = "local_config_tf")

# TF submodule compilation doesn't take care of grpc deps. Do it manually here.
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()

# Configure Android.
load("//third_party/android:android_configure.bzl", "android_configure")
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()

android_configure(name="local_config_android")
load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
)
apple_support_dependencies()

load("@upb//bazel:repository_defs.bzl", "bazel_version_repository")
bazel_version_repository(name = "bazel_version")

load("@local_config_android//:android.bzl", "android_workspace")

# Set up Android.
load("//third_party/android:android_configure.bzl", "android_configure")
android_configure(name="local_config_android")
load("@local_config_android//:android.bzl", "android_workspace")
android_workspace()

17 changes: 17 additions & 0 deletions tensorflow_lite_support/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# TFLite Support is a toolkit that helps users to develop ML and deploy TFLite
# models onto mobile devices.

package(
default_visibility = ["//visibility:private"],
licenses = ["notice"], # Apache 2.0
)

exports_files(["LICENSE"])

package_group(
name = "users",
packages = [
"//research/kernel/softskills/...",
"//tensorflow_lite_support/...",
],
)
86 changes: 86 additions & 0 deletions tensorflow_lite_support/codegen/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# The tools for generating wrapper classes for a TFLite model with metadata.

package(
default_visibility = [
"//visibility:public",
],
licenses = ["notice"], # Apache 2.0
)

cc_library(
name = "utils",
srcs = [
"utils.cc",
],
hdrs = [
"utils.h",
],
deps = [
],
)

cc_library(
name = "code_generator",
srcs = [
"code_generator.cc",
],
hdrs = [
"code_generator.h",
],
deps = [
":utils",
"//tensorflow_lite_support/metadata:metadata_schema_cc",
],
)

cc_library(
name = "metadata_helper",
srcs = [
"metadata_helper.cc",
],
hdrs = [
"metadata_helper.h",
],
deps = [
":utils",
"//tensorflow_lite_support/metadata:metadata_schema_cc",
"@org_tensorflow//tensorflow/lite/schema:schema_fbs",
],
)

cc_library(
name = "android_java_generator",
srcs = [
"android_java_generator.cc",
],
hdrs = [
"android_java_generator.h",
],
deps = [
":code_generator",
":metadata_helper",
":utils",
"//tensorflow_lite_support/metadata:metadata_schema_cc",
"@org_tensorflow//tensorflow/lite/schema:schema_fbs",
],
)

cc_test(
name = "code_generator_test",
size = "small",
srcs = ["code_generator_test.cc"],
data = ["//tensorflow_lite_support/metadata:metadata_schema.fbs"],
deps = [
":code_generator",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "utils_test",
srcs = ["utils_test.cc"],
deps = [
":utils",
"@com_google_googletest//:gtest_main",
],
)
13 changes: 13 additions & 0 deletions tensorflow_lite_support/codegen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# TensorFlow Lite Android Wrapper Code Generator

For TensorFlow Lite model enhanced with [metadata](https://www.tensorflow.org/lite/convert/metadata.md),
developers can use the TensorFlow Lite Android wrapper code generator to create
platform specific wrapper code. The wrapper code removes the need to interact
directly with `ByteBuffer`. Instead, developers can interact with the TensorFlow
Lite model with typed objects such as `Bitmap` and `Rect`.

The usefulness of the code generator depend on the completeness of the
TensorFlow Lite model's metadata entry. Refer to the `<Codegen usage>` section
under relevant fields in
[metadata_schema.fbs](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/experimental/support/metadata/metadata_schema.fbs),
to see how the codegen tool parses each field.
Loading