STT-tensorflow/tensorflow/lite/micro/tools/make
Nick Kreeger fbf407383c Reduce the size of TfLiteTensor for the TF Micro runtime.
This change uses the existing micro-specific build flag (TF_LITE_STATIC_MEMORY) to reduce the size of TfLiteTensor. In this build setting, only the minimum number of fields required for preparing and initializing a model in TFLM are used. This build define is opt-in only for internal builds and continues to be enabled by default in Makefile builds./

All TFLM internal targets can be built with this flag by adding '--copt=-DTF_LITE_STATIC_MEMORY'.

This change reduces the sizeof(TfLiteTensor) to 64 bytes (64bit systems) down from 112 bytes (64 bit systems).

TfLiteTensor struct reduced by 1.75x (~43% reduction)
Tail allocation reduced by: 2,592kb (~12.5% reduction)
Total allocation reduced by: 2,592kb (~12% reduction)

Optimized results from memory_arena_threshold_test:
Keyword Model:
--------------
[RecordingMicroAllocator] Arena allocation total 18448 bytes
[RecordingMicroAllocator] Arena allocation head 672 bytes
[RecordingMicroAllocator] Arena allocation tail 17776 bytes
[RecordingMicroAllocator] 'TfLiteTensor struct' used 3456 bytes with alignment overhead (requested 3456 bytes for 54 tensors)
[RecordingMicroAllocator] 'TfLiteTensor quantization data' used 1728 bytes with alignment overhead (requested 1728 bytes for 108 allocations)
[RecordingMicroAllocator] 'TfLiteTensor variable buffer data' used 10240 bytes with alignment overhead (requested 10240 bytes for 7 allocations)
[RecordingMicroAllocator] 'NodeAndRegistration struct' used 1200 bytes with alignment overhead (requested 1200 bytes for 15 NodeAndRegistration structs)
[RecordingMicroAllocator] 'Operator runtime data' used 148 bytes with alignment overhead (requested 148 bytes for 13 OpData structs)

Test Conv Model:
----------------
[RecordingMicroAllocator] Arena allocation total 10960 bytes
[RecordingMicroAllocator] Arena allocation head 7744 bytes
[RecordingMicroAllocator] Arena allocation tail 3216 bytes
[RecordingMicroAllocator] 'TfLiteTensor struct' used 960 bytes with alignment overhead (requested 960 bytes for 15 tensors)
[RecordingMicroAllocator] 'TfLiteTensor quantization data' used 768 bytes with alignment overhead (requested 752 bytes for 24 allocations)
[RecordingMicroAllocator] 'TfLiteTensor variable buffer data' used 0 bytes with alignment overhead (requested 0 bytes for 0 allocations)
[RecordingMicroAllocator] 'NodeAndRegistration struct' used 560 bytes with alignment overhead (requested 560 bytes for 7 NodeAndRegistration structs)
[RecordingMicroAllocator] 'Operator runtime data' used 136 bytes with alignment overhead (requested 136 bytes for 5 OpData structs)

PiperOrigin-RevId: 317335359
Change-Id: Ic3d4d2c3e62249f072ece8f621f9ef94eaa28589
2020-06-19 10:45:51 -07:00
..
ext_libs Merge pull request #38861 from mansnils:update_mve_flag 2020-06-17 16:52:02 -07:00
targets Merge pull request #40299 from HimaxWiseEyePlus:master 2020-06-17 16:45:55 -07:00
templates Optimized Arduino library by enabling precompilation 2020-06-18 15:21:09 -07:00
.gitignore Moved TensorFlow Lite Micro out of experimental folder 2019-12-09 11:43:28 -08:00
download_and_extract.sh Use CMSIS-NN optimized kernels for Arduino library 2020-06-12 16:17:33 -07:00
fix_arduino_subfolders_test.sh Moved TensorFlow Lite Micro out of experimental folder 2019-12-09 11:43:28 -08:00
fix_arduino_subfolders.py Merge pull request #32287 from jenselofsson:micro_recognition 2020-04-23 12:50:03 -07:00
generate_keil_project_test.sh
generate_keil_project.py Small adjustments on import spacing. 2019-12-19 16:00:05 -08:00
helper_functions.inc Merge pull request #38175 from sensiml:features/gen_projects 2020-06-10 11:22:20 -07:00
Makefile Reduce the size of TfLiteTensor for the TF Micro runtime. 2020-06-19 10:45:51 -07:00
merge_arduino_zips_test.sh Moved TensorFlow Lite Micro out of experimental folder 2019-12-09 11:43:28 -08:00
merge_arduino_zips.py Moved TensorFlow Lite Micro out of experimental folder 2019-12-09 11:43:28 -08:00
third_party_downloads.inc Merge pull request #40299 from HimaxWiseEyePlus:master 2020-06-17 16:45:55 -07:00
transform_arduino_source_test.sh
transform_arduino_source.py minor spelling tweaks 2020-03-08 15:41:21 +09:00
transform_esp_source_test.sh Moved TensorFlow Lite Micro out of experimental folder 2019-12-09 11:43:28 -08:00
transform_source.py minor spelling tweaks 2020-03-08 15:41:21 +09:00