Skip to content

Commit 3ce83f0

Browse files
authored
Merge pull request #11 from tensorflow/test_317265064
Move metadata, codegen and java lib into the new repo.
2 parents 3247aa9 + e38a0b3 commit 3ce83f0

File tree

121 files changed

+16192
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+16192
-439
lines changed

BUILD

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
# TFLite Support is a toolkit that helps users to develop ML and deploy TFLite
2-
# models onto mobile devices.
3-
4-
package(
5-
default_visibility = ["//visibility:private"],
6-
licenses = ["notice"], # Apache 2.0
7-
)
8-
9-
exports_files(["LICENSE"])
10-
11-
package_group(
12-
name = "users",
13-
packages = [
14-
"//research/kernel/softskills/...",
15-
"//third_party/tensorflow_lite_support/...",
1+
exports_files(
2+
[
3+
"LICENSE",
164
],
175
)

WORKSPACE

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,95 @@ http_archive(
1414

1515
http_archive(
1616
name = "org_tensorflow",
17-
strip_prefix = "tensorflow-2.2.0",
18-
sha256 = "fd3e6580cfe2035aa80d569b76bba5f33119362907f3d77039b6bedf76172712",
17+
sha256 = "bb8b10da8184ce747f0348ea5b0d0aaf9e9bbe63cf68363d0e1bcdb72b4d3315",
18+
strip_prefix = "tensorflow-5d49dc5526324443931a33cc84d66c8bcae9cea2",
1919
urls = [
20-
"https://github.com/tensorflow/tensorflow/archive/v2.2.0.zip"
20+
"https://github.com/tensorflow/tensorflow/archive/5d49dc5526324443931a33cc84d66c8bcae9cea2.zip", # 2020-06-13
2121
],
2222
)
2323

24-
# Configure TF.
25-
load("@org_tensorflow//tensorflow:workspace.bzl", "tf_workspace")
24+
# Set up dependencies. Need to do this before set up TF so that our modification
25+
# could take effects.
26+
load("//third_party:repo.bzl", "third_party_http_archive")
27+
28+
third_party_http_archive(
29+
name = "pybind11",
30+
urls = [
31+
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/pybind/pybind11/archive/v2.4.3.tar.gz",
32+
"https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz",
33+
],
34+
sha256 = "1eed57bc6863190e35637290f97a20c81cfe4d9090ac0a24f3bbf08f265eb71d",
35+
strip_prefix = "pybind11-2.4.3",
36+
build_file = "//third_party:pybind11.BUILD",
37+
)
38+
39+
http_archive(
40+
name = "absl_py",
41+
sha256 = "603febc9b95a8f2979a7bdb77d2f5e4d9b30d4e0d59579f88eba67d4e4cc5462",
42+
strip_prefix = "abseil-py-pypi-v0.9.0",
43+
urls = [
44+
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-py/archive/pypi-v0.9.0.tar.gz",
45+
"https://github.com/abseil/abseil-py/archive/pypi-v0.9.0.tar.gz",
46+
],
47+
)
2648

49+
http_archive(
50+
name = "com_google_absl",
51+
build_file = "//third_party:com_google_absl.BUILD",
52+
sha256 = "f368a8476f4e2e0eccf8a7318b98dafbe30b2600f4e3cf52636e5eb145aba06a",
53+
strip_prefix = "abseil-cpp-df3ea785d8c30a9503321a3d35ee7d35808f190d",
54+
urls = [
55+
"https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
56+
"https://github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
57+
],
58+
)
59+
60+
http_archive(
61+
name = "six_archive",
62+
build_file = "//third_party:six.BUILD",
63+
sha256 = "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73",
64+
strip_prefix = "six-1.12.0",
65+
urls = [
66+
"https://storage.googleapis.com/mirror.tensorflow.org/pypi.python.org/packages/source/s/six/six-1.12.0.tar.gz",
67+
"https://pypi.python.org/packages/source/s/six/six-1.12.0.tar.gz",
68+
],
69+
)
70+
71+
load("//third_party/flatbuffers:workspace.bzl", flatbuffers = "repo")
72+
73+
flatbuffers()
74+
75+
76+
# Set up TF.
77+
load("@org_tensorflow//tensorflow:workspace.bzl", "tf_workspace")
2778
tf_workspace(tf_repo_name="@org_tensorflow")
2879

2980
load("//third_party/tensorflow:tf_configure.bzl", "tf_configure")
30-
3181
tf_configure(name = "local_config_tf")
3282

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

34-
# Configure Android.
35-
load("//third_party/android:android_configure.bzl", "android_configure")
87+
load(
88+
"@build_bazel_rules_apple//apple:repositories.bzl",
89+
"apple_rules_dependencies",
90+
)
91+
apple_rules_dependencies()
3692

37-
android_configure(name="local_config_android")
93+
load(
94+
"@build_bazel_apple_support//lib:repositories.bzl",
95+
"apple_support_dependencies",
96+
)
97+
apple_support_dependencies()
98+
99+
load("@upb//bazel:repository_defs.bzl", "bazel_version_repository")
100+
bazel_version_repository(name = "bazel_version")
38101

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

103+
# Set up Android.
104+
load("//third_party/android:android_configure.bzl", "android_configure")
105+
android_configure(name="local_config_android")
106+
load("@local_config_android//:android.bzl", "android_workspace")
41107
android_workspace()
108+

tensorflow_lite_support/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# TFLite Support is a toolkit that helps users to develop ML and deploy TFLite
2+
# models onto mobile devices.
3+
4+
package(
5+
default_visibility = ["//visibility:private"],
6+
licenses = ["notice"], # Apache 2.0
7+
)
8+
9+
exports_files(["LICENSE"])
10+
11+
package_group(
12+
name = "users",
13+
packages = [
14+
"//research/kernel/softskills/...",
15+
"//tensorflow_lite_support/...",
16+
],
17+
)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# The tools for generating wrapper classes for a TFLite model with metadata.
2+
3+
package(
4+
default_visibility = [
5+
"//visibility:public",
6+
],
7+
licenses = ["notice"], # Apache 2.0
8+
)
9+
10+
cc_library(
11+
name = "utils",
12+
srcs = [
13+
"utils.cc",
14+
],
15+
hdrs = [
16+
"utils.h",
17+
],
18+
deps = [
19+
],
20+
)
21+
22+
cc_library(
23+
name = "code_generator",
24+
srcs = [
25+
"code_generator.cc",
26+
],
27+
hdrs = [
28+
"code_generator.h",
29+
],
30+
deps = [
31+
":utils",
32+
"//tensorflow_lite_support/metadata:metadata_schema_cc",
33+
],
34+
)
35+
36+
cc_library(
37+
name = "metadata_helper",
38+
srcs = [
39+
"metadata_helper.cc",
40+
],
41+
hdrs = [
42+
"metadata_helper.h",
43+
],
44+
deps = [
45+
":utils",
46+
"//tensorflow_lite_support/metadata:metadata_schema_cc",
47+
"@org_tensorflow//tensorflow/lite/schema:schema_fbs",
48+
],
49+
)
50+
51+
cc_library(
52+
name = "android_java_generator",
53+
srcs = [
54+
"android_java_generator.cc",
55+
],
56+
hdrs = [
57+
"android_java_generator.h",
58+
],
59+
deps = [
60+
":code_generator",
61+
":metadata_helper",
62+
":utils",
63+
"//tensorflow_lite_support/metadata:metadata_schema_cc",
64+
"@org_tensorflow//tensorflow/lite/schema:schema_fbs",
65+
],
66+
)
67+
68+
cc_test(
69+
name = "code_generator_test",
70+
size = "small",
71+
srcs = ["code_generator_test.cc"],
72+
data = ["//tensorflow_lite_support/metadata:metadata_schema.fbs"],
73+
deps = [
74+
":code_generator",
75+
"@com_google_googletest//:gtest_main",
76+
],
77+
)
78+
79+
cc_test(
80+
name = "utils_test",
81+
srcs = ["utils_test.cc"],
82+
deps = [
83+
":utils",
84+
"@com_google_googletest//:gtest_main",
85+
],
86+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# TensorFlow Lite Android Wrapper Code Generator
2+
3+
For TensorFlow Lite model enhanced with [metadata](https://www.tensorflow.org/lite/convert/metadata.md),
4+
developers can use the TensorFlow Lite Android wrapper code generator to create
5+
platform specific wrapper code. The wrapper code removes the need to interact
6+
directly with `ByteBuffer`. Instead, developers can interact with the TensorFlow
7+
Lite model with typed objects such as `Bitmap` and `Rect`.
8+
9+
The usefulness of the code generator depend on the completeness of the
10+
TensorFlow Lite model's metadata entry. Refer to the `<Codegen usage>` section
11+
under relevant fields in
12+
[metadata_schema.fbs](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/experimental/support/metadata/metadata_schema.fbs),
13+
to see how the codegen tool parses each field.

0 commit comments

Comments
 (0)