xmos-ai-tools 1.3.2.dev80__py3-none-macosx_10_15_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xmos_ai_tools/__init__.py +7 -0
- xmos_ai_tools/io_server/__init__.py +151 -0
- xmos_ai_tools/runtime/__init__.py +0 -0
- xmos_ai_tools/runtime/buildfiles/aitoolslib.cmake +13 -0
- xmos_ai_tools/runtime/buildfiles/aitoolslib.make +8 -0
- xmos_ai_tools/runtime/include/flash_server.h +74 -0
- xmos_ai_tools/runtime/include/flatbuffers/allocator.h +68 -0
- xmos_ai_tools/runtime/include/flatbuffers/array.h +243 -0
- xmos_ai_tools/runtime/include/flatbuffers/base.h +474 -0
- xmos_ai_tools/runtime/include/flatbuffers/bfbs_generator.h +43 -0
- xmos_ai_tools/runtime/include/flatbuffers/buffer.h +142 -0
- xmos_ai_tools/runtime/include/flatbuffers/buffer_ref.h +53 -0
- xmos_ai_tools/runtime/include/flatbuffers/code_generators.h +235 -0
- xmos_ai_tools/runtime/include/flatbuffers/default_allocator.h +64 -0
- xmos_ai_tools/runtime/include/flatbuffers/detached_buffer.h +114 -0
- xmos_ai_tools/runtime/include/flatbuffers/flatbuffer_builder.h +1197 -0
- xmos_ai_tools/runtime/include/flatbuffers/flatbuffers.h +270 -0
- xmos_ai_tools/runtime/include/flatbuffers/flatc.h +111 -0
- xmos_ai_tools/runtime/include/flatbuffers/flexbuffers.h +1897 -0
- xmos_ai_tools/runtime/include/flatbuffers/grpc.h +300 -0
- xmos_ai_tools/runtime/include/flatbuffers/hash.h +127 -0
- xmos_ai_tools/runtime/include/flatbuffers/idl.h +1232 -0
- xmos_ai_tools/runtime/include/flatbuffers/minireflect.h +419 -0
- xmos_ai_tools/runtime/include/flatbuffers/pch/flatc_pch.h +39 -0
- xmos_ai_tools/runtime/include/flatbuffers/pch/pch.h +38 -0
- xmos_ai_tools/runtime/include/flatbuffers/reflection.h +502 -0
- xmos_ai_tools/runtime/include/flatbuffers/reflection_generated.h +1449 -0
- xmos_ai_tools/runtime/include/flatbuffers/registry.h +128 -0
- xmos_ai_tools/runtime/include/flatbuffers/stl_emulation.h +509 -0
- xmos_ai_tools/runtime/include/flatbuffers/string.h +64 -0
- xmos_ai_tools/runtime/include/flatbuffers/struct.h +53 -0
- xmos_ai_tools/runtime/include/flatbuffers/table.h +168 -0
- xmos_ai_tools/runtime/include/flatbuffers/util.h +690 -0
- xmos_ai_tools/runtime/include/flatbuffers/vector.h +370 -0
- xmos_ai_tools/runtime/include/flatbuffers/vector_downward.h +271 -0
- xmos_ai_tools/runtime/include/flatbuffers/verifier.h +283 -0
- xmos_ai_tools/runtime/include/ioserver.h +44 -0
- xmos_ai_tools/runtime/include/lib_nn/api/TransposeConv.h +24 -0
- xmos_ai_tools/runtime/include/lib_nn/api/add_int16.h +27 -0
- xmos_ai_tools/runtime/include/lib_nn/api/add_int16_transform.h +42 -0
- xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16.h +22 -0
- xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16_transform.h +34 -0
- xmos_ai_tools/runtime/include/lib_nn/api/expand_8_to_16.h +8 -0
- xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16.h +42 -0
- xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16_transform.h +71 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_api.h +15 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_bin_types.h +14 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_config.h +287 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_conv2d_structs.h +72 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_image.h +26 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_layers.h +303 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_op_helper.h +132 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_op_utils.h +150 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_operator.h +18 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_pooling.h +551 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_types.h +83 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_window_params.h +55 -0
- xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16.h +54 -0
- xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_kernel_transform.h +37 -0
- xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_mappings.h +13 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quadratic_approximation.h +82 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quadratic_interpolation.h +23 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16.h +22 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16_transform.h +33 -0
- xmos_ai_tools/runtime/include/lib_nn/api/version.h +13 -0
- xmos_ai_tools/runtime/include/lib_nn/api/vpu_memmove_word_aligned.h +15 -0
- xmos_ai_tools/runtime/include/lib_nn/api/vpu_memset_256.h +55 -0
- xmos_ai_tools/runtime/include/lib_nn/api/vpu_sim.h +118 -0
- xmos_ai_tools/runtime/include/lib_nn/api/xs3_vpu.h +216 -0
- xmos_ai_tools/runtime/include/lib_nn/api/xs3a_registers.h +2869 -0
- xmos_ai_tools/runtime/include/lib_nn/src/asm/asm_constants.h +41 -0
- xmos_ai_tools/runtime/include/lib_nn/src/asm/window_op_plan.h +25 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/fast_flash.h +47 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/inference_engine.h +218 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/memory_parallel_transport.h +52 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/version.h +13 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_config.h +17 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_device_memory.h +62 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_shared_config.h +31 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/conv2d_float.h +155 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_common.h +19 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_custom_options.h +28 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_error_reporter.h +32 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_interpreter.h +49 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_ops.h +71 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_profiler.h +49 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_utils.h +160 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/thread_call.h +119 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_defs.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_device.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_descriptors.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_requests.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud.h +518 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_conf_default.h +11 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_device.h +87 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_descriptors.h +191 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_requests.h +120 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/XUD_USB_Defines.h +70 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/hid.h +23 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio10.h +30 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio20.h +357 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudiocommon.h +168 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/delay_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/energy_flexbuffers_generated_data.h +28 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/fft_flexbuffers_generated_data.h +37 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_log_flexbuffers_generated_data.h +27 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_spectral_subtraction_flexbuffers_generated_data.h +26 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/framer_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/irfft.h +31 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/overlap_add_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/pcan_flexbuffers_generated_data.h +7 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/rfft.h +31 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/stacker_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/window_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/src/circular_buffer.h +118 -0
- xmos_ai_tools/runtime/include/signal/src/complex.h +29 -0
- xmos_ai_tools/runtime/include/signal/src/energy.h +38 -0
- xmos_ai_tools/runtime/include/signal/src/fft_auto_scale.h +35 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank.h +69 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank_log.h +38 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank_spectral_subtraction.h +73 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank_square_root.h +34 -0
- xmos_ai_tools/runtime/include/signal/src/irfft.h +84 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_common.h +49 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_float.h +31 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int16.h +30 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int32.h +31 -0
- xmos_ai_tools/runtime/include/signal/src/log.h +30 -0
- xmos_ai_tools/runtime/include/signal/src/max_abs.h +31 -0
- xmos_ai_tools/runtime/include/signal/src/msb.h +32 -0
- xmos_ai_tools/runtime/include/signal/src/overlap_add.h +46 -0
- xmos_ai_tools/runtime/include/signal/src/pcan_argc_fixed.h +41 -0
- xmos_ai_tools/runtime/include/signal/src/rfft.h +85 -0
- xmos_ai_tools/runtime/include/signal/src/square_root.h +32 -0
- xmos_ai_tools/runtime/include/signal/src/window.h +31 -0
- xmos_ai_tools/runtime/include/signal/testdata/fft_test_data.h +48 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/array.h +156 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/builtin_op_data.h +22 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/builtin_ops.h +241 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/c/builtin_op_data.h +20 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/c/c_api_types.h +26 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/c/common.h +30 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/context_util.h +54 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/api/error_reporter.h +72 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/api/flatbuffer_conversions.h +440 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/api/tensor_utils.h +28 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/c/builtin_op_data.h +626 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/c/c_api_types.h +178 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/c/common.h +1496 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/macros.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/bits.h +102 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft.h +50 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_io.h +34 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_util.h +34 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank.h +63 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_io.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.h +50 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_io.h +31 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_util.h +52 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_common.h +48 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_int16.h +33 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_lut.h +40 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_io.h +33 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_util.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction.h +46 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_io.h +36 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_util.h +50 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control_util.h +57 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_io.h +34 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_util.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/common.h +1358 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/compatibility.h +122 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/cppmath.h +40 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/max.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/min.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/optimized/neon_check.h +20 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor.h +141 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor_utils.h +623 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/quantization_util.h +292 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add.h +561 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add_n.h +86 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/arg_min_max.h +88 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_matmul.h +275 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_to_space_nd.h +101 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/binary_function.h +91 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_args.h +56 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_to.h +97 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/ceil.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/comparisons.h +271 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/concatenation.h +141 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/conv.h +289 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/cumsum.h +175 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depth_to_space.h +79 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h +100 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_uint8.h +319 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/dequantize.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/div.h +247 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/elu.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/exp.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fill.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_div.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_mod.h +44 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fully_connected.h +323 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/hard_swish.h +168 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/add.h +250 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/conv.h +241 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/depthwise_conv.h +291 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h +126 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/l2normalization.h +67 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/logistic.h +121 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mean.h +18 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mul.h +194 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h +264 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/tanh.h +117 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/transpose_conv.h +224 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/l2normalization.h +90 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/leaky_relu.h +69 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/log_softmax.h +256 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/logistic.h +132 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/lstm_cell.h +422 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/maximum_minimum.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/mul.h +267 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/neg.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pad.h +169 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pooling.h +303 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils.h +333 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils_impl.h +244 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/prelu.h +111 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h +140 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/quantize.h +89 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/reduce.h +491 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/requantize.h +70 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_bilinear.h +233 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_nearest_neighbor.h +102 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/round.h +51 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/select.h +151 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/slice.h +80 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/softmax.h +233 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_batch_nd.h +109 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_depth.h +80 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/strided_slice.h +147 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/sub.h +465 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/tanh.h +129 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose.h +203 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose_conv.h +225 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/runtime_shape.h +168 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/strided_slice_logic.h +278 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/tensor_ctypes.h +42 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/types.h +1096 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/kernel_util.h +341 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/op_macros.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/padding.h +115 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/ibuffer_allocator.h +100 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/non_persistent_arena_buffer_allocator.h +104 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/persistent_arena_buffer_allocator.h +58 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/recording_single_arena_buffer_allocator.h +63 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/single_arena_buffer_allocator.h +144 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/benchmarks/micro_benchmark.h +95 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/compatibility.h +32 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/cortex_m_generic/debug_log_callback.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/debug_log.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_model_settings.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/expected_output_data.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/input_data.h +108 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/network_model.h +166 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/detection_responder.h +32 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/image_provider.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/main_functions.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/model_settings.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/fake_micro_context.h +70 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/flatbuffer_utils.h +65 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activation_utils.h +57 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activations.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/add.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_function_specializations.h +141 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_interface.h +75 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_slicers.h +56 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_tf_utils.h +310 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buf_mgr.h +145 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buffers.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_common.h +24 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_tflm_lib.h +613 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/mcps_macros.h +115 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/types.h +1286 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer_flexbuffers_generated_data.h +22 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv.h +117 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv_test.h +94 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/depthwise_conv.h +80 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/dequantize.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/detection_postprocess_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ethosu.h +28 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/fully_connected.h +112 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/hard_swish.h +30 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_runner.h +86 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_util.h +150 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/leaky_relu.h +43 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logical.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logistic.h +42 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval.h +541 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval_test.h +817 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_shared.h +150 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_ops.h +158 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_tensor_utils.h +56 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/mul.h +74 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pad.h +27 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pooling.h +142 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/prelu.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/quantize.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reduce.h +65 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reshape.h +26 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/softmax.h +67 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/strided_slice.h +40 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/sub.h +60 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/svdf.h +100 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/conv_test_data.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/lstm_test_data.h +579 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/hifimini/fixedpoint_utils.h +139 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_eval.h +216 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_shared.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_add.h +48 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_conv.h +89 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_depthwise_conv.h +74 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_fully_connected.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pad.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pooling.h +76 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reduce.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reshape.h +44 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_softmax.h +58 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_svdf.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_helpers.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h +170 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/linear_memory_planner.h +53 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/memory_plan_struct.h +73 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/micro_memory_planner.h +95 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/non_persistent_buffer_planner_shim.h +133 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocation_info.h +138 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocator.h +351 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_arena_constants.h +28 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_common.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_context.h +176 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_graph.h +79 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter.h +189 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_context.h +125 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_graph.h +110 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_log.h +42 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_mutable_op_resolver.h +708 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_op_resolver.h +62 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler.h +140 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler_interface.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_resource_variable.h +89 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_time.h +36 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_utils.h +162 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/mock_micro_graph.h +60 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/interpreter/src/python_ops_resolver.h +21 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size.h +30 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size_wrapper.h +33 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_allocator.h +125 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_interpreter.h +69 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/system_setup.h +27 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helper_custom_ops.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helpers.h +334 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/micro_test.h +267 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/test_conv_model.h +23 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/flatbuffer_conversions_bridge.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h +36 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/log_utils.h +273 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/metrics.h +41 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/op_resolver.h +127 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/portable_type_to_tflitetype.h +75 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_generated.h +24644 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_utils.h +33 -0
- xmos_ai_tools/runtime/include/tile_ram_server.h +38 -0
- xmos_ai_tools/runtime/lib/libhost_xtflitemicro.a +0 -0
- xmos_ai_tools/runtime/lib/libxtflitemicro.a +0 -0
- xmos_ai_tools/xformer/__init__.py +60 -0
- xmos_ai_tools/xformer/flash.py +190 -0
- xmos_ai_tools/xinterpreters/__init__.py +1 -0
- xmos_ai_tools/xinterpreters/exceptions.py +38 -0
- xmos_ai_tools/xinterpreters/host_interpreter.py +652 -0
- xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.1.0.1.dylib +0 -0
- xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.dylib +0 -0
- xmos_ai_tools-1.3.2.dev80.data/data/bin/xcore-opt +0 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/METADATA +33 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/RECORD +395 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/WHEEL +5 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/top_level.txt +1 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
/* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
|
16
|
+
#ifndef TENSORFLOW_LITE_MICRO_RECORDING_MICRO_ALLOCATOR_H_
|
17
|
+
#define TENSORFLOW_LITE_MICRO_RECORDING_MICRO_ALLOCATOR_H_
|
18
|
+
|
19
|
+
#include "tensorflow/lite/micro/arena_allocator/recording_single_arena_buffer_allocator.h"
|
20
|
+
#include "tensorflow/lite/micro/compatibility.h"
|
21
|
+
#include "tensorflow/lite/micro/micro_allocator.h"
|
22
|
+
|
23
|
+
namespace tflite_micro {
|
24
|
+
|
25
|
+
// List of buckets currently recorded by this class. Each type keeps a list of
|
26
|
+
// allocated information during model initialization.
|
27
|
+
// TODO(b/169834511): Add tracking for scratch buffer allocations.
|
28
|
+
enum class RecordedAllocationType {
|
29
|
+
kTfLiteEvalTensorData,
|
30
|
+
kPersistentTfLiteTensorData,
|
31
|
+
kPersistentTfLiteTensorQuantizationData,
|
32
|
+
kPersistentBufferData,
|
33
|
+
kTfLiteTensorVariableBufferData,
|
34
|
+
kNodeAndRegistrationArray,
|
35
|
+
kOpData,
|
36
|
+
};
|
37
|
+
|
38
|
+
// Container for holding information about allocation recordings by a given
|
39
|
+
// type. Each recording contains the number of bytes requested, the actual bytes
|
40
|
+
// allocated (can defer from requested by alignment), and the number of items
|
41
|
+
// allocated.
|
42
|
+
struct RecordedAllocation {
|
43
|
+
size_t requested_bytes;
|
44
|
+
size_t used_bytes;
|
45
|
+
size_t count;
|
46
|
+
};
|
47
|
+
|
48
|
+
// Utility subclass of MicroAllocator that records all allocations
|
49
|
+
// inside the arena. A summary of allocations can be logged through the
|
50
|
+
// ErrorReporter by invoking LogAllocations(). This special allocator requires
|
51
|
+
// an instance of RecordingSingleArenaBufferAllocator to capture allocations in
|
52
|
+
// the head and tail. Arena allocation recording can be retrieved by type
|
53
|
+
// through the GetRecordedAllocation() function. This class should only be used
|
54
|
+
// for auditing memory usage or integration testing.
|
55
|
+
class RecordingMicroAllocator : public MicroAllocator {
|
56
|
+
public:
|
57
|
+
static RecordingMicroAllocator* Create(uint8_t* tensor_arena,
|
58
|
+
size_t arena_size);
|
59
|
+
|
60
|
+
// Returns the fixed amount of memory overhead of RecordingMicroAllocator.
|
61
|
+
static size_t GetDefaultTailUsage();
|
62
|
+
|
63
|
+
// Returns the recorded allocations information for a given allocation type.
|
64
|
+
RecordedAllocation GetRecordedAllocation(
|
65
|
+
RecordedAllocationType allocation_type) const;
|
66
|
+
|
67
|
+
const RecordingSingleArenaBufferAllocator* GetSimpleMemoryAllocator() const;
|
68
|
+
|
69
|
+
// Logs out through the ErrorReporter all allocation recordings by type
|
70
|
+
// defined in RecordedAllocationType.
|
71
|
+
void PrintAllocations() const;
|
72
|
+
|
73
|
+
void* AllocatePersistentBuffer(size_t bytes) override;
|
74
|
+
|
75
|
+
protected:
|
76
|
+
TfLiteStatus AllocateNodeAndRegistrations(
|
77
|
+
const Model* model, SubgraphAllocations* subgraph_allocations) override;
|
78
|
+
TfLiteStatus AllocateTfLiteEvalTensors(
|
79
|
+
const Model* model, SubgraphAllocations* subgraph_allocations) override;
|
80
|
+
TfLiteStatus AllocateVariables(
|
81
|
+
const SubGraph* subgraph, TfLiteEvalTensor* eval_tensors,
|
82
|
+
const int32_t* offline_planner_offsets) override;
|
83
|
+
// TODO(b/162311891): Once all kernels have been updated to the new API drop
|
84
|
+
// this method. It is only used to record TfLiteTensor persistent allocations.
|
85
|
+
TfLiteTensor* AllocatePersistentTfLiteTensorInternal() override;
|
86
|
+
|
87
|
+
// TODO(b/162311891): Once all kernels have been updated to the new API drop
|
88
|
+
// this function since all allocations for quantized data will take place in
|
89
|
+
// the temp section.
|
90
|
+
TfLiteStatus PopulateTfLiteTensorFromFlatbuffer(const Model* model,
|
91
|
+
TfLiteTensor* tensor,
|
92
|
+
int tensor_index,
|
93
|
+
int subgraph_index,
|
94
|
+
bool allocate_temp) override;
|
95
|
+
|
96
|
+
private:
|
97
|
+
RecordingMicroAllocator(RecordingSingleArenaBufferAllocator* memory_allocator,
|
98
|
+
MicroMemoryPlanner* memory_planner);
|
99
|
+
|
100
|
+
void PrintRecordedAllocation(RecordedAllocationType allocation_type,
|
101
|
+
const char* allocation_name,
|
102
|
+
const char* allocation_description) const;
|
103
|
+
|
104
|
+
RecordedAllocation SnapshotAllocationUsage() const;
|
105
|
+
void RecordAllocationUsage(const RecordedAllocation& snapshotted_allocation,
|
106
|
+
RecordedAllocation& recorded_allocation);
|
107
|
+
|
108
|
+
const RecordingSingleArenaBufferAllocator* recording_memory_allocator_;
|
109
|
+
|
110
|
+
RecordedAllocation recorded_tflite_eval_tensor_data_ = {};
|
111
|
+
RecordedAllocation recorded_persistent_tflite_tensor_data_ = {};
|
112
|
+
RecordedAllocation recorded_persistent_tflite_tensor_quantization_data_ = {};
|
113
|
+
RecordedAllocation recorded_persistent_buffer_data_ = {};
|
114
|
+
RecordedAllocation recorded_tflite_tensor_variable_buffer_data_ = {};
|
115
|
+
RecordedAllocation recorded_node_and_registration_array_data_ = {};
|
116
|
+
|
117
|
+
// TODO(b/187993291): Re-enable OpData allocating tracking.
|
118
|
+
RecordedAllocation recorded_op_data_ = {};
|
119
|
+
|
120
|
+
TF_LITE_REMOVE_VIRTUAL_DELETE
|
121
|
+
};
|
122
|
+
|
123
|
+
} // namespace tflite_micro
|
124
|
+
|
125
|
+
#endif // TENSORFLOW_LITE_MICRO_RECORDING_MICRO_ALLOCATOR_H_
|
@@ -0,0 +1,69 @@
|
|
1
|
+
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
|
16
|
+
#ifndef TENSORFLOW_LITE_MICRO_RECORDING_MICRO_INTERPRETER_H_
|
17
|
+
#define TENSORFLOW_LITE_MICRO_RECORDING_MICRO_INTERPRETER_H_
|
18
|
+
|
19
|
+
#include "tensorflow/lite/micro/micro_interpreter.h"
|
20
|
+
#include "tensorflow/lite/micro/micro_profiler_interface.h"
|
21
|
+
#include "tensorflow/lite/micro/recording_micro_allocator.h"
|
22
|
+
|
23
|
+
namespace tflite_micro {
|
24
|
+
|
25
|
+
// Utility subclass that enables internal recordings of the MicroInterpreter.
|
26
|
+
// This class should be used to audit and analyze memory arena usage for a given
|
27
|
+
// model and interpreter.
|
28
|
+
//
|
29
|
+
// After construction and the first Invoke() or AllocateTensors() call - the
|
30
|
+
// memory usage is recorded and available through the GetMicroAllocator()
|
31
|
+
// function. See RecordingMicroAlloctor for more details on what is currently
|
32
|
+
// recorded from arena allocations.
|
33
|
+
//
|
34
|
+
// It is recommended for users to increase the tensor arena size by at least 1kb
|
35
|
+
// to ensure enough additional memory is available for internal recordings.
|
36
|
+
class RecordingMicroInterpreter : public MicroInterpreter {
|
37
|
+
public:
|
38
|
+
RecordingMicroInterpreter(const Model* model,
|
39
|
+
const MicroOpResolver& op_resolver,
|
40
|
+
uint8_t* tensor_arena, size_t tensor_arena_size,
|
41
|
+
MicroResourceVariables* resource_variable = nullptr,
|
42
|
+
MicroProfilerInterface* profiler = nullptr)
|
43
|
+
: MicroInterpreter(
|
44
|
+
model, op_resolver,
|
45
|
+
RecordingMicroAllocator::Create(tensor_arena, tensor_arena_size),
|
46
|
+
resource_variable, profiler),
|
47
|
+
recording_micro_allocator_(
|
48
|
+
static_cast<const RecordingMicroAllocator&>(allocator())) {}
|
49
|
+
|
50
|
+
RecordingMicroInterpreter(const Model* model,
|
51
|
+
const MicroOpResolver& op_resolver,
|
52
|
+
RecordingMicroAllocator* allocator,
|
53
|
+
MicroResourceVariables* resource_variable = nullptr,
|
54
|
+
MicroProfilerInterface* profiler = nullptr)
|
55
|
+
: MicroInterpreter(model, op_resolver, allocator, resource_variable,
|
56
|
+
profiler),
|
57
|
+
recording_micro_allocator_(*allocator) {}
|
58
|
+
|
59
|
+
const RecordingMicroAllocator& GetMicroAllocator() const {
|
60
|
+
return recording_micro_allocator_;
|
61
|
+
}
|
62
|
+
|
63
|
+
private:
|
64
|
+
const RecordingMicroAllocator& recording_micro_allocator_;
|
65
|
+
};
|
66
|
+
|
67
|
+
} // namespace tflite_micro
|
68
|
+
|
69
|
+
#endif // TENSORFLOW_LITE_MICRO_RECORDING_MICRO_INTERPRETER_H_
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
#ifndef TENSORFLOW_LITE_MICRO_SYSTEM_SETUP_H_
|
16
|
+
#define TENSORFLOW_LITE_MICRO_SYSTEM_SETUP_H_
|
17
|
+
|
18
|
+
namespace tflite_micro {
|
19
|
+
|
20
|
+
// This should called during initialization of TFLM binaries and tests. It can
|
21
|
+
// be specialized if there is a need for custom target-specific intialization.
|
22
|
+
// For more information, see tensorflow/lite/micro/system_setup.cc.
|
23
|
+
void InitializeTarget();
|
24
|
+
|
25
|
+
} // namespace tflite_micro
|
26
|
+
|
27
|
+
#endif // TENSORFLOW_LITE_MICRO_SYSTEM_SETUP_H_
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
|
16
|
+
#ifndef TENSORFLOW_LITE_MICRO_TEST_HELPER_CUSTOM_OPS_H_
|
17
|
+
#define TENSORFLOW_LITE_MICRO_TEST_HELPER_CUSTOM_OPS_H_
|
18
|
+
|
19
|
+
#include <cstdint>
|
20
|
+
#include <limits>
|
21
|
+
|
22
|
+
#include "flatbuffers/flatbuffers.h" // from @flatbuffers
|
23
|
+
#include "tensorflow/lite/kernels/internal/compatibility.h"
|
24
|
+
#include "tensorflow/lite/kernels/internal/tensor_ctypes.h"
|
25
|
+
#include "tensorflow/lite/micro/micro_common.h"
|
26
|
+
#include "tensorflow/lite/micro/micro_utils.h"
|
27
|
+
#include "tensorflow/lite/portable_type_to_tflitetype.h"
|
28
|
+
#include "tensorflow/lite/schema/schema_generated.h"
|
29
|
+
|
30
|
+
namespace tflite_micro {
|
31
|
+
namespace testing {
|
32
|
+
|
33
|
+
class PackerOp {
|
34
|
+
public:
|
35
|
+
static const TFLMRegistration* getRegistration();
|
36
|
+
static TFLMRegistration* GetMutableRegistration();
|
37
|
+
static void* Init(TfLiteContext* context, const char* buffer, size_t length);
|
38
|
+
static void Free(TfLiteContext* context, void* buffer);
|
39
|
+
static TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node);
|
40
|
+
static TfLiteStatus Invoke(TfLiteContext* context, TfLiteNode* node);
|
41
|
+
|
42
|
+
private:
|
43
|
+
static bool freed_;
|
44
|
+
};
|
45
|
+
|
46
|
+
} // namespace testing
|
47
|
+
} // namespace tflite_micro
|
48
|
+
|
49
|
+
#endif // TENSORFLOW_LITE_MICRO_TEST_HELPER_CUSTOM_OPS_H_
|
@@ -0,0 +1,334 @@
|
|
1
|
+
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
|
16
|
+
#ifndef TENSORFLOW_LITE_MICRO_TEST_HELPERS_H_
|
17
|
+
#define TENSORFLOW_LITE_MICRO_TEST_HELPERS_H_
|
18
|
+
|
19
|
+
#include <algorithm>
|
20
|
+
#include <cstdint>
|
21
|
+
#include <limits>
|
22
|
+
#include <type_traits>
|
23
|
+
|
24
|
+
#include "flatbuffers/flatbuffers.h" // from @flatbuffers
|
25
|
+
#include "tensorflow/lite/c/common.h"
|
26
|
+
#include "tensorflow/lite/kernels/internal/compatibility.h"
|
27
|
+
#include "tensorflow/lite/kernels/internal/tensor_ctypes.h"
|
28
|
+
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
|
29
|
+
#include "tensorflow/lite/micro/micro_utils.h"
|
30
|
+
#include "tensorflow/lite/portable_type_to_tflitetype.h"
|
31
|
+
#include "tensorflow/lite/schema/schema_generated.h"
|
32
|
+
|
33
|
+
namespace tflite_micro {
|
34
|
+
namespace testing {
|
35
|
+
|
36
|
+
constexpr int kOfflinePlannerHeaderSize = 3;
|
37
|
+
using TestingOpResolver = tflite_micro::MicroMutableOpResolver<10>;
|
38
|
+
|
39
|
+
struct NodeConnection_ {
|
40
|
+
std::initializer_list<int32_t> input;
|
41
|
+
std::initializer_list<int32_t> output;
|
42
|
+
};
|
43
|
+
typedef struct NodeConnection_ NodeConnection;
|
44
|
+
|
45
|
+
// A simple operator that returns the median of the input with the number of
|
46
|
+
// times the kernel was invoked. The implementation below is deliberately
|
47
|
+
// complicated, just to demonstrate how kernel memory planning works.
|
48
|
+
class SimpleStatefulOp {
|
49
|
+
static constexpr int kBufferNotAllocated = 0;
|
50
|
+
// Inputs:
|
51
|
+
static constexpr int kInputTensor = 0;
|
52
|
+
// Outputs:
|
53
|
+
static constexpr int kMedianTensor = 0;
|
54
|
+
static constexpr int kInvokeCount = 1;
|
55
|
+
struct OpData {
|
56
|
+
int* invoke_count = nullptr;
|
57
|
+
int sorting_buffer = kBufferNotAllocated;
|
58
|
+
};
|
59
|
+
|
60
|
+
public:
|
61
|
+
static const TFLMRegistration* getRegistration();
|
62
|
+
static TFLMRegistration* GetMutableRegistration();
|
63
|
+
static void* Init(TfLiteContext* context, const char* buffer, size_t length);
|
64
|
+
static TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node);
|
65
|
+
static TfLiteStatus Invoke(TfLiteContext* context, TfLiteNode* node);
|
66
|
+
};
|
67
|
+
|
68
|
+
class MockCustom {
|
69
|
+
public:
|
70
|
+
static const TFLMRegistration* getRegistration();
|
71
|
+
static TFLMRegistration* GetMutableRegistration();
|
72
|
+
static void* Init(TfLiteContext* context, const char* buffer, size_t length);
|
73
|
+
static void Free(TfLiteContext* context, void* buffer);
|
74
|
+
static TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node);
|
75
|
+
static TfLiteStatus Invoke(TfLiteContext* context, TfLiteNode* node);
|
76
|
+
|
77
|
+
static bool freed_;
|
78
|
+
};
|
79
|
+
|
80
|
+
// A simple operator with the purpose of testing multiple inputs. It returns
|
81
|
+
// the sum of the inputs.
|
82
|
+
class MultipleInputs {
|
83
|
+
public:
|
84
|
+
static const TFLMRegistration* getRegistration();
|
85
|
+
static TFLMRegistration* GetMutableRegistration();
|
86
|
+
static void* Init(TfLiteContext* context, const char* buffer, size_t length);
|
87
|
+
static void Free(TfLiteContext* context, void* buffer);
|
88
|
+
static TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node);
|
89
|
+
static TfLiteStatus Invoke(TfLiteContext* context, TfLiteNode* node);
|
90
|
+
|
91
|
+
static bool freed_;
|
92
|
+
};
|
93
|
+
|
94
|
+
// A simple no-op operator.
|
95
|
+
class NoOp {
|
96
|
+
public:
|
97
|
+
static const TFLMRegistration* getRegistration();
|
98
|
+
static TFLMRegistration* GetMutableRegistration();
|
99
|
+
static void* Init(TfLiteContext* context, const char* buffer, size_t length);
|
100
|
+
static void Free(TfLiteContext* context, void* buffer);
|
101
|
+
static TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node);
|
102
|
+
static TfLiteStatus Invoke(TfLiteContext* context, TfLiteNode* node);
|
103
|
+
|
104
|
+
static bool freed_;
|
105
|
+
};
|
106
|
+
|
107
|
+
// Returns an Op Resolver that can be used in the testing code.
|
108
|
+
TfLiteStatus GetTestingOpResolver(TestingOpResolver& op_resolver);
|
109
|
+
|
110
|
+
// Returns a simple example flatbuffer TensorFlow Lite model. Contains 1 input,
|
111
|
+
// 1 layer of weights, 1 output Tensor, and 1 operator.
|
112
|
+
const Model* GetSimpleMockModel();
|
113
|
+
|
114
|
+
// Returns a flatbuffer TensorFlow Lite model with more inputs, variable
|
115
|
+
// tensors, and operators.
|
116
|
+
const Model* GetComplexMockModel();
|
117
|
+
|
118
|
+
// Returns a simple example flatbuffer TensorFlow Lite model. Contains 1 input,
|
119
|
+
// 1 layer of weights, 1 output Tensor, and 1 operator.
|
120
|
+
// The size of all three tensors is 256 x 256, which is larger than what other
|
121
|
+
// models provide from this test helper.
|
122
|
+
const Model* GetModelWith256x256Tensor();
|
123
|
+
|
124
|
+
// Returns a simple flatbuffer model with two branches.
|
125
|
+
const Model* GetSimpleModelWithBranch();
|
126
|
+
|
127
|
+
// Returns a simple example flatbuffer TensorFlow Lite model. Contains 3 inputs,
|
128
|
+
// 1 output Tensor, and 1 operator.
|
129
|
+
const Model* GetSimpleMultipleInputsModel();
|
130
|
+
|
131
|
+
// Returns a simple flatbuffer model with offline planned tensors
|
132
|
+
// @param[in] num_tensors Number of tensors in the model.
|
133
|
+
// @param[in] metadata_buffer Metadata for offline planner.
|
134
|
+
// @param[in] node_con List of connections, i.e. operators
|
135
|
+
// in the model.
|
136
|
+
// @param[in] num_conns Number of connections.
|
137
|
+
// @param[in] num_subgraph_inputs How many of the input tensors are in
|
138
|
+
// the subgraph inputs. The default value
|
139
|
+
// of 0 means all of the input tensors
|
140
|
+
// are in the subgraph input list. There
|
141
|
+
// must be at least 1 input tensor in the
|
142
|
+
// subgraph input list.
|
143
|
+
const Model* GetModelWithOfflinePlanning(int num_tensors,
|
144
|
+
const int32_t* metadata_buffer,
|
145
|
+
NodeConnection* node_conn,
|
146
|
+
int num_conns,
|
147
|
+
int num_subgraph_inputs = 0);
|
148
|
+
|
149
|
+
// Returns a flatbuffer with a single operator, two inputs (one unused) and one
|
150
|
+
// output.
|
151
|
+
const Model* GetModelWithUnusedInputs();
|
152
|
+
|
153
|
+
// Returns a flatbuffer with a single operator, zero inputs and two outputs
|
154
|
+
// (one unused).
|
155
|
+
const Model* GetModelWithUnusedOperatorOutputs();
|
156
|
+
|
157
|
+
// Returns a flatbuffer model with `simple_stateful_op`
|
158
|
+
const Model* GetSimpleStatefulModel();
|
159
|
+
|
160
|
+
// Returns a flatbuffer model with "if" and two subgraphs.
|
161
|
+
const Model* GetSimpleModelWithSubgraphsAndIf();
|
162
|
+
|
163
|
+
// Returns a flatbuffer model with "if" and two subgraphs one of which is empty.
|
164
|
+
const Model* GetSimpleModelWithIfAndEmptySubgraph();
|
165
|
+
|
166
|
+
// Returns a flatbuffer model with "while" and three subgraphs.
|
167
|
+
const Model* GetSimpleModelWithSubgraphsAndWhile();
|
168
|
+
|
169
|
+
// Returns a flatbuffer model with "if" and two subgraphs and the input tensor 1
|
170
|
+
// of "if" subgraph overlaps with the input tensor 2 of subgraph 1.
|
171
|
+
const Model* GetModelWithIfAndSubgraphInputTensorOverlap();
|
172
|
+
|
173
|
+
// Returns a flatbuffer model with null subgraph/operator inputs and outputs.
|
174
|
+
const Model* GetSimpleModelWithNullInputsAndOutputs();
|
175
|
+
|
176
|
+
// Builds a one-dimensional flatbuffer tensor of the given size.
|
177
|
+
const Tensor* Create1dFlatbufferTensor(int size, bool is_variable = false);
|
178
|
+
|
179
|
+
// Builds a one-dimensional flatbuffer tensor of the given size with
|
180
|
+
// quantization metadata.
|
181
|
+
const Tensor* CreateQuantizedFlatbufferTensor(int size);
|
182
|
+
|
183
|
+
// Creates a one-dimensional tensor with no quantization metadata.
|
184
|
+
const Tensor* CreateMissingQuantizationFlatbufferTensor(int size);
|
185
|
+
|
186
|
+
// Creates a vector of flatbuffer buffers.
|
187
|
+
const flatbuffers::Vector<flatbuffers::Offset<Buffer>>*
|
188
|
+
CreateFlatbufferBuffers();
|
189
|
+
|
190
|
+
// Performs a simple string comparison without requiring standard C library.
|
191
|
+
int TestStrcmp(const char* a, const char* b);
|
192
|
+
|
193
|
+
void PopulateContext(TfLiteTensor* tensors, int tensors_size,
|
194
|
+
TfLiteContext* context);
|
195
|
+
|
196
|
+
// Create a TfLiteIntArray from an array of ints. The first element in the
|
197
|
+
// supplied array must be the size of the array expressed as an int.
|
198
|
+
TfLiteIntArray* IntArrayFromInts(const int* int_array);
|
199
|
+
|
200
|
+
// Create a TfLiteFloatArray from an array of floats. The first element in the
|
201
|
+
// supplied array must be the size of the array expressed as a float.
|
202
|
+
TfLiteFloatArray* FloatArrayFromFloats(const float* floats);
|
203
|
+
|
204
|
+
// Assumes that `src_tensor` is a buffer where each element is a 4-bit value
|
205
|
+
// stored in 8-bit.
|
206
|
+
// Returns a new buffer that is packed densely with 2 4-bit values in a byte.
|
207
|
+
// The packing format is low-bits-first, i.e. the lower nibble of a byte is
|
208
|
+
// filled first, followed by the upper nibble.
|
209
|
+
void PackInt4ValuesDenselyInPlace(uint8_t* src_buffer, int buffer_size);
|
210
|
+
|
211
|
+
template <typename T>
|
212
|
+
TfLiteTensor CreateTensor(const T* data, TfLiteIntArray* dims,
|
213
|
+
const bool is_variable = false,
|
214
|
+
TfLiteType type = kTfLiteNoType) {
|
215
|
+
TfLiteTensor result;
|
216
|
+
result.dims = dims;
|
217
|
+
result.params = {};
|
218
|
+
result.quantization = {kTfLiteNoQuantization, nullptr};
|
219
|
+
result.is_variable = is_variable;
|
220
|
+
result.allocation_type = kTfLiteMemNone;
|
221
|
+
result.data.data = const_cast<T*>(data);
|
222
|
+
result.bytes = ElementCount(*dims) * sizeof(T);
|
223
|
+
result.data.data = const_cast<T*>(data);
|
224
|
+
|
225
|
+
if (type == kTfLiteInt4) {
|
226
|
+
result.type = kTfLiteInt4;
|
227
|
+
PackInt4ValuesDenselyInPlace(tflite_micro::GetTensorData<uint8_t>(&result),
|
228
|
+
ElementCount(*dims));
|
229
|
+
result.bytes = ((ElementCount(*dims) + 1) / 2);
|
230
|
+
} else {
|
231
|
+
// Const cast is used to allow passing in const and non-const arrays within
|
232
|
+
// a single CreateTensor method. A Const array should be used for immutable
|
233
|
+
// input tensors and non-const array should be used for mutable and output
|
234
|
+
// tensors.
|
235
|
+
result.type = typeToTfLiteType<T>();
|
236
|
+
}
|
237
|
+
return result;
|
238
|
+
}
|
239
|
+
|
240
|
+
template <typename T>
|
241
|
+
TfLiteTensor CreateQuantizedTensor(const T* data, TfLiteIntArray* dims,
|
242
|
+
const float scale, const int zero_point = 0,
|
243
|
+
const bool is_variable = false,
|
244
|
+
TfLiteType type = kTfLiteNoType) {
|
245
|
+
TfLiteTensor result = CreateTensor(data, dims, is_variable, type);
|
246
|
+
result.params = {scale, zero_point};
|
247
|
+
result.quantization = {kTfLiteAffineQuantization, nullptr};
|
248
|
+
return result;
|
249
|
+
}
|
250
|
+
|
251
|
+
template <typename T>
|
252
|
+
TfLiteTensor CreateQuantizedTensor(const float* input, T* quantized,
|
253
|
+
TfLiteIntArray* dims, float scale,
|
254
|
+
int zero_point, bool is_variable = false,
|
255
|
+
TfLiteType type = kTfLiteNoType) {
|
256
|
+
int input_size = ElementCount(*dims);
|
257
|
+
tflite_micro::Quantize(input, quantized, input_size, scale, zero_point);
|
258
|
+
return CreateQuantizedTensor(quantized, dims, scale, zero_point, is_variable,
|
259
|
+
type);
|
260
|
+
}
|
261
|
+
|
262
|
+
TfLiteTensor CreateQuantizedBiasTensor(const float* data, int16_t* quantized,
|
263
|
+
TfLiteIntArray* dims, float input_scale,
|
264
|
+
float weights_scale,
|
265
|
+
bool is_variable = false);
|
266
|
+
|
267
|
+
TfLiteTensor CreateQuantizedBiasTensor(const float* data, int32_t* quantized,
|
268
|
+
TfLiteIntArray* dims, float input_scale,
|
269
|
+
float weights_scale,
|
270
|
+
bool is_variable = false);
|
271
|
+
|
272
|
+
TfLiteTensor CreateQuantizedBiasTensor(const float* data,
|
273
|
+
std::int64_t* quantized,
|
274
|
+
TfLiteIntArray* dims, float input_scale,
|
275
|
+
float weights_scale,
|
276
|
+
bool is_variable = false);
|
277
|
+
|
278
|
+
// Quantizes int32_t bias tensor with per-channel weights determined by input
|
279
|
+
// scale multiplied by weight scale for each channel.
|
280
|
+
TfLiteTensor CreatePerChannelQuantizedBiasTensor(
|
281
|
+
const float* input, int32_t* quantized, TfLiteIntArray* dims,
|
282
|
+
float input_scale, float* weight_scales, float* scales, int* zero_points,
|
283
|
+
TfLiteAffineQuantization* affine_quant, int quantized_dimension,
|
284
|
+
bool is_variable = false);
|
285
|
+
|
286
|
+
// Quantizes int64_t bias tensor with per-channel weights determined by input
|
287
|
+
// scale multiplied by weight scale for each channel.
|
288
|
+
TfLiteTensor CreatePerChannelQuantizedBiasTensor(
|
289
|
+
const float* input, std::int64_t* quantized, TfLiteIntArray* dims,
|
290
|
+
float input_scale, float* weight_scales, float* scales, int* zero_points,
|
291
|
+
TfLiteAffineQuantization* affine_quant, int quantized_dimension,
|
292
|
+
bool is_variable = false);
|
293
|
+
|
294
|
+
TfLiteTensor CreateSymmetricPerChannelQuantizedTensor(
|
295
|
+
const float* input, int8_t* quantized, TfLiteIntArray* dims, float* scales,
|
296
|
+
int* zero_points, TfLiteAffineQuantization* affine_quant,
|
297
|
+
int quantized_dimension, bool is_variable = false,
|
298
|
+
TfLiteType tensor_weight_type = kTfLiteNoType);
|
299
|
+
|
300
|
+
// Returns the number of tensors in the default subgraph for a tflite_micro::Model.
|
301
|
+
size_t GetModelTensorCount(const Model* model);
|
302
|
+
|
303
|
+
// Derives the asymmetric quantization scaling factor from a min and max range.
|
304
|
+
template <typename T>
|
305
|
+
inline float ScaleFromMinMax(const float min, const float max) {
|
306
|
+
return (max - min) /
|
307
|
+
static_cast<float>((std::numeric_limits<T>::max() * 1.0) -
|
308
|
+
std::numeric_limits<T>::min());
|
309
|
+
}
|
310
|
+
|
311
|
+
// Derives the symmetric quantization scaling factor from a min and max range.
|
312
|
+
template <typename T>
|
313
|
+
inline float SymmetricScaleFromMinMax(const float min, const float max) {
|
314
|
+
const int32_t kScale =
|
315
|
+
std::numeric_limits<typename std::make_signed<T>::type>::max();
|
316
|
+
const float range = std::max(std::abs(min), std::abs(max));
|
317
|
+
if (range == 0) {
|
318
|
+
return 1.0f;
|
319
|
+
} else {
|
320
|
+
return range / kScale;
|
321
|
+
}
|
322
|
+
}
|
323
|
+
|
324
|
+
// Derives the quantization zero point from a min and max range.
|
325
|
+
template <typename T>
|
326
|
+
inline int ZeroPointFromMinMax(const float min, const float max) {
|
327
|
+
return static_cast<int>(std::numeric_limits<T>::min()) +
|
328
|
+
static_cast<int>(-min / ScaleFromMinMax<T>(min, max) + 0.5f);
|
329
|
+
}
|
330
|
+
|
331
|
+
} // namespace testing
|
332
|
+
} // namespace tflite_micro
|
333
|
+
|
334
|
+
#endif // TENSORFLOW_LITE_MICRO_TEST_HELPERS_H_
|