Skip to content

Commit 2fa2e03

Browse files
authored
feat: add tool for visualizing compressed (and uncompressed) models (#3099)
Add a development tool that prints compressed and uncompressed .tflite models to stdout in a human-readable, searchable, structured, text format. Helpful annotations (indexes of lists, names of operators, etc.) derived from the model are added as virtual fields with names beginning with an _underscore. Add a unit test which simply ensures the viewer does not crash when run on several models found in the source tree. BUG=see description
1 parent 9f409bb commit 2fa2e03

File tree

6 files changed

+519
-0
lines changed

6 files changed

+519
-0
lines changed

tensorflow/lite/micro/compression/BUILD

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ load(
1010
)
1111
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
1212
load("@tflm_pip_deps//:requirements.bzl", "requirement")
13+
load("view_tests.bzl", "generate_view_tests")
1314

1415
package(
1516
default_visibility = [
@@ -229,3 +230,24 @@ py_test(
229230
requirement("tensorflow"),
230231
],
231232
)
233+
234+
py_binary(
235+
name = "view",
236+
srcs = [
237+
"view.py",
238+
],
239+
deps = [
240+
":metadata_py",
241+
"//tensorflow/lite/python:schema_py",
242+
"@absl_py//absl:app",
243+
requirement("bitarray"),
244+
requirement("prettyprinter"),
245+
],
246+
)
247+
248+
generate_view_tests([
249+
"//tensorflow/lite/micro/models:keyword_scrambled.tflite",
250+
"//tensorflow/lite/micro/models:keyword_scrambled_8bit.tflite",
251+
"//tensorflow/lite/micro/models:person_detect.tflite",
252+
"//tensorflow/lite/micro/models:person_detect_vela.tflite",
253+
])

0 commit comments

Comments
 (0)