Commit graph

57 commits

Author SHA1 Message Date
Esun Kim
183da3e302
Typo in code (#3447)
* Typo in code

* Format
2026-02-11 20:34:42 +00:00
Esun Kim
89bf22f7a6
Ah.. revert legacy_create_init (#3440) 2026-02-10 11:14:56 -08:00
Esun Kim
b4bb8128b6
[CI] Docker test fixes (#3436)
* Fix Python module shadowing in Docker CI

Applies legacy_create_init = False to Python rules in BUILD files to prevent Bazel from automatically generating __init__.py files. This prevents the root 'signal/' directory (which contains C++ kernels but no Python source) from being treated as a Python package, which was shadowing the standard library 'signal' module and causing psutil failures in the tflm-ci Docker container.

* Fix directory path in Docker workflows
2026-02-10 10:51:10 -08:00
Esun Kim
5353e52846
Various HasFailures added to micro_test_v2 (#3397)
* API

* Refactored

* Huh
2026-01-31 11:38:10 -08:00
Esun Kim
0c05a37bcc
[Testing] New Testing API (#3311)
* Fixed StackAllocator

* Bumped kStackAllocatorSize to 16KB

* Simplified

* Added micro_test v2

* Sample migration

* More APIs

* Fixed format

* Output is more aligned with gtest

* Removed legacy-eq

* Migrated memory_planner tests

* Code style

* Added ~~~ALL TESTS PASSED~~~

* Review

* Review 2

* Output messages
2026-01-29 17:17:35 +00:00
Esun Kim
e224763936
Added ResetVariableTensor (#3298)
* Added ResetVariableTensor

* Return kTfLiteError if case of error

* Added new test to Makefile

* Better quantiazation check

* EXPECT in the test

* Typo

* Fixed API usage
2026-01-26 21:22:13 +00:00
Esun Kim
b41b1cb25e
Clean-up shebang (#3356) 2026-01-26 14:07:28 -08:00
Esun Kim
fd33340e06
Revert "[CI] Replaced tensorflow with tensorflow-cpu (#3261)" (#3290)
This reverts commit 9cbf6e0403.
2026-01-12 11:19:37 -08:00
Esun Kim
9cbf6e0403
[CI] Replaced tensorflow with tensorflow-cpu (#3261)
* Replaced tensorflow with tensorflow-cpu

* Use tensorflow-cpu for bazel targets
2025-12-03 13:43:14 -08:00
Esun Kim
4186e7ddeb
Reenable recording_micro_allocator_test (#3207)
* Reenable tests

* Added alignas to kTestConvModelData
2025-10-03 09:15:38 -07:00
Esun Kim
858f5a3edd
[CI] Removed six, updated absl_py (#3203)
* Removed ci/install_qemu.sh

* Removed six from direct deps

* Removed six from tflm-ci docker

* Use requirement(absl_py)

* New qemu-user
2025-09-25 14:37:39 -07:00
Esun Kim
ba753cef3e
[CI] Fix build (#3194)
- 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
2025-09-19 20:48:22 +00:00
David Davis
3fedcbfc10
Don't allow silent failures for Xtensa binaries (#3156)
@tensorflow/micro

Do not allow programs, which are not unit tests, to silently fail when run using the Xtensa simulator. The generic benchmark application is one such program for which failures were not being reported.

Check the exit status of the simulator when running programs that are not unit tests.

bug=fixes #3155
2025-08-02 03:01:14 +00:00
suleshahid
bc68d362d6
Remove deprecated BUILD tags (#3091)
These tags have been deprecated and are unused now. Syncing with upstream and removing them from the BUILD files.

BUG=remove deprecated tags
2025-04-08 19:21:25 +00:00
Ryan Kuester
b68c655367
build(bazel): replace cc_* with tflm_cc_* in remaining TFLM code (#2768)
Replace cc_* targets remaining in TFLM code with tflm_cc_*
targets. These are targets which did not formerly use the common
copts. Avoid changing imported TFLite code, if for no other
reason than to avoid merge conflicts during the automatic sync
with upstream TFLite.

BUG=#2636
2024-11-15 05:08:54 +00:00
David Davis
39f9f1912a
TFLM compression changes (2nd) (#2653)
@tensorflow/micro

Preparatory changes for upcomming PRs related to TFLM compression changes.

Add unit testing failure check macro.

bug=#2652
2024-08-06 17:36:03 +00:00
RJ Ascani
29526e413b
Replace tensorflow-cpu usage with tensorflow (#2396)
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
2024-02-23 00:35:22 +00:00
RJ Ascani
a7238a13e0
Disable per channel quantization for FC layers (#2465)
BUG=b/324385802
2024-02-22 21:32:07 +00:00
RJ Ascani
4b2bdd1a6c
Remove unused visibility spec (#2403)
BUG=cleanup
2024-01-19 19:11:43 +00:00
RJ Ascani
7a63bce432
Revert "Compute output shapes for some kernels (#2356)" (#2390)
This change broke some internal models, so reverting this until we can better understand why.

This also reverts PR #2383. When relanded, both should go back in together.

BUG=b/318738218
2024-01-11 22:24:58 +00:00
David Davis
bb54330fda
Compute output shapes for some kernels (#2356)
@tensorflow/micro

Update the output tensor shape during prepare phase when the computed shape does not match the shape in the flatbuffer.

Kernels:
- BATCH_TO_SPACE_ND
- SPACE_TO_BATCH_ND
- CONV
- RESHAPE
- EXPAND_DIMS
- DEPTHWISE_CONV

Update CMSIS_NN and ARC_MLI optimized kernels.
Add additional tests from TfLite for BATCH_TO_SPACE_ND and SPACE_TO_BATCH_ND.
Update existing tests.
Add tests for Keras model using convolution with dilation > 1.

Update memory_arena_threshold_test to increase total, tail, and persistent allocation sizes:
- Add 20 bytes for CONV output shape
- Add 15 bytes for arena allocation alignment
- x2 convolution layers

Update micro_speech_test arena size as per description in C++ code.

See #2319 for additional details.

Resolves [b/317362237](https://issuetracker.google.com/317362237)

bug=fixes #2368 #1646 #1629 #1231 #2338 #2319
2024-01-02 22:22:36 +00:00
RJ Ascani
83bbff9a0e
Revert "SPACE_TO_BATCH_ND: update output tensor shape" (#2339)
Temporarily reverting so that we can reland with SpaceToBatch, BatchToSpace, Conv2D and ExpandDims output tensor resizing atomically.

Reverts tensorflow/tflite-micro#2335

BUG=#2338
2023-11-30 23:19:30 +00:00
David Davis
50433190cf
SPACE_TO_BATCH_ND: update output tensor shape (#2335)
@tensorflow/micro

Update the output tensor shape during prepare phase when the computed shape does not match the shape in the flatbuffer.

Added additional tests from TfLite.

See #2319 for additional details.

Resolves [b/313360569](https://issuetracker.google.com/313360569)

bug=fixes #2332 fixes #2319 #1646 #1629 #1231
2023-11-28 17:43:15 +00:00
David Davis
a8421cf61e
Enable Corstone 300 to run on CI backend (#2321)
@tensorflow/micro

Update makefile and download scripts to allow Corstone 300 to build and run on the CI backend.

Output extra stats at the end of the simulator run.

bug=fixes #2324
2023-11-21 21:02:02 +00:00
David Davis
d5a83db0d0
Change micro_speech example (#2249)
@tensorflow/micro 

Create Python examples that use Signal Ops Library.
Create Python examples for micro_speech model prediction.
Update README documentation.
Update images.
Add additional speech sample files (silence, noise) to testdata directory.
Add audio preprocessing models to models  directory.
Update Bazel BUILD files.
Update Makefiles
Add micro_speech to project generation examples for bluepill
Disable micro_speech_test for Hexagon (b/302404477)

bug=fixes  #2248
2023-10-12 23:17:32 +00:00
Steven Toribio
80cb11b131
load()s are being added in preparation for changes being made to Blaze/Bazel (#2160)
`load()`s are being added in preparation for changes being made to Blaze/Bazel !

corresponding [google3 cl](https://critique.corp.google.com/cl/553849494)

BUG=[b/295216390](https://b.corp.google.com/issues/295216390)
2023-08-10 03:30:46 +00:00
RJ Ascani
7a3ef35d14
Remove leftover riscv32_mcu files (#2090)
There were a few leftover files after PR #2061 for the riscv32_mcu target. Since that target is no longer buildable, these files are not needed. This PR removes those remaining files.

BUG=http://b/286622884
2023-06-30 08:01:41 +00:00
Advait Jain
7ab206e502
Remove unused RISCV targets. (#2061)
BUG=http://b/286622884
2023-06-15 22:31:39 +00:00
TANMAY DAS
148af67d3a
Remove redundant step of creating elf file from hexa test. (#2003)
BUG=http://b/284589445
2023-05-28 05:45:23 +00:00
Shlomi Regev
095d270fc1
Add a target architecture for a generic RISCV32 CPU. (#1924)
Also add a script to test a binary with QEMU and a script to measure the size of a binary.

BUG=277663402
2023-04-21 16:59:07 +00:00
Mike Bernico
5d81216567
Add QEMU Emulation to CI flow (#1892)
Addresses #1891 and adds Cortex M QEMU based unit tests to the CI flow.

Verification:

1. From repo root, run the command `tensorflow/lite/micro/tools/ci_build/test_cortex_m_qemu.sh`
2. Verify that all tests pass


Note this doesn't remove or change anything related to renode, for the sake of brevity, but we can remove renode here if desired.

 BUG=1891
2023-04-14 07:11:10 +00:00
Advait Jain
a9def8fbae
Removed a few more files that are specific to STM32F4. (#1862)
Missed removing these files with https://github.com/tensorflow/tflite-micro/pull/1861

BUG=http://b/275917313
2023-04-03 18:09:38 +00:00
Advait Jain
ffd7d16c86
Remove STM32F4 and test CMSIS_NN kernels with bluepill. (#1861)
BUG=http://b/275917313
2023-03-29 23:09:02 -07:00
Advait Jain
015a7c488f
Update to Renode 1.13.2
With help from @PiotrZierhoffer, this PR updates TFLM to use the Renode release from Oct 3 (renode-1.13.2.linux-portable).

Manually confirmed that I can run the following command locally (http://b/257332395):
```
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=bluepill test -j8
```

BUG=http://b/260027053 and http://b/257332395
2022-11-22 23:54:41 +00:00
Renjie
282bcef7e6
Add random seed to the conv network training used in testing
BUG=b/248060722

Every random operation should be seeded to help debugging (deterministic outputs). Set the seed inside the conv net training code since random data is used as training inputs. 

Also, testing criteria on the quantization parameters are relaxed before b/248061370 is ready.
2022-09-22 01:20:35 +00:00
Vamsi Krishna Manchala
6fdade1aed
Update TFLM examples, kernels and integration tests to clean-up the usage of ErrorReporter
This PR updates remainder of the TFLM examples, all the kernels and integration tests to remove the usage of ErrorReporter as per the changes made to the TFLM Framework API in https://github.com/tensorflow/tflite-micro/pull/1415; replaces TF_LITE_REPORT_ERROR with MicroPrintf.

BUG=http://b/192091017, http://b/245802069
2022-09-20 20:46:26 +00:00
TANMAY DAS
5330f1620b
Changing the gen directory from tensorflow/lite/micro/make/gen to gen/.
BUG=https://b.corp.google.com/issues/244204467
2022-09-01 01:27:56 +00:00
Steven Toribio
dc09835ce3
TF_LITE_MICRO_EXPECT_EQ / TF_LITE_MICRO_EXPECT_NE type checking (#1131)
* changed TF_LITE_MICRO_EXPECT_* macros to check for int type inputs using std::is_same and decltype.

* fix cpplint formatting

* more cpplint changes

* x86 compiler debug

* more x86 test debug

* debugging x86

* trying typeid instead of decltype/is_same combo

* trying typeid instead of decltype/is_same combo

* trying decltype/is_same again

* trying decltype/is_same again

* trying decltype/is_same again

* trying decltype/is_same again

* debug

* testing #error

* testing

* testing

* testing

* testing

* testing

* trying

* fixed cpplint error

* fixing github formatting presubmit error

* reverting changes

* isolated test to try changes to macro on

* Expect equal changes based on pr and bugonizer suggestions from Ting and Deqiang

* figuring out why changes don't compile

* syntax error

* syntax error

* debugging

* fixed control flow mistake

* Done with EQ macro time for NE

* wrote changes to NE based on EQ changes

* tested NE/EQ and then resotred file used for isolated testing back to what it was in main branch

* formating change for git style check presubmit

* formating change for git style check presubmit

* formating change for git style check presubmit

* refactored the parts of x86 and kernal test that weren't compatible with change. Replaced with EXPECT_NEAR equivalents using a very small epsilon

* git presubmit style formatting changes

* git presubmit style formatting changes

* git presubmit style formatting changes

* git presubmit style formatting changes

* bazel test fixes for presubmit

* change include iostream to type_traits for is_same

* changed .0.0000000001f to 1e-5f in test for to make it easier to read

* rolling back changes to all test files

* changed to EXPECT_EQ and EXPECT_NE to use std::numeric_limits<decltype(delta)>::epsilon()

* control flow fix

* control flow fix

* control flow fix

* debugging

* debugging

* debugging

* debugging

* debugging

* debugging compile error

* reverting EXPECT_NE to prev change and testing EQ seperately

* presubmit github formatting change

* reverting example to test to main

* git fromat fix for presubmit

* git fromat fix for presubmit

* changing is_same to is_floating_point to make code easier to read

* changing is_same to is_floating_point to make code easier to read

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* debugging nullptr error with EXPECT_NE

* not using NEAR like implementation for NE due to issues with Null_ptrs used in NE test. But honestly no current test use EXPECT_NE with floats or doubles. But in case they do added error message suggestion users use EXPECT_NEAR for Float double not equals testing

* not using NEAR like implementation for NE due to issues with Null_ptrs used in NE test. But honestly no current test use EXPECT_NE with floats or doubles. But in case they do added error message suggestion users use EXPECT_NEAR for Float double not equals testing

* logic error fix for if statement

* returning test file used to test macro changes back to orginal

* changed based on cr suggestions by deqiang

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* git style changes presubmit changes

* typo in a string

* fixed all test that used nullptr's with EXPECT_NE to use EXPECT macro instead

* github style presubmit fixes

* github style presubmit fixes

* github style presubmit fixes

* fixing compiler errors non x86 and accidental change to a test file

* channing EXPECT_NE in helloworld that was reverted

* fixing presubmit

* fixing style presubmit

* fixing presubmit

* changing TF_LITE_MICRO_EXPECT to be consistent

* accidentally changed a variable name

* changing all EXPECT to EXPECT(PTR != nullptr)

* irrevlavent EXPECT macro usage

* changing one ptr != nullptr to expect(ptr)

* style fixes for presubmit

* style fixes for presubmit

* fixing file from merge conflict

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-07-21 00:03:29 +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
deqiangc
008b8e6ea6
Add additional visibility to micro_test (#1126)
* Add additional visibility to micro_test

BUG=https://b/232264277

* Fix typo

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-11 23:50:51 +00:00
Advait Jain
85585153ba
Enable person_detection_test on stm32f4 + Renode (#771)
* Enable person_detection_test on stm32f4 + bluepill.

Manually tested the following command:
```
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=stm32f4 OPTIMIZED_KERNEL_DIR=cmsis_nn test_person_detection_test
```

Also, a little bit of cleanup in the name of the tests and binaries and
remove mentions to sparkfun_edge.

BUG=http://b/209700478

* exclude person_detection for bluepill.

* Update timeout to get test to pass on bluepill.
2021-12-09 17:00:50 -08:00
Artem Tsvetkov
de3c12c9e1
Removing ARC code related to examples and updating make files and test scripts. (#737) 2021-12-09 08:23:49 -08:00
Shlomi Regev
3decf3263d
Add script for getting the size of a binary built for the Xtensa (#752)
Co-authored-by: Deqiang Chen <deqiangc@google.com>
Co-authored-by: deqiangc <86809673+deqiangc@users.noreply.github.com>
2021-12-02 22:41:48 +00: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
3e190e5389
Add ability to use bazel + tensorflow pip package. (#615)
* Add ability to use bazel + tensorflow pip package.

We can now run python tests that make use of the Tensorflow pip package
with bazel.

Tested the following command:
```
bazel run tensorflow/lite/micro/testing:generate_test_models
bazel test tensorflow/lite/micro/examples/person_detection/utils:raw_to_bitmap_test
```

BUG=http://b/186670822

* Adding absl_py as a source repo (instead of using as a pip package).
2021-10-21 15:16:06 -07:00
Jakub Piecuch
ba8a76b0b5
Add support for running tests using Renode for 32-bit RISC-V architecture (#547)
This PR adds support for running TFLM tests on a 32-bit RISC-V platform based on HiFive 1 simulated with Renode.
Issue #545 contains a summary of the changes.

BUG=#545
2021-10-19 22:47:26 +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
Advait Jain
70d160ae53
Remove some of the hardware specific code that has not been updated for a while. (#502)
We are moving towards removing ***all*** hardware-specific example code
out of the TFLM repository, and this PR is a step in that direction.

BUG=https://github.com/tensorflow/tflite-micro/issues/407
2021-09-13 21:34:43 +00:00
Shlomi Regev
f75696cb9e
Some improvements to build scripts (#481)
1. Add TENSORFLOW_ROOT as a prefix to paths in helper_functions.inc. This enables us to include this file from an external directory. Useful when building a custom op library.
2. Add a script size_hexagon_binary.sh to measure the size of a Hexagon binary, and a matching make macro/rule to invoke it. Similar scripts can be created for any target.
3. Lint fixes to generate_cc_array.py
4. Move HEXAGON_TFLM_LIB from the ext_lib makefile to
hexagon_makefile.inc. This library is needed by any binary, so it
belongs on the LDFLAGS.

Co-authored-by: Advait Jain <advaitjain@users.noreply.github.com>
2021-09-07 17:10:57 +00:00
Advait Jain
169a27b204
Add reason for disabling the layering check. (#441)
And restore -layering_check to a few places where it got removed with https://github.com/tensorflow/tflite-micro/pull/435/

BUG=http://b/177257332
2021-08-19 18:42:19 +00:00