xmos-ai-tools 1.3.2.dev80__py3-none-macosx_10_15_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xmos_ai_tools/__init__.py +7 -0
- xmos_ai_tools/io_server/__init__.py +151 -0
- xmos_ai_tools/runtime/__init__.py +0 -0
- xmos_ai_tools/runtime/buildfiles/aitoolslib.cmake +13 -0
- xmos_ai_tools/runtime/buildfiles/aitoolslib.make +8 -0
- xmos_ai_tools/runtime/include/flash_server.h +74 -0
- xmos_ai_tools/runtime/include/flatbuffers/allocator.h +68 -0
- xmos_ai_tools/runtime/include/flatbuffers/array.h +243 -0
- xmos_ai_tools/runtime/include/flatbuffers/base.h +474 -0
- xmos_ai_tools/runtime/include/flatbuffers/bfbs_generator.h +43 -0
- xmos_ai_tools/runtime/include/flatbuffers/buffer.h +142 -0
- xmos_ai_tools/runtime/include/flatbuffers/buffer_ref.h +53 -0
- xmos_ai_tools/runtime/include/flatbuffers/code_generators.h +235 -0
- xmos_ai_tools/runtime/include/flatbuffers/default_allocator.h +64 -0
- xmos_ai_tools/runtime/include/flatbuffers/detached_buffer.h +114 -0
- xmos_ai_tools/runtime/include/flatbuffers/flatbuffer_builder.h +1197 -0
- xmos_ai_tools/runtime/include/flatbuffers/flatbuffers.h +270 -0
- xmos_ai_tools/runtime/include/flatbuffers/flatc.h +111 -0
- xmos_ai_tools/runtime/include/flatbuffers/flexbuffers.h +1897 -0
- xmos_ai_tools/runtime/include/flatbuffers/grpc.h +300 -0
- xmos_ai_tools/runtime/include/flatbuffers/hash.h +127 -0
- xmos_ai_tools/runtime/include/flatbuffers/idl.h +1232 -0
- xmos_ai_tools/runtime/include/flatbuffers/minireflect.h +419 -0
- xmos_ai_tools/runtime/include/flatbuffers/pch/flatc_pch.h +39 -0
- xmos_ai_tools/runtime/include/flatbuffers/pch/pch.h +38 -0
- xmos_ai_tools/runtime/include/flatbuffers/reflection.h +502 -0
- xmos_ai_tools/runtime/include/flatbuffers/reflection_generated.h +1449 -0
- xmos_ai_tools/runtime/include/flatbuffers/registry.h +128 -0
- xmos_ai_tools/runtime/include/flatbuffers/stl_emulation.h +509 -0
- xmos_ai_tools/runtime/include/flatbuffers/string.h +64 -0
- xmos_ai_tools/runtime/include/flatbuffers/struct.h +53 -0
- xmos_ai_tools/runtime/include/flatbuffers/table.h +168 -0
- xmos_ai_tools/runtime/include/flatbuffers/util.h +690 -0
- xmos_ai_tools/runtime/include/flatbuffers/vector.h +370 -0
- xmos_ai_tools/runtime/include/flatbuffers/vector_downward.h +271 -0
- xmos_ai_tools/runtime/include/flatbuffers/verifier.h +283 -0
- xmos_ai_tools/runtime/include/ioserver.h +44 -0
- xmos_ai_tools/runtime/include/lib_nn/api/TransposeConv.h +24 -0
- xmos_ai_tools/runtime/include/lib_nn/api/add_int16.h +27 -0
- xmos_ai_tools/runtime/include/lib_nn/api/add_int16_transform.h +42 -0
- xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16.h +22 -0
- xmos_ai_tools/runtime/include/lib_nn/api/dequantize_int16_transform.h +34 -0
- xmos_ai_tools/runtime/include/lib_nn/api/expand_8_to_16.h +8 -0
- xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16.h +42 -0
- xmos_ai_tools/runtime/include/lib_nn/api/multiply_int16_transform.h +71 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_api.h +15 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_bin_types.h +14 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_config.h +287 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_conv2d_structs.h +72 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_image.h +26 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_layers.h +303 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_op_helper.h +132 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_op_utils.h +150 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_operator.h +18 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_pooling.h +551 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_types.h +83 -0
- xmos_ai_tools/runtime/include/lib_nn/api/nn_window_params.h +55 -0
- xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16.h +54 -0
- xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_kernel_transform.h +37 -0
- xmos_ai_tools/runtime/include/lib_nn/api/output_transform_fn_int16_mappings.h +13 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quadratic_approximation.h +82 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quadratic_interpolation.h +23 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16.h +22 -0
- xmos_ai_tools/runtime/include/lib_nn/api/quantize_int16_transform.h +33 -0
- xmos_ai_tools/runtime/include/lib_nn/api/version.h +13 -0
- xmos_ai_tools/runtime/include/lib_nn/api/vpu_memmove_word_aligned.h +15 -0
- xmos_ai_tools/runtime/include/lib_nn/api/vpu_memset_256.h +55 -0
- xmos_ai_tools/runtime/include/lib_nn/api/vpu_sim.h +118 -0
- xmos_ai_tools/runtime/include/lib_nn/api/xs3_vpu.h +216 -0
- xmos_ai_tools/runtime/include/lib_nn/api/xs3a_registers.h +2869 -0
- xmos_ai_tools/runtime/include/lib_nn/src/asm/asm_constants.h +41 -0
- xmos_ai_tools/runtime/include/lib_nn/src/asm/window_op_plan.h +25 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/fast_flash.h +47 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/inference_engine.h +218 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/memory_parallel_transport.h +52 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/version.h +13 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_config.h +17 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_device_memory.h +62 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/api/xcore_shared_config.h +31 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/conv2d_float.h +155 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_common.h +19 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_custom_options.h +28 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_error_reporter.h +32 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_interpreter.h +49 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_ops.h +71 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_profiler.h +49 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_utils.h +160 -0
- xmos_ai_tools/runtime/include/lib_tflite_micro/src/thread_call.h +119 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_defs.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_device.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_descriptors.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/legacy/usb_std_requests.h +4 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud.h +518 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_conf_default.h +11 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_device.h +87 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_descriptors.h +191 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/api/xud_std_requests.h +120 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/XUD_USB_Defines.h +70 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/hid.h +23 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio10.h +30 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudio20.h +357 -0
- xmos_ai_tools/runtime/include/lib_xud/lib_xud/src/user/class/usbaudiocommon.h +168 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/delay_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/energy_flexbuffers_generated_data.h +28 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/fft_flexbuffers_generated_data.h +37 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_log_flexbuffers_generated_data.h +27 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_spectral_subtraction_flexbuffers_generated_data.h +26 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/framer_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/irfft.h +31 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/overlap_add_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/pcan_flexbuffers_generated_data.h +7 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/rfft.h +31 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/stacker_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/micro/kernels/window_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/signal/src/circular_buffer.h +118 -0
- xmos_ai_tools/runtime/include/signal/src/complex.h +29 -0
- xmos_ai_tools/runtime/include/signal/src/energy.h +38 -0
- xmos_ai_tools/runtime/include/signal/src/fft_auto_scale.h +35 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank.h +69 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank_log.h +38 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank_spectral_subtraction.h +73 -0
- xmos_ai_tools/runtime/include/signal/src/filter_bank_square_root.h +34 -0
- xmos_ai_tools/runtime/include/signal/src/irfft.h +84 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_common.h +49 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_float.h +31 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int16.h +30 -0
- xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int32.h +31 -0
- xmos_ai_tools/runtime/include/signal/src/log.h +30 -0
- xmos_ai_tools/runtime/include/signal/src/max_abs.h +31 -0
- xmos_ai_tools/runtime/include/signal/src/msb.h +32 -0
- xmos_ai_tools/runtime/include/signal/src/overlap_add.h +46 -0
- xmos_ai_tools/runtime/include/signal/src/pcan_argc_fixed.h +41 -0
- xmos_ai_tools/runtime/include/signal/src/rfft.h +85 -0
- xmos_ai_tools/runtime/include/signal/src/square_root.h +32 -0
- xmos_ai_tools/runtime/include/signal/src/window.h +31 -0
- xmos_ai_tools/runtime/include/signal/testdata/fft_test_data.h +48 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/array.h +156 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/builtin_op_data.h +22 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/builtin_ops.h +241 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/c/builtin_op_data.h +20 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/c/c_api_types.h +26 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/c/common.h +30 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/context_util.h +54 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/api/error_reporter.h +72 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/api/flatbuffer_conversions.h +440 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/api/tensor_utils.h +28 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/c/builtin_op_data.h +626 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/c/c_api_types.h +178 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/c/common.h +1496 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/core/macros.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/bits.h +102 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft.h +50 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_io.h +34 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/fft_util.h +34 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank.h +63 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_io.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/filterbank_util.h +50 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_io.h +31 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/frontend_util.h +52 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_common.h +48 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/kiss_fft_int16.h +33 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_lut.h +40 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_io.h +33 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/log_scale_util.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction.h +46 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_io.h +36 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/noise_reduction_util.h +50 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/pcan_gain_control_util.h +57 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_io.h +34 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/experimental/microfrontend/lib/window_util.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/common.h +1358 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/compatibility.h +122 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/cppmath.h +40 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/max.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/min.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/optimized/neon_check.h +20 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor.h +141 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor_utils.h +623 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/quantization_util.h +292 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add.h +561 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add_n.h +86 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/arg_min_max.h +88 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_matmul.h +275 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/batch_to_space_nd.h +101 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/binary_function.h +91 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_args.h +56 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/broadcast_to.h +97 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/ceil.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/comparisons.h +271 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/concatenation.h +141 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/conv.h +289 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/cumsum.h +175 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depth_to_space.h +79 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h +100 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_uint8.h +319 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/dequantize.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/div.h +247 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/elu.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/exp.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fill.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_div.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/floor_mod.h +44 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/fully_connected.h +323 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/hard_swish.h +168 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/add.h +250 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/conv.h +241 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/depthwise_conv.h +291 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h +126 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/l2normalization.h +67 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/logistic.h +121 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mean.h +18 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mul.h +194 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h +264 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/tanh.h +117 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/transpose_conv.h +224 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/l2normalization.h +90 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/leaky_relu.h +69 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/log_softmax.h +256 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/logistic.h +132 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/lstm_cell.h +422 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/maximum_minimum.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/mul.h +267 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/neg.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pad.h +169 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/pooling.h +303 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils.h +333 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/portable_tensor_utils_impl.h +244 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/prelu.h +111 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h +140 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/quantize.h +89 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/reduce.h +491 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/requantize.h +70 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_bilinear.h +233 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_nearest_neighbor.h +102 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/round.h +51 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/select.h +151 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/slice.h +80 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/softmax.h +233 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_batch_nd.h +109 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/space_to_depth.h +80 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/strided_slice.h +147 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/sub.h +465 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/tanh.h +129 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose.h +203 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/transpose_conv.h +225 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/runtime_shape.h +168 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/strided_slice_logic.h +278 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/tensor_ctypes.h +42 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/types.h +1096 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/kernel_util.h +341 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/op_macros.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/kernels/padding.h +115 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/ibuffer_allocator.h +100 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/non_persistent_arena_buffer_allocator.h +104 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/persistent_arena_buffer_allocator.h +58 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/recording_single_arena_buffer_allocator.h +63 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/arena_allocator/single_arena_buffer_allocator.h +144 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/benchmarks/micro_benchmark.h +95 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/compatibility.h +32 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/cortex_m_generic/debug_log_callback.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/debug_log.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_model_settings.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/expected_output_data.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/input_data.h +108 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/network_tester/network_model.h +166 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/detection_responder.h +32 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/image_provider.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/main_functions.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/person_detection/model_settings.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/fake_micro_context.h +70 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/flatbuffer_utils.h +65 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activation_utils.h +57 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/activations.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/add.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_function_specializations.h +141 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_interface.h +75 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_slicers.h +56 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/mli_tf_utils.h +310 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buf_mgr.h +145 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/arc_mli/scratch_buffers.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_common.h +24 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/ceva_tflm_lib.h +613 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/mcps_macros.h +115 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ceva/types.h +1286 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer_flexbuffers_generated_data.h +22 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv.h +117 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv_test.h +94 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/depthwise_conv.h +80 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/dequantize.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/detection_postprocess_flexbuffers_generated_data.h +25 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ethosu.h +28 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/fully_connected.h +112 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/hard_swish.h +30 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_runner.h +86 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_util.h +150 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/leaky_relu.h +43 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logical.h +35 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/logistic.h +42 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval.h +541 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_eval_test.h +817 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/lstm_shared.h +150 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_ops.h +158 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_tensor_utils.h +56 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/mul.h +74 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pad.h +27 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pooling.h +142 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/prelu.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/quantize.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reduce.h +65 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reshape.h +26 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/softmax.h +67 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/strided_slice.h +40 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/sub.h +60 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/svdf.h +100 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/conv_test_data.h +37 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/testdata/lstm_test_data.h +579 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/hifimini/fixedpoint_utils.h +139 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_eval.h +216 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/lstm_shared.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_add.h +48 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_conv.h +89 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_depthwise_conv.h +74 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_fully_connected.h +78 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pad.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_pooling.h +76 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reduce.h +47 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reshape.h +44 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_softmax.h +58 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_svdf.h +39 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_helpers.h +64 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h +170 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/linear_memory_planner.h +53 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/memory_plan_struct.h +73 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/micro_memory_planner.h +95 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/non_persistent_buffer_planner_shim.h +133 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocation_info.h +138 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocator.h +351 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_arena_constants.h +28 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_common.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_context.h +176 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_graph.h +79 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter.h +189 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_context.h +125 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_graph.h +110 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_log.h +42 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_mutable_op_resolver.h +708 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_op_resolver.h +62 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler.h +140 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler_interface.h +38 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_resource_variable.h +89 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_time.h +36 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_utils.h +162 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/mock_micro_graph.h +60 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/interpreter/src/python_ops_resolver.h +21 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size.h +30 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/tflite_size/src/flatbuffer_size_wrapper.h +33 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_allocator.h +125 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/recording_micro_interpreter.h +69 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/system_setup.h +27 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helper_custom_ops.h +49 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helpers.h +334 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/micro_test.h +267 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/test_conv_model.h +23 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/flatbuffer_conversions_bridge.h +45 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h +36 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/log_utils.h +273 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/metrics.h +41 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/op_resolver.h +127 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/portable_type_to_tflitetype.h +75 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_generated.h +24644 -0
- xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_utils.h +33 -0
- xmos_ai_tools/runtime/include/tile_ram_server.h +38 -0
- xmos_ai_tools/runtime/lib/libhost_xtflitemicro.a +0 -0
- xmos_ai_tools/runtime/lib/libxtflitemicro.a +0 -0
- xmos_ai_tools/xformer/__init__.py +60 -0
- xmos_ai_tools/xformer/flash.py +190 -0
- xmos_ai_tools/xinterpreters/__init__.py +1 -0
- xmos_ai_tools/xinterpreters/exceptions.py +38 -0
- xmos_ai_tools/xinterpreters/host_interpreter.py +652 -0
- xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.1.0.1.dylib +0 -0
- xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.dylib +0 -0
- xmos_ai_tools-1.3.2.dev80.data/data/bin/xcore-opt +0 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/METADATA +33 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/RECORD +395 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/WHEEL +5 -0
- xmos_ai_tools-1.3.2.dev80.dist-info/top_level.txt +1 -0
@@ -0,0 +1,370 @@
|
|
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_VECTOR_H_
|
18
|
+
#define FLATBUFFERS_VECTOR_H_
|
19
|
+
|
20
|
+
#include "flatbuffers/base.h"
|
21
|
+
#include "flatbuffers/buffer.h"
|
22
|
+
|
23
|
+
namespace flatbuffers {
|
24
|
+
|
25
|
+
struct String;
|
26
|
+
|
27
|
+
// An STL compatible iterator implementation for Vector below, effectively
|
28
|
+
// calling Get() for every element.
|
29
|
+
template<typename T, typename IT> struct VectorIterator {
|
30
|
+
typedef std::random_access_iterator_tag iterator_category;
|
31
|
+
typedef IT value_type;
|
32
|
+
typedef ptrdiff_t difference_type;
|
33
|
+
typedef IT *pointer;
|
34
|
+
typedef IT &reference;
|
35
|
+
|
36
|
+
VectorIterator(const uint8_t *data, uoffset_t i)
|
37
|
+
: data_(data + IndirectHelper<T>::element_stride * i) {}
|
38
|
+
VectorIterator(const VectorIterator &other) : data_(other.data_) {}
|
39
|
+
VectorIterator() : data_(nullptr) {}
|
40
|
+
|
41
|
+
VectorIterator &operator=(const VectorIterator &other) {
|
42
|
+
data_ = other.data_;
|
43
|
+
return *this;
|
44
|
+
}
|
45
|
+
|
46
|
+
VectorIterator &operator=(VectorIterator &&other) {
|
47
|
+
data_ = other.data_;
|
48
|
+
return *this;
|
49
|
+
}
|
50
|
+
|
51
|
+
bool operator==(const VectorIterator &other) const {
|
52
|
+
return data_ == other.data_;
|
53
|
+
}
|
54
|
+
|
55
|
+
bool operator<(const VectorIterator &other) const {
|
56
|
+
return data_ < other.data_;
|
57
|
+
}
|
58
|
+
|
59
|
+
bool operator!=(const VectorIterator &other) const {
|
60
|
+
return data_ != other.data_;
|
61
|
+
}
|
62
|
+
|
63
|
+
difference_type operator-(const VectorIterator &other) const {
|
64
|
+
return (data_ - other.data_) / IndirectHelper<T>::element_stride;
|
65
|
+
}
|
66
|
+
|
67
|
+
// Note: return type is incompatible with the standard
|
68
|
+
// `reference operator*()`.
|
69
|
+
IT operator*() const { return IndirectHelper<T>::Read(data_, 0); }
|
70
|
+
|
71
|
+
// Note: return type is incompatible with the standard
|
72
|
+
// `pointer operator->()`.
|
73
|
+
IT operator->() const { return IndirectHelper<T>::Read(data_, 0); }
|
74
|
+
|
75
|
+
VectorIterator &operator++() {
|
76
|
+
data_ += IndirectHelper<T>::element_stride;
|
77
|
+
return *this;
|
78
|
+
}
|
79
|
+
|
80
|
+
VectorIterator operator++(int) {
|
81
|
+
VectorIterator temp(data_, 0);
|
82
|
+
data_ += IndirectHelper<T>::element_stride;
|
83
|
+
return temp;
|
84
|
+
}
|
85
|
+
|
86
|
+
VectorIterator operator+(const uoffset_t &offset) const {
|
87
|
+
return VectorIterator(data_ + offset * IndirectHelper<T>::element_stride,
|
88
|
+
0);
|
89
|
+
}
|
90
|
+
|
91
|
+
VectorIterator &operator+=(const uoffset_t &offset) {
|
92
|
+
data_ += offset * IndirectHelper<T>::element_stride;
|
93
|
+
return *this;
|
94
|
+
}
|
95
|
+
|
96
|
+
VectorIterator &operator--() {
|
97
|
+
data_ -= IndirectHelper<T>::element_stride;
|
98
|
+
return *this;
|
99
|
+
}
|
100
|
+
|
101
|
+
VectorIterator operator--(int) {
|
102
|
+
VectorIterator temp(data_, 0);
|
103
|
+
data_ -= IndirectHelper<T>::element_stride;
|
104
|
+
return temp;
|
105
|
+
}
|
106
|
+
|
107
|
+
VectorIterator operator-(const uoffset_t &offset) const {
|
108
|
+
return VectorIterator(data_ - offset * IndirectHelper<T>::element_stride,
|
109
|
+
0);
|
110
|
+
}
|
111
|
+
|
112
|
+
VectorIterator &operator-=(const uoffset_t &offset) {
|
113
|
+
data_ -= offset * IndirectHelper<T>::element_stride;
|
114
|
+
return *this;
|
115
|
+
}
|
116
|
+
|
117
|
+
private:
|
118
|
+
const uint8_t *data_;
|
119
|
+
};
|
120
|
+
|
121
|
+
template<typename Iterator>
|
122
|
+
struct VectorReverseIterator : public std::reverse_iterator<Iterator> {
|
123
|
+
explicit VectorReverseIterator(Iterator iter)
|
124
|
+
: std::reverse_iterator<Iterator>(iter) {}
|
125
|
+
|
126
|
+
// Note: return type is incompatible with the standard
|
127
|
+
// `reference operator*()`.
|
128
|
+
typename Iterator::value_type operator*() const {
|
129
|
+
auto tmp = std::reverse_iterator<Iterator>::current;
|
130
|
+
return *--tmp;
|
131
|
+
}
|
132
|
+
|
133
|
+
// Note: return type is incompatible with the standard
|
134
|
+
// `pointer operator->()`.
|
135
|
+
typename Iterator::value_type operator->() const {
|
136
|
+
auto tmp = std::reverse_iterator<Iterator>::current;
|
137
|
+
return *--tmp;
|
138
|
+
}
|
139
|
+
};
|
140
|
+
|
141
|
+
// This is used as a helper type for accessing vectors.
|
142
|
+
// Vector::data() assumes the vector elements start after the length field.
|
143
|
+
template<typename T> class Vector {
|
144
|
+
public:
|
145
|
+
typedef VectorIterator<T, typename IndirectHelper<T>::mutable_return_type>
|
146
|
+
iterator;
|
147
|
+
typedef VectorIterator<T, typename IndirectHelper<T>::return_type>
|
148
|
+
const_iterator;
|
149
|
+
typedef VectorReverseIterator<iterator> reverse_iterator;
|
150
|
+
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
|
151
|
+
|
152
|
+
typedef typename flatbuffers::bool_constant<flatbuffers::is_scalar<T>::value>
|
153
|
+
scalar_tag;
|
154
|
+
|
155
|
+
static FLATBUFFERS_CONSTEXPR bool is_span_observable =
|
156
|
+
scalar_tag::value && (FLATBUFFERS_LITTLEENDIAN || sizeof(T) == 1);
|
157
|
+
|
158
|
+
uoffset_t size() const { return EndianScalar(length_); }
|
159
|
+
|
160
|
+
// Deprecated: use size(). Here for backwards compatibility.
|
161
|
+
FLATBUFFERS_ATTRIBUTE([[deprecated("use size() instead")]])
|
162
|
+
uoffset_t Length() const { return size(); }
|
163
|
+
|
164
|
+
typedef typename IndirectHelper<T>::return_type return_type;
|
165
|
+
typedef typename IndirectHelper<T>::mutable_return_type mutable_return_type;
|
166
|
+
typedef return_type value_type;
|
167
|
+
|
168
|
+
return_type Get(uoffset_t i) const {
|
169
|
+
FLATBUFFERS_ASSERT(i < size());
|
170
|
+
return IndirectHelper<T>::Read(Data(), i);
|
171
|
+
}
|
172
|
+
|
173
|
+
return_type operator[](uoffset_t i) const { return Get(i); }
|
174
|
+
|
175
|
+
// If this is a Vector of enums, T will be its storage type, not the enum
|
176
|
+
// type. This function makes it convenient to retrieve value with enum
|
177
|
+
// type E.
|
178
|
+
template<typename E> E GetEnum(uoffset_t i) const {
|
179
|
+
return static_cast<E>(Get(i));
|
180
|
+
}
|
181
|
+
|
182
|
+
// If this a vector of unions, this does the cast for you. There's no check
|
183
|
+
// to make sure this is the right type!
|
184
|
+
template<typename U> const U *GetAs(uoffset_t i) const {
|
185
|
+
return reinterpret_cast<const U *>(Get(i));
|
186
|
+
}
|
187
|
+
|
188
|
+
// If this a vector of unions, this does the cast for you. There's no check
|
189
|
+
// to make sure this is actually a string!
|
190
|
+
const String *GetAsString(uoffset_t i) const {
|
191
|
+
return reinterpret_cast<const String *>(Get(i));
|
192
|
+
}
|
193
|
+
|
194
|
+
const void *GetStructFromOffset(size_t o) const {
|
195
|
+
return reinterpret_cast<const void *>(Data() + o);
|
196
|
+
}
|
197
|
+
|
198
|
+
iterator begin() { return iterator(Data(), 0); }
|
199
|
+
const_iterator begin() const { return const_iterator(Data(), 0); }
|
200
|
+
|
201
|
+
iterator end() { return iterator(Data(), size()); }
|
202
|
+
const_iterator end() const { return const_iterator(Data(), size()); }
|
203
|
+
|
204
|
+
reverse_iterator rbegin() { return reverse_iterator(end()); }
|
205
|
+
const_reverse_iterator rbegin() const {
|
206
|
+
return const_reverse_iterator(end());
|
207
|
+
}
|
208
|
+
|
209
|
+
reverse_iterator rend() { return reverse_iterator(begin()); }
|
210
|
+
const_reverse_iterator rend() const {
|
211
|
+
return const_reverse_iterator(begin());
|
212
|
+
}
|
213
|
+
|
214
|
+
const_iterator cbegin() const { return begin(); }
|
215
|
+
|
216
|
+
const_iterator cend() const { return end(); }
|
217
|
+
|
218
|
+
const_reverse_iterator crbegin() const { return rbegin(); }
|
219
|
+
|
220
|
+
const_reverse_iterator crend() const { return rend(); }
|
221
|
+
|
222
|
+
// Change elements if you have a non-const pointer to this object.
|
223
|
+
// Scalars only. See reflection.h, and the documentation.
|
224
|
+
void Mutate(uoffset_t i, const T &val) {
|
225
|
+
FLATBUFFERS_ASSERT(i < size());
|
226
|
+
WriteScalar(data() + i, val);
|
227
|
+
}
|
228
|
+
|
229
|
+
// Change an element of a vector of tables (or strings).
|
230
|
+
// "val" points to the new table/string, as you can obtain from
|
231
|
+
// e.g. reflection::AddFlatBuffer().
|
232
|
+
void MutateOffset(uoffset_t i, const uint8_t *val) {
|
233
|
+
FLATBUFFERS_ASSERT(i < size());
|
234
|
+
static_assert(sizeof(T) == sizeof(uoffset_t), "Unrelated types");
|
235
|
+
WriteScalar(data() + i,
|
236
|
+
static_cast<uoffset_t>(val - (Data() + i * sizeof(uoffset_t))));
|
237
|
+
}
|
238
|
+
|
239
|
+
// Get a mutable pointer to tables/strings inside this vector.
|
240
|
+
mutable_return_type GetMutableObject(uoffset_t i) const {
|
241
|
+
FLATBUFFERS_ASSERT(i < size());
|
242
|
+
return const_cast<mutable_return_type>(IndirectHelper<T>::Read(Data(), i));
|
243
|
+
}
|
244
|
+
|
245
|
+
// The raw data in little endian format. Use with care.
|
246
|
+
const uint8_t *Data() const {
|
247
|
+
return reinterpret_cast<const uint8_t *>(&length_ + 1);
|
248
|
+
}
|
249
|
+
|
250
|
+
uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); }
|
251
|
+
|
252
|
+
// Similarly, but typed, much like std::vector::data
|
253
|
+
const T *data() const { return reinterpret_cast<const T *>(Data()); }
|
254
|
+
T *data() { return reinterpret_cast<T *>(Data()); }
|
255
|
+
|
256
|
+
template<typename K> return_type LookupByKey(K key) const {
|
257
|
+
void *search_result = std::bsearch(
|
258
|
+
&key, Data(), size(), IndirectHelper<T>::element_stride, KeyCompare<K>);
|
259
|
+
|
260
|
+
if (!search_result) {
|
261
|
+
return nullptr; // Key not found.
|
262
|
+
}
|
263
|
+
|
264
|
+
const uint8_t *element = reinterpret_cast<const uint8_t *>(search_result);
|
265
|
+
|
266
|
+
return IndirectHelper<T>::Read(element, 0);
|
267
|
+
}
|
268
|
+
|
269
|
+
template<typename K> mutable_return_type MutableLookupByKey(K key) {
|
270
|
+
return const_cast<mutable_return_type>(LookupByKey(key));
|
271
|
+
}
|
272
|
+
|
273
|
+
protected:
|
274
|
+
// This class is only used to access pre-existing data. Don't ever
|
275
|
+
// try to construct these manually.
|
276
|
+
Vector();
|
277
|
+
|
278
|
+
uoffset_t length_;
|
279
|
+
|
280
|
+
private:
|
281
|
+
// This class is a pointer. Copying will therefore create an invalid object.
|
282
|
+
// Private and unimplemented copy constructor.
|
283
|
+
Vector(const Vector &);
|
284
|
+
Vector &operator=(const Vector &);
|
285
|
+
|
286
|
+
template<typename K> static int KeyCompare(const void *ap, const void *bp) {
|
287
|
+
const K *key = reinterpret_cast<const K *>(ap);
|
288
|
+
const uint8_t *data = reinterpret_cast<const uint8_t *>(bp);
|
289
|
+
auto table = IndirectHelper<T>::Read(data, 0);
|
290
|
+
|
291
|
+
// std::bsearch compares with the operands transposed, so we negate the
|
292
|
+
// result here.
|
293
|
+
return -table->KeyCompareWithValue(*key);
|
294
|
+
}
|
295
|
+
};
|
296
|
+
|
297
|
+
template<class U>
|
298
|
+
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U> &vec)
|
299
|
+
FLATBUFFERS_NOEXCEPT {
|
300
|
+
static_assert(Vector<U>::is_span_observable,
|
301
|
+
"wrong type U, only LE-scalar, or byte types are allowed");
|
302
|
+
return span<U>(vec.data(), vec.size());
|
303
|
+
}
|
304
|
+
|
305
|
+
template<class U>
|
306
|
+
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_span(
|
307
|
+
const Vector<U> &vec) FLATBUFFERS_NOEXCEPT {
|
308
|
+
static_assert(Vector<U>::is_span_observable,
|
309
|
+
"wrong type U, only LE-scalar, or byte types are allowed");
|
310
|
+
return span<const U>(vec.data(), vec.size());
|
311
|
+
}
|
312
|
+
|
313
|
+
template<class U>
|
314
|
+
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<uint8_t> make_bytes_span(
|
315
|
+
Vector<U> &vec) FLATBUFFERS_NOEXCEPT {
|
316
|
+
static_assert(Vector<U>::scalar_tag::value,
|
317
|
+
"wrong type U, only LE-scalar, or byte types are allowed");
|
318
|
+
return span<uint8_t>(vec.Data(), vec.size() * sizeof(U));
|
319
|
+
}
|
320
|
+
|
321
|
+
template<class U>
|
322
|
+
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const uint8_t> make_bytes_span(
|
323
|
+
const Vector<U> &vec) FLATBUFFERS_NOEXCEPT {
|
324
|
+
static_assert(Vector<U>::scalar_tag::value,
|
325
|
+
"wrong type U, only LE-scalar, or byte types are allowed");
|
326
|
+
return span<const uint8_t>(vec.Data(), vec.size() * sizeof(U));
|
327
|
+
}
|
328
|
+
|
329
|
+
// Represent a vector much like the template above, but in this case we
|
330
|
+
// don't know what the element types are (used with reflection.h).
|
331
|
+
class VectorOfAny {
|
332
|
+
public:
|
333
|
+
uoffset_t size() const { return EndianScalar(length_); }
|
334
|
+
|
335
|
+
const uint8_t *Data() const {
|
336
|
+
return reinterpret_cast<const uint8_t *>(&length_ + 1);
|
337
|
+
}
|
338
|
+
uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); }
|
339
|
+
|
340
|
+
protected:
|
341
|
+
VectorOfAny();
|
342
|
+
|
343
|
+
uoffset_t length_;
|
344
|
+
|
345
|
+
private:
|
346
|
+
VectorOfAny(const VectorOfAny &);
|
347
|
+
VectorOfAny &operator=(const VectorOfAny &);
|
348
|
+
};
|
349
|
+
|
350
|
+
template<typename T, typename U>
|
351
|
+
Vector<Offset<T>> *VectorCast(Vector<Offset<U>> *ptr) {
|
352
|
+
static_assert(std::is_base_of<T, U>::value, "Unrelated types");
|
353
|
+
return reinterpret_cast<Vector<Offset<T>> *>(ptr);
|
354
|
+
}
|
355
|
+
|
356
|
+
template<typename T, typename U>
|
357
|
+
const Vector<Offset<T>> *VectorCast(const Vector<Offset<U>> *ptr) {
|
358
|
+
static_assert(std::is_base_of<T, U>::value, "Unrelated types");
|
359
|
+
return reinterpret_cast<const Vector<Offset<T>> *>(ptr);
|
360
|
+
}
|
361
|
+
|
362
|
+
// Convenient helper function to get the length of any vector, regardless
|
363
|
+
// of whether it is null or not (the field is not set).
|
364
|
+
template<typename T> static inline size_t VectorLength(const Vector<T> *v) {
|
365
|
+
return v ? v->size() : 0;
|
366
|
+
}
|
367
|
+
|
368
|
+
} // namespace flatbuffers
|
369
|
+
|
370
|
+
#endif // FLATBUFFERS_VERIFIER_H_
|
@@ -0,0 +1,271 @@
|
|
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_VECTOR_DOWNWARD_H_
|
18
|
+
#define FLATBUFFERS_VECTOR_DOWNWARD_H_
|
19
|
+
|
20
|
+
#include "flatbuffers/base.h"
|
21
|
+
#include "flatbuffers/default_allocator.h"
|
22
|
+
#include "flatbuffers/detached_buffer.h"
|
23
|
+
|
24
|
+
namespace flatbuffers {
|
25
|
+
|
26
|
+
// This is a minimal replication of std::vector<uint8_t> functionality,
|
27
|
+
// except growing from higher to lower addresses. i.e push_back() inserts data
|
28
|
+
// in the lowest address in the vector.
|
29
|
+
// Since this vector leaves the lower part unused, we support a "scratch-pad"
|
30
|
+
// that can be stored there for temporary data, to share the allocated space.
|
31
|
+
// Essentially, this supports 2 std::vectors in a single buffer.
|
32
|
+
class vector_downward {
|
33
|
+
public:
|
34
|
+
explicit vector_downward(size_t initial_size, Allocator *allocator,
|
35
|
+
bool own_allocator, size_t buffer_minalign)
|
36
|
+
: allocator_(allocator),
|
37
|
+
own_allocator_(own_allocator),
|
38
|
+
initial_size_(initial_size),
|
39
|
+
buffer_minalign_(buffer_minalign),
|
40
|
+
reserved_(0),
|
41
|
+
size_(0),
|
42
|
+
buf_(nullptr),
|
43
|
+
cur_(nullptr),
|
44
|
+
scratch_(nullptr) {}
|
45
|
+
|
46
|
+
vector_downward(vector_downward &&other)
|
47
|
+
// clang-format on
|
48
|
+
: allocator_(other.allocator_),
|
49
|
+
own_allocator_(other.own_allocator_),
|
50
|
+
initial_size_(other.initial_size_),
|
51
|
+
buffer_minalign_(other.buffer_minalign_),
|
52
|
+
reserved_(other.reserved_),
|
53
|
+
size_(other.size_),
|
54
|
+
buf_(other.buf_),
|
55
|
+
cur_(other.cur_),
|
56
|
+
scratch_(other.scratch_) {
|
57
|
+
// No change in other.allocator_
|
58
|
+
// No change in other.initial_size_
|
59
|
+
// No change in other.buffer_minalign_
|
60
|
+
other.own_allocator_ = false;
|
61
|
+
other.reserved_ = 0;
|
62
|
+
other.buf_ = nullptr;
|
63
|
+
other.cur_ = nullptr;
|
64
|
+
other.scratch_ = nullptr;
|
65
|
+
}
|
66
|
+
|
67
|
+
vector_downward &operator=(vector_downward &&other) {
|
68
|
+
// Move construct a temporary and swap idiom
|
69
|
+
vector_downward temp(std::move(other));
|
70
|
+
swap(temp);
|
71
|
+
return *this;
|
72
|
+
}
|
73
|
+
|
74
|
+
~vector_downward() {
|
75
|
+
clear_buffer();
|
76
|
+
clear_allocator();
|
77
|
+
}
|
78
|
+
|
79
|
+
void reset() {
|
80
|
+
clear_buffer();
|
81
|
+
clear();
|
82
|
+
}
|
83
|
+
|
84
|
+
void clear() {
|
85
|
+
if (buf_) {
|
86
|
+
cur_ = buf_ + reserved_;
|
87
|
+
} else {
|
88
|
+
reserved_ = 0;
|
89
|
+
cur_ = nullptr;
|
90
|
+
}
|
91
|
+
size_ = 0;
|
92
|
+
clear_scratch();
|
93
|
+
}
|
94
|
+
|
95
|
+
void clear_scratch() { scratch_ = buf_; }
|
96
|
+
|
97
|
+
void clear_allocator() {
|
98
|
+
if (own_allocator_ && allocator_) { delete allocator_; }
|
99
|
+
allocator_ = nullptr;
|
100
|
+
own_allocator_ = false;
|
101
|
+
}
|
102
|
+
|
103
|
+
void clear_buffer() {
|
104
|
+
if (buf_) Deallocate(allocator_, buf_, reserved_);
|
105
|
+
buf_ = nullptr;
|
106
|
+
}
|
107
|
+
|
108
|
+
// Relinquish the pointer to the caller.
|
109
|
+
uint8_t *release_raw(size_t &allocated_bytes, size_t &offset) {
|
110
|
+
auto *buf = buf_;
|
111
|
+
allocated_bytes = reserved_;
|
112
|
+
offset = static_cast<size_t>(cur_ - buf_);
|
113
|
+
|
114
|
+
// release_raw only relinquishes the buffer ownership.
|
115
|
+
// Does not deallocate or reset the allocator. Destructor will do that.
|
116
|
+
buf_ = nullptr;
|
117
|
+
clear();
|
118
|
+
return buf;
|
119
|
+
}
|
120
|
+
|
121
|
+
// Relinquish the pointer to the caller.
|
122
|
+
DetachedBuffer release() {
|
123
|
+
// allocator ownership (if any) is transferred to DetachedBuffer.
|
124
|
+
DetachedBuffer fb(allocator_, own_allocator_, buf_, reserved_, cur_,
|
125
|
+
size());
|
126
|
+
if (own_allocator_) {
|
127
|
+
allocator_ = nullptr;
|
128
|
+
own_allocator_ = false;
|
129
|
+
}
|
130
|
+
buf_ = nullptr;
|
131
|
+
clear();
|
132
|
+
return fb;
|
133
|
+
}
|
134
|
+
|
135
|
+
size_t ensure_space(size_t len) {
|
136
|
+
FLATBUFFERS_ASSERT(cur_ >= scratch_ && scratch_ >= buf_);
|
137
|
+
if (len > static_cast<size_t>(cur_ - scratch_)) { reallocate(len); }
|
138
|
+
// Beyond this, signed offsets may not have enough range:
|
139
|
+
// (FlatBuffers > 2GB not supported).
|
140
|
+
FLATBUFFERS_ASSERT(size() < FLATBUFFERS_MAX_BUFFER_SIZE);
|
141
|
+
return len;
|
142
|
+
}
|
143
|
+
|
144
|
+
inline uint8_t *make_space(size_t len) {
|
145
|
+
if (len) {
|
146
|
+
ensure_space(len);
|
147
|
+
cur_ -= len;
|
148
|
+
size_ += static_cast<uoffset_t>(len);
|
149
|
+
}
|
150
|
+
return cur_;
|
151
|
+
}
|
152
|
+
|
153
|
+
// Returns nullptr if using the DefaultAllocator.
|
154
|
+
Allocator *get_custom_allocator() { return allocator_; }
|
155
|
+
|
156
|
+
inline uoffset_t size() const { return size_; }
|
157
|
+
|
158
|
+
uoffset_t scratch_size() const {
|
159
|
+
return static_cast<uoffset_t>(scratch_ - buf_);
|
160
|
+
}
|
161
|
+
|
162
|
+
size_t capacity() const { return reserved_; }
|
163
|
+
|
164
|
+
uint8_t *data() const {
|
165
|
+
FLATBUFFERS_ASSERT(cur_);
|
166
|
+
return cur_;
|
167
|
+
}
|
168
|
+
|
169
|
+
uint8_t *scratch_data() const {
|
170
|
+
FLATBUFFERS_ASSERT(buf_);
|
171
|
+
return buf_;
|
172
|
+
}
|
173
|
+
|
174
|
+
uint8_t *scratch_end() const {
|
175
|
+
FLATBUFFERS_ASSERT(scratch_);
|
176
|
+
return scratch_;
|
177
|
+
}
|
178
|
+
|
179
|
+
uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; }
|
180
|
+
|
181
|
+
void push(const uint8_t *bytes, size_t num) {
|
182
|
+
if (num > 0) { memcpy(make_space(num), bytes, num); }
|
183
|
+
}
|
184
|
+
|
185
|
+
// Specialized version of push() that avoids memcpy call for small data.
|
186
|
+
template<typename T> void push_small(const T &little_endian_t) {
|
187
|
+
make_space(sizeof(T));
|
188
|
+
*reinterpret_cast<T *>(cur_) = little_endian_t;
|
189
|
+
}
|
190
|
+
|
191
|
+
template<typename T> void scratch_push_small(const T &t) {
|
192
|
+
ensure_space(sizeof(T));
|
193
|
+
*reinterpret_cast<T *>(scratch_) = t;
|
194
|
+
scratch_ += sizeof(T);
|
195
|
+
}
|
196
|
+
|
197
|
+
// fill() is most frequently called with small byte counts (<= 4),
|
198
|
+
// which is why we're using loops rather than calling memset.
|
199
|
+
void fill(size_t zero_pad_bytes) {
|
200
|
+
make_space(zero_pad_bytes);
|
201
|
+
for (size_t i = 0; i < zero_pad_bytes; i++) cur_[i] = 0;
|
202
|
+
}
|
203
|
+
|
204
|
+
// Version for when we know the size is larger.
|
205
|
+
// Precondition: zero_pad_bytes > 0
|
206
|
+
void fill_big(size_t zero_pad_bytes) {
|
207
|
+
memset(make_space(zero_pad_bytes), 0, zero_pad_bytes);
|
208
|
+
}
|
209
|
+
|
210
|
+
void pop(size_t bytes_to_remove) {
|
211
|
+
cur_ += bytes_to_remove;
|
212
|
+
size_ -= static_cast<uoffset_t>(bytes_to_remove);
|
213
|
+
}
|
214
|
+
|
215
|
+
void scratch_pop(size_t bytes_to_remove) { scratch_ -= bytes_to_remove; }
|
216
|
+
|
217
|
+
void swap(vector_downward &other) {
|
218
|
+
using std::swap;
|
219
|
+
swap(allocator_, other.allocator_);
|
220
|
+
swap(own_allocator_, other.own_allocator_);
|
221
|
+
swap(initial_size_, other.initial_size_);
|
222
|
+
swap(buffer_minalign_, other.buffer_minalign_);
|
223
|
+
swap(reserved_, other.reserved_);
|
224
|
+
swap(size_, other.size_);
|
225
|
+
swap(buf_, other.buf_);
|
226
|
+
swap(cur_, other.cur_);
|
227
|
+
swap(scratch_, other.scratch_);
|
228
|
+
}
|
229
|
+
|
230
|
+
void swap_allocator(vector_downward &other) {
|
231
|
+
using std::swap;
|
232
|
+
swap(allocator_, other.allocator_);
|
233
|
+
swap(own_allocator_, other.own_allocator_);
|
234
|
+
}
|
235
|
+
|
236
|
+
private:
|
237
|
+
// You shouldn't really be copying instances of this class.
|
238
|
+
FLATBUFFERS_DELETE_FUNC(vector_downward(const vector_downward &));
|
239
|
+
FLATBUFFERS_DELETE_FUNC(vector_downward &operator=(const vector_downward &));
|
240
|
+
|
241
|
+
Allocator *allocator_;
|
242
|
+
bool own_allocator_;
|
243
|
+
size_t initial_size_;
|
244
|
+
size_t buffer_minalign_;
|
245
|
+
size_t reserved_;
|
246
|
+
uoffset_t size_;
|
247
|
+
uint8_t *buf_;
|
248
|
+
uint8_t *cur_; // Points at location between empty (below) and used (above).
|
249
|
+
uint8_t *scratch_; // Points to the end of the scratchpad in use.
|
250
|
+
|
251
|
+
void reallocate(size_t len) {
|
252
|
+
auto old_reserved = reserved_;
|
253
|
+
auto old_size = size();
|
254
|
+
auto old_scratch_size = scratch_size();
|
255
|
+
reserved_ +=
|
256
|
+
(std::max)(len, old_reserved ? old_reserved / 2 : initial_size_);
|
257
|
+
reserved_ = (reserved_ + buffer_minalign_ - 1) & ~(buffer_minalign_ - 1);
|
258
|
+
if (buf_) {
|
259
|
+
buf_ = ReallocateDownward(allocator_, buf_, old_reserved, reserved_,
|
260
|
+
old_size, old_scratch_size);
|
261
|
+
} else {
|
262
|
+
buf_ = Allocate(allocator_, reserved_);
|
263
|
+
}
|
264
|
+
cur_ = buf_ + reserved_ - old_size;
|
265
|
+
scratch_ = buf_ + old_scratch_size;
|
266
|
+
}
|
267
|
+
};
|
268
|
+
|
269
|
+
} // namespace flatbuffers
|
270
|
+
|
271
|
+
#endif // FLATBUFFERS_VECTOR_DOWNWARD_H_
|