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.
Files changed (395) hide show
  1. xmos_ai_tools/__init__.py +7 -0
  2. xmos_ai_tools/io_server/__init__.py +151 -0
  3. xmos_ai_tools/runtime/__init__.py +0 -0
  4. xmos_ai_tools/runtime/buildfiles/aitoolslib.cmake +13 -0
  5. xmos_ai_tools/runtime/buildfiles/aitoolslib.make +8 -0
  6. xmos_ai_tools/runtime/include/flash_server.h +74 -0
  7. xmos_ai_tools/runtime/include/flatbuffers/allocator.h +68 -0
  8. xmos_ai_tools/runtime/include/flatbuffers/array.h +243 -0
  9. xmos_ai_tools/runtime/include/flatbuffers/base.h +474 -0
  10. xmos_ai_tools/runtime/include/flatbuffers/bfbs_generator.h +43 -0
  11. xmos_ai_tools/runtime/include/flatbuffers/buffer.h +142 -0
  12. xmos_ai_tools/runtime/include/flatbuffers/buffer_ref.h +53 -0
  13. xmos_ai_tools/runtime/include/flatbuffers/code_generators.h +235 -0
  14. xmos_ai_tools/runtime/include/flatbuffers/default_allocator.h +64 -0
  15. xmos_ai_tools/runtime/include/flatbuffers/detached_buffer.h +114 -0
  16. xmos_ai_tools/runtime/include/flatbuffers/flatbuffer_builder.h +1197 -0
  17. xmos_ai_tools/runtime/include/flatbuffers/flatbuffers.h +270 -0
  18. xmos_ai_tools/runtime/include/flatbuffers/flatc.h +111 -0
  19. xmos_ai_tools/runtime/include/flatbuffers/flexbuffers.h +1897 -0
  20. xmos_ai_tools/runtime/include/flatbuffers/grpc.h +300 -0
  21. xmos_ai_tools/runtime/include/flatbuffers/hash.h +127 -0
  22. xmos_ai_tools/runtime/include/flatbuffers/idl.h +1232 -0
  23. xmos_ai_tools/runtime/include/flatbuffers/minireflect.h +419 -0
  24. xmos_ai_tools/runtime/include/flatbuffers/pch/flatc_pch.h +39 -0
  25. xmos_ai_tools/runtime/include/flatbuffers/pch/pch.h +38 -0
  26. xmos_ai_tools/runtime/include/flatbuffers/reflection.h +502 -0
  27. xmos_ai_tools/runtime/include/flatbuffers/reflection_generated.h +1449 -0
  28. xmos_ai_tools/runtime/include/flatbuffers/registry.h +128 -0
  29. xmos_ai_tools/runtime/include/flatbuffers/stl_emulation.h +509 -0
  30. xmos_ai_tools/runtime/include/flatbuffers/string.h +64 -0
  31. xmos_ai_tools/runtime/include/flatbuffers/struct.h +53 -0
  32. xmos_ai_tools/runtime/include/flatbuffers/table.h +168 -0
  33. xmos_ai_tools/runtime/include/flatbuffers/util.h +690 -0
  34. xmos_ai_tools/runtime/include/flatbuffers/vector.h +370 -0
  35. xmos_ai_tools/runtime/include/flatbuffers/vector_downward.h +271 -0
  36. xmos_ai_tools/runtime/include/flatbuffers/verifier.h +283 -0
  37. xmos_ai_tools/runtime/include/ioserver.h +44 -0
  38. xmos_ai_tools/runtime/include/lib_nn/api/TransposeConv.h +24 -0
  39. xmos_ai_tools/runtime/include/lib_nn/api/add_int16.h +27 -0
  40. xmos_ai_tools/runtime/include/lib_nn/api/add_int16_transform.h +42 -0
  41. xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16.h +22 -0
  42. xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16_transform.h +34 -0
  43. xmos_ai_tools/runtime/include/lib_nn/api/expand_8_to_16.h +8 -0
  44. xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16.h +42 -0
  45. xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16_transform.h +71 -0
  46. xmos_ai_tools/runtime/include/lib_nn/api/nn_api.h +15 -0
  47. xmos_ai_tools/runtime/include/lib_nn/api/nn_bin_types.h +14 -0
  48. xmos_ai_tools/runtime/include/lib_nn/api/nn_config.h +287 -0
  49. xmos_ai_tools/runtime/include/lib_nn/api/nn_conv2d_structs.h +72 -0
  50. xmos_ai_tools/runtime/include/lib_nn/api/nn_image.h +26 -0
  51. xmos_ai_tools/runtime/include/lib_nn/api/nn_layers.h +303 -0
  52. xmos_ai_tools/runtime/include/lib_nn/api/nn_op_helper.h +132 -0
  53. xmos_ai_tools/runtime/include/lib_nn/api/nn_op_utils.h +150 -0
  54. xmos_ai_tools/runtime/include/lib_nn/api/nn_operator.h +18 -0
  55. xmos_ai_tools/runtime/include/lib_nn/api/nn_pooling.h +551 -0
  56. xmos_ai_tools/runtime/include/lib_nn/api/nn_types.h +83 -0
  57. xmos_ai_tools/runtime/include/lib_nn/api/nn_window_params.h +55 -0
  58. xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16.h +54 -0
  59. xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_kernel_transform.h +37 -0
  60. xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_mappings.h +13 -0
  61. xmos_ai_tools/runtime/include/lib_nn/api/quadratic_approximation.h +82 -0
  62. xmos_ai_tools/runtime/include/lib_nn/api/quadratic_interpolation.h +23 -0
  63. xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16.h +22 -0
  64. xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16_transform.h +33 -0
  65. xmos_ai_tools/runtime/include/lib_nn/api/version.h +13 -0
  66. xmos_ai_tools/runtime/include/lib_nn/api/vpu_memmove_word_aligned.h +15 -0
  67. xmos_ai_tools/runtime/include/lib_nn/api/vpu_memset_256.h +55 -0
  68. xmos_ai_tools/runtime/include/lib_nn/api/vpu_sim.h +118 -0
  69. xmos_ai_tools/runtime/include/lib_nn/api/xs3_vpu.h +216 -0
  70. xmos_ai_tools/runtime/include/lib_nn/api/xs3a_registers.h +2869 -0
  71. xmos_ai_tools/runtime/include/lib_nn/src/asm/asm_constants.h +41 -0
  72. xmos_ai_tools/runtime/include/lib_nn/src/asm/window_op_plan.h +25 -0
  73. xmos_ai_tools/runtime/include/lib_tflite_micro/api/fast_flash.h +47 -0
  74. xmos_ai_tools/runtime/include/lib_tflite_micro/api/inference_engine.h +218 -0
  75. xmos_ai_tools/runtime/include/lib_tflite_micro/api/memory_parallel_transport.h +52 -0
  76. xmos_ai_tools/runtime/include/lib_tflite_micro/api/version.h +13 -0
  77. xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_config.h +17 -0
  78. xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_device_memory.h +62 -0
  79. xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_shared_config.h +31 -0
  80. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/conv2d_float.h +155 -0
  81. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_common.h +19 -0
  82. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_custom_options.h +28 -0
  83. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_error_reporter.h +32 -0
  84. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_interpreter.h +49 -0
  85. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_ops.h +71 -0
  86. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_profiler.h +49 -0
  87. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_utils.h +160 -0
  88. xmos_ai_tools/runtime/include/lib_tflite_micro/src/thread_call.h +119 -0
  89. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_defs.h +4 -0
  90. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_device.h +4 -0
  91. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_descriptors.h +4 -0
  92. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_requests.h +4 -0
  93. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud.h +518 -0
  94. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_conf_default.h +11 -0
  95. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_device.h +87 -0
  96. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_descriptors.h +191 -0
  97. xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_requests.h +120 -0
  98. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/XUD_USB_Defines.h +70 -0
  99. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/hid.h +23 -0
  100. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio10.h +30 -0
  101. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio20.h +357 -0
  102. xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudiocommon.h +168 -0
  103. xmos_ai_tools/runtime/include/signal/micro/kernels/delay_flexbuffers_generated_data.h +25 -0
  104. xmos_ai_tools/runtime/include/signal/micro/kernels/energy_flexbuffers_generated_data.h +28 -0
  105. xmos_ai_tools/runtime/include/signal/micro/kernels/fft_flexbuffers_generated_data.h +37 -0
  106. xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_flexbuffers_generated_data.h +25 -0
  107. xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_log_flexbuffers_generated_data.h +27 -0
  108. xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_spectral_subtraction_flexbuffers_generated_data.h +26 -0
  109. xmos_ai_tools/runtime/include/signal/micro/kernels/framer_flexbuffers_generated_data.h +25 -0
  110. xmos_ai_tools/runtime/include/signal/micro/kernels/irfft.h +31 -0
  111. xmos_ai_tools/runtime/include/signal/micro/kernels/overlap_add_flexbuffers_generated_data.h +25 -0
  112. xmos_ai_tools/runtime/include/signal/micro/kernels/pcan_flexbuffers_generated_data.h +7 -0
  113. xmos_ai_tools/runtime/include/signal/micro/kernels/rfft.h +31 -0
  114. xmos_ai_tools/runtime/include/signal/micro/kernels/stacker_flexbuffers_generated_data.h +25 -0
  115. xmos_ai_tools/runtime/include/signal/micro/kernels/window_flexbuffers_generated_data.h +25 -0
  116. xmos_ai_tools/runtime/include/signal/src/circular_buffer.h +118 -0
  117. xmos_ai_tools/runtime/include/signal/src/complex.h +29 -0
  118. xmos_ai_tools/runtime/include/signal/src/energy.h +38 -0
  119. xmos_ai_tools/runtime/include/signal/src/fft_auto_scale.h +35 -0
  120. xmos_ai_tools/runtime/include/signal/src/filter_bank.h +69 -0
  121. xmos_ai_tools/runtime/include/signal/src/filter_bank_log.h +38 -0
  122. xmos_ai_tools/runtime/include/signal/src/filter_bank_spectral_subtraction.h +73 -0
  123. xmos_ai_tools/runtime/include/signal/src/filter_bank_square_root.h +34 -0
  124. xmos_ai_tools/runtime/include/signal/src/irfft.h +84 -0
  125. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_common.h +49 -0
  126. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_float.h +31 -0
  127. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int16.h +30 -0
  128. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int32.h +31 -0
  129. xmos_ai_tools/runtime/include/signal/src/log.h +30 -0
  130. xmos_ai_tools/runtime/include/signal/src/max_abs.h +31 -0
  131. xmos_ai_tools/runtime/include/signal/src/msb.h +32 -0
  132. xmos_ai_tools/runtime/include/signal/src/overlap_add.h +46 -0
  133. xmos_ai_tools/runtime/include/signal/src/pcan_argc_fixed.h +41 -0
  134. xmos_ai_tools/runtime/include/signal/src/rfft.h +85 -0
  135. xmos_ai_tools/runtime/include/signal/src/square_root.h +32 -0
  136. xmos_ai_tools/runtime/include/signal/src/window.h +31 -0
  137. xmos_ai_tools/runtime/include/signal/testdata/fft_test_data.h +48 -0
  138. xmos_ai_tools/runtime/include/tensorflow/lite/array.h +156 -0
  139. xmos_ai_tools/runtime/include/tensorflow/lite/builtin_op_data.h +22 -0
  140. xmos_ai_tools/runtime/include/tensorflow/lite/builtin_ops.h +241 -0
  141. xmos_ai_tools/runtime/include/tensorflow/lite/c/builtin_op_data.h +20 -0
  142. xmos_ai_tools/runtime/include/tensorflow/lite/c/c_api_types.h +26 -0
  143. xmos_ai_tools/runtime/include/tensorflow/lite/c/common.h +30 -0
  144. xmos_ai_tools/runtime/include/tensorflow/lite/context_util.h +54 -0
  145. xmos_ai_tools/runtime/include/tensorflow/lite/core/api/error_reporter.h +72 -0
  146. xmos_ai_tools/runtime/include/tensorflow/lite/core/api/flatbuffer_conversions.h +440 -0
  147. xmos_ai_tools/runtime/include/tensorflow/lite/core/api/tensor_utils.h +28 -0
  148. xmos_ai_tools/runtime/include/tensorflow/lite/core/c/builtin_op_data.h +626 -0
  149. xmos_ai_tools/runtime/include/tensorflow/lite/core/c/c_api_types.h +178 -0
  150. xmos_ai_tools/runtime/include/tensorflow/lite/core/c/common.h +1496 -0
  151. xmos_ai_tools/runtime/include/tensorflow/lite/core/macros.h +78 -0
  152. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/bits.h +102 -0
  153. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft.h +50 -0
  154. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_io.h +34 -0
  155. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_util.h +34 -0
  156. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank.h +63 -0
  157. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_io.h +35 -0
  158. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.h +50 -0
  159. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend.h +64 -0
  160. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_io.h +31 -0
  161. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_util.h +52 -0
  162. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_common.h +48 -0
  163. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_int16.h +33 -0
  164. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_lut.h +40 -0
  165. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale.h +39 -0
  166. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_io.h +33 -0
  167. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_util.h +45 -0
  168. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction.h +46 -0
  169. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_io.h +36 -0
  170. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_util.h +50 -0
  171. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control.h +47 -0
  172. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control_util.h +57 -0
  173. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window.h +49 -0
  174. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_io.h +34 -0
  175. xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_util.h +45 -0
  176. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/common.h +1358 -0
  177. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/compatibility.h +122 -0
  178. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/cppmath.h +40 -0
  179. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/max.h +35 -0
  180. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/min.h +35 -0
  181. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/optimized/neon_check.h +20 -0
  182. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor.h +141 -0
  183. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor_utils.h +623 -0
  184. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/quantization_util.h +292 -0
  185. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add.h +561 -0
  186. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add_n.h +86 -0
  187. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/arg_min_max.h +88 -0
  188. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_matmul.h +275 -0
  189. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_to_space_nd.h +101 -0
  190. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/binary_function.h +91 -0
  191. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_args.h +56 -0
  192. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_to.h +97 -0
  193. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/ceil.h +37 -0
  194. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/comparisons.h +271 -0
  195. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/concatenation.h +141 -0
  196. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/conv.h +289 -0
  197. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/cumsum.h +175 -0
  198. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depth_to_space.h +79 -0
  199. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h +100 -0
  200. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_uint8.h +319 -0
  201. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/dequantize.h +78 -0
  202. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/div.h +247 -0
  203. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/elu.h +37 -0
  204. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/exp.h +38 -0
  205. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fill.h +38 -0
  206. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor.h +39 -0
  207. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_div.h +35 -0
  208. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_mod.h +44 -0
  209. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fully_connected.h +323 -0
  210. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/hard_swish.h +168 -0
  211. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/add.h +250 -0
  212. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/conv.h +241 -0
  213. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/depthwise_conv.h +291 -0
  214. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h +126 -0
  215. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/l2normalization.h +67 -0
  216. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/logistic.h +121 -0
  217. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mean.h +18 -0
  218. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mul.h +194 -0
  219. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h +264 -0
  220. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/tanh.h +117 -0
  221. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/transpose_conv.h +224 -0
  222. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/l2normalization.h +90 -0
  223. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/leaky_relu.h +69 -0
  224. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/log_softmax.h +256 -0
  225. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/logistic.h +132 -0
  226. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/lstm_cell.h +422 -0
  227. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/maximum_minimum.h +64 -0
  228. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/mul.h +267 -0
  229. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/neg.h +37 -0
  230. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pad.h +169 -0
  231. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pooling.h +303 -0
  232. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils.h +333 -0
  233. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils_impl.h +244 -0
  234. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/prelu.h +111 -0
  235. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h +140 -0
  236. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/quantize.h +89 -0
  237. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/reduce.h +491 -0
  238. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/requantize.h +70 -0
  239. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_bilinear.h +233 -0
  240. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_nearest_neighbor.h +102 -0
  241. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/round.h +51 -0
  242. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/select.h +151 -0
  243. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/slice.h +80 -0
  244. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/softmax.h +233 -0
  245. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_batch_nd.h +109 -0
  246. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_depth.h +80 -0
  247. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/strided_slice.h +147 -0
  248. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/sub.h +465 -0
  249. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/tanh.h +129 -0
  250. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose.h +203 -0
  251. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose_conv.h +225 -0
  252. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/runtime_shape.h +168 -0
  253. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/strided_slice_logic.h +278 -0
  254. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/tensor_ctypes.h +42 -0
  255. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/types.h +1096 -0
  256. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/kernel_util.h +341 -0
  257. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/op_macros.h +49 -0
  258. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/padding.h +115 -0
  259. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/ibuffer_allocator.h +100 -0
  260. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/non_persistent_arena_buffer_allocator.h +104 -0
  261. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/persistent_arena_buffer_allocator.h +58 -0
  262. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/recording_single_arena_buffer_allocator.h +63 -0
  263. xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/single_arena_buffer_allocator.h +144 -0
  264. xmos_ai_tools/runtime/include/tensorflow/lite/micro/benchmarks/micro_benchmark.h +95 -0
  265. xmos_ai_tools/runtime/include/tensorflow/lite/micro/compatibility.h +32 -0
  266. xmos_ai_tools/runtime/include/tensorflow/lite/micro/cortex_m_generic/debug_log_callback.h +49 -0
  267. xmos_ai_tools/runtime/include/tensorflow/lite/micro/debug_log.h +38 -0
  268. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_model_settings.h +37 -0
  269. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/expected_output_data.h +47 -0
  270. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/input_data.h +108 -0
  271. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/network_model.h +166 -0
  272. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/detection_responder.h +32 -0
  273. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/image_provider.h +38 -0
  274. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/main_functions.h +37 -0
  275. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/model_settings.h +35 -0
  276. xmos_ai_tools/runtime/include/tensorflow/lite/micro/fake_micro_context.h +70 -0
  277. xmos_ai_tools/runtime/include/tensorflow/lite/micro/flatbuffer_utils.h +65 -0
  278. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activation_utils.h +57 -0
  279. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activations.h +64 -0
  280. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/add.h +78 -0
  281. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_function_specializations.h +141 -0
  282. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_interface.h +75 -0
  283. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_slicers.h +56 -0
  284. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_tf_utils.h +310 -0
  285. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buf_mgr.h +145 -0
  286. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buffers.h +78 -0
  287. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_common.h +24 -0
  288. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_tflm_lib.h +613 -0
  289. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/mcps_macros.h +115 -0
  290. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/types.h +1286 -0
  291. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer.h +45 -0
  292. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer_flexbuffers_generated_data.h +22 -0
  293. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv.h +117 -0
  294. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv_test.h +94 -0
  295. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/depthwise_conv.h +80 -0
  296. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/dequantize.h +38 -0
  297. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/detection_postprocess_flexbuffers_generated_data.h +25 -0
  298. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ethosu.h +28 -0
  299. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/fully_connected.h +112 -0
  300. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/hard_swish.h +30 -0
  301. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_runner.h +86 -0
  302. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_util.h +150 -0
  303. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/leaky_relu.h +43 -0
  304. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logical.h +35 -0
  305. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logistic.h +42 -0
  306. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval.h +541 -0
  307. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval_test.h +817 -0
  308. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_shared.h +150 -0
  309. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_ops.h +158 -0
  310. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_tensor_utils.h +56 -0
  311. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/mul.h +74 -0
  312. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pad.h +27 -0
  313. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pooling.h +142 -0
  314. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/prelu.h +39 -0
  315. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/quantize.h +37 -0
  316. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reduce.h +65 -0
  317. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reshape.h +26 -0
  318. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/softmax.h +67 -0
  319. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/strided_slice.h +40 -0
  320. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/sub.h +60 -0
  321. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/svdf.h +100 -0
  322. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/conv_test_data.h +37 -0
  323. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/lstm_test_data.h +579 -0
  324. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm.h +47 -0
  325. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/hifimini/fixedpoint_utils.h +139 -0
  326. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_eval.h +216 -0
  327. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_shared.h +78 -0
  328. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa.h +38 -0
  329. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_add.h +48 -0
  330. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_conv.h +89 -0
  331. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_depthwise_conv.h +74 -0
  332. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_fully_connected.h +78 -0
  333. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pad.h +49 -0
  334. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pooling.h +76 -0
  335. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reduce.h +47 -0
  336. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reshape.h +44 -0
  337. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_softmax.h +58 -0
  338. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_svdf.h +39 -0
  339. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_helpers.h +64 -0
  340. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h +170 -0
  341. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/linear_memory_planner.h +53 -0
  342. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/memory_plan_struct.h +73 -0
  343. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/micro_memory_planner.h +95 -0
  344. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/non_persistent_buffer_planner_shim.h +133 -0
  345. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocation_info.h +138 -0
  346. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocator.h +351 -0
  347. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_arena_constants.h +28 -0
  348. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_common.h +38 -0
  349. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_context.h +176 -0
  350. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_graph.h +79 -0
  351. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter.h +189 -0
  352. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_context.h +125 -0
  353. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_graph.h +110 -0
  354. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_log.h +42 -0
  355. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_mutable_op_resolver.h +708 -0
  356. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_op_resolver.h +62 -0
  357. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler.h +140 -0
  358. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler_interface.h +38 -0
  359. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_resource_variable.h +89 -0
  360. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_time.h +36 -0
  361. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_utils.h +162 -0
  362. xmos_ai_tools/runtime/include/tensorflow/lite/micro/mock_micro_graph.h +60 -0
  363. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/interpreter/src/python_ops_resolver.h +21 -0
  364. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size.h +30 -0
  365. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size_wrapper.h +33 -0
  366. xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_allocator.h +125 -0
  367. xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_interpreter.h +69 -0
  368. xmos_ai_tools/runtime/include/tensorflow/lite/micro/system_setup.h +27 -0
  369. xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helper_custom_ops.h +49 -0
  370. xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helpers.h +334 -0
  371. xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/micro_test.h +267 -0
  372. xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/test_conv_model.h +23 -0
  373. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/flatbuffer_conversions_bridge.h +45 -0
  374. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h +36 -0
  375. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/log_utils.h +273 -0
  376. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/metrics.h +41 -0
  377. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/op_resolver.h +127 -0
  378. xmos_ai_tools/runtime/include/tensorflow/lite/portable_type_to_tflitetype.h +75 -0
  379. xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_generated.h +24644 -0
  380. xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_utils.h +33 -0
  381. xmos_ai_tools/runtime/include/tile_ram_server.h +38 -0
  382. xmos_ai_tools/runtime/lib/libhost_xtflitemicro.a +0 -0
  383. xmos_ai_tools/runtime/lib/libxtflitemicro.a +0 -0
  384. xmos_ai_tools/xformer/__init__.py +60 -0
  385. xmos_ai_tools/xformer/flash.py +190 -0
  386. xmos_ai_tools/xinterpreters/__init__.py +1 -0
  387. xmos_ai_tools/xinterpreters/exceptions.py +38 -0
  388. xmos_ai_tools/xinterpreters/host_interpreter.py +652 -0
  389. xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.1.0.1.dylib +0 -0
  390. xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.dylib +0 -0
  391. xmos_ai_tools-1.3.2.dev80.data/data/bin/xcore-opt +0 -0
  392. xmos_ai_tools-1.3.2.dev80.dist-info/METADATA +33 -0
  393. xmos_ai_tools-1.3.2.dev80.dist-info/RECORD +395 -0
  394. xmos_ai_tools-1.3.2.dev80.dist-info/WHEEL +5 -0
  395. xmos_ai_tools-1.3.2.dev80.dist-info/top_level.txt +1 -0
