Python targets in this repository import one another under the
"tflite_micro" package namespace, which //:tflite_micro_shim synthesizes
at import time. The shim is required under Bzlmod, where the main
repository's runfiles root is the fixed name "_main" rather than the
module name, so the "tflite_micro" prefix no longer resolves on its own.
Every such target therefore had to list //:tflite_micro_shim in its
deps, which was repetitive and easy to forget.
Add tflm_py_library, tflm_py_test, and tflm_py_binary wrappers in a new
//python:py_rules.bzl that inject the shim dependency automatically,
following the naming convention of the existing tflm_cc_* wrappers, and
document the shim's rationale there. Convert every target that
previously listed the shim to the corresponding wrapper and drop the
explicit dependency. The dependency graph is unchanged; only the means
by which the shim is attached differs.
- Upgraded the Bazel BuildTool to the latest version (8.2.1).
- Updated the `tflm-ci` Docker image and pushed the new tag (0.6.1) to the `ghcr.io/tflm-bot/tflm-ci registry`.
- Updated the WORKSPACE to load `rules_cc` and `rules_shell` explicitly
- Ran `buildifier` to ensure all BUILD files to have all the fixes.
BUG=Clean-up
The CI sync from the upstream TF has been failing for the last month due
to the relocation of certain TFLite files. In particular, some schema
files were relocated to tensorflow/compiler/mlir/lite subfolder. This PR
mirrors the migration and adds a few redirection headers to ensure
source compatibility for now.
This PR also includes a TF sync as well to get us caught up again. While
that could have been done separately, this is done together to ensure
everything continues to build with the relocations.
BUG=b/351824449
The tensorflow-cpu package does not support MacOS or non-x86 hardware. Replacing the tensorflow-cpu python package requirement with the tensorflow meta package should enable the bazel build and the dependent python scripts to be used on those platforms.
BUG=#2367, #1781
* Sync from upstream TF.
* Generate C++ bindings for schema as part of the import.
Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
Co-authored-by: Advait Jain <advaitjain@google.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Generate Micro Mutable Op Resolver for a given model
Also adds functionality to generate a test to verify the generated
header file.
Adds a CI script that does this for the person_detect.tflite file.
Change-Id: I5de316da7f7ec6b916371156e57e35da1b236911
* Break out TestDataGenerator from generate_per_layer_test.py
TestDataGenerator is also used by gen_micro_mutable_op_resolver_test.py.
TestDataGenerator.generate_test() and generate_build_file() are moved
out. They have to be implemented by the inheriting class
since they are not generic and would be different for every user.
Adds generate_golden() to TestDataGenerator since it is generic.
* Fix formatting errors from code style test
* Fix format error
* Fix 2 formatting errors
* Address review comments
* Add documentation to generate_goldens()
* Fix review comment
* Address review comments
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Use csv file name to determine type of the array.
This will allow us to have either int8 or int16 be generated from csv
files and will expand the types of integration tests that we can run.
Renamed all the files with:
```bash
for CSV in $(ls *.csv)
do
mv "${CSV}" "$(basename ${CSV} .csv)_int16.csv"
done
```
Also,
* added the integration_test to x86 makefile per-PR CI
* changed bazel target to cc_test so that the integration test is run
as part of CI.
If this slows down the CI, we will add a mechanism to run a more
exhaustive test suite nightly, but we are currently going to err on the
side of having more coverage.
For now, running the integration tests on x86 is fast.
BUG=http://b/205042963
* Initial implementation of tool to generate integration tests.
Manually tested that tests can be generated with:
```
python tensorflow/lite/micro/integration_tests/generate_per_layer_tests.py --input_tflite_file tensorflow/lite/micro/models/person_detect.tflite --output_dir tensorflow/lite/micro/integration_tests/person_detect/conv
```
And run with:
```
make -f tensorflow/lite/micro/tools/make/Makefile test_integration_tests_person_detect_conv_test
bazel test tensorflow/lite/micro/integration_tests/person_detect/conv:integration_test
```
This tool is in very early stages of prototyping. Follow-up PRs will add tests and improve the tool.
Some bugs:
* http://b/205046520
* http://b/205042963
* http://b/204109200
BUG=see description.
* fix build file formatting.
* Fix the bazel build
* Actually fix the build.
* Allow using Python scripts without bazel.
Manually verified and documented the steps that I can follow to run
Python code without Bazel.
BUG=http://b/204109200
NO_CHECK_TFLITE_FILES=manually ran the sync script.
* Address review comments.
Sync additional Python flatbuffer utils from Tensorflow.
* strip_strings
* visualize
Manually confirmed that I can strip strings and visualize from the TFLM repo:
```
bazel build tensorflow/lite/tools:strip_strings
bazel build tensorflow/lite/tools:visualize
bazel-bin/tensorflow/lite/tools/strip_strings --input_tflite_file tensorflow/lite/micro/models/person_detect.tflite --output_tflite_file tensorflow/lite/micro/models/person_detect.strip_strings.tflite
bazel-bin/tensorflow/lite/tools/visualize tensorflow/lite/micro/models/person_detect.strip_strings.tflite tensorflow/lite/micro/models/person_detect.strip_strings.tflite.html
```
Additionally, this changes switches the bazel build to use tensorflow-cpu to avoid CUDA not found warnings.
BUG=http://b/204109200
This is the first step towards being able to manipulate flatbuffers from
Python from the TFLM github repository.
Manually confirmed that the following command works:
```
bazel test tensorflow/lite/tools:flatbuffer_utils_test
```
Note that the code that is sync'd from TF needs to have an updated
import path and we have changed the sync script to perform this
transformation.
These python tests will also be run as part of the bazel CI.
BUG=http://b/204109200