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,474 @@
1
+ #ifndef FLATBUFFERS_BASE_H_
2
+ #define FLATBUFFERS_BASE_H_
3
+
4
+ // clang-format off
5
+
6
+ // If activate should be declared and included first.
7
+ #if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \
8
+ defined(_MSC_VER) && defined(_DEBUG)
9
+ // The _CRTDBG_MAP_ALLOC inside <crtdbg.h> will replace
10
+ // calloc/free (etc) to its debug version using #define directives.
11
+ #define _CRTDBG_MAP_ALLOC
12
+ #include <stdlib.h>
13
+ #include <crtdbg.h>
14
+ // Replace operator new by trace-enabled version.
15
+ #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
16
+ #define new DEBUG_NEW
17
+ #endif
18
+
19
+ #if !defined(FLATBUFFERS_ASSERT)
20
+ #include <assert.h>
21
+ #define FLATBUFFERS_ASSERT assert
22
+ #elif defined(FLATBUFFERS_ASSERT_INCLUDE)
23
+ // Include file with forward declaration
24
+ #include FLATBUFFERS_ASSERT_INCLUDE
25
+ #endif
26
+
27
+ #ifndef ARDUINO
28
+ #include <cstdint>
29
+ #endif
30
+
31
+ #include <cstddef>
32
+ #include <cstdlib>
33
+ #include <cstring>
34
+
35
+ #if defined(ARDUINO) && !defined(ARDUINOSTL_M_H)
36
+ #include <utility.h>
37
+ #else
38
+ #include <utility>
39
+ #endif
40
+
41
+ #include <string>
42
+ #include <type_traits>
43
+ #include <vector>
44
+ #include <set>
45
+ #include <algorithm>
46
+ #include <iterator>
47
+ #include <memory>
48
+
49
+ #if defined(__unix__) && !defined(FLATBUFFERS_LOCALE_INDEPENDENT)
50
+ #include <unistd.h>
51
+ #endif
52
+
53
+ #ifdef __ANDROID__
54
+ #include <android/api-level.h>
55
+ #endif
56
+
57
+ #if defined(__ICCARM__)
58
+ #include <intrinsics.h>
59
+ #endif
60
+
61
+ // Note the __clang__ check is needed, because clang presents itself
62
+ // as an older GNUC compiler (4.2).
63
+ // Clang 3.3 and later implement all of the ISO C++ 2011 standard.
64
+ // Clang 3.4 and later implement all of the ISO C++ 2014 standard.
65
+ // http://clang.llvm.org/cxx_status.html
66
+
67
+ // Note the MSVC value '__cplusplus' may be incorrect:
68
+ // The '__cplusplus' predefined macro in the MSVC stuck at the value 199711L,
69
+ // indicating (erroneously!) that the compiler conformed to the C++98 Standard.
70
+ // This value should be correct starting from MSVC2017-15.7-Preview-3.
71
+ // The '__cplusplus' will be valid only if MSVC2017-15.7-P3 and the `/Zc:__cplusplus` switch is set.
72
+ // Workaround (for details see MSDN):
73
+ // Use the _MSC_VER and _MSVC_LANG definition instead of the __cplusplus for compatibility.
74
+ // The _MSVC_LANG macro reports the Standard version regardless of the '/Zc:__cplusplus' switch.
75
+
76
+ #if defined(__GNUC__) && !defined(__clang__)
77
+ #define FLATBUFFERS_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
78
+ #else
79
+ #define FLATBUFFERS_GCC 0
80
+ #endif
81
+
82
+ #if defined(__clang__)
83
+ #define FLATBUFFERS_CLANG (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
84
+ #else
85
+ #define FLATBUFFERS_CLANG 0
86
+ #endif
87
+
88
+ /// @cond FLATBUFFERS_INTERNAL
89
+ #if __cplusplus <= 199711L && \
90
+ (!defined(_MSC_VER) || _MSC_VER < 1600) && \
91
+ (!defined(__GNUC__) || \
92
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40400))
93
+ #error A C++11 compatible compiler with support for the auto typing is \
94
+ required for FlatBuffers.
95
+ #error __cplusplus _MSC_VER __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__
96
+ #endif
97
+
98
+ #if !defined(__clang__) && \
99
+ defined(__GNUC__) && \
100
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ < 40600)
101
+ // Backwards compatibility for g++ 4.4, and 4.5 which don't have the nullptr
102
+ // and constexpr keywords. Note the __clang__ check is needed, because clang
103
+ // presents itself as an older GNUC compiler.
104
+ #ifndef nullptr_t
105
+ const class nullptr_t {
106
+ public:
107
+ template<class T> inline operator T*() const { return 0; }
108
+ private:
109
+ void operator&() const;
110
+ } nullptr = {};
111
+ #endif
112
+ #ifndef constexpr
113
+ #define constexpr const
114
+ #endif
115
+ #endif
116
+
117
+ // The wire format uses a little endian encoding (since that's efficient for
118
+ // the common platforms).
119
+ #if defined(__s390x__)
120
+ #define FLATBUFFERS_LITTLEENDIAN 0
121
+ #endif // __s390x__
122
+ #if !defined(FLATBUFFERS_LITTLEENDIAN)
123
+ #if defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
124
+ #if (defined(__BIG_ENDIAN__) || \
125
+ (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
126
+ #define FLATBUFFERS_LITTLEENDIAN 0
127
+ #else
128
+ #define FLATBUFFERS_LITTLEENDIAN 1
129
+ #endif // __BIG_ENDIAN__
130
+ #elif defined(_MSC_VER)
131
+ #if defined(_M_PPC)
132
+ #define FLATBUFFERS_LITTLEENDIAN 0
133
+ #else
134
+ #define FLATBUFFERS_LITTLEENDIAN 1
135
+ #endif
136
+ #else
137
+ #error Unable to determine endianness, define FLATBUFFERS_LITTLEENDIAN.
138
+ #endif
139
+ #endif // !defined(FLATBUFFERS_LITTLEENDIAN)
140
+
141
+ #define FLATBUFFERS_VERSION_MAJOR 2
142
+ #define FLATBUFFERS_VERSION_MINOR 0
143
+ #define FLATBUFFERS_VERSION_REVISION 6
144
+ #define FLATBUFFERS_STRING_EXPAND(X) #X
145
+ #define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
146
+ namespace flatbuffers {
147
+ // Returns version as string "MAJOR.MINOR.REVISION".
148
+ const char* FLATBUFFERS_VERSION();
149
+ }
150
+
151
+ #if (!defined(_MSC_VER) || _MSC_VER > 1600) && \
152
+ (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 407)) || \
153
+ defined(__clang__)
154
+ #define FLATBUFFERS_FINAL_CLASS final
155
+ #define FLATBUFFERS_OVERRIDE override
156
+ #define FLATBUFFERS_EXPLICIT_CPP11 explicit
157
+ #define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : flatbuffers::voffset_t
158
+ #else
159
+ #define FLATBUFFERS_FINAL_CLASS
160
+ #define FLATBUFFERS_OVERRIDE
161
+ #define FLATBUFFERS_EXPLICIT_CPP11
162
+ #define FLATBUFFERS_VTABLE_UNDERLYING_TYPE
163
+ #endif
164
+
165
+ #if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \
166
+ (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \
167
+ (defined(__cpp_constexpr) && __cpp_constexpr >= 200704)
168
+ #define FLATBUFFERS_CONSTEXPR constexpr
169
+ #define FLATBUFFERS_CONSTEXPR_CPP11 constexpr
170
+ #define FLATBUFFERS_CONSTEXPR_DEFINED
171
+ #else
172
+ #define FLATBUFFERS_CONSTEXPR const
173
+ #define FLATBUFFERS_CONSTEXPR_CPP11
174
+ #endif
175
+
176
+ #if (defined(__cplusplus) && __cplusplus >= 201402L) || \
177
+ (defined(__cpp_constexpr) && __cpp_constexpr >= 201304)
178
+ #define FLATBUFFERS_CONSTEXPR_CPP14 FLATBUFFERS_CONSTEXPR_CPP11
179
+ #else
180
+ #define FLATBUFFERS_CONSTEXPR_CPP14
181
+ #endif
182
+
183
+ #if (defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) || \
184
+ (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023026)) || \
185
+ defined(__clang__)
186
+ #define FLATBUFFERS_NOEXCEPT noexcept
187
+ #else
188
+ #define FLATBUFFERS_NOEXCEPT
189
+ #endif
190
+
191
+ // NOTE: the FLATBUFFERS_DELETE_FUNC macro may change the access mode to
192
+ // private, so be sure to put it at the end or reset access mode explicitly.
193
+ #if (!defined(_MSC_VER) || _MSC_FULL_VER >= 180020827) && \
194
+ (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)) || \
195
+ defined(__clang__)
196
+ #define FLATBUFFERS_DELETE_FUNC(func) func = delete
197
+ #else
198
+ #define FLATBUFFERS_DELETE_FUNC(func) private: func
199
+ #endif
200
+
201
+ #if (!defined(_MSC_VER) || _MSC_VER >= 1900) && \
202
+ (!defined(__GNUC__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || \
203
+ defined(__clang__)
204
+ #define FLATBUFFERS_DEFAULT_DECLARATION
205
+ #endif
206
+
207
+ // Check if we can use template aliases
208
+ // Not possible if Microsoft Compiler before 2012
209
+ // Possible is the language feature __cpp_alias_templates is defined well
210
+ // Or possible if the C++ std is C+11 or newer
211
+ #if (defined(_MSC_VER) && _MSC_VER > 1700 /* MSVC2012 */) \
212
+ || (defined(__cpp_alias_templates) && __cpp_alias_templates >= 200704) \
213
+ || (defined(__cplusplus) && __cplusplus >= 201103L)
214
+ #define FLATBUFFERS_TEMPLATES_ALIASES
215
+ #endif
216
+
217
+ #ifndef FLATBUFFERS_HAS_STRING_VIEW
218
+ // Only provide flatbuffers::string_view if __has_include can be used
219
+ // to detect a header that provides an implementation
220
+ #if defined(__has_include)
221
+ // Check for std::string_view (in c++17)
222
+ #if __has_include(<string_view>) && (__cplusplus >= 201606 || (defined(_HAS_CXX17) && _HAS_CXX17))
223
+ #include <string_view>
224
+ namespace flatbuffers {
225
+ typedef std::string_view string_view;
226
+ }
227
+ #define FLATBUFFERS_HAS_STRING_VIEW 1
228
+ // Check for std::experimental::string_view (in c++14, compiler-dependent)
229
+ #elif __has_include(<experimental/string_view>) && (__cplusplus >= 201411)
230
+ #include <experimental/string_view>
231
+ namespace flatbuffers {
232
+ typedef std::experimental::string_view string_view;
233
+ }
234
+ #define FLATBUFFERS_HAS_STRING_VIEW 1
235
+ // Check for absl::string_view
236
+ #elif __has_include("absl/strings/string_view.h")
237
+ #include "absl/strings/string_view.h"
238
+ namespace flatbuffers {
239
+ typedef absl::string_view string_view;
240
+ }
241
+ #define FLATBUFFERS_HAS_STRING_VIEW 1
242
+ #endif
243
+ #endif // __has_include
244
+ #endif // !FLATBUFFERS_HAS_STRING_VIEW
245
+
246
+ #ifndef FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
247
+ // Allow heap allocations to be used
248
+ #define FLATBUFFERS_GENERAL_HEAP_ALLOC_OK 1
249
+ #endif // !FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
250
+
251
+ #ifndef FLATBUFFERS_HAS_NEW_STRTOD
252
+ // Modern (C++11) strtod and strtof functions are available for use.
253
+ // 1) nan/inf strings as argument of strtod;
254
+ // 2) hex-float as argument of strtod/strtof.
255
+ #if (defined(_MSC_VER) && _MSC_VER >= 1900) || \
256
+ (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || \
257
+ (defined(__clang__))
258
+ #define FLATBUFFERS_HAS_NEW_STRTOD 1
259
+ #endif
260
+ #endif // !FLATBUFFERS_HAS_NEW_STRTOD
261
+
262
+ #ifndef FLATBUFFERS_LOCALE_INDEPENDENT
263
+ // Enable locale independent functions {strtof_l, strtod_l,strtoll_l, strtoull_l}.
264
+ #if ((defined(_MSC_VER) && _MSC_VER >= 1800) || \
265
+ (defined(_XOPEN_VERSION) && (_XOPEN_VERSION>=700)) && (!defined(__ANDROID_API__) || (defined(__ANDROID_API__) && (__ANDROID_API__>=21))))
266
+ #define FLATBUFFERS_LOCALE_INDEPENDENT 1
267
+ #else
268
+ #define FLATBUFFERS_LOCALE_INDEPENDENT 0
269
+ #endif
270
+ #endif // !FLATBUFFERS_LOCALE_INDEPENDENT
271
+
272
+ // Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
273
+ // - __supress_ubsan__("undefined")
274
+ // - __supress_ubsan__("signed-integer-overflow")
275
+ #if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
276
+ #define __supress_ubsan__(type) __attribute__((no_sanitize(type)))
277
+ #elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
278
+ #define __supress_ubsan__(type) __attribute__((no_sanitize_undefined))
279
+ #else
280
+ #define __supress_ubsan__(type)
281
+ #endif
282
+
283
+ // This is constexpr function used for checking compile-time constants.
284
+ // Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
285
+ template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
286
+ return !!t;
287
+ }
288
+
289
+ // Enable C++ attribute [[]] if std:c++17 or higher.
290
+ #if ((__cplusplus >= 201703L) \
291
+ || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
292
+ // All attributes unknown to an implementation are ignored without causing an error.
293
+ #define FLATBUFFERS_ATTRIBUTE(attr) attr
294
+
295
+ #define FLATBUFFERS_FALLTHROUGH() [[fallthrough]]
296
+ #else
297
+ #define FLATBUFFERS_ATTRIBUTE(attr)
298
+
299
+ #if FLATBUFFERS_CLANG >= 30800
300
+ #define FLATBUFFERS_FALLTHROUGH() [[clang::fallthrough]]
301
+ #elif FLATBUFFERS_GCC >= 70300
302
+ #define FLATBUFFERS_FALLTHROUGH() [[gnu::fallthrough]]
303
+ #else
304
+ #define FLATBUFFERS_FALLTHROUGH()
305
+ #endif
306
+ #endif
307
+
308
+ /// @endcond
309
+
310
+ /// @file
311
+ namespace flatbuffers {
312
+
313
+ /// @cond FLATBUFFERS_INTERNAL
314
+ // Our default offset / size type, 32bit on purpose on 64bit systems.
315
+ // Also, using a consistent offset type maintains compatibility of serialized
316
+ // offset values between 32bit and 64bit systems.
317
+ typedef uint32_t uoffset_t;
318
+
319
+ // Signed offsets for references that can go in both directions.
320
+ typedef int32_t soffset_t;
321
+
322
+ // Offset/index used in v-tables, can be changed to uint8_t in
323
+ // format forks to save a bit of space if desired.
324
+ typedef uint16_t voffset_t;
325
+
326
+ typedef uintmax_t largest_scalar_t;
327
+
328
+ // In 32bits, this evaluates to 2GB - 1
329
+ #define FLATBUFFERS_MAX_BUFFER_SIZE ((1ULL << (sizeof(::flatbuffers::soffset_t) * 8 - 1)) - 1)
330
+
331
+ // We support aligning the contents of buffers up to this size.
332
+ #define FLATBUFFERS_MAX_ALIGNMENT 16
333
+
334
+ /// @brief The length of a FlatBuffer file header.
335
+ static const size_t kFileIdentifierLength = 4;
336
+
337
+ inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) {
338
+ return (min_align <= align) && (align <= (FLATBUFFERS_MAX_ALIGNMENT)) &&
339
+ (align & (align - 1)) == 0; // must be power of 2
340
+ }
341
+
342
+ #if defined(_MSC_VER)
343
+ #pragma warning(disable: 4351) // C4351: new behavior: elements of array ... will be default initialized
344
+ #pragma warning(push)
345
+ #pragma warning(disable: 4127) // C4127: conditional expression is constant
346
+ #endif
347
+
348
+ template<typename T> T EndianSwap(T t) {
349
+ #if defined(_MSC_VER)
350
+ #define FLATBUFFERS_BYTESWAP16 _byteswap_ushort
351
+ #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong
352
+ #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64
353
+ #elif defined(__ICCARM__)
354
+ #define FLATBUFFERS_BYTESWAP16 __REV16
355
+ #define FLATBUFFERS_BYTESWAP32 __REV
356
+ #define FLATBUFFERS_BYTESWAP64(x) \
357
+ ((__REV(static_cast<uint32_t>(x >> 32U))) | (static_cast<uint64_t>(__REV(static_cast<uint32_t>(x)))) << 32U)
358
+ #else
359
+ #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 && !defined(__clang__)
360
+ // __builtin_bswap16 was missing prior to GCC 4.8.
361
+ #define FLATBUFFERS_BYTESWAP16(x) \
362
+ static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16))
363
+ #else
364
+ #define FLATBUFFERS_BYTESWAP16 __builtin_bswap16
365
+ #endif
366
+ #define FLATBUFFERS_BYTESWAP32 __builtin_bswap32
367
+ #define FLATBUFFERS_BYTESWAP64 __builtin_bswap64
368
+ #endif
369
+ if (sizeof(T) == 1) { // Compile-time if-then's.
370
+ return t;
371
+ } else if (sizeof(T) == 2) {
372
+ union { T t; uint16_t i; } u = { t };
373
+ u.i = FLATBUFFERS_BYTESWAP16(u.i);
374
+ return u.t;
375
+ } else if (sizeof(T) == 4) {
376
+ union { T t; uint32_t i; } u = { t };
377
+ u.i = FLATBUFFERS_BYTESWAP32(u.i);
378
+ return u.t;
379
+ } else if (sizeof(T) == 8) {
380
+ union { T t; uint64_t i; } u = { t };
381
+ u.i = FLATBUFFERS_BYTESWAP64(u.i);
382
+ return u.t;
383
+ } else {
384
+ FLATBUFFERS_ASSERT(0);
385
+ return t;
386
+ }
387
+ }
388
+
389
+ #if defined(_MSC_VER)
390
+ #pragma warning(pop)
391
+ #endif
392
+
393
+
394
+ template<typename T> T EndianScalar(T t) {
395
+ #if FLATBUFFERS_LITTLEENDIAN
396
+ return t;
397
+ #else
398
+ return EndianSwap(t);
399
+ #endif
400
+ }
401
+
402
+ template<typename T>
403
+ // UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
404
+ __supress_ubsan__("alignment")
405
+ T ReadScalar(const void *p) {
406
+ return EndianScalar(*reinterpret_cast<const T *>(p));
407
+ }
408
+
409
+ // See https://github.com/google/flatbuffers/issues/5950
410
+
411
+ #if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000)
412
+ #pragma GCC diagnostic push
413
+ #pragma GCC diagnostic ignored "-Wstringop-overflow"
414
+ #endif
415
+
416
+ template<typename T>
417
+ // UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
418
+ __supress_ubsan__("alignment")
419
+ void WriteScalar(void *p, T t) {
420
+ *reinterpret_cast<T *>(p) = EndianScalar(t);
421
+ }
422
+
423
+ template<typename T> struct Offset;
424
+ template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
425
+ *reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
426
+ }
427
+
428
+ #if (FLATBUFFERS_GCC >= 100000) && (FLATBUFFERS_GCC < 110000)
429
+ #pragma GCC diagnostic pop
430
+ #endif
431
+
432
+ // Computes how many bytes you'd have to pad to be able to write an
433
+ // "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
434
+ // memory).
435
+ __supress_ubsan__("unsigned-integer-overflow")
436
+ inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
437
+ return ((~buf_size) + 1) & (scalar_size - 1);
438
+ }
439
+
440
+ // Generic 'operator==' with conditional specialisations.
441
+ // T e - new value of a scalar field.
442
+ // T def - default of scalar (is known at compile-time).
443
+ template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }
444
+
445
+ #if defined(FLATBUFFERS_NAN_DEFAULTS) && \
446
+ defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
447
+ // Like `operator==(e, def)` with weak NaN if T=(float|double).
448
+ template<typename T> inline bool IsFloatTheSameAs(T e, T def) {
449
+ return (e == def) || ((def != def) && (e != e));
450
+ }
451
+ template<> inline bool IsTheSameAs<float>(float e, float def) {
452
+ return IsFloatTheSameAs(e, def);
453
+ }
454
+ template<> inline bool IsTheSameAs<double>(double e, double def) {
455
+ return IsFloatTheSameAs(e, def);
456
+ }
457
+ #endif
458
+
459
+ // Check 'v' is out of closed range [low; high].
460
+ // Workaround for GCC warning [-Werror=type-limits]:
461
+ // comparison is always true due to limited range of data type.
462
+ template<typename T>
463
+ inline bool IsOutRange(const T &v, const T &low, const T &high) {
464
+ return (v < low) || (high < v);
465
+ }
466
+
467
+ // Check 'v' is in closed range [low; high].
468
+ template<typename T>
469
+ inline bool IsInRange(const T &v, const T &low, const T &high) {
470
+ return !IsOutRange(v, low, high);
471
+ }
472
+
473
+ } // namespace flatbuffers
474
+ #endif // FLATBUFFERS_BASE_H_
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2021 Google Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #ifndef FLATBUFFERS_BFBS_GENERATOR_H_
18
+ #define FLATBUFFERS_BFBS_GENERATOR_H_
19
+
20
+ #include <cstdint>
21
+
22
+ namespace flatbuffers {
23
+
24
+ enum GeneratorStatus {
25
+ OK,
26
+ FAILED,
27
+ FAILED_VERIFICATION,
28
+ };
29
+
30
+ // A Flatbuffer Code Generator that receives a binary serialized reflection.fbs
31
+ // and generates code from it.
32
+ class BfbsGenerator {
33
+ public:
34
+ virtual ~BfbsGenerator() {}
35
+
36
+ // Generate code from the provided `buffer` of given `length`. The buffer is
37
+ // a serialized reflection.fbs.
38
+ virtual GeneratorStatus Generate(const uint8_t *buffer, int64_t length) = 0;
39
+ };
40
+
41
+ } // namespace flatbuffers
42
+
43
+ #endif // FLATBUFFERS_BFBS_GENERATOR_H_
@@ -0,0 +1,142 @@
1
+ /*
2
+ * Copyright 2021 Google Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #ifndef FLATBUFFERS_BUFFER_H_
18
+ #define FLATBUFFERS_BUFFER_H_
19
+
20
+ #include "flatbuffers/base.h"
21
+
22
+ namespace flatbuffers {
23
+
24
+ // Wrapper for uoffset_t to allow safe template specialization.
25
+ // Value is allowed to be 0 to indicate a null object (see e.g. AddOffset).
26
+ template<typename T> struct Offset {
27
+ uoffset_t o;
28
+ Offset() : o(0) {}
29
+ Offset(uoffset_t _o) : o(_o) {}
30
+ Offset<void> Union() const { return Offset<void>(o); }
31
+ bool IsNull() const { return !o; }
32
+ };
33
+
34
+ inline void EndianCheck() {
35
+ int endiantest = 1;
36
+ // If this fails, see FLATBUFFERS_LITTLEENDIAN above.
37
+ FLATBUFFERS_ASSERT(*reinterpret_cast<char *>(&endiantest) ==
38
+ FLATBUFFERS_LITTLEENDIAN);
39
+ (void)endiantest;
40
+ }
41
+
42
+ template<typename T> FLATBUFFERS_CONSTEXPR size_t AlignOf() {
43
+ // clang-format off
44
+ #ifdef _MSC_VER
45
+ return __alignof(T);
46
+ #else
47
+ #ifndef alignof
48
+ return __alignof__(T);
49
+ #else
50
+ return alignof(T);
51
+ #endif
52
+ #endif
53
+ // clang-format on
54
+ }
55
+
56
+ // Lexicographically compare two strings (possibly containing nulls), and
57
+ // return true if the first is less than the second.
58
+ static inline bool StringLessThan(const char *a_data, uoffset_t a_size,
59
+ const char *b_data, uoffset_t b_size) {
60
+ const auto cmp = memcmp(a_data, b_data, (std::min)(a_size, b_size));
61
+ return cmp == 0 ? a_size < b_size : cmp < 0;
62
+ }
63
+
64
+ // When we read serialized data from memory, in the case of most scalars,
65
+ // we want to just read T, but in the case of Offset, we want to actually
66
+ // perform the indirection and return a pointer.
67
+ // The template specialization below does just that.
68
+ // It is wrapped in a struct since function templates can't overload on the
69
+ // return type like this.
70
+ // The typedef is for the convenience of callers of this function
71
+ // (avoiding the need for a trailing return decltype)
72
+ template<typename T> struct IndirectHelper {
73
+ typedef T return_type;
74
+ typedef T mutable_return_type;
75
+ static const size_t element_stride = sizeof(T);
76
+ static return_type Read(const uint8_t *p, uoffset_t i) {
77
+ return EndianScalar((reinterpret_cast<const T *>(p))[i]);
78
+ }
79
+ };
80
+ template<typename T> struct IndirectHelper<Offset<T>> {
81
+ typedef const T *return_type;
82
+ typedef T *mutable_return_type;
83
+ static const size_t element_stride = sizeof(uoffset_t);
84
+ static return_type Read(const uint8_t *p, uoffset_t i) {
85
+ p += i * sizeof(uoffset_t);
86
+ return reinterpret_cast<return_type>(p + ReadScalar<uoffset_t>(p));
87
+ }
88
+ };
89
+ template<typename T> struct IndirectHelper<const T *> {
90
+ typedef const T *return_type;
91
+ typedef T *mutable_return_type;
92
+ static const size_t element_stride = sizeof(T);
93
+ static return_type Read(const uint8_t *p, uoffset_t i) {
94
+ return reinterpret_cast<const T *>(p + i * sizeof(T));
95
+ }
96
+ };
97
+
98
+ /// @brief Get a pointer to the the file_identifier section of the buffer.
99
+ /// @return Returns a const char pointer to the start of the file_identifier
100
+ /// characters in the buffer. The returned char * has length
101
+ /// 'flatbuffers::FlatBufferBuilder::kFileIdentifierLength'.
102
+ /// This function is UNDEFINED for FlatBuffers whose schema does not include
103
+ /// a file_identifier (likely points at padding or the start of a the root
104
+ /// vtable).
105
+ inline const char *GetBufferIdentifier(const void *buf,
106
+ bool size_prefixed = false) {
107
+ return reinterpret_cast<const char *>(buf) +
108
+ ((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t));
109
+ }
110
+
111
+ // Helper to see if the identifier in a buffer has the expected value.
112
+ inline bool BufferHasIdentifier(const void *buf, const char *identifier,
113
+ bool size_prefixed = false) {
114
+ return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier,
115
+ flatbuffers::kFileIdentifierLength) == 0;
116
+ }
117
+
118
+ /// @cond FLATBUFFERS_INTERNAL
119
+ // Helpers to get a typed pointer to the root object contained in the buffer.
120
+ template<typename T> T *GetMutableRoot(void *buf) {
121
+ EndianCheck();
122
+ return reinterpret_cast<T *>(
123
+ reinterpret_cast<uint8_t *>(buf) +
124
+ EndianScalar(*reinterpret_cast<uoffset_t *>(buf)));
125
+ }
126
+
127
+ template<typename T> T *GetMutableSizePrefixedRoot(void *buf) {
128
+ return GetMutableRoot<T>(reinterpret_cast<uint8_t *>(buf) +
129
+ sizeof(uoffset_t));
130
+ }
131
+
132
+ template<typename T> const T *GetRoot(const void *buf) {
133
+ return GetMutableRoot<T>(const_cast<void *>(buf));
134
+ }
135
+
136
+ template<typename T> const T *GetSizePrefixedRoot(const void *buf) {
137
+ return GetRoot<T>(reinterpret_cast<const uint8_t *>(buf) + sizeof(uoffset_t));
138
+ }
139
+
140
+ } // namespace flatbuffers
141
+
142
+ #endif // FLATBUFFERS_BUFFER_H_