Commit graph

108 commits

Author SHA1 Message Date
suleshahid
1e74475fde
Update Flatbuffer version to 2.0.6 and generate schema local. (#1374) 2022-08-25 18:01:35 +00:00
jwithers
67e9d8f60d
Issue on error
New issue creation and updating mechanism for action error trapping.

On error creates a new issue with the tag ci:bot_issue if one doesn't exist. Places information about the script failing and run in the body.

If an issue with the script name in the body and the ci:bot_issue tag exists and is open, will update with a comment about the current failure.

Error trapping implemented for testing in generate_integration_tests.yml

BUG=https://issuetracker.google.com/issues/229828377
2022-08-24 02:26:07 +00:00
Advait Jain
b4b0891668
Update list of sync'd files and manually run the sync script.
BUG=http://b/238904420
NO_CHECK_TFLITE_FILES=manual sync after updating file list.
2022-08-15 23:22:33 +00:00
TFLM-bot
0c8c12342c
Automated sync from github.com/tensorflow/tensorflow (#1225)
* 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>
2022-07-21 09:59:11 +00:00
Advait Jain
4ff9841b7f
Using flatbuffers-1.12.0 to generate Python bindings from schema.fbs (#1259)
* Using flatbuffers-1.12.0 to generate Python bindings from schema.fbs

This is a bit of a short-term workaround that is necessary to keep the
TF to TFLM sync functioning. Ideally we would be able to use a newer
version of flatbuffers with TFLM and generate the Python and C++
bindings directly from schema.fbs.

BUG=235888271

* Use a different version from upstream TF.

* fix the flatbuffers.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-07-20 22:10:20 +00:00
Ting Yan
74c6914e58
Add div.h to list of files to sync from TFLite (#1208)
Co-authored-by: Pauline Sho <psho@google.com>
Co-authored-by: deqiangc <86809673+deqiangc@users.noreply.github.com>
2022-06-21 18:27:30 +00:00
Pauline Sho
90d62ab628
Implement Python interpreter for TFLM (#1147)
* First pass working with float input/output

* Numpy buffer input works. Got a sine graph for hello world output.

Copyright notice

* Remove static references

* Output tensors work

* Output tensors work

* bazel test works

bazel test tensorflow/lite/micro/tools:interpreter_test
--test_output=all

* Successfully built extension with Python setuptools

cd tensorflow/lite/micro/tools/interpreter_pypi
python -m build
pip install dist/example_tflm_interpreter_psho-0.0.3-cp39-cp39-linux_x86_64.whl --force-reinstall
python tests/test-interpreter.py

TestPyPi:
pip uninstall example-tflm-interpreter-psho
python -m twine upload --repository testpypi dist/example-tflm-interpreter-psho-0.0.3.tar.gz
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple example-tflm-interpreter-psho==0.0.3
python tests/test-interpreter.py

* Refactored some

* Cleaned for production and tested with conv model

* Fixed formatting

* Fixed numpy header issue for Docker. Need to fix double registration issue that's somehow only present in Docker.

* Test fix with changes in ci.yml

* Added sudo

* Added nomsan and noasan tags to python test

* Added -layering-check, used py_library instead of py_binary to generate conv model, added micro namespace

* Removed extra debug code

* Added new tests

* Changed reinterpret_steal to cast

* Addressed PR comments

* size log refactor (#1156)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Addressed PR and review comments

* adding documentation to log_binary* workflows. (#1161)

* Automated binary size log update (#1160)

* Create an allocator to manage persistent arena (#1174)

* Create an allocator to manage persistent arena

This PR corresponds to internal cl/452380512.

Create an allocator to manage persistent arena.
This is another step towards the feature of enabling the client to
have two separate memory arenas.

BUG=https://b/226971240

* Manually patch due to Makefile difference

* Fix virtual environment when building Vela for Arm Ethos-U (#1177)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Removed print statement

Co-authored-by: jwithers <jpwithers@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: TFLM-bot <tflm-github-bot@google.com>
Co-authored-by: deqiangc <86809673+deqiangc@users.noreply.github.com>
Co-authored-by: Måns Nilsson <mans.nilsson@arm.com>
2022-06-03 19:09:54 +00:00
Ting Yan
11b2dc0cec
Update bazel version from 5.1.0 to 5.1.1 (#1047) 2022-04-13 20:32:32 +00:00
Ting Yan
b8856c07c9
Update bazel version to 5.1.0 (#1015) 2022-04-04 18:28:20 +00:00
deqiangc
2225fc7d5d
Add a script to sync third_party/hexagon from codelinaro (#1011)
BUG=https://b/227665919
2022-03-31 23:46:20 +00:00
deqiangc
71db650dbb
Sync schema.fbs from upstream (#1000)
tflite_micro does not directly use schema.fbs to generate header file,
but it provides good documentation value and is required by some
projects.

BUG=https://b/226974950
2022-03-26 00:47:37 +00:00
deqiangc
2babf76f59
Add broadcast_args.h and broadcast_to.h as part of sync from upstream (#958) 2022-03-07 10:59:01 -08:00
deqiangc
c9b21d3a39
Sync from upstream after updating the sync file list (#938)
This PR:
1. Update the tflite_files.txt with two additional files to be
pulled in
2. Add build rules to include context_util, builtin_op_data.h
and builtin_ops.h
3. Sync from upstream manually

BUG=observe errors in automatically
sync from upstream

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-02-18 04:10:59 +00:00
deqiangc
186c590bea
common.c is renamed to common.cc in upstream (#935)
common.c is renamed to common.cc in upstream
github.com/tensorflow/tensorflow/commit/848e84c5a3acda31847457cbd52742436e024984

Hence, change the name to sync it properly

BUG=observe error in sync from tf upstream
2022-02-16 23:43:58 +00:00
Ting Yan
b9bee52306
Add context_util.h to file list to sync from tensorflow (#934) 2022-02-16 21:10:22 +00:00
Ting Yan
4a76325a61
Add tensor_utils header files from TensorFlow Lite (#926)
* Add tensor_utils header files from TensorFlow Lite

* Removed tensor_utils_common.h and added new file lstm_cell.h

tensor_utils_common.h is absorbed into portable_tensor_utils.h
in http://cl/428845263 and lstm_cell.h is separated from
reference_ops.h in http://cl/428639888 and refactored in
http://cl/428808334 for TFLM.
2022-02-15 22:21:36 +00:00
rockyrhodes
8461ecfea9
Tensorflow now requires version 5.0.0. (#904) 2022-02-02 03:48:15 +00:00
deqiangc
6698e1affb
Fix yapf version in docker container (#891)
When upgrading the docker container, we see new format
fix/check on existing python file. That is because we did not
fix yapf version. This PR sets the yapf version to the
latest 0.32.0, which is what the latest container is using

BUG=https://issuetracker.google.com/216670232
2022-02-01 01:22:49 +00:00
jwithers
b6fd2cd840
adding pandas and matplotlib (#878)
* adding pandas and matplotlib

* updating container tag to latest

* fixing formatting issues that have been slipping through older ci setup

Co-authored-by: deqiangc <86809673+deqiangc@users.noreply.github.com>
2022-01-27 22:52:58 +00:00
Advait Jain
f0d3c2b444
Tensorflow requires 4.2.2 with https://github.com/tensorflow/tensorflow/pull/53363 (#824)
Without this change, the sync workflow fails with:
```
ERROR: The project you're trying to build requires Bazel 4.2.2 (specified in /tmp/tensorflow/.bazelversion), but it wasn't found in /usr/local/lib/bazel/bin.
```

BUG=fix broken sync from upstream TF

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-12-29 23:53:57 +00:00
Advait Jain
fa8ccf571b
Update bazel to 4.2.1 to match upstream TF (#767)
BUG=fix sync from tensorflow to tflite-micro
2021-12-08 16:57:25 -08:00
Advait Jain
e77f57733f
Sync schema_util.py from TF to TFLM. (#652)
This is needed to properly access the builtin code.

BUG=http://b/204109200
NO_CHECK_TFLITE_FILES=manually sync'd the code
2021-11-03 18:56:30 +00:00
Advait Jain
e958bb1161
Allow using Python scripts without bazel. (#639)
* 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.
2021-10-29 14:40:24 -07:00
Advait Jain
be7f88c81a
Sync additional Python flatbuffer utils from Tensorflow (#635)
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
2021-10-28 23:15:35 +00:00
Advait Jain
05694f8c38
Add flatbuffer_utils and corresponding test to the bazel build. (#632)
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
2021-10-28 15:57:34 -07:00
Advait Jain
6cb1580846
Update to the latest buildifier release. (#633)
* Update to the latest buildifier release.

For the previous buildifier version, the exit code would always be 0
(regardless of whether files needed formatting or not).

Manually confirmed that with version 4.2.3 the test_code_style.sh script
correctly errors out when a BUILD file has formatting errors (and that
it doesn't with the previous version).

Also,
 * Updated the docker container and pointing to the new container.
 * Fix the formatting errors in .bzl file that crept in because this check was not working in OSS.

BUG=http://b/203803273

* Exclude the downloads directory.

* Updated docs based on review comments.
2021-10-27 22:46:49 +00:00
Advait Jain
b5ed16a738
Sync Python flatbuffer bindings, tools and utils from TF. (#626)
This is a first step towards enabling flatbuffer manipulation from
Python.

As part of this change:
  * we generate the python flatbuffer bindings from the tensorflow
    repository and copy the schema_py_generated into the TFLM repo.

  * sync common python flatbuffer manipulation code from upstream TF.

Manually tested that the sync script runs as expected:
```
./ci/sync_from_upstream_tf.sh
```

BUG=http://b/204109200
2021-10-26 22:46:55 +00:00
Jakub Piecuch
a70d50acaa
Prepare for adding support for running RISC-V tests (#570)
* Bump renode and robot versions

Signed-off-by: Jakub Piecuch <jpiecuch@antmicro.com>

* Refactor test_with_renode.sh

Pass the name of the UART device as a parameter, since RISC-V uses
a different name.
Also pass the full list of binaries to test instead of a directory,
so that we can filter some tests out from within make, which is easier
compared to doing it in bash.

Signed-off-by: Jakub Piecuch <jpiecuch@antmicro.com>

* Use TfLiteRound instead of std::round in hard_swish_test

Signed-off-by: Jakub Piecuch <jpiecuch@antmicro.com>

* Don't pass UART name as an argument to test_with_renode.sh

Passing it as an argument works when running tests via `make test`, but
it breaks when we try to run a single test via `make test_foo`, because
the recipe for `make test_foo` doesn't pass the `${UART_NAME}` argument
to the test script.

Signed-off-by: Jakub Piecuch <jpiecuch@antmicro.com>
2021-10-06 08:58:56 -07:00
Nat Jeffries
13c69667be
Add features to cast, add slice, clean up split. (#568) 2021-10-04 15:33:41 -07:00
deqiangc
02898348ac
Add a hexagon build presubmit (#518)
* Add a hexagon build presubmit
Also update Hexagon Docker file

* Add a todo for to enable unit test for hexagon

Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
2021-09-20 22:59:30 +00:00
Nat Jeffries
6768147920
Generate cc and header files for micro_speech. (#429) 2021-08-27 22:18:07 +00:00
deqiangc
406a57cc24
Make size check workflow error out if memory footprint increase (#450)
* Make size check workflow error out if memory footprint increase
between head of main and this PR.

This error can be disabled by putting MEM_CHANGE_OK= tag.
In either case, a memory footprint comparison report will be produced
as part of this workflow action.

The plan is for the code reviewer to audit the report when the
PR increase memory footprint and only
allow the PR that increase memory footprint to be merged with
MEM_CHANGE_OK=what_is_the_reason_for_this_increase_and_why_this_is_ok

The PR shall be up to date for the comparison to be accurate.
So before applying MEM_CHANGE_OK=, please make the PR branch up to date.

BUG=http://b/196637015

* Fix an if condition
2021-08-25 21:58:02 +00:00
deqiangc
9da0734d67
Fix event_name in size_check.yml and also fix permission of size_comp.py to be executable (#434)
BUG=http://b/196637015
2021-08-18 00:20:19 +00:00
deqiangc
b9dd7bad38
Create a binary size test. (#417)
* Create a test used for binary size test.
Also create a script to generate size report of a such binary.
Modify the size_comp.py to be more generic (not limited to xtensa).

what is tensorflow/lite/micro/tools/ci_build/binary_size_test will
be eventually removed once we verify the feature.

The next PR will update the yml file for the size_check.yml.

BUG=http://b/196637015

* Restore lines that are deleted by mistakes

* Update comments
2021-08-17 20:06:41 +00:00
Advait Jain
766063c53e
Add Pillow to Dockerfile.micro (#415)
* Add Pillow to Dockerfile.micro

Needed with the changes from https://github.com/tensorflow/tflite-micro/pull/410

BUG=http://b/196630709

* address review comments.
2021-08-17 16:18:59 +00:00
jwithers
d9b2263c84
Size comparison for binaries (#254)
* binary size check implementation

* doc comment changes

Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
2021-08-16 17:55:50 +00:00
nyadla-sys
e0ad084b65
Have a TFLM-specific version of lite/kernels/internal/portable_tensor… (#379)
Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
2021-08-09 18:02:34 +00:00
Advait Jain
d5430e855f
Remove files from the tflite_files list that should not be shared. (#340)
* Remove files from the tflite_files list that should not be shared.

This was added with
https://github.com/tensorflow/tflite-micro/pull/134/.

However, the correct approach would be to only pull in the portable
implementations from:
 * be7a4de6ad/tensorflow/lite/kernels/internal/reference/portable_tensor_utils.cc
 * be7a4de6ad/tensorflow/lite/kernels/internal/reference/portable_tensor_utils.h
 * be7a4de6ad/tensorflow/lite/kernels/internal/reference/portable_tensor_utils_impl.h

* Added the portable_tensor_utils to the files to sync.
2021-08-02 23:01:12 +00:00
Advait Jain
762ff80073
Groundwork to enable python format checks (via yapf) as part of the CI. (#314)
With this change:
 * we are set up to use yapf as part of the docker container
 * pigweed patch is updated to use the google Python style (pep8 with indent of 2 spaces)
 * some documentation updates.

The code still needs to be formatted, and then the Python formatting check will be turned on as part of ci.

BUG=http://b/194404216
2021-07-22 21:21:00 +00:00
Advait Jain
454c072edb
Have a TFLM-specific version of lite/kernels/op_macros.h (#275)
* Have a TFLM-specific version of lite/kernels/op_macros.h

 * After this change, we can remove the TFLM-specific code from upstream
   Tensorflow.
 * Both the TfLite and TFLM implementations of op_macros.h will be
   simplified.

BUG=http://b/187728891
NO_CHECK_TFLITE_FILE=lite/kernels/kernel_util.cc will be modified in upstream as well

* Fix target-specific makefile build.
2021-07-14 17:57:12 +00:00
Advait Jain
2d465d7edc
Fixes to the check tflite files workflow (#270)
* modify a tflite file in the tflite-micro repository.

* fix the path

* Update workflow logic to complete workflow without error with NO_CHECK_TFLITE_FILES

* revert change to the tflite files.
2021-07-13 00:01:50 +00:00
jwithers
7ea0ff500a
fail PRs that overwrite a set of files from upstream (#195)
* fail PRs that overwrite a set of files from upstream

* Change some names, modify Python script logic etc.

* small fixes.

* Use more restrictive TFLM-bot token.

Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
Co-authored-by: Advait Jain <advaitjain@google.com>
2021-07-12 23:46:17 +00:00
Advait Jain
c0a2358a0d
Update sync script now that TFLM has been deleted from upstream Tensorflow. (#260) 2021-07-08 20:56:32 +00:00
jwithers
f897bca58c
dockerfile for hexagon testing tools (#186)
Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
2021-06-17 16:53:37 +00:00
Advait Jain
f583f92992
Fix the style check docker container. (#156)
Following the pattern of #151 and fixes #11.
2021-06-09 19:54:51 +00:00
David Davis
e319e739b9
Add files from TfLite (#134)
Added batch_matmul.h and tensor_utils_common.h that are needed for the BATCH_MATMUL operator.

Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
2021-06-07 18:42:15 +00:00
Ryan Kuester
8e2f711b4a
Sync reference implementation of SPACE_TO_DEPTH from lite (#114)
Add the header containing the reference implementation of op
SPACE_TO_DEPTH to the list of files which are synced from the
upstream TensorFlow repository. This reference is needed for the
forthcoming implementation of SPACE_TO_DEPTH here in micro.
2021-06-02 19:05:15 +00:00
Advait Jain
23f608fd2b
Updated sync and use of shared TFL/TFLM code. (#104)
* The TFLM Makefile globs all the shared TFL/TFLM code.
 * This allows us to move the explicit list of sources and headers to the
   sync script since that is where we determine what code needs to be
   sync'd from upstream TF.

With this change, we are ready to have the tflite_micro repository be
the source of truth for all TFLM code and sync only the shared TFL/TFLM
code from the tensorflow repo.

Bug: http://b/182914089
2021-06-01 22:27:10 +00:00
Advait Jain
be84df4361
Sync micro_speech example from upstream TF. (#102)
Bug: http://b/184876027
2021-05-26 22:33:07 +00:00
Advait Jain
07b981ffdc
Visibility patch for the testing code is no longer needed. (#88)
More context in http://b/188226023
2021-05-20 12:10:52 -07:00