xmos-ai-tools 1.3.2.dev180__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 +73 -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 +307 -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 +153 -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 +83 -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 +53 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/inference_engine.h +218 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/load_weights.h +64 -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_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 +79 -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 +68 -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 +64 -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 +651 -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.dev180.data/data/bin/xcore-opt +0 -0
- xmos_ai_tools-1.3.2.dev180.dist-info/METADATA +33 -0
- xmos_ai_tools-1.3.2.dev180.dist-info/RECORD +395 -0
- xmos_ai_tools-1.3.2.dev180.dist-info/WHEEL +5 -0
- xmos_ai_tools-1.3.2.dev180.dist-info/top_level.txt +1 -0
@@ -0,0 +1,341 @@
|
|
1
|
+
/* Copyright 2017 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_KERNELS_KERNEL_UTIL_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_KERNEL_UTIL_H_
|
17
|
+
|
18
|
+
#include <stdint.h>
|
19
|
+
|
20
|
+
#include <limits>
|
21
|
+
#ifndef TF_LITE_STATIC_MEMORY
|
22
|
+
#include <string>
|
23
|
+
#endif // TF_LITE_STATIC_MEMORY
|
24
|
+
|
25
|
+
#include "tensorflow/lite/core/c/builtin_op_data.h"
|
26
|
+
#include "tensorflow/lite/core/c/common.h"
|
27
|
+
#ifndef NDEBUG
|
28
|
+
#include "tensorflow/lite/kernels/op_macros.h"
|
29
|
+
#endif
|
30
|
+
|
31
|
+
namespace tflite_micro {
|
32
|
+
|
33
|
+
// A fair number of functions in this header have historically been inline.
|
34
|
+
// It is ok to change functions to not be inline if the latency with
|
35
|
+
// benchmark_model for MobileNet + MobileBERT is unaffected. If such a change is
|
36
|
+
// made, move the newly non-inlined function declarations to the top of this
|
37
|
+
// header file.
|
38
|
+
|
39
|
+
// Note: You must check if result is not null:
|
40
|
+
//
|
41
|
+
// TfLiteTensor* my_tensor = GetInput(context, node, kMyTensorIdx);
|
42
|
+
// TF_LITE_ENSURE(context, my_tensor != nullptr);
|
43
|
+
//
|
44
|
+
// This is because the index might point to the optional tensor constant
|
45
|
+
// (kTfLiteOptionalTensor) in which case there is no tensor to return.
|
46
|
+
const TfLiteTensor* GetInput(const TfLiteContext* context,
|
47
|
+
const TfLiteNode* node, int index);
|
48
|
+
|
49
|
+
// Same as `GetInput` but returns boolean and uses output argument for tensor.
|
50
|
+
//
|
51
|
+
// TfLiteTensor* my_tensor;
|
52
|
+
// TF_LITE_ENSURE_OK(context,
|
53
|
+
// GetInputSafe(context, node, kMyTensorIdx, &my_tensor));
|
54
|
+
// // can use my_tensor directly from here onwards, it is not nullptr
|
55
|
+
//
|
56
|
+
// Should be used in cases where the binary size is too large.
|
57
|
+
TfLiteStatus GetInputSafe(const TfLiteContext* context, const TfLiteNode* node,
|
58
|
+
int index, const TfLiteTensor** tensor);
|
59
|
+
|
60
|
+
// Note: You must check if result is not null:
|
61
|
+
//
|
62
|
+
// TfLiteTensor* my_tensor = GetVariableInput(context, node, kMyTensorIdx);
|
63
|
+
// TF_LITE_ENSURE(context, my_tensor != nullptr);
|
64
|
+
//
|
65
|
+
// This is because the index might point to the optional tensor constant
|
66
|
+
// (kTfLiteOptionalTensor) in which case there is no tensor to return.
|
67
|
+
TfLiteTensor* GetVariableInput(TfLiteContext* context, const TfLiteNode* node,
|
68
|
+
int index);
|
69
|
+
|
70
|
+
// Note: You must check if result is not null:
|
71
|
+
//
|
72
|
+
// TfLiteTensor* my_tensor = GetOutput(context, node, kMyTensorIdx);
|
73
|
+
// TF_LITE_ENSURE(context, my_tensor != nullptr);
|
74
|
+
//
|
75
|
+
// This is because the index might point to the optional tensor constant
|
76
|
+
// (kTfLiteOptionalTensor) in which case there is no tensor to return.
|
77
|
+
TfLiteTensor* GetOutput(TfLiteContext* context, const TfLiteNode* node,
|
78
|
+
int index);
|
79
|
+
|
80
|
+
// Same as `GetOutput` but returns boolean and uses output argument for tensor.
|
81
|
+
//
|
82
|
+
// TfLiteTensor* my_tensor;
|
83
|
+
// TF_LITE_ENSURE_OK(context,
|
84
|
+
// GetOutputSafe(context, node, kMyTensorIdx, &my_tensor));
|
85
|
+
// // can use my_tensor directly from here onwards, it is not nullptr
|
86
|
+
//
|
87
|
+
// Should be used in cases where the binary size is too large.
|
88
|
+
TfLiteStatus GetOutputSafe(const TfLiteContext* context, const TfLiteNode* node,
|
89
|
+
int index, TfLiteTensor** tensor);
|
90
|
+
|
91
|
+
// Note: You must check if result is not null:
|
92
|
+
//
|
93
|
+
// TfLiteTensor* my_tensor = GetOptionalInputTensor(context, node, kIdx);
|
94
|
+
// TF_LITE_ENSURE(context, my_tensor != nullptr);
|
95
|
+
//
|
96
|
+
// This is because the index might point to the optional tensor constant
|
97
|
+
// (kTfLiteOptionalTensor) in which case there is no tensor to return.
|
98
|
+
//
|
99
|
+
// Deprecated. GetInput has the same functionality.
|
100
|
+
const TfLiteTensor* GetOptionalInputTensor(const TfLiteContext* context,
|
101
|
+
const TfLiteNode* node, int index);
|
102
|
+
|
103
|
+
#ifndef TF_LITE_STATIC_MEMORY
|
104
|
+
// Note: You must check if result is not null:
|
105
|
+
//
|
106
|
+
// TfLiteTensor* my_tensor = GetTemporary(context, node, kMyTensorIdx);
|
107
|
+
// TF_LITE_ENSURE(context, my_tensor != nullptr);
|
108
|
+
//
|
109
|
+
// This is because the index might point to the optional tensor constant
|
110
|
+
// (kTfLiteOptionalTensor) in which case there is no tensor to return.
|
111
|
+
TfLiteTensor* GetTemporary(TfLiteContext* context, const TfLiteNode* node,
|
112
|
+
int index);
|
113
|
+
|
114
|
+
// Same as `GetTemporary` but returns boolean and uses output argument for
|
115
|
+
// tensor.
|
116
|
+
//
|
117
|
+
// TfLiteTensor* my_tensor;
|
118
|
+
// TF_LITE_ENSURE_OK(context,
|
119
|
+
// GetTemporarySafe(context, node, kMyTensorIdx,
|
120
|
+
// &my_tensor));
|
121
|
+
// // can use my_tensor directly from here onwards, it is not nullptr
|
122
|
+
//
|
123
|
+
// Should be used in cases where the binary size is too large.
|
124
|
+
TfLiteStatus GetTemporarySafe(const TfLiteContext* context,
|
125
|
+
const TfLiteNode* node, int index,
|
126
|
+
TfLiteTensor** tensor);
|
127
|
+
|
128
|
+
// Note: You must check if result is not null:
|
129
|
+
//
|
130
|
+
// TfLiteTensor* my_tensor = GetIntermediates(context, node, kMyTensorIdx);
|
131
|
+
// TF_LITE_ENSURE(context, my_tensor != nullptr);
|
132
|
+
//
|
133
|
+
// This is because the index might point to the optional tensor constant
|
134
|
+
// (kTfLiteOptionalTensor) in which case there is no tensor to return.
|
135
|
+
const TfLiteTensor* GetIntermediates(TfLiteContext* context,
|
136
|
+
const TfLiteNode* node, int index);
|
137
|
+
|
138
|
+
// Same as `GetIntermediates` but returns boolean and uses output argument for
|
139
|
+
// tensor.
|
140
|
+
//
|
141
|
+
// TfLiteTensor* my_tensor;
|
142
|
+
// TF_LITE_ENSURE_OK(context,
|
143
|
+
// GetIntermediatesSafe(context, node, kMyTensorIdx,
|
144
|
+
// &my_tensor));
|
145
|
+
// // can use my_tensor directly from here onwards, it is not nullptr
|
146
|
+
//
|
147
|
+
// Should be used in cases where the binary size is too large.
|
148
|
+
TfLiteStatus GetIntermediatesSafe(const TfLiteContext* context,
|
149
|
+
const TfLiteNode* node, int index,
|
150
|
+
TfLiteTensor** tensor);
|
151
|
+
#endif // TF_LITE_STATIC_MEMORY
|
152
|
+
|
153
|
+
inline int NumDimensions(const TfLiteTensor* t) { return t->dims->size; }
|
154
|
+
inline int SizeOfDimension(const TfLiteTensor* t, int dim) {
|
155
|
+
return t->dims->data[dim];
|
156
|
+
}
|
157
|
+
|
158
|
+
inline int NumInputs(const TfLiteNode* node) {
|
159
|
+
return node->inputs == nullptr ? 0 : node->inputs->size;
|
160
|
+
}
|
161
|
+
inline int NumOutputs(const TfLiteNode* node) {
|
162
|
+
return node->outputs == nullptr ? 0 : node->outputs->size;
|
163
|
+
}
|
164
|
+
|
165
|
+
#ifndef TF_LITE_STATIC_MEMORY
|
166
|
+
inline int NumIntermediates(const TfLiteNode* node) {
|
167
|
+
return node->intermediates->size;
|
168
|
+
}
|
169
|
+
#endif // TF_LITE_STATIC_MEMORY
|
170
|
+
|
171
|
+
inline int64_t NumElements(const int* dims, int num_dims) {
|
172
|
+
int64_t count = 1;
|
173
|
+
for (int i = 0; i < num_dims; ++i) {
|
174
|
+
#ifndef NDEBUG
|
175
|
+
if (count <= 0) {
|
176
|
+
break;
|
177
|
+
}
|
178
|
+
// Check that number of elements can fit in 32 bit int. Most of tflite
|
179
|
+
// assumes the result of `NumElements` is < MAX_INT and static or implicit
|
180
|
+
// casts to `int32_t` without any checks. It is more meaningful to check
|
181
|
+
// that the result fits into 32 bits than for standard overflow on 64 bit
|
182
|
+
// type.
|
183
|
+
TF_LITE_ASSERT(dims[i] < std::numeric_limits<int>::max() / count);
|
184
|
+
#endif
|
185
|
+
count *= dims[i];
|
186
|
+
}
|
187
|
+
return count;
|
188
|
+
}
|
189
|
+
|
190
|
+
inline int64_t NumElements(const TfLiteIntArray* dims) {
|
191
|
+
return NumElements(dims->data, dims->size);
|
192
|
+
}
|
193
|
+
|
194
|
+
inline int64_t NumElements(const TfLiteTensor* t) {
|
195
|
+
return NumElements(t->dims);
|
196
|
+
}
|
197
|
+
|
198
|
+
// Determines whether tensor is constant.
|
199
|
+
// TODO(b/138199592): Introduce new query which checks for constant OR
|
200
|
+
// persistent-read-only, which would be useful for most tensor kernels that
|
201
|
+
// are potentially dynamic based on the input tensor value availability at the
|
202
|
+
// time of prepare.
|
203
|
+
inline bool IsConstantTensor(const TfLiteTensor* tensor) {
|
204
|
+
return tensor->allocation_type == kTfLiteMmapRo;
|
205
|
+
}
|
206
|
+
|
207
|
+
inline bool IsConstantOrPersistentTensor(const TfLiteTensor* tensor) {
|
208
|
+
return IsConstantTensor(tensor) ||
|
209
|
+
(tensor->allocation_type == kTfLitePersistentRo);
|
210
|
+
}
|
211
|
+
|
212
|
+
// Determines whether tensor is dynamic. Note that a tensor can be non-const and
|
213
|
+
// not dynamic. This function specifically checks for a dynamic tensor.
|
214
|
+
inline bool IsDynamicTensor(const TfLiteTensor* tensor) {
|
215
|
+
return tensor->allocation_type == kTfLiteDynamic;
|
216
|
+
}
|
217
|
+
#ifndef TF_LITE_STATIC_MEMORY
|
218
|
+
// Sets tensor to dynamic.
|
219
|
+
inline void SetTensorToDynamic(TfLiteTensor* tensor) {
|
220
|
+
if (tensor->allocation_type != kTfLiteDynamic) {
|
221
|
+
TfLiteTensorDataFree(tensor);
|
222
|
+
tensor->allocation_type = kTfLiteDynamic;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
// Sets tensor to persistent and read-only.
|
227
|
+
inline void SetTensorToPersistentRo(TfLiteTensor* tensor) {
|
228
|
+
if (tensor->allocation_type != kTfLitePersistentRo) {
|
229
|
+
TfLiteTensorDataFree(tensor);
|
230
|
+
tensor->allocation_type = kTfLitePersistentRo;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
#endif // TF_LITE_STATIC_MEMORY
|
234
|
+
|
235
|
+
// Determines whether it is a hybrid op - one that has float inputs and
|
236
|
+
// quantized weights.
|
237
|
+
inline bool IsHybridOp(const TfLiteTensor* input, const TfLiteTensor* weight) {
|
238
|
+
return ((weight->type == kTfLiteUInt8 || weight->type == kTfLiteInt8) &&
|
239
|
+
input->type == kTfLiteFloat32);
|
240
|
+
}
|
241
|
+
|
242
|
+
// Check dimensionality match and populate OpData for Conv and DepthwiseConv.
|
243
|
+
TfLiteStatus PopulateConvolutionQuantizationParams(
|
244
|
+
TfLiteContext* context, const TfLiteTensor* input,
|
245
|
+
const TfLiteTensor* filter, const TfLiteTensor* bias, TfLiteTensor* output,
|
246
|
+
const TfLiteFusedActivation& activation, int32_t* multiplier, int* shift,
|
247
|
+
int32_t* output_activation_min, int32_t* output_activation_max,
|
248
|
+
int32_t* per_channel_multiplier, int32_t* per_channel_shift);
|
249
|
+
|
250
|
+
TfLiteStatus PopulateConvolutionQuantizationParams(
|
251
|
+
TfLiteContext* context, const TfLiteTensor* input,
|
252
|
+
const TfLiteTensor* filter, const TfLiteTensor* bias, TfLiteTensor* output,
|
253
|
+
const TfLiteFusedActivation& activation, int32_t* multiplier, int* shift,
|
254
|
+
int32_t* output_activation_min, int32_t* output_activation_max,
|
255
|
+
int32_t* per_channel_multiplier, int32_t* per_channel_shift,
|
256
|
+
int num_channels);
|
257
|
+
|
258
|
+
// Calculates the multiplication factor for a quantized convolution (or
|
259
|
+
// quantized depthwise convolution) involving the given tensors. Returns an
|
260
|
+
// error if the scales of the tensors are not compatible.
|
261
|
+
TfLiteStatus GetQuantizedConvolutionMultipler(TfLiteContext* context,
|
262
|
+
const TfLiteTensor* input,
|
263
|
+
const TfLiteTensor* filter,
|
264
|
+
const TfLiteTensor* bias,
|
265
|
+
TfLiteTensor* output,
|
266
|
+
double* multiplier);
|
267
|
+
|
268
|
+
TfLiteStatus GetQuantizedConvolutionMultipler(TfLiteContext* context,
|
269
|
+
const TfLiteTensor* input,
|
270
|
+
const TfLiteTensor* filter,
|
271
|
+
TfLiteTensor* output,
|
272
|
+
double* multiplier);
|
273
|
+
|
274
|
+
// Calculates the useful quantized range of an activation layer given its
|
275
|
+
// activation tensor.
|
276
|
+
TfLiteStatus CalculateActivationRangeQuantized(TfLiteContext* context,
|
277
|
+
TfLiteFusedActivation activation,
|
278
|
+
TfLiteTensor* output,
|
279
|
+
int32_t* act_min,
|
280
|
+
int32_t* act_max);
|
281
|
+
|
282
|
+
// Calculates the useful range of an activation layer given its activation
|
283
|
+
// tensor.a
|
284
|
+
template <typename T>
|
285
|
+
void CalculateActivationRange(TfLiteFusedActivation activation,
|
286
|
+
T* activation_min, T* activation_max) {
|
287
|
+
if (activation == kTfLiteActRelu) {
|
288
|
+
*activation_min = 0;
|
289
|
+
*activation_max = std::numeric_limits<T>::max();
|
290
|
+
} else if (activation == kTfLiteActRelu6) {
|
291
|
+
*activation_min = 0;
|
292
|
+
*activation_max = 6;
|
293
|
+
} else if (activation == kTfLiteActReluN1To1) {
|
294
|
+
*activation_min = -1;
|
295
|
+
*activation_max = 1;
|
296
|
+
} else {
|
297
|
+
*activation_min = std::numeric_limits<T>::lowest();
|
298
|
+
*activation_max = std::numeric_limits<T>::max();
|
299
|
+
}
|
300
|
+
}
|
301
|
+
|
302
|
+
// Return true if the given tensors have the same shape.
|
303
|
+
bool HaveSameShapes(const TfLiteTensor* input1, const TfLiteTensor* input2);
|
304
|
+
|
305
|
+
#if !defined(TF_LITE_STATIC_MEMORY)
|
306
|
+
// Gets the output shape from the input tensor.
|
307
|
+
TfLiteStatus GetOutputShapeFromInput(TfLiteContext* context,
|
308
|
+
const TfLiteTensor* input,
|
309
|
+
TfLiteIntArray** output_shape);
|
310
|
+
|
311
|
+
std::string GetShapeDebugString(const TfLiteIntArray* shape);
|
312
|
+
|
313
|
+
#endif // !defined(TF_LITE_STATIC_MEMORY)
|
314
|
+
|
315
|
+
// Calculates the output_shape that is necessary for element-wise operations
|
316
|
+
// with broadcasting involving the two input tensors.
|
317
|
+
TfLiteStatus CalculateShapeForBroadcast(TfLiteContext* context,
|
318
|
+
const TfLiteTensor* input1,
|
319
|
+
const TfLiteTensor* input2,
|
320
|
+
TfLiteIntArray** output_shape);
|
321
|
+
|
322
|
+
// Calculates the output_shape that is necessary for element-wise operations
|
323
|
+
// with broadcasting involving the three input tensors.
|
324
|
+
TfLiteStatus CalculateShapeForBroadcast(TfLiteContext* context,
|
325
|
+
const TfLiteTensor* input1,
|
326
|
+
const TfLiteTensor* input2,
|
327
|
+
const TfLiteTensor* input3,
|
328
|
+
TfLiteIntArray** output_shape);
|
329
|
+
|
330
|
+
// Return the size of given type in bytes. Return 0 in case of string.
|
331
|
+
int TfLiteTypeGetSize(TfLiteType type);
|
332
|
+
|
333
|
+
// Whether the current platform is mobile (Android or iOS).
|
334
|
+
bool IsMobilePlatform();
|
335
|
+
|
336
|
+
// Returns whether there is unspecified dimension in the tensor's dim signature.
|
337
|
+
bool HasUnspecifiedDimension(const TfLiteTensor* tensor);
|
338
|
+
|
339
|
+
} // namespace tflite_micro
|
340
|
+
|
341
|
+
#endif // TENSORFLOW_LITE_KERNELS_KERNEL_UTIL_H_
|
@@ -0,0 +1,49 @@
|
|
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
|
+
#ifndef TENSORFLOW_LITE_KERNELS_OP_MACROS_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_OP_MACROS_H_
|
17
|
+
|
18
|
+
#include "tensorflow/lite/micro/micro_log.h"
|
19
|
+
|
20
|
+
#if !defined(TF_LITE_MCU_DEBUG_LOG)
|
21
|
+
#include <cstdlib>
|
22
|
+
#define TFLITE_ABORT abort()
|
23
|
+
#else
|
24
|
+
inline void AbortImpl() {
|
25
|
+
MicroPrintf("HALTED");
|
26
|
+
while (1) {
|
27
|
+
}
|
28
|
+
}
|
29
|
+
#define TFLITE_ABORT AbortImpl();
|
30
|
+
#endif
|
31
|
+
|
32
|
+
#if defined(NDEBUG)
|
33
|
+
#define TFLITE_ASSERT_FALSE (static_cast<void>(0))
|
34
|
+
#else
|
35
|
+
#define TFLITE_ASSERT_FALSE TFLITE_ABORT
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#define TF_LITE_FATAL(msg) \
|
39
|
+
do { \
|
40
|
+
MicroPrintf("%s", (msg)); \
|
41
|
+
TFLITE_ABORT; \
|
42
|
+
} while (0)
|
43
|
+
|
44
|
+
#define TF_LITE_ASSERT(x) \
|
45
|
+
do { \
|
46
|
+
if (!(x)) TF_LITE_FATAL(#x); \
|
47
|
+
} while (0)
|
48
|
+
|
49
|
+
#endif // TENSORFLOW_LITE_KERNELS_OP_MACROS_H_
|
@@ -0,0 +1,115 @@
|
|
1
|
+
/* Copyright 2017 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_KERNELS_PADDING_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_PADDING_H_
|
17
|
+
|
18
|
+
#include "tensorflow/lite/core/c/builtin_op_data.h"
|
19
|
+
#include "tensorflow/lite/kernels/internal/types.h"
|
20
|
+
|
21
|
+
namespace tflite_micro {
|
22
|
+
|
23
|
+
inline int ComputePadding(int stride, int dilation_rate, int in_size,
|
24
|
+
int filter_size, int out_size) {
|
25
|
+
int effective_filter_size = (filter_size - 1) * dilation_rate + 1;
|
26
|
+
int padding = ((out_size - 1) * stride + effective_filter_size - in_size) / 2;
|
27
|
+
return padding > 0 ? padding : 0;
|
28
|
+
}
|
29
|
+
|
30
|
+
// It's not guaranteed that padding is symmetric. It's important to keep
|
31
|
+
// offset for algorithms need all paddings.
|
32
|
+
inline int ComputePaddingWithOffset(int stride, int dilation_rate, int in_size,
|
33
|
+
int filter_size, int out_size,
|
34
|
+
int* offset) {
|
35
|
+
int effective_filter_size = (filter_size - 1) * dilation_rate + 1;
|
36
|
+
int total_padding =
|
37
|
+
((out_size - 1) * stride + effective_filter_size - in_size);
|
38
|
+
total_padding = total_padding > 0 ? total_padding : 0;
|
39
|
+
*offset = total_padding % 2;
|
40
|
+
return total_padding / 2;
|
41
|
+
}
|
42
|
+
|
43
|
+
// Matching GetWindowedOutputSize in TensorFlow.
|
44
|
+
inline int ComputeOutSize(TfLitePadding padding, int image_size,
|
45
|
+
int filter_size, int stride, int dilation_rate = 1) {
|
46
|
+
int effective_filter_size = (filter_size - 1) * dilation_rate + 1;
|
47
|
+
|
48
|
+
// TODO(b/186448822): This uses 0 since the function has no other way to
|
49
|
+
// report error case
|
50
|
+
if (stride == 0) return 0;
|
51
|
+
|
52
|
+
switch (padding) {
|
53
|
+
case kTfLitePaddingSame:
|
54
|
+
return (image_size + stride - 1) / stride;
|
55
|
+
case kTfLitePaddingValid:
|
56
|
+
return (image_size + stride - effective_filter_size) / stride;
|
57
|
+
default:
|
58
|
+
return 0;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
inline TfLitePaddingValues ComputePaddingHeightWidth(
|
63
|
+
int stride_height, int stride_width, int dilation_rate_height,
|
64
|
+
int dilation_rate_width, int in_height, int in_width, int filter_height,
|
65
|
+
int filter_width, TfLitePadding padding, int* out_height, int* out_width) {
|
66
|
+
*out_width = ComputeOutSize(padding, in_width, filter_width, stride_width,
|
67
|
+
dilation_rate_width);
|
68
|
+
*out_height = ComputeOutSize(padding, in_height, filter_height, stride_height,
|
69
|
+
dilation_rate_height);
|
70
|
+
|
71
|
+
TfLitePaddingValues padding_values;
|
72
|
+
int offset = 0;
|
73
|
+
padding_values.height =
|
74
|
+
ComputePaddingWithOffset(stride_height, dilation_rate_height, in_height,
|
75
|
+
filter_height, *out_height, &offset);
|
76
|
+
padding_values.height_offset = offset;
|
77
|
+
padding_values.width =
|
78
|
+
ComputePaddingWithOffset(stride_width, dilation_rate_width, in_width,
|
79
|
+
filter_width, *out_width, &offset);
|
80
|
+
padding_values.width_offset = offset;
|
81
|
+
return padding_values;
|
82
|
+
}
|
83
|
+
|
84
|
+
inline Padding3DValues ComputePadding3DValues(
|
85
|
+
int stride_height, int stride_width, int stride_depth,
|
86
|
+
int dilation_rate_height, int dilation_rate_width, int dilation_rate_depth,
|
87
|
+
int in_height, int in_width, int in_depth, int filter_height,
|
88
|
+
int filter_width, int filter_depth, TfLitePadding padding, int* out_height,
|
89
|
+
int* out_width, int* out_depth) {
|
90
|
+
*out_width = ComputeOutSize(padding, in_width, filter_width, stride_width,
|
91
|
+
dilation_rate_width);
|
92
|
+
*out_height = ComputeOutSize(padding, in_height, filter_height, stride_height,
|
93
|
+
dilation_rate_height);
|
94
|
+
*out_depth = ComputeOutSize(padding, in_depth, filter_depth, stride_depth,
|
95
|
+
dilation_rate_depth);
|
96
|
+
|
97
|
+
Padding3DValues padding_values;
|
98
|
+
int offset = 0;
|
99
|
+
padding_values.depth =
|
100
|
+
ComputePaddingWithOffset(stride_depth, dilation_rate_depth, in_depth,
|
101
|
+
filter_depth, *out_depth, &offset);
|
102
|
+
padding_values.depth_offset = offset;
|
103
|
+
padding_values.height =
|
104
|
+
ComputePaddingWithOffset(stride_height, dilation_rate_height, in_height,
|
105
|
+
filter_height, *out_height, &offset);
|
106
|
+
padding_values.height_offset = offset;
|
107
|
+
padding_values.width =
|
108
|
+
ComputePaddingWithOffset(stride_width, dilation_rate_width, in_width,
|
109
|
+
filter_width, *out_width, &offset);
|
110
|
+
padding_values.width_offset = offset;
|
111
|
+
return padding_values;
|
112
|
+
}
|
113
|
+
} // namespace tflite_micro
|
114
|
+
|
115
|
+
#endif // TENSORFLOW_LITE_KERNELS_PADDING_H_
|
@@ -0,0 +1,100 @@
|
|
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
|
+
#ifndef TENSORFLOW_LITE_MICRO_ARENA_ALLOCATOR_IBUFFER_ALLOCATOR_H_
|
16
|
+
#define TENSORFLOW_LITE_MICRO_ARENA_ALLOCATOR_IBUFFER_ALLOCATOR_H_
|
17
|
+
|
18
|
+
#include <cstddef>
|
19
|
+
#include <cstdint>
|
20
|
+
|
21
|
+
#include "tensorflow/lite/c/c_api_types.h"
|
22
|
+
|
23
|
+
namespace tflite_micro {
|
24
|
+
// Interface classes that the TFLM framework relies on to get buffers it needs.
|
25
|
+
// There are two types of buffers that the TFLM framework requires: persistent
|
26
|
+
// and non-persistent. Persistent buffers, once allocated, are never freed by
|
27
|
+
// the TFLM framework. Non-persist buffers can be allocated and deallocated by
|
28
|
+
// the TFLM framework. This file defines two interfaces classes that TFLM
|
29
|
+
// framework will rely on to manage these buffers.
|
30
|
+
|
31
|
+
// Interface class for managing persistent buffers.
|
32
|
+
class IPersistentBufferAllocator {
|
33
|
+
public:
|
34
|
+
IPersistentBufferAllocator() {}
|
35
|
+
virtual ~IPersistentBufferAllocator() {}
|
36
|
+
|
37
|
+
// Allocates persistent memory. The persistent buffer is never freed.
|
38
|
+
virtual uint8_t* AllocatePersistentBuffer(size_t size, size_t alignment) = 0;
|
39
|
+
|
40
|
+
// Returns the size of all persistent allocations in bytes.
|
41
|
+
virtual size_t GetPersistentUsedBytes() const = 0;
|
42
|
+
};
|
43
|
+
|
44
|
+
// Interface class for managing non-persistent buffers.
|
45
|
+
// The default non-persistent buffers are temp buffers that are not resizable.
|
46
|
+
// Support of at least one resizable buffer is required.
|
47
|
+
class INonPersistentBufferAllocator {
|
48
|
+
public:
|
49
|
+
INonPersistentBufferAllocator() {}
|
50
|
+
virtual ~INonPersistentBufferAllocator() {}
|
51
|
+
|
52
|
+
// Allocates a temporary buffer. This buffer is not resizable.
|
53
|
+
virtual uint8_t* AllocateTemp(size_t size, size_t alignment) = 0;
|
54
|
+
|
55
|
+
// Signals that a temporary buffer is no longer needed.
|
56
|
+
virtual void DeallocateTemp(uint8_t* buf) = 0;
|
57
|
+
|
58
|
+
// Returns true if all temporary buffers are already deallocated.
|
59
|
+
virtual bool IsAllTempDeallocated() = 0;
|
60
|
+
|
61
|
+
// Signals that all temporary allocations can be reclaimed. TFLM calls this
|
62
|
+
// API when it knows that all temporary buffers that it requested has been
|
63
|
+
// deallocated. The goal of API is to facilitate implementations of
|
64
|
+
// INonPersistentBufferAllocator can reuse buffer with some reasonable
|
65
|
+
// complexity.
|
66
|
+
virtual TfLiteStatus ResetTempAllocations() = 0;
|
67
|
+
|
68
|
+
// Returns a buffer that is resizable viable ResizeBuffer().
|
69
|
+
virtual uint8_t* AllocateResizableBuffer(size_t size, size_t alignment) = 0;
|
70
|
+
|
71
|
+
// Resizes a buffer that is previously returned by the
|
72
|
+
// AllocateResizableBuffer.
|
73
|
+
virtual TfLiteStatus ResizeBuffer(uint8_t* resizable_buf, size_t size,
|
74
|
+
size_t alignment) = 0;
|
75
|
+
|
76
|
+
// Frees up the memory occupied by the resizable buffer.
|
77
|
+
virtual TfLiteStatus DeallocateResizableBuffer(uint8_t* resizable_buf) = 0;
|
78
|
+
|
79
|
+
// Returns a pointer pointing to the start of the overlay memory, which is
|
80
|
+
// used for activation tensors and scratch buffers by kernels at Invoke stage.
|
81
|
+
virtual uint8_t* GetOverlayMemoryAddress() const = 0;
|
82
|
+
|
83
|
+
// Reserves the size of the overlay memory. This overlay is reserved for the
|
84
|
+
// kernels at Invoke stage. This is referred to as the overlay because before
|
85
|
+
// Invoket state, the same memory can be used for temp buffers. The layout of
|
86
|
+
// the memory is planned by the memory planner separately at Invoke stage.
|
87
|
+
virtual TfLiteStatus ReserveNonPersistentOverlayMemory(size_t size,
|
88
|
+
size_t alignment) = 0;
|
89
|
+
|
90
|
+
// Returns the size of non-persistent buffer in use.
|
91
|
+
virtual size_t GetNonPersistentUsedBytes() const = 0;
|
92
|
+
|
93
|
+
// Returns the number of bytes available with a given alignment. This number
|
94
|
+
// takes in account any temporary allocations.
|
95
|
+
virtual size_t GetAvailableMemory(size_t alignment) const = 0;
|
96
|
+
};
|
97
|
+
|
98
|
+
} // namespace tflite_micro
|
99
|
+
|
100
|
+
#endif // TENSORFLOW_LITE_MICRO_ARENA_ALLOCATOR_IBUFFER_ALLOCATOR_H_
|