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
* ci(bazel): simplify scripts and configuration in advance of additions
Simplify the Bazel-related CI scripts and BUILD configuration in
preparation for adding several more for the compression feature.
- Move CC=clang to .bazelrc
- Define CXX in case it's already defined in the environment, in
which case it overrides deferring to CC
- Replace --repo_env, which doesn't affect build, with --action_env
- Move commented-out ubsan invocation to its own CI job. Since
ubsan was commented out, Bazel invocations have moved to their
own jobs so they can run in parallel.
- Consistently test all targets, `...`, since TFLM is no longer
confined to the tensorflow/lite/micro directory. Filter out
inappropriate new targets with no.san tags.
- Don't run `bazel build ...` before `bazel test ...`; the latter
already builds all non-test targets.
- Remove obsolete filter for `no_oss`, there were no more
`no_oss` tags in the tree.
- Stop using readable_run: it has diverged from its original
meaning and now only redirects stderr to stdout. This is not
needed.
BUG=see description
* refactor: clarify intention to run at top and test entire project
Clarify that the scripts run from the root directory of the
project by restoring the change of directory at the top of the
script, even though CI runs from the root directory of the
project.
Also clarify the intention that all tests in the project be run
by specifying `//...`, rather than `...`, which means all targets
at or below the working directory.
Numpy 2.0 will explicitly downcast now, which casues us to see a regerssion in the conversion for the audio model.
BUG=[361070678](https://b.corp.google.com/issues/361070678)
### Problem description:
In the original code, pointer arithmetic of gain_lut and the assignment of gain_lut[4 * interval + 3] could potentially lead to out-of-bounds array access.
On certain architectures (e.g., macOS ARM64), this out-of-bounds access causes the program to crash.
BUG=None, reported issue#2464
### Solution:
Increase the size of the gain_lut_storage array by 1 to provide an extra buffer and prevent overflow during the calculation within the loop.
### Risks and considerations:
Increasing the array size will slightly increase memory usage.
In extremely resource-constrained systems, alternative algorithm implementations may need to be considered.
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
The py_tflm_signal_library macro generates multiple targets, some of which are referenced by an internal subdirectory target. This PR adds a default visibility for the package for all targets to be visibile within the subpackage.
BUG=b/316963245
The targets for building the ops should depend on
"//third_party/tflite_micro/python/tflite_micro/signal/utils:util Instead of just their unit tests.
BUG=315941833
Functionality to use the rest of the Signal Library OPs directly from python.
Test with `bazel run python/tflite_micro/signal:stacker_op_test` and `bazel run python/tflite_micro/signal:filter_bank_ops_test`
BUG=[287346710](http://b/287346710)
We this PR, you can use these ops directly from python, including in TF graphs.
Test with `bazel run python/tflite_micro/signal:framer_op_test`, etc.
BUG=[287346710](http://b/287346710)
Extends the Signal Library Delay OP to be usable from python.
Can test via `bazel run python/tflite_micro/signal:delay_op_test`
BUG=[287346710](http://b/287346710)
This PR adds additional FFT op functionality in the Signal library, namely adding the FFT Auto Scale operation.
Testing added in the original `fft_test.cc` and `fft_ops_test.py`.
BUG=[287346710](http://b/287346710)
This is needed to properly build all the ops together. Since we are calling into a singular utils function to load the ops, if it checks for any other ops, it would break before this.
Now we make it build all ops everytime utils.py is built.
BUG=[288938993](http://b/288938993)
Second OP for the TFLM Signal library, Real-Valued Fast Fourier Transform.
The RFFT OP provides three resolutions: `FLOAT, INT16, INT32`
Similar usage as to previous Window OP:
* `op_resolver.AddRfft()` (which will add all resolutions, and determine the type at runtime)
* `op_resolver.AddRfftFloat()`, `op_resolver.AddRfftInt16()`, `op_resolver.AddRfftInt32()` for a specific resolution type.
* or via python as can be seen in `fft_ops_test.py`
3 testing options are provided:
* Micro(C++): bazel run signal/micro/kernels:fft_test
* Tensorflow/Micro(Python): bazel run python/tflite_micro/signal:fft_ops_test
* Makefile(C++): make -f tensorflow/lite/micro/tools/make/Makefile test_kernel_fft_test
BUG=[287346710](http://b/287346710)
To package the module `runtime` as `tflite_micro.runtime`, put `runtime` under
a directory representing the Python namespace package `tflite_micro`. For
organization's sake, move it all to the top-level directory `python/`. Adjust
tests and docs to match.
Some code outside of the Python extension module has come to depend on
`python/tflite_micro:python_ops_resolver` as a replacement for
`all_ops_resolver` (e.g.:`t/l/m/integration_tests/seanet/add/integration_tests.cc`).
`python_ops_resolver` is intended to be a private implementation detail of the
Python extension module. For now, grandfather in the dependent code by updating
its references to the resolver's location; however, soon the dependent code
should be migrated away to a different resolver. (#2033,
https://issuetracker.google.com/286508251)
BUG=part of #1484
We have some name clash issues with the current Window OP name.
We will be changing it from "Window"->"SignalWindow" until the names clashes are resolved and revert back afterwards.
This is an internal implementation detail, so user level API has no change from current usage, i.e. still use (op_resolver.AddWindow() and window_op.window)
BUG=[286250473](http://b/286250473)
First Op for the TFLM Signal Processing Ops library.
Doc linked in bug.
The Window OP is a custom signal processing OP similar to what is found in tf.signal library, but specific for integer (int16) purposes.
You can directly use this as a builtin op via the op resolver as:
* `op_resolver.AddWindow()`
* or via python as shown in `window_op_test.py`
3 testing options are provided:
* Micro(C++): `bazel run signal/micro/kernels:window_test`
* Tensorflow/Micro(Python): `bazel run python/tflite_micro/signal:window_op_test`
* Makefile(C++): `make -f tensorflow/lite/micro/tools/make/Makefile test_kernel_window_test`
BUG=[259145369](http://b/259145369)