apps_mlearning_tflite-micro/tensorflow/lite/micro
Xie Lin 12699e7952 Tflm: Add per-channel quantization support to FULLY_CONNECTED operator
This commit fixes the inference accuracy issue in tflite-micro
by adding per-channel quantization support to the FULLY_CONNECTED operator.

Root Cause:
- The fork only supported per-tensor quantization (single scale/zero_point
  for entire weight tensor)
- Upstream added per-channel quantization (independent scale/zero_point per
  output channel) which provides better accuracy

Changes:
1. tensorflow/lite/micro/kernels/fully_connected.h
   - Added is_per_channel flag
   - Added per_channel_output_multiplier array
   - Added per_channel_output_shift array

2. tensorflow/lite/micro/kernels/fully_connected_common.cc
   - Updated quantization parameter calculation to support per-channel

3. tensorflow/lite/micro/kernels/fully_connected.cc
   - Added conditional execution path for per-channel quantization
   - Preserved TFLITE_MODEL_COMPILER customization

Signed-off-by: Xie Lin <xielin3@xiaomi.com>
2026-04-20 14:48:10 +08:00
..
arc_custom use unsigned data types for counter values (#1151) (#1169) 2022-06-11 00:39:35 +00:00
arc_emsdp Add MicroSnPrintf (#2343) 2026-04-20 14:47:55 +08:00
arena_allocator Introduce tflite_bridge to hide MicroErrorReporter 2022-11-18 20:09:02 +00:00
benchmarks Update readmes (#2216) 2023-09-11 15:56:50 +00:00
bluepill Add MicroSnPrintf (#2343) 2026-04-20 14:47:55 +08:00
ceva use unsigned data types for counter values (#1151) (#1169) 2022-06-11 00:39:35 +00:00
chre Add MicroSnPrintf (#2343) 2026-04-20 14:47:55 +08:00
cortex_m_corstone_300 Update readmes (#2216) 2023-09-11 15:56:50 +00:00
cortex_m_generic Fix cortex_m_generic C++ linkage errors (#2350) 2026-04-20 14:47:56 +08:00
docs Add kernel build flag for prioritizing speed or size (#2408) 2026-04-20 14:48:01 +08:00
examples Replace tensorflow-cpu usage with tensorflow (#2396) 2026-04-20 14:48:01 +08:00
hexagon use unsigned data types for counter values (#1151) (#1169) 2022-06-11 00:39:35 +00:00
integration_tests Replace tensorflow-cpu usage with tensorflow (#2396) 2026-04-20 14:48:01 +08:00
kernels Tflm: Add per-channel quantization support to FULLY_CONNECTED operator 2026-04-20 14:48:10 +08:00
memory_planner Fix a linker error: undefined kMaxBufferCount (#2458) 2026-04-20 14:48:01 +08:00
models Update visibility of recipes:resource_variable_lib and micro/models (#1999) 2023-05-25 20:34:25 +00:00
nuttx tflite-micro: fix some typos and bugs on specific product 2026-04-20 14:48:08 +08:00
python Replace tensorflow-cpu usage with tensorflow (#2396) 2026-04-20 14:48:01 +08:00
riscv32_generic Add MicroSnPrintf (#2343) 2026-04-20 14:47:55 +08:00
testing Replace tensorflow-cpu usage with tensorflow (#2396) 2026-04-20 14:48:01 +08:00
tflite_bridge Remove unnecessary visibility. (#2174) 2023-08-16 23:35:08 +00:00
tools tflite-micro: enhance benchmarking tool for NuttX integration and profiling 2026-04-20 14:48:10 +08:00
BUILD Add MicroSnPrintf (#2343) 2026-04-20 14:47:55 +08:00
build_def.bzl build: Add -Wno-unused-parameter to bazel build (#2237) 2023-09-21 02:23:53 +00:00
compatibility.h Manually sync'd code from upstream TF. (#2) 2021-04-09 11:17:58 -07:00
debug_log.cc tflite-micro: improve timing precision, logging, and memory management 2026-04-20 14:48:10 +08:00
debug_log.h Add MicroSnPrintf (#2343) 2026-04-20 14:47:55 +08:00
fake_micro_context.cc Make MicroContext and MicroGraph abstract (#2202) 2023-09-11 21:17:51 +00:00
fake_micro_context.h Make MicroContext and MicroGraph abstract (#2202) 2023-09-11 21:17:51 +00:00
fake_micro_context_test.cc Make MicroContext and MicroGraph abstract (#2202) 2023-09-11 21:17:51 +00:00
flatbuffer_utils.cc Remove support for big-endian in the TFLM inference code. (#689) 2021-11-17 11:42:30 -08:00
flatbuffer_utils.h Remove support for big-endian in the TFLM inference code. (#689) 2021-11-17 11:42:30 -08:00
flatbuffer_utils_test.cc Provide a lightweight version of flexbuffers::Vector (#243) 2021-07-08 23:45:01 +00:00
memory_arena_threshold_test.cc Revert "Compute output shapes for some kernels (#2356)" (#2390) 2026-04-20 14:47:58 +08:00
memory_helpers.cc Fix warning: 'Length' is deprecated (#1944) 2023-04-28 15:29:41 +00:00
memory_helpers.h Add templatised version of AlignSizeUp 2022-11-18 18:58:25 +00:00
memory_helpers_test.cc Add templatised version of AlignSizeUp 2022-11-18 18:58:25 +00:00
micro_allocation_info.cc Add support for offline planning in case of multiple subgraphs (#1195) 2023-03-29 04:05:07 +00:00
micro_allocation_info.h Introduce tflite_bridge to hide MicroErrorReporter 2022-11-18 20:09:02 +00:00
micro_allocation_info_test.cc clanup lifetimes of unused tensors 2022-12-14 18:24:04 +00:00
micro_allocator.cc Compile mechanism base. 2026-04-20 14:48:03 +08:00
micro_allocator.h Compile mechanism base. 2026-04-20 14:48:03 +08:00
micro_allocator_test.cc Add test for MicroAllocator null pointer check (#2108) 2023-07-06 17:35:47 +00:00
micro_arena_constants.h Create a header file to hold tflm arena related constants (#700) 2021-11-18 20:11:55 +00:00
micro_common.h Compile mechanism base. 2026-04-20 14:48:03 +08:00
micro_context.cc Make MicroContext and MicroGraph abstract (#2202) 2023-09-11 21:17:51 +00:00
micro_context.h Make MicroContext and MicroGraph abstract (#2202) 2023-09-11 21:17:51 +00:00
micro_graph.h Make MicroContext and MicroGraph abstract (#2202) 2023-09-11 21:17:51 +00:00
micro_interpreter.cc tflite: Delegate mechanism 2026-04-20 14:48:05 +08:00
micro_interpreter.h tflite: Delegate mechanism 2026-04-20 14:48:05 +08:00
micro_interpreter_context.cc tflite: Delegate mechanism 2026-04-20 14:48:05 +08:00
micro_interpreter_context.h tflite: Delegate mechanism 2026-04-20 14:48:05 +08:00
micro_interpreter_context_test.cc Make MicroContext and MicroGraph abstract (#2202) 2023-09-11 21:17:51 +00:00
micro_interpreter_graph.cc tflite: Delegate mechanism 2026-04-20 14:48:05 +08:00
micro_interpreter_graph.h tflite: Delegate mechanism 2026-04-20 14:48:05 +08:00
micro_interpreter_test.cc `Adds a test to MicroInterpreter Test for GetTensor Failure Case` (#2281) 2023-10-19 01:47:44 +00:00
micro_log.cc Add MicroSnPrintf (#2343) 2026-04-20 14:47:55 +08:00
micro_log.h Add MicroSnPrintf (#2343) 2026-04-20 14:47:55 +08:00
micro_log_test.cc Add MicroSnPrintf (#2343) 2026-04-20 14:47:55 +08:00
micro_mutable_op_resolver.h Sub int8 2026-04-20 14:48:06 +08:00
micro_mutable_op_resolver_test.cc TFLM swapping TfLiteRegistration_V1 struct to a new more embedded friendly api in the TFLMRegistration struct (#2001) 2023-05-26 06:48:51 +00:00
micro_op_resolver.cc TFLM swapping TfLiteRegistration_V1 struct to a new more embedded friendly api in the TFLMRegistration struct (#2001) 2023-05-26 06:48:51 +00:00
micro_op_resolver.h TFLM swapping TfLiteRegistration_V1 struct to a new more embedded friendly api in the TFLMRegistration struct (#2001) 2023-05-26 06:48:51 +00:00
micro_profiler.cc tflite-micro: improve timing precision, logging, and memory management 2026-04-20 14:48:10 +08:00
micro_profiler.h tflite-micro: improve timing precision, logging, and memory management 2026-04-20 14:48:10 +08:00
micro_profiler_interface.h Add virtual destructor to fix build error from `-Wnon-virtual-dtor`. 2022-09-26 16:46:02 +00:00
micro_resource_variable.cc Adds default values to MicroResourceVariable (#1750) 2023-02-17 22:37:45 +00:00
micro_resource_variable.h Adds default values to MicroResourceVariable (#1750) 2023-02-17 22:37:45 +00:00
micro_resource_variable_test.cc Adds default values to MicroResourceVariable (#1750) 2023-02-17 22:37:45 +00:00
micro_time.cc tflite-micro: improve timing precision, logging, and memory management 2026-04-20 14:48:10 +08:00
micro_time.h use unsigned data types for counter values (#1151) (#1169) 2022-06-11 00:39:35 +00:00
micro_time_test.cc use unsigned data types for counter values (#1151) (#1169) 2022-06-11 00:39:35 +00:00
micro_utils.cc Adding 4bit test case for conv.cc (#1573) 2022-11-22 13:56:11 -08:00
micro_utils.h Adding 4bit test case for conv.cc (#1573) 2022-11-22 13:56:11 -08:00
micro_utils_test.cc Simplify flexible array member representation in BufferPlan (#709) 2021-11-19 17:56:32 +00:00
mock_micro_graph.cc Make MicroContext and MicroGraph abstract (#2202) 2023-09-11 21:17:51 +00:00
mock_micro_graph.h Make MicroContext and MicroGraph abstract (#2202) 2023-09-11 21:17:51 +00:00
recording_micro_allocator.cc tflite-micro: improve timing precision, logging, and memory management 2026-04-20 14:48:10 +08:00
recording_micro_allocator.h tflite-micro: improve timing precision, logging, and memory management 2026-04-20 14:48:10 +08:00
recording_micro_allocator_test.cc remove usage of AllOpsResolver (#1947) 2023-05-03 02:07:45 +00:00
recording_micro_interpreter.h Remove TFLM Framework support to using ErrorReporter 2022-10-19 16:57:54 +00:00
system_setup.cc Manually sync'd code from upstream TF. (#2) 2021-04-09 11:17:58 -07:00
system_setup.h Manually sync'd code from upstream TF. (#2) 2021-04-09 11:17:58 -07:00
test_helper_custom_ops.cc TFLM swapping TfLiteRegistration_V1 struct to a new more embedded friendly api in the TFLMRegistration struct (#2001) 2023-05-26 06:48:51 +00:00
test_helper_custom_ops.h TFLM swapping TfLiteRegistration_V1 struct to a new more embedded friendly api in the TFLMRegistration struct (#2001) 2023-05-26 06:48:51 +00:00
test_helpers.cc Port BATCH_MATMUL (#2147) 2023-09-06 16:16:09 +00:00
test_helpers.h Fix zero-point calculation rounding error (#2326) 2026-04-20 14:47:55 +08:00
testing_helpers_test.cc Adding 4bit test case for conv.cc (#1573) 2022-11-22 13:56:11 -08:00