Commit graph

1271 commits

Author SHA1 Message Date
David Davis
8f1f3b2623
WHILE operator input/output copy fix (#3633)
@tensorflow/micro

Remove extraneous tensor copy operation after first invocation of condition subgraph.

Move copy of operator inputs to outputs, such that it occurs before the first invocation of the condition subgraph. This preserves the operator inputs when one or more of them is the output of DECODE, and alternate decompression memory is in use. This is because the output of DECODE is for immediate consumption by the next operator in the graph (WHILE), yet it is possible for the WHILE subgraph invocations to share memory with the original DECODE output.

Update the unit test for multiple invocations of the condition and body subgraphs.

When copying tensors between operator inputs/outputs and subgraph inputs/outputs, check if the source and destination tensors share memory.

bug=fixes #3632
2026-07-20 17:58:59 +00:00
David Davis
0965635467
Fix benchmark tool alternate profiler (#3629)
@tensorflow/micro

Set the alternate profiler in the benchmark tool prior to the `Prepare` phase (before calling `MicroInterpreter::AllocateTensors`).  This is because the DECODE operator requires the alternate `MicroProfilerInterface` to already be initialized during the `Prepare` phase.

Previously the alternate profiler was only required during the `Eval` phase with the legacy compression code.  This fix does not change the functionality of the benchmark tool with respect to the legacy compression.

bug=#3628
2026-07-13 18:10:56 +00:00
Esun Kim
5750228374
Add Reset support to CircularBuffer op (#3618)
* Add reset support to circular_buffer

* Format
2026-07-08 21:34:43 +00:00
Esun Kim
bc0e8c658b
Re-enable 3D x 2D BatchMatMul dimension collapse for adj_x=true (#3599)
* Re-enable 3D x 2D BatchMatMul dimension collapse for adj_x=true

* Code style
2026-07-08 15:32:05 +00:00
Esun Kim
e142972d4f
Manual sync from sync from github.com/tensorflow/tensorflow (#3616)
* Synced

* Added FLOAT8_* types
2026-07-01 18:13:01 -07:00
Ryan Kuester
6c67d478e3
feat(compression): add Huffman and Pruning compression support (#3612)
Add spec types, YAML parser support, and plugin stubs for Huffman and
Pruning compression methods. The plugins raise CompressionError when
invoked, to be replaced with working implementations later.

BUG=part of #3256
2026-06-30 22:53:59 +00:00
Esun Kim
aa7d6f9fd8
Added Error Handling & Defensive Programming Guide (#3539)
* Added Error Handling & Defensive Programming Guide

* Review
2026-06-30 22:24:50 +00:00
Ryan Kuester
9bfaeadf48
feat(compression): add LUT compression plugin (#3608)
Implement LutCompressor using the Compressor protocol. Lookup table
compression replaces tensor values with indices into a table of unique
values, producing packed indices and ancillary data in the format
expected by the TFLM DECODE kernel.

Supports per-tensor and per-channel compression, sizes value tables to
actual unique count, and handles unquantized tensors.

BUG=part of #3256
2026-06-24 22:44:48 +00:00
Måns Nilsson
acc13e42eb
Update CMSIS-NN download (#3607)
- Adapt build logic to not build float support since TFLM does not use
  the CMSIS-NN CMake path.

- Zero-initialize the cmsis_nn_lstm_context used by the int8 and int16
  unidirectional sequence LSTM paths so optional fields such as hidden_state do
  not contain stack garbage.

Change-Id: I5b44a3a231eb19023e004a5652b207930853648f

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
2026-06-24 04:03:35 +00:00
Ryan Kuester
074b75f8ec
feat(compression): add Compressor protocol (#3590)
Define the plugin interface for compression methods. Each compressor
implements the Compressor protocol with a compress() method that returns
encoded data and ancillary data.

BUG=part of #3256
2026-06-18 20:15:56 +00:00
Esun Kim
7ca66d18e7
Ensure int64 accumulation for bias-less 16x8 ops in TFLM kernels (#3598) 2026-06-16 23:58:19 +00:00
Esun Kim
b6ee3dc974
Fix missing quantizedBiasType setting for 16x8 requantization (#3597) 2026-06-16 15:53:23 +00:00
Ryan Kuester
e0b2c281f2
feat(compression): add DECODE operator types and metadata (#3589)
Add decode module with DecodeType constants and DecodeCommonMetadata,
per the TFLM DECODE Operator Design document.

BUG=part of #3256
2026-06-06 01:31:13 +00:00
Ryan Kuester
eea46d3d61
chore(compression): remove test_models.py (#3587)
Remove test_models module and its tests, now superseded by
model_editor.

BUG=part of #3256
2026-06-04 18:44:14 +00:00
Ryan Kuester
ac1fae3619
refactor(compression): replace test_models with model_editor in compress_test (#3586)
Replace dictionary-based test_models.build() with model_editor's
declarative API for building test models.

BUG=part of #3256
2026-06-02 16:09:54 +00:00
Ryan Kuester
730449fef1
chore(compression): remove model_facade.py (#3585)
Remove model_facade module and its tests, now superseded by
model_editor.

BUG=part of #3256
2026-06-01 23:03:06 +00:00
Ryan Kuester
c2accf5c8f
refactor(compression): migrate compress.py from model_facade to model_editor (#3580)
Replace model_facade with model_editor in compress.py and tests.
model_editor provides a cleaner API with better buffer and metadata
handling.

Update BUILD dependencies accordingly.

BUG=part of #3256
2026-06-01 16:36:48 +00:00
Esun Kim
63819227bc
Fix cmsis-nn pooling (#3584) 2026-06-01 16:24:20 +00:00
Ryan Kuester
7c26381de5
feat(compression): implement model_editor for TFLite model manipulation (#3575)
Implement unified module for creating, reading, and modifying TFLite
models with a clean API. The module eliminates manual index tracking
and buffer management through automatic bookkeeping, supporting both
declarative and imperative construction styles.

Wrapper classes (Tensor, Operator, Subgraph, Model) hold the underlying
flatbuffer T objects as backing storage rather than copying fields into
dataclasses. This ensures all schema fields are preserved during
read-modify-write cycles, even fields not explicitly handled by
model_editor. Future schema additions will be preserved automatically.

Add comprehensive test coverage including field preservation tests that
verify unhandled schema fields survive read-modify-write.

BUG=part of #3256
2026-05-29 21:42:17 +00:00
Ryan Kuester
db550c38c9
refactor(compression): hoist numpy dtype map into tensor_type (#3578)
Add a tensor_type module that holds the single mapping from a TFLite
TensorType to a numpy dtype, and convert view.py to use it. The mapping
was inlined in view.py; centralizing it gives the compression tooling
one place to maintain as more callers need to read tensor buffers as
numpy arrays.

tensor_type.to_numpy() raises ValueError for types with no clean numpy
equivalent (STRING, RESOURCE, VARIANT, BFLOAT16, and the sub-byte
integer types) instead of silently returning a wrong dtype. Only types
with an unambiguous little-endian numpy representation are mapped.

BUG=part of #3256
2026-05-28 21:56:37 +00:00
Esun Kim
cc99d0597f
Removed batch_size assert in depthwise_conv (#3562) 2026-05-27 16:41:22 +00:00
Esun Kim
2ba41b0f3e
Fixed rank support in pad and min/max (#3563) 2026-05-27 16:41:17 +00:00
Esun Kim
7914a2d7a1
Clean-up unused bzl load (#3576) 2026-05-26 22:55:55 +00:00
Ryan Kuester
068c6a59b6
build(bazel): inject tflite_micro shim via tflm_py_* wrappers (#3573)
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.
2026-05-26 19:51:58 +00:00
Esun Kim
d0890bb456
Updated CMSIS_NN to the latest (6d9d61d) (#3565) 2026-05-21 22:05:29 +00:00
Esun Kim
a9952453ab
Improve Check TfLite Files (#3566) 2026-05-21 14:40:16 -07:00
Esun Kim
9f5ac257ee
No tensorflow 2 (#3548) 2026-05-06 21:17:46 +00:00
Esun Kim
1c2bae841e
No tensorflow 1 (#3546)
* No tensorflow 1

* Vendoring our own utils

* Vendoering revise

* Removed unnecessary tf pythons

* Reformat
2026-05-06 18:31:12 +00:00
Esun Kim
cf8c42a16f
Align Conv INT16 accumulator logic with FullyConnected (#3537)
* Align Conv INT16 accumulator logic with FullyConnected

* Applied to optimized kernels

* Format fix
2026-05-06 13:02:51 +00:00
Esun Kim
51bee03bed
Default to 64-bit accumulation for 16x8 Fully Connected without bias (#3522) 2026-04-09 18:35:03 +00:00
Esun Kim
c36885e9e6
[Fix] Batch MatMul Op (#3413)
* Added BatchMatMulOpTestFloat32Test_BatchSizeTwo_Broadcast_LHSAdjoint

Added BatchMatMulOpTestFloat32Test_BatchSizeTwo_Broadcast_RHSAdjoint

* Fixed cmsis_nn/batch_matmul.cc
2026-04-09 18:34:59 +00:00
Nicolás Arrieta Larraza
f5302ed4fa
Add 16bit xtensa depthwise conv kernel support (#3481)
* Added 16x8 xtensa depthwise conv kernel

* Added int16 support only for HIFI5

* Code formatting
2026-03-18 16:23:13 +00:00
Esun Kim
5aa7a2e4b4
Format (#3477) 2026-02-12 13:49:57 -08:00
Esun Kim
ba95ae6972
Fixed generate_per_layer_tests.py (#3470) 2026-02-12 10:58:01 -08:00
Esun Kim
807c35d6a9
Bazel Module (#3364)
* Work

* Review update

* Enabled tests

* Bazel: Suppress warnings from external repositories

* Fixed whl_test

* Formatted

* More format
2026-02-11 14:11:47 -08:00
Esun Kim
183da3e302
Typo in code (#3447)
* Typo in code

* Format
2026-02-11 20:34:42 +00:00
Esun Kim
d7f46b6fb7
[Doc] Fix typos (#3446)
* Fix typos

* Typos

* More

* Last
2026-02-11 17:18:49 +00:00
Esun Kim
510a6c505c
pick 42ff343b # Fix handling of empty CSV files in generate_cc_arrays.py (#3423)
csv.
2026-02-10 23:25:19 +00:00
Esun Kim
c0564e46c5
[CI] More fixes (#3442)
* Fixed micro_allocator.cc

* Removed needs-mmap-rnd usage

* Disable python tests under bazel

* Removed -Werror
2026-02-10 13:54:49 -08: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
unmeshna017
5b93e5b3fe
Added activation function for CREF code of transpose_conv operator. (#3278) 2026-02-10 15:23:45 +00:00
unmeshna017
ef48280f08
Updated the CREF code of the resize nearest neighbor operator to use the half_pixel_centers attribute from params. (#3279) 2026-02-10 15:23:00 +00:00
Esun Kim
88f8587b3f
[T2] Refactor Group 8: Decode (#3375)
* Refactor t2-8

* Fix
2026-02-03 17:50:27 +00:00
Esun Kim
63d4dbd332
[T2] Refactor Group 9z: Compression (#3393)
* Refactor t2-9z

Refactor t2-11z

Refactor t2-19z

Refactor t2-7z

* Fix

* Review
2026-02-03 17:50:04 +00:00
Esun Kim
51bc0e8978
[T2] Refactor Group 3 (#3370)
* Refactor t2-3

* Fix

* Fix

* Fix API misuse
2026-02-03 17:28:07 +00:00
Esun Kim
a6cd602b1a
[T2] Refactor Group 19 (#3386)
* Refactor t2-19

* Undo
2026-02-02 17:51:09 +00:00
Esun Kim
95c1e6534d
[T2] Refactor Group 16 (#3383)
* Refactor t2-16

* Fix

* Fix
2026-02-02 17:50:50 +00:00
Esun Kim
e44f83652c
[T2] Refactor Group 11 (#3378)
* Refactor t2-11

* Undo
2026-02-02 17:50:01 +00:00
Esun Kim
1712dc2c33
[T2] Refactor Group 9 (#3376)
* Refactor t2-9

* Undo
2026-02-02 17:49:36 +00:00