Add a fluent builder API for creating compression specifications
without writing YAML strings. This is useful in scripts and
Jupyter notebooks.
Example usage:
spec = (compression.SpecBuilder()
.add_tensor(subgraph=0, tensor=2)
.with_lut(index_bitwidth=4)
.build())
BUG=#3125
Co-authored-by: suleshahid <110432064+suleshahid@users.noreply.github.com>
* Sync files related to Reverse_V2 from TFLite
#3110
* Added Reverse_V2 changes
BUG=fixes #3110
* Using stable_sort instead of sort & format fixes
* Replace std::stable_sort with qsort
* fix format issues
* fix format issues
* fix format issues
* Updated the changes as per the review
---------
Co-authored-by: suleshahid <110432064+suleshahid@users.noreply.github.com>
feat(python): add compression module to tflite_micro Python package
Integrate the TFLM compression tools into the tflite_micro Python
package, allowing users to compress models directly from Python code
that imports the package.
Usage:
from tflite_micro import compression
Details:
- Add compress_lib py_library target in compression BUILD
- Create compression package with __init__.py exposing public API
- Include compression module in Python package dependencies
- Add compression dependencies to wheel requirements
BUG=see description
@tensorflow/micro
Fixes MicroInterpreterContext::set_external_context so that it can be called during InterpreterState::kInit.
Add unit test for kInit state.
Cleanup other external context tests.
bug=fixes #3101
There are older toolchains that don't support C++17 and are still used in shipping products.
Rewrite hexdump.cc to not use C++17 features (std::byte and Class Template Argument Deduction). Also remove forcing of -std=libc for xtensa targets, which was added because stdlib isn't supported with -std=c++17.
BUG=410831256
As a unit test, it belongs on MICROLITE_TEST_SRCS, which gets filtered out of MICROLITE_CC_SRCS. Keeping it on the source list results in it being compiled into the tflm archive, where its main() function conflicts with the application's main.
Also, since hexdump.cc calls DebugVsnprintf(), we need to define it in debug_log.cc, also when TF_LITE_STRIP_ERROR_STRINGS is #defined, else compilation fails. Move the #ifdef TF_LITE_STRIP_ERROR_STRINGS to be inside the function implementation, rather around the whole function.
BUG=384562154
Added checks to ensure input, output quantization parameters are same.
Without this check, pooling ops would silently ignore even if the IO quantization parameters are different.
bug=fixes
Removing redundant assignments for CMSIS_PATH and adding the possibility to override Device Family Pack (DFP) path with a new CORTEX_DFP_PATH make variable.
This allows flexibility in where the CMSIS and DFP sources reside.
BUG=More flexible build structure
@tensorflow/micro
Handle the failure to allocate temporary memory for a TfLiteTensor in a more graceful way. This allows most kernels in the Prepare phase to not crash due to a DCHECK on memory allocation failure.
bug=fixes #3057
Compress using a single value table when a tensor is per-tensor
quantized, as indicated by the presence of only one quantization
scale and zero point. Update unit tests accordingly and augment
`test_models` to accommodate additional quantization fields.
Abandon the logic that a tensor should be compressed along the
NHWC channel dimension if the quantization parameters do not
specify an axis. Instead, fail with an error if the compression
axis cannot be inferred from the quantization parameters.
The interpreter already expects a single value table when a
tensor is per-tensor quantized.
BUG=part of #2636
Add instructions for using the tool with compressed models,
including profiling timing for decompression and alternate memory
regions. Update the tested targets list to include additional
Xtensa architectures. Provide example build and run commands for
compressed models with alternate decompression memory. Correct
typos and improve clarity in build instructions and example
outputs. Update compiler flags and example output to reflect
recent changes.
BUG=part of #2636
Add a check in `micro_allocator.cc` to verify the compression
metadata schema version. If the schema version in the metadata is
greater than the expected version, log a schema version mismatch
error and return a `nullptr`. This prevents potential issues
arising from using a newer, unsupported schema version.
BUG=part of #2636
Clarify the usage of `MicroContext::AllocateDecompressionScratchBuffer`
and`tflite::micro::GetTensorData` for handling decompressed tensor
data.
Add a section on alternate decompression memory regions,
explaining how to specify and use specialized memory for
decompression.
Update instructions for compressing models using a YAML
specification.
Simplify the model compression and alignment command examples.
Spin off new Generic Benchmark Application documentation.
BUG=part of #2636
Modify `PrintMemoryPlan` in `greedy_memory_planner.cc` for better
handling of tensor indices and scratch buffers.
Fix `total_ticks_per_tag_` usage in `micro_profiler.cc` and add
`ClearEvents` method.
Update `Makefile.inc` and `generic_model_benchmark.cc` to support
alternate memory regions and CRC32 checks for data integrity.
Include compression data in `metrics.cc` allocation records and
handle architecture-specific directives in
`show_meta_data.cc.template`.
BUG=see description
Add `AllocateCompressedTensorsList` method to manage compressed
tensor allocations. Update `RecordedAllocationType` to include
`kCompressionData` for tracking compression-related allocations.
Add `TestCompressedModel` test case to validate compressed tensor
allocation functionality.
BUG=part of #2636
Implement tensor decompression in op fully_connected. Extend
tests to validate operation on compressed tensors.
Include Xtensa extensions for decompression, as they are required
by the tests.
Fix the effect on memory_arena_threshold_test by setting a
different expected value for the persistent buffer allocation
when compression is configured in. The allocation was allowed to
vary by 3%; however, compression adds ~10%. Set the expected
value to the measured value when compression is configured in.
BUG=part of #2636
Decompress_test has some issues internally due to compatibility checking.
Changed define to 1 line for easier regex for internal change.
BUG=compression BUILD fix internal