@@ -0,0 +1,351 @@
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_ALLOCATOR_H_
16
+ #define TENSORFLOW_LITE_MICRO_MICRO_ALLOCATOR_H_
17
+
18
+ #include <cstddef>
19
+ #include <cstdint>
20
+
21
+ #include "tensorflow/lite/micro/arena_allocator/single_arena_buffer_allocator.h"
22
+ #include "tensorflow/lite/micro/compatibility.h"
23
+ #include "tensorflow/lite/micro/flatbuffer_utils.h"
24
+ #include "tensorflow/lite/micro/memory_planner/micro_memory_planner.h"
25
+ #include "tensorflow/lite/micro/micro_common.h"
26
+ #include "tensorflow/lite/micro/tflite_bridge/flatbuffer_conversions_bridge.h"
27
+ #include "tensorflow/lite/schema/schema_generated.h"
28
+
29
+ namespace tflite_micro {
30
+
31
+ // TODO(b/199402574): rename to tflite_internal or just remove internal
32
+ // namespace.
33
+ namespace internal {
34
+
35
+ // Sets up all of the data structure members for a TfLiteTensor based on the
36
+ // contents of a serialized tensor in the flatbuffer.
37
+ // TODO(b/162311891): Drop this method when the interpreter has an API for
38
+ // returning buffers on TfLiteEvalTensor.
39
+ TfLiteStatus InitializeTfLiteTensorFromFlatbuffer(
40
+ IPersistentBufferAllocator* persistent_buffer_allocator,
41
+ INonPersistentBufferAllocator* non_persistent_buffer_allocator,
42
+ bool allocate_temp, const tflite_micro::Tensor& flatbuffer_tensor,
43
+ const flatbuffers::Vector<flatbuffers::Offset<Buffer>>* buffers,
44
+ TfLiteTensor* result);
45
+
46
+ // Holds placeholder information for a scratch buffer request from a kernel.
47
+ // This struct is only used during the model prepare stage. Each request from a
48
+ // kernel is stored in the head section. During the prepare stage, the head
49
+ // section will at least hold kMaxScratchBuffersPerOp number of requests plus
50
+ // any requests from previous kernel requests.
51
+ //
52
+ // When the memory plan is finalized, these structs are no longer used in favor
53
+ // of a sequential, array of ScratchBufferHandle allocations in the tail
54
+ // section. These allocations are indexed by the request API defined in the
55
+ // TfLiteContext struct.
56
+ struct ScratchBufferRequest {
57
+ // Number of bytes required by the buffer. The actual allocated size might be
58
+ // greater than `bytes` due to buffer alignment.
59
+ size_t bytes;
60
+ // Node where the buffer is allocated for. This provides useful information to
61
+ // determine the lifetime of the buffer. In AllocationInfo, this buffer will
62
+ // have `before` = node_idx and `after` = node_idx.
63
+ int node_idx;
64
+ int subgraph_idx;
65
+ };
66
+
67
+ } // namespace internal
68
+
69
+ // Enum used to keep track of which MemoryPlanner is being used for
70
+ // MicroAllocater::Create();
71
+ enum class MemoryPlannerType {
72
+ kGreedy,
73
+ kLinear,
74
+ };
75
+
76
+ struct NodeAndRegistration {
77
+ TfLiteNode node;
78
+ const TFLMRegistration* registration;
79
+ };
80
+
81
+ // Holds a pointer to a buffer for a scratch buffer requested by a kernel during
82
+ // the model prepare stage. This struct is allocated in-place and allows for
83
+ // quick pointer-indexed lookup for speed during model inference.
84
+ struct ScratchBufferHandle {
85
+ // Pointer to location of the scratch buffer:
86
+ uint8_t* data;
87
+ };
88
+
89
+ // Stores all per-subgraph allocations. This includes the node and registration
90
+ // array, and tensor list for each subgraph.
91
+ struct SubgraphAllocations {
92
+ NodeAndRegistration* node_and_registrations;
93
+ TfLiteEvalTensor* tensors;
94
+ };
95
+
96
+ // Allocator responsible for allocating memory for all intermediate tensors
97
+ // necessary to invoke a model.
98
+ //
99
+ // The lifetime of the model, tensor arena and error reporter must be at
100
+ // least as long as that of the allocator object, since the allocator needs
101
+ // them to be accessible during its entire lifetime.
102
+ //
103
+ // The MicroAllocator simply plans out additional allocations that are required
104
+ // to standup a model for inference in TF Micro. This class currently relies on
105
+ // an additional allocator - SingleArenaBufferAllocator - for all allocations
106
+ // from an arena. These allocations are divided into head (non-persistent) and
107
+ // tail (persistent) regions:
108
+ //
109
+ // Memory layout to help understand how it works
110
+ // This information could change in the future version.
111
+ // ************** .memory_allocator->GetBuffer()
112
+ // Tensors/Scratch buffers (head)
113
+ // ************** .head_watermark
114
+ // unused memory
115
+ // ************** .memory_allocator->GetBuffer() + ->GetMaxBufferSize()
116
+ // - ->GetDataSize()
117
+ // persistent area (tail)
118
+ // ************** .memory_allocator->GetBuffer() + ->GetMaxBufferSize()
119
+ class MicroAllocator {
120
+ public:
121
+ // Creates a MicroAllocator instance from a given tensor arena. This arena
122
+ // will be managed by the created instance. The GreedyMemoryPlanner will
123
+ // by default be used and created on the arena.
124
+ // Note: Please use alignas(16) to make sure tensor_arena is 16
125
+ // bytes aligned, otherwise some head room will be wasted.
126
+ // TODO(b/157615197): Cleanup constructor + factory usage.
127
+ static MicroAllocator* Create(
128
+ uint8_t* tensor_arena, size_t arena_size,
129
+ MemoryPlannerType memory_planner_type = MemoryPlannerType::kGreedy);
130
+
131
+ // Creates a MicroAllocator instance from a given tensor arena and a given
132
+ // MemoryPlanner. This arena will be managed by the created instance. Note:
133
+ // Please use alignas(16) to make sure tensor_arena is 16 bytes
134
+ // aligned, otherwise some head room will be wasted.
135
+ static MicroAllocator* Create(uint8_t* tensor_arena, size_t arena_size,
136
+ MicroMemoryPlanner* memory_planner);
137
+
138
+ // Creates a MicroAllocator instance using the provided
139
+ // SingleArenaBufferAllocator instance and the MemoryPlanner. This allocator
140
+ // instance will use the SingleArenaBufferAllocator instance to manage
141
+ // allocations internally.
142
+ static MicroAllocator* Create(SingleArenaBufferAllocator* memory_allocator,
143
+ MicroMemoryPlanner* memory_planner);
144
+
145
+ // Creates a MicroAllocator instance using the provided
146
+ // SingleArenaBufferAllocator instance and the MemoryPlanner. This allocator
147
+ // instance will use the SingleArenaBufferAllocator instance to manage
148
+ // allocations internally.
149
+ static MicroAllocator* Create(
150
+ uint8_t* persistent_tensor_arena, size_t persistent_arena_size,
151
+ uint8_t* non_persistent_tensor_arena, size_t non_persistent_arena_size,
152
+ MemoryPlannerType memory_planner_type = MemoryPlannerType::kGreedy);
153
+
154
+ // Returns the fixed amount of memory overhead of MicroAllocator.
155
+ static size_t GetDefaultTailUsage(bool is_memory_planner_given);
156
+
157
+ // Returns True if the MicroAllocator uses a LinearMemoryPlanner(is compatible
158
+ // with the PerserveAllTensors flag / feature ) and False otherwise.
159
+ bool preserves_all_tensor() const {
160
+ return memory_planner_->preserves_all_tensors();
161
+ };
162
+
163
+ // Allocates internal resources required for model inference for each subgraph
164
+ // from the arena.
165
+ //
166
+ // This method will run through the flatbuffer data supplied in the model to
167
+ // properly allocate tensor, node, and op registration data. This method is
168
+ // expected to be followed with a call to FinishModelAllocation() Returns a
169
+ // pointer to an array of SubgraphAllocations (also stored in the tail of the
170
+ // arena) where each index corresponds to a different subgraph in the model.
171
+ // Return value is nullptr if the allocations failed.
172
+ SubgraphAllocations* StartModelAllocation(const Model* model);
173
+
174
+ // Finish allocating internal resources required for model inference.
175
+ //
176
+ // -Plan the memory for activation tensors and scratch buffers.
177
+ // -Update eval tensors for each subgraph based on planned offsets.
178
+ // -Allocate scratch buffer handles array and update based on planned offsets.
179
+ //
180
+ // This method should be called after assigning model resources
181
+ // in StartModelAllocation(). The subgraph_allocations pointer should be the
182
+ // value passed into this class during StartModelAllocation(). Scratch buffer
183
+ // handles are stored in the out-param `scratch_buffer_handles` array which is
184
+ // allocated in this method. This value will be used in `GetScratchBuffer`
185
+ // call to retrieve scratch buffers.
186
+ TfLiteStatus FinishModelAllocation(
187
+ const Model* model, SubgraphAllocations* subgraph_allocations,
188
+ ScratchBufferHandle** scratch_buffer_handles);
189
+
190
+ // Allocates a TfLiteTensor struct and populates the returned value with
191
+ // properties from the model flatbuffer. This struct is allocated from
192
+ // persistent arena memory is only guaranteed for the lifetime of the
193
+ // application. The eval_tensors pointer should be the value passed into this
194
+ // class during StartModelAllocation() and contains the source-of-truth for
195
+ // buffers.
196
+ virtual TfLiteTensor* AllocatePersistentTfLiteTensor(
197
+ const Model* model, const SubgraphAllocations* subgraph_allocations,
198
+ int tensor_index, int subgraph_index);
199
+
200
+ // Allocates a TfLiteTensor struct and populates the returned value with
201
+ // properties from the model flatbuffer. This struct is allocated from
202
+ // temporary arena memory is only guaranteed until a call is made to
203
+ // ResetTempAllocations(). Subgraph_allocations contains the array of
204
+ // TfLiteEvalTensors. If the newly allocated temp at the specified subgraph
205
+ // and tensor index is already present int the TfLiteEvalTensor array, its
206
+ // data buffer will be re-used.
207
+ virtual TfLiteTensor* AllocateTempTfLiteTensor(
208
+ const Model* model, const SubgraphAllocations* subgraph_allocations,
209
+ int tensor_index, int subgraph_index);
210
+
211
+ virtual void DeallocateTempTfLiteTensor(TfLiteTensor*);
212
+
213
+ // Returns a pointer to a buffer from the temporary arena memory and is only
214
+ // guaranteed until a call is made to ResetTempAllocations().
215
+ virtual uint8_t* AllocateTempBuffer(size_t size, size_t alignment);
216
+
217
+ // Signals that the temporary buffer no longer needed.
218
+ virtual void DeallocateTempBuffer(uint8_t* buffer);
219
+
220
+ // Resets all temporary allocations. This method should be called after a
221
+ // chain of temp allocations (e.g. chain of TfLiteTensor objects via
222
+ // AllocateTfLiteTensor()).
223
+ virtual TfLiteStatus ResetTempAllocations();
224
+
225
+ // Returns true if all temporary buffers including temp TfLiteTensor are
226
+ // already deallocated.
227
+ virtual bool IsAllTempDeallocated();
228
+
229
+ // Allocates persistent buffer which has the same life time as the allocator.
230
+ // The memory is immediately available and is allocated from the tail of the
231
+ // arena.
232
+ virtual void* AllocatePersistentBuffer(size_t bytes);
233
+
234
+ // Register a scratch buffer of size `bytes` for Node with `node_id`.
235
+ // This method only requests a buffer with a given size to be used after a
236
+ // model has finished allocation via FinishModelAllocation(). All requested
237
+ // buffers will be accessible by the out-param in that method.
238
+ TfLiteStatus RequestScratchBufferInArena(size_t bytes, int subgraph_idx,
239
+ int* buffer_idx);
240
+
241
+ // Finish allocating a specific NodeAndRegistration prepare block (kernel
242
+ // entry for a model) with a given node ID. This call ensures that any scratch
243
+ // buffer requests and temporary allocations are handled and ready for the
244
+ // next node prepare block.
245
+ TfLiteStatus FinishPrepareNodeAllocations(int node_id);
246
+
247
+ // Returns the arena usage in bytes, only available after
248
+ // `FinishModelAllocation`. Otherwise, it will return 0.
249
+ size_t used_bytes() const;
250
+
251
+ TfLiteBridgeBuiltinDataAllocator* GetBuiltinDataAllocator();
252
+
253
+ MicroMemoryPlanner* memory_planner() { return memory_planner_;}
254
+
255
+ // Returns the pointer for the array of ScratchBufferRequest allocations in
256
+ // the head section.
257
+ internal::ScratchBufferRequest* GetScratchBufferRequests();
258
+
259
+ size_t GetScratchBufferRequestCount() { return scratch_buffer_request_count_;}
260
+
261
+ protected:
262
+ MicroAllocator(SingleArenaBufferAllocator* memory_allocator,
263
+ MicroMemoryPlanner* memory_planner);
264
+ MicroAllocator(IPersistentBufferAllocator* persistent_buffer_allocator,
265
+ INonPersistentBufferAllocator* non_persistent_buffer_allocator,
266
+ MicroMemoryPlanner* memory_planner);
267
+ virtual ~MicroAllocator();
268
+
269
+ // Allocates an array in the arena to hold pointers to the node and
270
+ // registration pointers required to represent the inference graph of the
271
+ // model.
272
+ virtual TfLiteStatus AllocateNodeAndRegistrations(
273
+ const Model* model, SubgraphAllocations* subgraph_allocations);
274
+
275
+ // Allocates the list of persistent TfLiteEvalTensors that are used for the
276
+ // "eval" phase of model inference. These structs will be the source of truth
277
+ // for all tensor buffers.
278
+ virtual TfLiteStatus AllocateTfLiteEvalTensors(
279
+ const Model* model, SubgraphAllocations* subgraph_allocations);
280
+
281
+ // Allocates persistent tensor buffers for variable tensors in the subgraph.
282
+ // Online and offline variable tensors are handled differently hence the
283
+ // offline_planner_offsets parameter is needed.
284
+ virtual TfLiteStatus AllocateVariables(
285
+ const SubGraph* subgraph, TfLiteEvalTensor* eval_tensors,
286
+ const int32_t* offline_planner_offsets);
287
+
288
+ // Allocate and return a persistent TfLiteTensor.
289
+ // TODO(b/162311891): Drop this method when the interpreter has an API for
290
+ // accessing TfLiteEvalTensor structs.
291
+ virtual TfLiteTensor* AllocatePersistentTfLiteTensorInternal();
292
+
293
+ // Populates a TfLiteTensor struct with data from the model flatbuffer. Any
294
+ // quantization data is allocated from either the tail (persistent) or temp
295
+ // sections of the arena based on the allocation flag.
296
+ virtual TfLiteStatus PopulateTfLiteTensorFromFlatbuffer(const Model* model,
297
+ TfLiteTensor* tensor,
298
+ int tensor_index,
299
+ int subgraph_idx,
300
+ bool allocate_temp);
301
+
302
+ private:
303
+ // Commits a memory plan for all non-persistent buffer allocations in the
304
+ // 'head' section of the memory arena. The eval_tensors pointer is the list of
305
+ // pre-allocated TfLiteEvalTensor structs that will point to the buffers that
306
+ // will be allocated into the head section in this function call. The
307
+ // scratch_buffer_handles pointer is the array of pre-allocated
308
+ // ScratchBufferHandle structs that will point to allocated buffers also in
309
+ // the head section.
310
+ virtual TfLiteStatus CommitStaticMemoryPlan(
311
+ const Model* model, SubgraphAllocations* allocations,
312
+ ScratchBufferHandle* scratch_buffer_handles);
313
+
314
+ // Allocates an array of ScratchBufferHandle structs in the tail section for a
315
+ // given number of handles.
316
+ virtual TfLiteStatus AllocateScratchBufferHandles(
317
+ ScratchBufferHandle** scratch_buffer_handles, size_t handle_count);
318
+
319
+ // Clears all internal scratch buffer request counts and resets the head to
320
+ // prepare for kernels to request scratch buffer data when a model is
321
+ // preparing.
322
+ TfLiteStatus InitScratchBufferData();
323
+
324
+ // A simple memory allocator that always allocate from the arena tail or head.
325
+ INonPersistentBufferAllocator* non_persistent_buffer_allocator_;
326
+ IPersistentBufferAllocator* persistent_buffer_allocator_;
327
+
328
+ // Allocator used to allocate persistent builtin data.
329
+ TfLiteBridgeBuiltinDataAllocator* builtin_data_allocator_;
330
+
331
+ // Activation buffer memory planner.
332
+ MicroMemoryPlanner* memory_planner_;
333
+
334
+ bool model_is_allocating_;
335
+
336
+ // Holds the number of ScratchBufferRequest instances stored in the head
337
+ // section when a model is allocating.
338
+ size_t scratch_buffer_request_count_ = 0;
339
+
340
+ // Holds ScratchBufferRequest when a model is allocating
341
+ uint8_t* scratch_buffer_head_ = nullptr;
342
+
343
+ // Holds the byte length of the memory plan with the largest head usage. Used
344
+ // to ensure that multi-tenant allocations can share the head for buffers.
345
+ size_t max_head_buffer_usage_ = 0;
346
+
347
+ TF_LITE_REMOVE_VIRTUAL_DELETE
348
+ };
349
+
350
+ } // namespace tflite_micro
351
+ #endif // TENSORFLOW_LITE_MICRO_MICRO_ALLOCATOR_H_
@@ -0,0 +1,28 @@
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_ARENA_CONSTANTS_H_
17
+ #define TENSORFLOW_LITE_MICRO_MICRO_ARENA_CONSTANTS_H_
18
+
19
+ namespace tflite_micro {
20
+
21
+ // The default buffer alignment requirement.
22
+ // We align tensor buffers to 16-byte boundaries, since this is a common
23
+ // requirement for SIMD extensions.
24
+ constexpr int MicroArenaBufferAlignment() { return 16; }
25
+
26
+ } // namespace tflite_micro
27
+
28
+ #endif // TENSORFLOW_LITE_MICRO_MICRO_ARENA_CONSTANTS_H_
@@ -0,0 +1,38 @@
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 THIRD_PARTY_TFLITE_MICRO_TENSORFLOW_LITE_MICRO_MICRO_COMMON_H_
16
+ #define THIRD_PARTY_TFLITE_MICRO_TENSORFLOW_LITE_MICRO_MICRO_COMMON_H_
17
+
18
+ #include "tensorflow/lite/c/common.h"
19
+
20
+ // TFLMRegistration defines the API that TFLM kernels need to implement.
21
+ // This will be replacing the current TfLiteRegistration_V1 struct with
22
+ // something more compatible Embedded enviroment TFLM is used in.
23
+ struct TFLMRegistration {
24
+ void* (*init)(TfLiteContext* context, const char* buffer, size_t length);
25
+ void (*free)(TfLiteContext* context, void* buffer);
26
+ TfLiteStatus (*prepare)(TfLiteContext* context, TfLiteNode* node);
27
+ TfLiteStatus (*invoke)(TfLiteContext* context, TfLiteNode* node);
28
+ void (*reset)(TfLiteContext* context, void* buffer);
29
+ int32_t builtin_code;
30
+ const char* custom_name;
31
+ };
32
+
33
+ struct TFLMInferenceRegistration {
34
+ TfLiteStatus (*invoke)(TfLiteContext* context, TfLiteNode* node);
35
+ void (*reset)(TfLiteContext* context, void* buffer);
36
+ };
37
+
38
+ #endif // THIRD_PARTY_TFLITE_MICRO_TENSORFLOW_LITE_MICRO_MICRO_COMMON_H_
@@ -0,0 +1,176 @@
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_CONTEXT_H_
17
+ #define TENSORFLOW_LITE_MICRO_MICRO_CONTEXT_H_
18
+
19
+ #include "tensorflow/lite/c/common.h"
20
+ #include "tensorflow/lite/micro/micro_graph.h"
21
+
22
+ #define XCORE_TFLITE_MICRO_PATCHED
23
+
24
+ #ifdef NO_INTERPRETER
25
+
26
+ namespace tflite_micro {
27
+ const TfLiteStatus kTfLiteAbort = static_cast<TfLiteStatus>(15);
28
+
29
+ struct MicroContext{
30
+ TfLiteTensor* (*AllocateTempInputTensor)(const TfLiteNode* node, int index);
31
+ TfLiteTensor* (*AllocateTempOutputTensor)(const TfLiteNode* node, int index);
32
+ void (*DeallocateTempTfLiteTensor)(TfLiteTensor* tensor);
33
+ void* (*external_context)();
34
+ MicroGraph& (*graph)();
35
+ };
36
+ static inline MicroContext* GetMicroContext(const struct TfLiteContext* context){
37
+ return reinterpret_cast<MicroContext*>(context->impl_);
38
+ }
39
+ }
40
+
41
+ #else
42
+
43
+ namespace tflite_micro {
44
+ // TODO(b/149795762): kTfLiteAbort cannot be part of the tflite TfLiteStatus.
45
+ const TfLiteStatus kTfLiteAbort = static_cast<TfLiteStatus>(15);
46
+
47
+ // MicroContext is eventually going to become the API between TFLM and the
48
+ // kernels, replacing all the functions in TfLiteContext. The end state is code
49
+ // kernels to have code like:
50
+ //
51
+ // MicroContext* micro_context = GetMicroContext(context);
52
+ // micro_context-><TFLM kernel API>
53
+ class MicroContext {
54
+ public:
55
+ virtual ~MicroContext() = default;
56
+
57
+ // Allocate persistent buffer which has the same life time as the interpreter.
58
+ // Returns nullptr on failure.
59
+ // The memory is allocated from the tail.
60
+ // This method is only available in Init or Prepare stage.
61
+ virtual void* AllocatePersistentBuffer(size_t bytes) = 0;
62
+
63
+ // Request a scratch buffer in the arena through static memory planning.
64
+ // This method is only available in Prepare stage and the buffer is allocated
65
+ // by the interpreter between Prepare and Eval stage. In Eval stage,
66
+ // GetScratchBuffer API can be used to fetch the address.
67
+ virtual TfLiteStatus RequestScratchBufferInArena(size_t bytes,
68
+ int* buffer_idx) = 0;
69
+
70
+ // Get the scratch buffer pointer.
71
+ // This method is only available in Eval stage.
72
+ virtual void* GetScratchBuffer(int buffer_idx) = 0;
73
+
74
+ // Returns a temporary TfLiteTensor struct for a given index.
75
+ virtual TfLiteTensor* AllocateTempTfLiteTensor(int tensor_idx) = 0;
76
+ virtual TfLiteTensor* AllocateTempTfLiteTensor(int tensor_idx, int sg){return nullptr;}
77
+
78
+ // Returns a temporary TfLiteTensor struct for the specified input tensor of a
79
+ // given mode. This is the recommended API over the deprecated
80
+ // GetInput/GetInputSafe to get a temp input tensor. The returned tensor shall
81
+ // be freed via calling DeallocateTempTfLiteTensor.
82
+ TfLiteTensor* AllocateTempInputTensor(const TfLiteNode* node, int index);
83
+
84
+ // Returns a temporary TfLiteTensor struct for the specified output tensor of
85
+ // a given mode. This is the recommended API over the deprecated
86
+ // GetOutput/GetOutputSafe to get a temp output tensor. The returned tensor
87
+ // shall be freed via calling DeallocateTempTfLiteTensor.
88
+ TfLiteTensor* AllocateTempOutputTensor(const TfLiteNode* node, int index);
89
+
90
+ // Returns a temporary TfLiteTensor struct for the specified intermediate
91
+ // tensor of a given mode. This is the recommended API over the deprecated
92
+ // GetIntermediates/GetIntermediatesSafe to get a temp intermediate tensor.
93
+ // The returned tensor shall be freed via calling DeallocateTempTfLiteTensor.
94
+ TfLiteTensor* AllocateTempIntermediateTensor(const TfLiteNode* node,
95
+ int index);
96
+
97
+ // Deallocates a temp TfLiteTensor.
98
+ virtual void DeallocateTempTfLiteTensor(TfLiteTensor* tensor) = 0;
99
+
100
+ // Returns a pointer to a temporary buffer (from the arena).
101
+ // This API is only valid from the kernel's Prepare function and
102
+ // the buffer's lifetime is also that of the Prepare function.
103
+ virtual uint8_t* AllocateTempBuffer(size_t size, size_t alignment) = 0;
104
+
105
+ // Signals that the temporary buffer is no longer needed.
106
+ virtual void DeallocateTempBuffer(uint8_t* buffer) = 0;
107
+
108
+ // Returns a TfLiteEvalTensor struct for a given index.
109
+ virtual TfLiteEvalTensor* GetEvalTensor(int tensor_idx) = 0;
110
+ virtual TfLiteEvalTensor* GetEvalTensor(int tensor_idx, int sg){return nullptr;}
111
+
112
+ // Does not take ownership of the pointer and the pointer must refer to valid
113
+ // an object that outlive this class instance.
114
+ // This can only be called once to set one external context.
115
+ virtual TfLiteStatus set_external_context(void* external_context_payload) = 0;
116
+
117
+ virtual void* external_context() = 0;
118
+
119
+ virtual MicroGraph& graph() = 0;
120
+
121
+ private:
122
+ TF_LITE_REMOVE_VIRTUAL_DELETE
123
+ };
124
+
125
+ inline MicroContext* GetMicroContext(const struct TfLiteContext* context) {
126
+ return reinterpret_cast<MicroContext*>(context->impl_);
127
+ }
128
+
129
+ // Deprecated API. Prefer to using the MicroContext API directly from the
130
+ // kernels.
131
+ // TODO(b/213010668): migrate all existing kernels to use MicroContext, delete
132
+ // these functions, and remove corresponding members from the TfLiteContext
133
+ // struct for TFLM.
134
+ inline void* MicroContextAllocatePersistentBuffer(TfLiteContext* ctx,
135
+ size_t bytes) {
136
+ return GetMicroContext(ctx)->AllocatePersistentBuffer(bytes);
137
+ }
138
+ inline TfLiteStatus MicroContextRequestScratchBufferInArena(TfLiteContext* ctx,
139
+ size_t bytes,
140
+ int* buffer_idx) {
141
+ return GetMicroContext(ctx)->RequestScratchBufferInArena(bytes, buffer_idx);
142
+ }
143
+ inline void* MicroContextGetScratchBuffer(TfLiteContext* ctx, int buffer_idx) {
144
+ return GetMicroContext(ctx)->GetScratchBuffer(buffer_idx);
145
+ }
146
+ inline TfLiteTensor* MicroContextGetTensor(const struct TfLiteContext* context,
147
+ int tensor_idx) {
148
+ return GetMicroContext(context)->AllocateTempTfLiteTensor(tensor_idx);
149
+ }
150
+ inline TfLiteTensor* MicroContextGetTensor(const struct TfLiteContext* context,
151
+ int tensor_idx, int sg) {
152
+ return GetMicroContext(context)->AllocateTempTfLiteTensor(tensor_idx, sg);
153
+ }
154
+ inline TfLiteEvalTensor* MicroContextGetEvalTensor(
155
+ const struct TfLiteContext* context, int tensor_idx) {
156
+ return GetMicroContext(context)->GetEvalTensor(tensor_idx);
157
+ }
158
+ inline TfLiteEvalTensor* MicroContextGetEvalTensor(
159
+ const struct TfLiteContext* context, int tensor_idx, int sg) {
160
+ return GetMicroContext(context)->GetEvalTensor(tensor_idx, sg);
161
+ }
162
+ inline TfLiteExternalContext* MicroContextGetExternalContext(
163
+ TfLiteContext* context, TfLiteExternalContextType unused) {
164
+ return reinterpret_cast<TfLiteExternalContext*>(
165
+ GetMicroContext(context)->external_context());
166
+ }
167
+
168
+ // Requests that an error be reported with format string msg.
169
+ void MicroContextReportOpError(struct TfLiteContext* context,
170
+ const char* format, ...);
171
+
172
+ } // namespace tflite_micro
173
+
174
+ #endif // NO_INTERPRETER
175
+
176
+ #endif // TENSORFLOW_LITE_MICRO_MICRO_CONTEXT_H_
@@ -0,0 +1,79 @@
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_GRAPH_H_
17
+ #define TENSORFLOW_LITE_MICRO_MICRO_GRAPH_H_
18
+
19
+ #include "tensorflow/lite/micro/compatibility.h"
20
+ #include "tensorflow/lite/micro/micro_common.h"
21
+ #include "tensorflow/lite/micro/micro_resource_variable.h"
22
+
23
+ #ifdef NO_INTERPRETER
24
+
25
+ namespace tflite_micro {
26
+ struct MicroGraph{
27
+ int (*NumSubgraphs)();
28
+ size_t (*NumSubgraphInputs)(int subgraph_idx);
29
+ size_t (*NumSubgraphOutputs)(int subgraph_idx);
30
+ TfLiteEvalTensor* (*GetSubgraphInput)(int subgraph_idx, int i);
31
+ TfLiteEvalTensor* (*GetSubgraphOutput)(int subgraph_idx, int i);
32
+ TfLiteStatus (*InvokeSubgraph)(int subgraph_idx);
33
+ };
34
+ }
35
+
36
+ #else
37
+
38
+ namespace tflite_micro {
39
+
40
+ // Abstracts the details of interacting with the graph from the kernels
41
+ //
42
+ // Provides methods to invoke any subgraph in the tflite_micro::Graph.
43
+ class MicroGraph {
44
+ public:
45
+ virtual ~MicroGraph() = default;
46
+
47
+ // Calls TFLMRegistration->Invoke for every operator in a single subgraph
48
+ // in the model.
49
+ virtual TfLiteStatus InvokeSubgraph(int subgraph_idx) = 0;
50
+
51
+ // Number of tensor inputs to a specified subgraph in the model.
52
+ virtual size_t NumSubgraphInputs(int subgraph_idx) = 0;
53
+
54
+ // Get the specified input tensor of a specified subgraph in the model.
55
+ virtual TfLiteEvalTensor* GetSubgraphInput(int subgraph_idx,
56
+ int input_idx) = 0;
57
+
58
+ // Number of tensor outputs from a specified subgraph in the model.
59
+ virtual size_t NumSubgraphOutputs(int subgraph_idx) = 0;
60
+
61
+ // Get the specified output tensor of a specified subgraph in the model.
62
+ virtual TfLiteEvalTensor* GetSubgraphOutput(int subgraph_idx,
63
+ int output_idx) = 0;
64
+
65
+ // Number of subgraphs in the model.
66
+ virtual int NumSubgraphs() = 0;
67
+
68
+ // Get the resource variables for this TFLM graph.
69
+ virtual MicroResourceVariables* GetResourceVariables() = 0;
70
+
71
+ private:
72
+ TF_LITE_REMOVE_VIRTUAL_DELETE
73
+ };
74
+
75
+ } // namespace tflite_micro
76
+
77
+ #endif // NO_INTERPRETER
78
+
79
+ #endif // TENSORFLOW_LITE_MICRO_MICRO_GRAPH_H_