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,189 @@
|
|
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_MICRO_INTERPRETER_H_
|
16
|
+
#define TENSORFLOW_LITE_MICRO_MICRO_INTERPRETER_H_
|
17
|
+
|
18
|
+
#include <cstddef>
|
19
|
+
#include <cstdint>
|
20
|
+
|
21
|
+
#include "flatbuffers/flatbuffers.h" // from @flatbuffers
|
22
|
+
#include "tensorflow/lite/c/c_api_types.h"
|
23
|
+
#include "tensorflow/lite/c/common.h"
|
24
|
+
#include "tensorflow/lite/core/api/error_reporter.h"
|
25
|
+
#include "tensorflow/lite/kernels/internal/tensor_ctypes.h"
|
26
|
+
#include "tensorflow/lite/micro/micro_allocator.h"
|
27
|
+
#include "tensorflow/lite/micro/micro_interpreter_context.h"
|
28
|
+
#include "tensorflow/lite/micro/micro_interpreter_graph.h"
|
29
|
+
#include "tensorflow/lite/micro/micro_op_resolver.h"
|
30
|
+
#include "tensorflow/lite/micro/micro_profiler_interface.h"
|
31
|
+
#include "tensorflow/lite/portable_type_to_tflitetype.h"
|
32
|
+
#include "tensorflow/lite/schema/schema_generated.h"
|
33
|
+
|
34
|
+
/// Copied from tensorflow/lite/version.h to avoid a dependency chain into
|
35
|
+
// tensorflow/core.
|
36
|
+
#define TFLITE_SCHEMA_VERSION (3)
|
37
|
+
|
38
|
+
namespace tflite_micro {
|
39
|
+
|
40
|
+
class MicroInterpreter {
|
41
|
+
public:
|
42
|
+
// The lifetime of the model, op resolver, tensor arena, error reporter,
|
43
|
+
// resource variables, and profiler must be at least as long as that of the
|
44
|
+
// interpreter object, since the interpreter may need to access them at any
|
45
|
+
// time. This means that you should usually create them with the same scope as
|
46
|
+
// each other, for example having them all allocated on the stack as local
|
47
|
+
// variables through a top-level function. The interpreter doesn't do any
|
48
|
+
// deallocation of any of the pointed-to objects, ownership remains with the
|
49
|
+
// caller.
|
50
|
+
MicroInterpreter(const Model* model, const MicroOpResolver& op_resolver,
|
51
|
+
uint8_t* tensor_arena, size_t tensor_arena_size,
|
52
|
+
MicroResourceVariables* resource_variables = nullptr,
|
53
|
+
MicroProfilerInterface* profiler = nullptr,
|
54
|
+
bool preserve_all_tensors = false);
|
55
|
+
|
56
|
+
// Create an interpreter instance using an existing MicroAllocator instance.
|
57
|
+
// This constructor should be used when creating an allocator that needs to
|
58
|
+
// have allocation handled in more than one interpreter or for recording
|
59
|
+
// allocations inside the interpreter. The lifetime of the allocator must be
|
60
|
+
// as long as that of the interpreter object.
|
61
|
+
MicroInterpreter(const Model* model, const MicroOpResolver& op_resolver,
|
62
|
+
MicroAllocator* allocator,
|
63
|
+
MicroResourceVariables* resource_variables = nullptr,
|
64
|
+
MicroProfilerInterface* profiler = nullptr);
|
65
|
+
|
66
|
+
~MicroInterpreter();
|
67
|
+
|
68
|
+
// Runs through the model and allocates all necessary input, output and
|
69
|
+
// intermediate tensors.
|
70
|
+
TfLiteStatus AllocateTensors();
|
71
|
+
|
72
|
+
// In order to support partial graph runs for strided models, this can return
|
73
|
+
// values other than kTfLiteOk and kTfLiteError.
|
74
|
+
// TODO(b/149795762): Add this to the TfLiteStatus enum.
|
75
|
+
TfLiteStatus Invoke();
|
76
|
+
|
77
|
+
// This is the recommended API for an application to pass an external payload
|
78
|
+
// pointer as an external context to kernels. The life time of the payload
|
79
|
+
// pointer should be at least as long as this interpreter. TFLM supports only
|
80
|
+
// one external context.
|
81
|
+
TfLiteStatus SetMicroExternalContext(void* external_context_payload);
|
82
|
+
|
83
|
+
TfLiteTensor* input(size_t index);
|
84
|
+
size_t inputs_size() const {
|
85
|
+
return model_->subgraphs()->Get(0)->inputs()->size();
|
86
|
+
}
|
87
|
+
const flatbuffers::Vector<int32_t>& inputs() const {
|
88
|
+
return *model_->subgraphs()->Get(0)->inputs();
|
89
|
+
}
|
90
|
+
TfLiteTensor* input_tensor(size_t index) { return input(index); }
|
91
|
+
template <class T>
|
92
|
+
T* typed_input_tensor(int tensor_index) {
|
93
|
+
if (TfLiteTensor* tensor_ptr = input_tensor(tensor_index)) {
|
94
|
+
if (tensor_ptr->type == typeToTfLiteType<T>()) {
|
95
|
+
return GetTensorData<T>(tensor_ptr);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
return nullptr;
|
99
|
+
}
|
100
|
+
|
101
|
+
TfLiteTensor* output(size_t index);
|
102
|
+
size_t outputs_size() const {
|
103
|
+
return model_->subgraphs()->Get(0)->outputs()->size();
|
104
|
+
}
|
105
|
+
const flatbuffers::Vector<int32_t>& outputs() const {
|
106
|
+
return *model_->subgraphs()->Get(0)->outputs();
|
107
|
+
}
|
108
|
+
TfLiteTensor* output_tensor(size_t index) { return output(index); }
|
109
|
+
template <class T>
|
110
|
+
T* typed_output_tensor(int tensor_index) {
|
111
|
+
if (TfLiteTensor* tensor_ptr = output_tensor(tensor_index)) {
|
112
|
+
if (tensor_ptr->type == typeToTfLiteType<T>()) {
|
113
|
+
return GetTensorData<T>(tensor_ptr);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
return nullptr;
|
117
|
+
}
|
118
|
+
|
119
|
+
// Returns a pointer to the tensor for the corresponding tensor_index
|
120
|
+
TfLiteEvalTensor* GetTensor(int tensor_index, int subgraph_index = 0);
|
121
|
+
|
122
|
+
// Reset the state to be what you would expect when the interpreter is first
|
123
|
+
// created. i.e. after Init and Prepare is called for the very first time.
|
124
|
+
TfLiteStatus Reset();
|
125
|
+
|
126
|
+
TfLiteStatus initialization_status() const { return initialization_status_; }
|
127
|
+
|
128
|
+
// Populates node and registration pointers representing the inference graph
|
129
|
+
// of the model from values inside the flatbuffer (loaded from the TfLiteModel
|
130
|
+
// instance). Persistent data (e.g. operator data) is allocated from the
|
131
|
+
// arena.
|
132
|
+
TfLiteStatus PrepareNodeAndRegistrationDataFromFlatbuffer();
|
133
|
+
|
134
|
+
// For debugging only.
|
135
|
+
// Returns the actual used arena in bytes. This method gives the optimal arena
|
136
|
+
// size. It's only available after `AllocateTensors` has been called.
|
137
|
+
// Note that normally `tensor_arena` requires 16 bytes alignment to fully
|
138
|
+
// utilize the space. If it's not the case, the optimial arena size would be
|
139
|
+
// arena_used_bytes() + 16.
|
140
|
+
size_t arena_used_bytes() const { return allocator_.used_bytes(); }
|
141
|
+
|
142
|
+
// Returns True if all Tensors are being preserves
|
143
|
+
// TODO(b/297106074) : revisit making C++ example or test for
|
144
|
+
// preserve_all_tesnors
|
145
|
+
bool preserve_all_tensors() const {
|
146
|
+
return allocator_.preserves_all_tensor();
|
147
|
+
}
|
148
|
+
|
149
|
+
size_t operators_size(int sg) const { return model_->subgraphs()->Get(sg)->operators()->size(); }
|
150
|
+
|
151
|
+
// For debugging only.
|
152
|
+
const NodeAndRegistration node_and_registration(int node_index, int sg) {
|
153
|
+
return graph_.GetAllocations()[sg].node_and_registrations[node_index];
|
154
|
+
}
|
155
|
+
|
156
|
+
protected:
|
157
|
+
const MicroAllocator& allocator() const { return allocator_; }
|
158
|
+
const TfLiteContext& context() const { return context_; }
|
159
|
+
|
160
|
+
private:
|
161
|
+
// TODO(b/158263161): Consider switching to Create() function to enable better
|
162
|
+
// error reporting during initialization.
|
163
|
+
void Init(MicroProfilerInterface* profiler);
|
164
|
+
|
165
|
+
// Gets the current subgraph index used from within context methods.
|
166
|
+
int get_subgraph_index() { return graph_.GetCurrentSubgraphIndex(); }
|
167
|
+
|
168
|
+
const Model* model_;
|
169
|
+
const MicroOpResolver& op_resolver_;
|
170
|
+
TfLiteContext context_ = {};
|
171
|
+
MicroAllocator& allocator_;
|
172
|
+
MicroInterpreterGraph graph_;
|
173
|
+
bool tensors_allocated_;
|
174
|
+
|
175
|
+
TfLiteStatus initialization_status_;
|
176
|
+
|
177
|
+
ScratchBufferHandle* scratch_buffer_handles_ = nullptr;
|
178
|
+
|
179
|
+
// TODO(b/162311891): Clean these pointers up when this class supports buffers
|
180
|
+
// from TfLiteEvalTensor.
|
181
|
+
TfLiteTensor** input_tensors_;
|
182
|
+
TfLiteTensor** output_tensors_;
|
183
|
+
|
184
|
+
MicroInterpreterContext micro_context_;
|
185
|
+
};
|
186
|
+
|
187
|
+
} // namespace tflite_micro
|
188
|
+
|
189
|
+
#endif // TENSORFLOW_LITE_MICRO_MICRO_INTERPRETER_H_
|
@@ -0,0 +1,125 @@
|
|
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_MICRO_INTERPRETER_CONTEXT_H_
|
17
|
+
#define TENSORFLOW_LITE_MICRO_MICRO_INTERPRETER_CONTEXT_H_
|
18
|
+
|
19
|
+
#include "tensorflow/lite/c/common.h"
|
20
|
+
#include "tensorflow/lite/micro/micro_allocator.h"
|
21
|
+
#include "tensorflow/lite/micro/micro_context.h"
|
22
|
+
#include "tensorflow/lite/micro/micro_interpreter_graph.h"
|
23
|
+
#include "tensorflow/lite/micro/micro_log.h"
|
24
|
+
|
25
|
+
namespace tflite_micro {
|
26
|
+
|
27
|
+
// A full implementation of the MicroContext, to be used by the
|
28
|
+
// MicroInterpreter. Kernels should not depend on this directly. Instead they
|
29
|
+
// should only depend on the MicroContext.
|
30
|
+
class MicroInterpreterContext : public MicroContext {
|
31
|
+
public:
|
32
|
+
// Enum that allows MicroContext to keep track of the stages different memory
|
33
|
+
// planning APIs are available to kernels.
|
34
|
+
enum class InterpreterState {
|
35
|
+
kInit,
|
36
|
+
kPrepare,
|
37
|
+
kMemoryPlanning,
|
38
|
+
kInvoke,
|
39
|
+
};
|
40
|
+
|
41
|
+
// Does not take any ownership, and all pointers must refer to valid objects
|
42
|
+
// that outlive the one constructed.
|
43
|
+
MicroInterpreterContext(MicroAllocator* allocator, const Model* model,
|
44
|
+
MicroInterpreterGraph* graph);
|
45
|
+
virtual ~MicroInterpreterContext();
|
46
|
+
|
47
|
+
// Allocate persistent buffer which has the same life time as the interpreter.
|
48
|
+
// Returns nullptr on failure.
|
49
|
+
// The memory is allocated from the tail.
|
50
|
+
// This method is only available in Init or Prepare stage.
|
51
|
+
// Virtual so that it can be faked for kernel tests.
|
52
|
+
virtual void* AllocatePersistentBuffer(size_t bytes) override;
|
53
|
+
|
54
|
+
// Request a scratch buffer in the arena through static memory planning.
|
55
|
+
// This method is only available in Prepare stage and the buffer is allocated
|
56
|
+
// by the interpreter between Prepare and Eval stage. In Eval stage,
|
57
|
+
// GetScratchBuffer API can be used to fetch the address.
|
58
|
+
// Virtual so that it can be faked for kernel tests.
|
59
|
+
virtual TfLiteStatus RequestScratchBufferInArena(size_t bytes,
|
60
|
+
int* buffer_idx) override;
|
61
|
+
|
62
|
+
// Get the scratch buffer pointer.
|
63
|
+
// This method is only available in Eval stage.
|
64
|
+
// Virtual so that it can be faked for kernel tests.
|
65
|
+
virtual void* GetScratchBuffer(int buffer_idx) override;
|
66
|
+
|
67
|
+
// Returns a temporary TfLiteTensor struct for a given index.
|
68
|
+
// Virtual so that it can be faked for kernel tests.
|
69
|
+
virtual TfLiteTensor* AllocateTempTfLiteTensor(int tensor_idx) override;
|
70
|
+
virtual TfLiteTensor* AllocateTempTfLiteTensor(int tensor_idx, int sg) override;
|
71
|
+
|
72
|
+
// Deallocates a temp TfLiteTensor.
|
73
|
+
// Virtual so that it can be faked for kernel tests.
|
74
|
+
virtual void DeallocateTempTfLiteTensor(TfLiteTensor* tensor) override;
|
75
|
+
|
76
|
+
// Returns a pointer to a temporary buffer (from the arena).
|
77
|
+
// This API is only valid from the kernel's Prepare function and
|
78
|
+
// the buffer's lifetime is also that of the Prepare function.
|
79
|
+
// Virtual so that it can be faked for kernel tests.
|
80
|
+
virtual uint8_t* AllocateTempBuffer(size_t size, size_t alignment) override;
|
81
|
+
|
82
|
+
// Signals that the temporary buffer is no longer needed.
|
83
|
+
// Virtual so that it can be faked for kernel tests.
|
84
|
+
virtual void DeallocateTempBuffer(uint8_t* buffer) override;
|
85
|
+
|
86
|
+
// Returns a TfLiteEvalTensor struct for a given index.
|
87
|
+
// Virtual so that it can be faked for kernel tests.
|
88
|
+
virtual TfLiteEvalTensor* GetEvalTensor(int tensor_idx) override;
|
89
|
+
virtual TfLiteEvalTensor* GetEvalTensor(int tensor_idx, int sg) override;
|
90
|
+
|
91
|
+
// Sets the State of MemoryPlanning MicroInterpreterContext
|
92
|
+
void SetInterpreterState(InterpreterState state);
|
93
|
+
|
94
|
+
// Sets the State of MemoryPlanning MicroInterpreterContext
|
95
|
+
InterpreterState GetInterpreterState() const;
|
96
|
+
|
97
|
+
// Does not take ownership of the pointer and the pointer must refer to valid
|
98
|
+
// an object that outlive this class instance.
|
99
|
+
// This can only be called once to set one external context.
|
100
|
+
TfLiteStatus set_external_context(void* external_context_payload) override;
|
101
|
+
|
102
|
+
void* external_context() override { return external_context_payload_; }
|
103
|
+
|
104
|
+
MicroGraph& graph() override { return graph_; }
|
105
|
+
|
106
|
+
// Sets the pointer to a list of ScratchBufferHandle instances.
|
107
|
+
// Not API between TFLM and kernels. Primarily used by the framework for
|
108
|
+
// housekeeping in MicroInterpreterContext.
|
109
|
+
void SetScratchBufferHandles(ScratchBufferHandle* scratch_buffer_handles);
|
110
|
+
|
111
|
+
private:
|
112
|
+
MicroAllocator& allocator_;
|
113
|
+
MicroInterpreterGraph& graph_;
|
114
|
+
const Model* model_;
|
115
|
+
InterpreterState state_;
|
116
|
+
|
117
|
+
ScratchBufferHandle* scratch_buffer_handles_ = nullptr;
|
118
|
+
void* external_context_payload_ = nullptr;
|
119
|
+
|
120
|
+
TF_LITE_REMOVE_VIRTUAL_DELETE
|
121
|
+
};
|
122
|
+
|
123
|
+
} // namespace tflite_micro
|
124
|
+
|
125
|
+
#endif // TENSORFLOW_LITE_MICRO_MICRO_INTERPRETER_CONTEXT_H_
|
@@ -0,0 +1,110 @@
|
|
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_MICRO_INTERPRETER_GRAPH_H_
|
17
|
+
#define TENSORFLOW_LITE_MICRO_MICRO_INTERPRETER_GRAPH_H_
|
18
|
+
|
19
|
+
#include "tensorflow/lite/micro/micro_allocator.h"
|
20
|
+
#include "tensorflow/lite/micro/micro_common.h"
|
21
|
+
#include "tensorflow/lite/micro/micro_graph.h"
|
22
|
+
#include "tensorflow/lite/micro/micro_resource_variable.h"
|
23
|
+
#include "tensorflow/lite/schema/schema_generated.h"
|
24
|
+
|
25
|
+
namespace tflite_micro {
|
26
|
+
|
27
|
+
// Abstracts the details of interacting with the tflite_micro::Model.
|
28
|
+
//
|
29
|
+
// Provides methods to access, initialize, prepare, invoke and free any
|
30
|
+
// subgraph in the tflite_micro::Graph.
|
31
|
+
class MicroInterpreterGraph : public MicroGraph {
|
32
|
+
public:
|
33
|
+
// The lifetime of the context, model, allocator and resource_variables must
|
34
|
+
// be at least as long as that of the graph object, since the this class may
|
35
|
+
// need to access them at any time. If resource_variables is a nullptr,
|
36
|
+
// GetResourceVariables will return a nullptr.
|
37
|
+
MicroInterpreterGraph(TfLiteContext* context, const Model* model,
|
38
|
+
MicroAllocator* allocator,
|
39
|
+
MicroResourceVariables* resource_variables);
|
40
|
+
virtual ~MicroInterpreterGraph();
|
41
|
+
|
42
|
+
// Sets up builtin data and calls TFLMRegistration->Init for every
|
43
|
+
// operator in every subgraph in the model.
|
44
|
+
virtual TfLiteStatus InitSubgraphs();
|
45
|
+
|
46
|
+
// Calls TFLMRegistration->Prepare for every operator in every subgraph
|
47
|
+
// in the model.
|
48
|
+
virtual TfLiteStatus PrepareSubgraphs();
|
49
|
+
|
50
|
+
// Calls TFLMRegistration->Reset for every operator in every subgraph in
|
51
|
+
// the model.
|
52
|
+
virtual TfLiteStatus ResetSubgraphs();
|
53
|
+
|
54
|
+
// Calls TFLMRegistration->Free for every operator in every subgraph in
|
55
|
+
// the model.
|
56
|
+
virtual TfLiteStatus FreeSubgraphs();
|
57
|
+
|
58
|
+
// Calls TFLMRegistration->Invoke for every operator in a single subgraph
|
59
|
+
// in the model.
|
60
|
+
virtual TfLiteStatus InvokeSubgraph(int subgraph_idx);
|
61
|
+
|
62
|
+
// Zeros out all variable tensors in all subgraphs in the model.
|
63
|
+
virtual TfLiteStatus ResetVariableTensors();
|
64
|
+
|
65
|
+
// Number of tensor inputs to a specified subgraph in the model.
|
66
|
+
virtual size_t NumSubgraphInputs(int subgraph_idx);
|
67
|
+
|
68
|
+
// Get the specified input tensor of a specified subgraph in the model.
|
69
|
+
virtual TfLiteEvalTensor* GetSubgraphInput(int subgraph_idx, int input_idx);
|
70
|
+
|
71
|
+
// Number of tensor outputs from a specified subgraph in the model.
|
72
|
+
virtual size_t NumSubgraphOutputs(int subgraph_idx);
|
73
|
+
|
74
|
+
// Get the specified output tensor of a specified subgraph in the model.
|
75
|
+
virtual TfLiteEvalTensor* GetSubgraphOutput(int subgraph_idx, int output_idx);
|
76
|
+
|
77
|
+
// Number of subgraphs in the model.
|
78
|
+
virtual int NumSubgraphs();
|
79
|
+
|
80
|
+
// Hook to pass in subgraph allocations tracked within the interpreter,
|
81
|
+
// allowing MicroInterpreterGraph to init / prepare / invoke subgraphs in the
|
82
|
+
// model.
|
83
|
+
void SetSubgraphAllocations(SubgraphAllocations* subgraph_allocations);
|
84
|
+
|
85
|
+
// Get the current subgraph index. Within an on operator, this is guaranteed
|
86
|
+
// to be the subgraph of that operator.
|
87
|
+
int GetCurrentSubgraphIndex() { return current_subgraph_index_; }
|
88
|
+
|
89
|
+
// Gets the list of alloctions for each subgraph. This is the source of truth
|
90
|
+
// for all per-subgraph allocation data.
|
91
|
+
SubgraphAllocations* GetAllocations() { return subgraph_allocations_; }
|
92
|
+
|
93
|
+
// Get the resource variables for this TFLM graph.
|
94
|
+
MicroResourceVariables* GetResourceVariables() { return resource_variables_; }
|
95
|
+
|
96
|
+
private:
|
97
|
+
TfLiteContext* context_;
|
98
|
+
const Model* model_;
|
99
|
+
MicroAllocator* allocator_;
|
100
|
+
SubgraphAllocations* subgraph_allocations_ = nullptr;
|
101
|
+
int current_subgraph_index_;
|
102
|
+
MicroResourceVariables* resource_variables_;
|
103
|
+
const flatbuffers::Vector<flatbuffers::Offset<SubGraph>>* subgraphs_;
|
104
|
+
|
105
|
+
TF_LITE_REMOVE_VIRTUAL_DELETE
|
106
|
+
};
|
107
|
+
|
108
|
+
} // namespace tflite_micro
|
109
|
+
|
110
|
+
#endif // TENSORFLOW_LITE_MICRO_MICRO_INTERPRETER_GRAPH_H_
|
@@ -0,0 +1,42 @@
|
|
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_MICRO_MICRO_LOG_H_
|
16
|
+
#define TENSORFLOW_LITE_MICRO_MICRO_LOG_H_
|
17
|
+
|
18
|
+
#if !defined(TF_LITE_STRIP_ERROR_STRINGS)
|
19
|
+
#include <cstdarg>
|
20
|
+
// These functions can be used independent of the MicroErrorReporter to get
|
21
|
+
// printf-like functionalitys and are common to all target platforms.
|
22
|
+
void MicroPrintf(const char* format, ...);
|
23
|
+
void VMicroPrintf(const char* format, va_list args);
|
24
|
+
#else
|
25
|
+
// We use a #define to ensure that the strings are completely stripped, to
|
26
|
+
// prevent an unnecessary increase in the binary size.
|
27
|
+
#define MicroPrintf(...) tflite_micro::Unused(__VA_ARGS__)
|
28
|
+
#define VMicroPrintf(...) tflite_micro::Unused(__VA_ARGS__)
|
29
|
+
#endif
|
30
|
+
|
31
|
+
namespace tflite_micro {
|
32
|
+
|
33
|
+
// From
|
34
|
+
// https://stackoverflow.com/questions/23235910/variadic-unused-function-macro
|
35
|
+
template <typename... Args>
|
36
|
+
void Unused(Args&&... args) {
|
37
|
+
(void)(sizeof...(args));
|
38
|
+
}
|
39
|
+
|
40
|
+
} // namespace tflite_micro
|
41
|
+
|
42
|
+
#endif // TENSORFLOW_LITE_MICRO_MICRO_LOG_H_
|