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,128 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2017 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_REGISTRY_H_
|
18
|
+
#define FLATBUFFERS_REGISTRY_H_
|
19
|
+
|
20
|
+
#include "flatbuffers/base.h"
|
21
|
+
#include "flatbuffers/idl.h"
|
22
|
+
|
23
|
+
namespace flatbuffers {
|
24
|
+
|
25
|
+
// Convenience class to easily parse or generate text for arbitrary FlatBuffers.
|
26
|
+
// Simply pre-populate it with all schema filenames that may be in use, and
|
27
|
+
// This class will look them up using the file_identifier declared in the
|
28
|
+
// schema.
|
29
|
+
class Registry {
|
30
|
+
public:
|
31
|
+
// Call this for all schemas that may be in use. The identifier has
|
32
|
+
// a function in the generated code, e.g. MonsterIdentifier().
|
33
|
+
void Register(const char *file_identifier, const char *schema_path) {
|
34
|
+
Schema schema;
|
35
|
+
schema.path_ = schema_path;
|
36
|
+
schemas_[file_identifier] = schema;
|
37
|
+
}
|
38
|
+
|
39
|
+
// Generate text from an arbitrary FlatBuffer by looking up its
|
40
|
+
// file_identifier in the registry.
|
41
|
+
bool FlatBufferToText(const uint8_t *flatbuf, size_t len, std::string *dest) {
|
42
|
+
// Get the identifier out of the buffer.
|
43
|
+
// If the buffer is truncated, exit.
|
44
|
+
if (len < sizeof(uoffset_t) + kFileIdentifierLength) {
|
45
|
+
lasterror_ = "buffer truncated";
|
46
|
+
return false;
|
47
|
+
}
|
48
|
+
std::string ident(
|
49
|
+
reinterpret_cast<const char *>(flatbuf) + sizeof(uoffset_t),
|
50
|
+
kFileIdentifierLength);
|
51
|
+
// Load and parse the schema.
|
52
|
+
Parser parser;
|
53
|
+
if (!LoadSchema(ident, &parser)) return false;
|
54
|
+
// Now we're ready to generate text.
|
55
|
+
if (!GenerateText(parser, flatbuf, dest)) {
|
56
|
+
lasterror_ = "unable to generate text for FlatBuffer binary";
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
return true;
|
60
|
+
}
|
61
|
+
|
62
|
+
// Converts a binary buffer to text using one of the schemas in the registry,
|
63
|
+
// use the file_identifier to indicate which.
|
64
|
+
// If DetachedBuffer::data() is null then parsing failed.
|
65
|
+
DetachedBuffer TextToFlatBuffer(const char *text,
|
66
|
+
const char *file_identifier) {
|
67
|
+
// Load and parse the schema.
|
68
|
+
Parser parser;
|
69
|
+
if (!LoadSchema(file_identifier, &parser)) return DetachedBuffer();
|
70
|
+
// Parse the text.
|
71
|
+
if (!parser.Parse(text)) {
|
72
|
+
lasterror_ = parser.error_;
|
73
|
+
return DetachedBuffer();
|
74
|
+
}
|
75
|
+
// We have a valid FlatBuffer. Detach it from the builder and return.
|
76
|
+
return parser.builder_.Release();
|
77
|
+
}
|
78
|
+
|
79
|
+
// Modify any parsing / output options used by the other functions.
|
80
|
+
void SetOptions(const IDLOptions &opts) { opts_ = opts; }
|
81
|
+
|
82
|
+
// If schemas used contain include statements, call this function for every
|
83
|
+
// directory the parser should search them for.
|
84
|
+
void AddIncludeDirectory(const char *path) { include_paths_.push_back(path); }
|
85
|
+
|
86
|
+
// Returns a human readable error if any of the above functions fail.
|
87
|
+
const std::string &GetLastError() { return lasterror_; }
|
88
|
+
|
89
|
+
private:
|
90
|
+
bool LoadSchema(const std::string &ident, Parser *parser) {
|
91
|
+
// Find the schema, if not, exit.
|
92
|
+
auto it = schemas_.find(ident);
|
93
|
+
if (it == schemas_.end()) {
|
94
|
+
// Don't attach the identifier, since it may not be human readable.
|
95
|
+
lasterror_ = "identifier for this buffer not in the registry";
|
96
|
+
return false;
|
97
|
+
}
|
98
|
+
auto &schema = it->second;
|
99
|
+
// Load the schema from disk. If not, exit.
|
100
|
+
std::string schematext;
|
101
|
+
if (!LoadFile(schema.path_.c_str(), false, &schematext)) {
|
102
|
+
lasterror_ = "could not load schema: " + schema.path_;
|
103
|
+
return false;
|
104
|
+
}
|
105
|
+
// Parse schema.
|
106
|
+
parser->opts = opts_;
|
107
|
+
if (!parser->Parse(schematext.c_str(), include_paths_.data(),
|
108
|
+
schema.path_.c_str())) {
|
109
|
+
lasterror_ = parser->error_;
|
110
|
+
return false;
|
111
|
+
}
|
112
|
+
return true;
|
113
|
+
}
|
114
|
+
|
115
|
+
struct Schema {
|
116
|
+
std::string path_;
|
117
|
+
// TODO(wvo) optionally cache schema file or parsed schema here.
|
118
|
+
};
|
119
|
+
|
120
|
+
std::string lasterror_;
|
121
|
+
IDLOptions opts_;
|
122
|
+
std::vector<const char *> include_paths_;
|
123
|
+
std::map<std::string, Schema> schemas_;
|
124
|
+
};
|
125
|
+
|
126
|
+
} // namespace flatbuffers
|
127
|
+
|
128
|
+
#endif // FLATBUFFERS_REGISTRY_H_
|
@@ -0,0 +1,509 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2017 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_STL_EMULATION_H_
|
18
|
+
#define FLATBUFFERS_STL_EMULATION_H_
|
19
|
+
|
20
|
+
// clang-format off
|
21
|
+
#include "flatbuffers/base.h"
|
22
|
+
|
23
|
+
#include <string>
|
24
|
+
#include <type_traits>
|
25
|
+
#include <vector>
|
26
|
+
#include <memory>
|
27
|
+
#include <limits>
|
28
|
+
|
29
|
+
// Detect C++17 compatible compiler.
|
30
|
+
// __cplusplus >= 201703L - a compiler has support of 'static inline' variables.
|
31
|
+
#if defined(FLATBUFFERS_USE_STD_OPTIONAL) \
|
32
|
+
|| (defined(__cplusplus) && __cplusplus >= 201703L) \
|
33
|
+
|| (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))
|
34
|
+
#include <optional>
|
35
|
+
#ifndef FLATBUFFERS_USE_STD_OPTIONAL
|
36
|
+
#define FLATBUFFERS_USE_STD_OPTIONAL
|
37
|
+
#endif
|
38
|
+
#endif // defined(FLATBUFFERS_USE_STD_OPTIONAL) ...
|
39
|
+
|
40
|
+
// The __cpp_lib_span is the predefined feature macro.
|
41
|
+
#if defined(FLATBUFFERS_USE_STD_SPAN)
|
42
|
+
#include <span>
|
43
|
+
#elif defined(__cpp_lib_span) && defined(__has_include)
|
44
|
+
#if __has_include(<span>)
|
45
|
+
#include <span>
|
46
|
+
#define FLATBUFFERS_USE_STD_SPAN
|
47
|
+
#endif
|
48
|
+
#else
|
49
|
+
// Disable non-trivial ctors if FLATBUFFERS_SPAN_MINIMAL defined.
|
50
|
+
#if !defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
51
|
+
#define FLATBUFFERS_SPAN_MINIMAL
|
52
|
+
#else
|
53
|
+
// Enable implicit construction of a span<T,N> from a std::array<T,N>.
|
54
|
+
#include <array>
|
55
|
+
#endif
|
56
|
+
#endif // defined(FLATBUFFERS_USE_STD_SPAN)
|
57
|
+
|
58
|
+
// This header provides backwards compatibility for older versions of the STL.
|
59
|
+
namespace flatbuffers {
|
60
|
+
|
61
|
+
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
62
|
+
template <typename T>
|
63
|
+
using numeric_limits = std::numeric_limits<T>;
|
64
|
+
#else
|
65
|
+
template <typename T> class numeric_limits :
|
66
|
+
public std::numeric_limits<T> {};
|
67
|
+
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
68
|
+
|
69
|
+
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
70
|
+
template <typename T> using is_scalar = std::is_scalar<T>;
|
71
|
+
template <typename T, typename U> using is_same = std::is_same<T,U>;
|
72
|
+
template <typename T> using is_floating_point = std::is_floating_point<T>;
|
73
|
+
template <typename T> using is_unsigned = std::is_unsigned<T>;
|
74
|
+
template <typename T> using is_enum = std::is_enum<T>;
|
75
|
+
template <typename T> using make_unsigned = std::make_unsigned<T>;
|
76
|
+
template<bool B, class T, class F>
|
77
|
+
using conditional = std::conditional<B, T, F>;
|
78
|
+
template<class T, T v>
|
79
|
+
using integral_constant = std::integral_constant<T, v>;
|
80
|
+
template <bool B>
|
81
|
+
using bool_constant = integral_constant<bool, B>;
|
82
|
+
using true_type = std::true_type;
|
83
|
+
using false_type = std::false_type;
|
84
|
+
#else
|
85
|
+
// MSVC 2010 doesn't support C++11 aliases.
|
86
|
+
template <typename T> struct is_scalar : public std::is_scalar<T> {};
|
87
|
+
template <typename T, typename U> struct is_same : public std::is_same<T,U> {};
|
88
|
+
template <typename T> struct is_floating_point :
|
89
|
+
public std::is_floating_point<T> {};
|
90
|
+
template <typename T> struct is_unsigned : public std::is_unsigned<T> {};
|
91
|
+
template <typename T> struct is_enum : public std::is_enum<T> {};
|
92
|
+
template <typename T> struct make_unsigned : public std::make_unsigned<T> {};
|
93
|
+
template<bool B, class T, class F>
|
94
|
+
struct conditional : public std::conditional<B, T, F> {};
|
95
|
+
template<class T, T v>
|
96
|
+
struct integral_constant : public std::integral_constant<T, v> {};
|
97
|
+
template <bool B>
|
98
|
+
struct bool_constant : public integral_constant<bool, B> {};
|
99
|
+
typedef bool_constant<true> true_type;
|
100
|
+
typedef bool_constant<false> false_type;
|
101
|
+
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
102
|
+
|
103
|
+
#if defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
104
|
+
template <class T> using unique_ptr = std::unique_ptr<T>;
|
105
|
+
#else
|
106
|
+
// MSVC 2010 doesn't support C++11 aliases.
|
107
|
+
// We're manually "aliasing" the class here as we want to bring unique_ptr
|
108
|
+
// into the flatbuffers namespace. We have unique_ptr in the flatbuffers
|
109
|
+
// namespace we have a completely independent implementation (see below)
|
110
|
+
// for C++98 STL implementations.
|
111
|
+
template <class T> class unique_ptr : public std::unique_ptr<T> {
|
112
|
+
public:
|
113
|
+
unique_ptr() {}
|
114
|
+
explicit unique_ptr(T* p) : std::unique_ptr<T>(p) {}
|
115
|
+
unique_ptr(std::unique_ptr<T>&& u) { *this = std::move(u); }
|
116
|
+
unique_ptr(unique_ptr&& u) { *this = std::move(u); }
|
117
|
+
unique_ptr& operator=(std::unique_ptr<T>&& u) {
|
118
|
+
std::unique_ptr<T>::reset(u.release());
|
119
|
+
return *this;
|
120
|
+
}
|
121
|
+
unique_ptr& operator=(unique_ptr&& u) {
|
122
|
+
std::unique_ptr<T>::reset(u.release());
|
123
|
+
return *this;
|
124
|
+
}
|
125
|
+
unique_ptr& operator=(T* p) {
|
126
|
+
return std::unique_ptr<T>::operator=(p);
|
127
|
+
}
|
128
|
+
};
|
129
|
+
#endif // defined(FLATBUFFERS_TEMPLATES_ALIASES)
|
130
|
+
|
131
|
+
#ifdef FLATBUFFERS_USE_STD_OPTIONAL
|
132
|
+
template<class T>
|
133
|
+
using Optional = std::optional<T>;
|
134
|
+
using nullopt_t = std::nullopt_t;
|
135
|
+
inline constexpr nullopt_t nullopt = std::nullopt;
|
136
|
+
|
137
|
+
#else
|
138
|
+
// Limited implementation of Optional<T> type for a scalar T.
|
139
|
+
// This implementation limited by trivial types compatible with
|
140
|
+
// std::is_arithmetic<T> or std::is_enum<T> type traits.
|
141
|
+
|
142
|
+
// A tag to indicate an empty flatbuffers::optional<T>.
|
143
|
+
struct nullopt_t {
|
144
|
+
explicit FLATBUFFERS_CONSTEXPR_CPP11 nullopt_t(int) {}
|
145
|
+
};
|
146
|
+
|
147
|
+
#if defined(FLATBUFFERS_CONSTEXPR_DEFINED)
|
148
|
+
namespace internal {
|
149
|
+
template <class> struct nullopt_holder {
|
150
|
+
static constexpr nullopt_t instance_ = nullopt_t(0);
|
151
|
+
};
|
152
|
+
template<class Dummy>
|
153
|
+
constexpr nullopt_t nullopt_holder<Dummy>::instance_;
|
154
|
+
}
|
155
|
+
static constexpr const nullopt_t &nullopt = internal::nullopt_holder<void>::instance_;
|
156
|
+
|
157
|
+
#else
|
158
|
+
namespace internal {
|
159
|
+
template <class> struct nullopt_holder {
|
160
|
+
static const nullopt_t instance_;
|
161
|
+
};
|
162
|
+
template<class Dummy>
|
163
|
+
const nullopt_t nullopt_holder<Dummy>::instance_ = nullopt_t(0);
|
164
|
+
}
|
165
|
+
static const nullopt_t &nullopt = internal::nullopt_holder<void>::instance_;
|
166
|
+
|
167
|
+
#endif
|
168
|
+
|
169
|
+
template<class T>
|
170
|
+
class Optional FLATBUFFERS_FINAL_CLASS {
|
171
|
+
// Non-scalar 'T' would extremely complicated Optional<T>.
|
172
|
+
// Use is_scalar<T> checking because flatbuffers flatbuffers::is_arithmetic<T>
|
173
|
+
// isn't implemented.
|
174
|
+
static_assert(flatbuffers::is_scalar<T>::value, "unexpected type T");
|
175
|
+
|
176
|
+
public:
|
177
|
+
~Optional() {}
|
178
|
+
|
179
|
+
FLATBUFFERS_CONSTEXPR_CPP11 Optional() FLATBUFFERS_NOEXCEPT
|
180
|
+
: value_(), has_value_(false) {}
|
181
|
+
|
182
|
+
FLATBUFFERS_CONSTEXPR_CPP11 Optional(nullopt_t) FLATBUFFERS_NOEXCEPT
|
183
|
+
: value_(), has_value_(false) {}
|
184
|
+
|
185
|
+
FLATBUFFERS_CONSTEXPR_CPP11 Optional(T val) FLATBUFFERS_NOEXCEPT
|
186
|
+
: value_(val), has_value_(true) {}
|
187
|
+
|
188
|
+
FLATBUFFERS_CONSTEXPR_CPP11 Optional(const Optional &other) FLATBUFFERS_NOEXCEPT
|
189
|
+
: value_(other.value_), has_value_(other.has_value_) {}
|
190
|
+
|
191
|
+
FLATBUFFERS_CONSTEXPR_CPP14 Optional &operator=(const Optional &other) FLATBUFFERS_NOEXCEPT {
|
192
|
+
value_ = other.value_;
|
193
|
+
has_value_ = other.has_value_;
|
194
|
+
return *this;
|
195
|
+
}
|
196
|
+
|
197
|
+
FLATBUFFERS_CONSTEXPR_CPP14 Optional &operator=(nullopt_t) FLATBUFFERS_NOEXCEPT {
|
198
|
+
value_ = T();
|
199
|
+
has_value_ = false;
|
200
|
+
return *this;
|
201
|
+
}
|
202
|
+
|
203
|
+
FLATBUFFERS_CONSTEXPR_CPP14 Optional &operator=(T val) FLATBUFFERS_NOEXCEPT {
|
204
|
+
value_ = val;
|
205
|
+
has_value_ = true;
|
206
|
+
return *this;
|
207
|
+
}
|
208
|
+
|
209
|
+
void reset() FLATBUFFERS_NOEXCEPT {
|
210
|
+
*this = nullopt;
|
211
|
+
}
|
212
|
+
|
213
|
+
void swap(Optional &other) FLATBUFFERS_NOEXCEPT {
|
214
|
+
std::swap(value_, other.value_);
|
215
|
+
std::swap(has_value_, other.has_value_);
|
216
|
+
}
|
217
|
+
|
218
|
+
FLATBUFFERS_CONSTEXPR_CPP11 FLATBUFFERS_EXPLICIT_CPP11 operator bool() const FLATBUFFERS_NOEXCEPT {
|
219
|
+
return has_value_;
|
220
|
+
}
|
221
|
+
|
222
|
+
FLATBUFFERS_CONSTEXPR_CPP11 bool has_value() const FLATBUFFERS_NOEXCEPT {
|
223
|
+
return has_value_;
|
224
|
+
}
|
225
|
+
|
226
|
+
FLATBUFFERS_CONSTEXPR_CPP11 const T& operator*() const FLATBUFFERS_NOEXCEPT {
|
227
|
+
return value_;
|
228
|
+
}
|
229
|
+
|
230
|
+
const T& value() const {
|
231
|
+
FLATBUFFERS_ASSERT(has_value());
|
232
|
+
return value_;
|
233
|
+
}
|
234
|
+
|
235
|
+
T value_or(T default_value) const FLATBUFFERS_NOEXCEPT {
|
236
|
+
return has_value() ? value_ : default_value;
|
237
|
+
}
|
238
|
+
|
239
|
+
private:
|
240
|
+
T value_;
|
241
|
+
bool has_value_;
|
242
|
+
};
|
243
|
+
|
244
|
+
template<class T>
|
245
|
+
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& opt, nullopt_t) FLATBUFFERS_NOEXCEPT {
|
246
|
+
return !opt;
|
247
|
+
}
|
248
|
+
template<class T>
|
249
|
+
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(nullopt_t, const Optional<T>& opt) FLATBUFFERS_NOEXCEPT {
|
250
|
+
return !opt;
|
251
|
+
}
|
252
|
+
|
253
|
+
template<class T, class U>
|
254
|
+
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& lhs, const U& rhs) FLATBUFFERS_NOEXCEPT {
|
255
|
+
return static_cast<bool>(lhs) && (*lhs == rhs);
|
256
|
+
}
|
257
|
+
|
258
|
+
template<class T, class U>
|
259
|
+
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const T& lhs, const Optional<U>& rhs) FLATBUFFERS_NOEXCEPT {
|
260
|
+
return static_cast<bool>(rhs) && (lhs == *rhs);
|
261
|
+
}
|
262
|
+
|
263
|
+
template<class T, class U>
|
264
|
+
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& lhs, const Optional<U>& rhs) FLATBUFFERS_NOEXCEPT {
|
265
|
+
return static_cast<bool>(lhs) != static_cast<bool>(rhs)
|
266
|
+
? false
|
267
|
+
: !static_cast<bool>(lhs) ? false : (*lhs == *rhs);
|
268
|
+
}
|
269
|
+
#endif // FLATBUFFERS_USE_STD_OPTIONAL
|
270
|
+
|
271
|
+
|
272
|
+
// Very limited and naive partial implementation of C++20 std::span<T,Extent>.
|
273
|
+
#if defined(FLATBUFFERS_USE_STD_SPAN)
|
274
|
+
inline constexpr std::size_t dynamic_extent = std::dynamic_extent;
|
275
|
+
template<class T, std::size_t Extent = std::dynamic_extent>
|
276
|
+
using span = std::span<T, Extent>;
|
277
|
+
|
278
|
+
#else // !defined(FLATBUFFERS_USE_STD_SPAN)
|
279
|
+
FLATBUFFERS_CONSTEXPR std::size_t dynamic_extent = static_cast<std::size_t>(-1);
|
280
|
+
|
281
|
+
// Exclude this code if MSVC2010 or non-STL Android is active.
|
282
|
+
// The non-STL Android doesn't have `std::is_convertible` required for SFINAE.
|
283
|
+
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
|
284
|
+
namespace internal {
|
285
|
+
// This is SFINAE helper class for checking of a common condition:
|
286
|
+
// > This overload only participates in overload resolution
|
287
|
+
// > Check whether a pointer to an array of U can be converted
|
288
|
+
// > to a pointer to an array of E.
|
289
|
+
// This helper is used for checking of 'U -> const U'.
|
290
|
+
template<class E, std::size_t Extent, class U, std::size_t N>
|
291
|
+
struct is_span_convertable {
|
292
|
+
using type =
|
293
|
+
typename std::conditional<std::is_convertible<U (*)[], E (*)[]>::value
|
294
|
+
&& (Extent == dynamic_extent || N == Extent),
|
295
|
+
int, void>::type;
|
296
|
+
};
|
297
|
+
|
298
|
+
template<typename T>
|
299
|
+
struct SpanIterator {
|
300
|
+
// TODO: upgrade to std::random_access_iterator_tag.
|
301
|
+
using iterator_category = std::forward_iterator_tag;
|
302
|
+
using difference_type = std::ptrdiff_t;
|
303
|
+
using value_type = typename std::remove_cv<T>::type;
|
304
|
+
using reference = T&;
|
305
|
+
using pointer = T*;
|
306
|
+
|
307
|
+
// Convince MSVC compiler that this iterator is trusted (it is verified).
|
308
|
+
#ifdef _MSC_VER
|
309
|
+
using _Unchecked_type = pointer;
|
310
|
+
#endif // _MSC_VER
|
311
|
+
|
312
|
+
SpanIterator(pointer ptr) : ptr_(ptr) {}
|
313
|
+
reference operator*() const { return *ptr_; }
|
314
|
+
pointer operator->() { return ptr_; }
|
315
|
+
SpanIterator& operator++() { ptr_++; return *this; }
|
316
|
+
SpanIterator operator++(int) { auto tmp = *this; ++(*this); return tmp; }
|
317
|
+
|
318
|
+
friend bool operator== (const SpanIterator& lhs, const SpanIterator& rhs) { return lhs.ptr_ == rhs.ptr_; }
|
319
|
+
friend bool operator!= (const SpanIterator& lhs, const SpanIterator& rhs) { return lhs.ptr_ != rhs.ptr_; }
|
320
|
+
|
321
|
+
private:
|
322
|
+
pointer ptr_;
|
323
|
+
};
|
324
|
+
} // namespace internal
|
325
|
+
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
|
326
|
+
|
327
|
+
// T - element type; must be a complete type that is not an abstract
|
328
|
+
// class type.
|
329
|
+
// Extent - the number of elements in the sequence, or dynamic.
|
330
|
+
template<class T, std::size_t Extent = dynamic_extent>
|
331
|
+
class span FLATBUFFERS_FINAL_CLASS {
|
332
|
+
public:
|
333
|
+
typedef T element_type;
|
334
|
+
typedef T& reference;
|
335
|
+
typedef const T& const_reference;
|
336
|
+
typedef T* pointer;
|
337
|
+
typedef const T* const_pointer;
|
338
|
+
typedef std::size_t size_type;
|
339
|
+
|
340
|
+
static FLATBUFFERS_CONSTEXPR size_type extent = Extent;
|
341
|
+
|
342
|
+
// Returns the number of elements in the span.
|
343
|
+
FLATBUFFERS_CONSTEXPR_CPP11 size_type size() const FLATBUFFERS_NOEXCEPT {
|
344
|
+
return count_;
|
345
|
+
}
|
346
|
+
|
347
|
+
// Returns the size of the sequence in bytes.
|
348
|
+
FLATBUFFERS_CONSTEXPR_CPP11
|
349
|
+
size_type size_bytes() const FLATBUFFERS_NOEXCEPT {
|
350
|
+
return size() * sizeof(element_type);
|
351
|
+
}
|
352
|
+
|
353
|
+
// Checks if the span is empty.
|
354
|
+
FLATBUFFERS_CONSTEXPR_CPP11 bool empty() const FLATBUFFERS_NOEXCEPT {
|
355
|
+
return size() == 0;
|
356
|
+
}
|
357
|
+
|
358
|
+
// Returns a pointer to the beginning of the sequence.
|
359
|
+
FLATBUFFERS_CONSTEXPR_CPP11 pointer data() const FLATBUFFERS_NOEXCEPT {
|
360
|
+
return data_;
|
361
|
+
}
|
362
|
+
|
363
|
+
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
|
364
|
+
using Iterator = internal::SpanIterator<T>;
|
365
|
+
using ConstIterator = internal::SpanIterator<const T>;
|
366
|
+
|
367
|
+
Iterator begin() const { return Iterator(data()); }
|
368
|
+
Iterator end() const { return Iterator(data() + size()); }
|
369
|
+
|
370
|
+
ConstIterator cbegin() const { return ConstIterator(data()); }
|
371
|
+
ConstIterator cend() const { return ConstIterator(data() + size()); }
|
372
|
+
#endif
|
373
|
+
|
374
|
+
// Returns a reference to the idx-th element of the sequence.
|
375
|
+
// The behavior is undefined if the idx is greater than or equal to size().
|
376
|
+
FLATBUFFERS_CONSTEXPR_CPP11 reference operator[](size_type idx) const {
|
377
|
+
return data()[idx];
|
378
|
+
}
|
379
|
+
|
380
|
+
FLATBUFFERS_CONSTEXPR_CPP11 span(const span &other) FLATBUFFERS_NOEXCEPT
|
381
|
+
: data_(other.data_), count_(other.count_) {}
|
382
|
+
|
383
|
+
FLATBUFFERS_CONSTEXPR_CPP14 span &operator=(const span &other)
|
384
|
+
FLATBUFFERS_NOEXCEPT {
|
385
|
+
data_ = other.data_;
|
386
|
+
count_ = other.count_;
|
387
|
+
}
|
388
|
+
|
389
|
+
// Limited implementation of
|
390
|
+
// `template <class It> constexpr std::span(It first, size_type count);`.
|
391
|
+
//
|
392
|
+
// Constructs a span that is a view over the range [first, first + count);
|
393
|
+
// the resulting span has: data() == first and size() == count.
|
394
|
+
// The behavior is undefined if [first, first + count) is not a valid range,
|
395
|
+
// or if (extent != flatbuffers::dynamic_extent && count != extent).
|
396
|
+
FLATBUFFERS_CONSTEXPR_CPP11
|
397
|
+
explicit span(pointer first, size_type count) FLATBUFFERS_NOEXCEPT
|
398
|
+
: data_ (Extent == dynamic_extent ? first : (Extent == count ? first : nullptr)),
|
399
|
+
count_(Extent == dynamic_extent ? count : (Extent == count ? Extent : 0)) {
|
400
|
+
// Make span empty if the count argument is incompatible with span<T,N>.
|
401
|
+
}
|
402
|
+
|
403
|
+
// Exclude this code if MSVC2010 is active. The MSVC2010 isn't C++11
|
404
|
+
// compliant, it doesn't support default template arguments for functions.
|
405
|
+
#if defined(FLATBUFFERS_SPAN_MINIMAL)
|
406
|
+
FLATBUFFERS_CONSTEXPR_CPP11 span() FLATBUFFERS_NOEXCEPT : data_(nullptr),
|
407
|
+
count_(0) {
|
408
|
+
static_assert(extent == 0 || extent == dynamic_extent, "invalid span");
|
409
|
+
}
|
410
|
+
|
411
|
+
#else
|
412
|
+
// Constructs an empty span whose data() == nullptr and size() == 0.
|
413
|
+
// This overload only participates in overload resolution if
|
414
|
+
// extent == 0 || extent == flatbuffers::dynamic_extent.
|
415
|
+
// A dummy template argument N is need dependency for SFINAE.
|
416
|
+
template<std::size_t N = 0,
|
417
|
+
typename internal::is_span_convertable<element_type, Extent, element_type, (N - N)>::type = 0>
|
418
|
+
FLATBUFFERS_CONSTEXPR_CPP11 span() FLATBUFFERS_NOEXCEPT : data_(nullptr),
|
419
|
+
count_(0) {
|
420
|
+
static_assert(extent == 0 || extent == dynamic_extent, "invalid span");
|
421
|
+
}
|
422
|
+
|
423
|
+
// Constructs a span that is a view over the array arr; the resulting span
|
424
|
+
// has size() == N and data() == std::data(arr). These overloads only
|
425
|
+
// participate in overload resolution if
|
426
|
+
// extent == std::dynamic_extent || N == extent is true and
|
427
|
+
// std::remove_pointer_t<decltype(std::data(arr))>(*)[]
|
428
|
+
// is convertible to element_type (*)[].
|
429
|
+
template<std::size_t N,
|
430
|
+
typename internal::is_span_convertable<element_type, Extent, element_type, N>::type = 0>
|
431
|
+
FLATBUFFERS_CONSTEXPR_CPP11 span(element_type (&arr)[N]) FLATBUFFERS_NOEXCEPT
|
432
|
+
: data_(arr), count_(N) {}
|
433
|
+
|
434
|
+
template<class U, std::size_t N,
|
435
|
+
typename internal::is_span_convertable<element_type, Extent, U, N>::type = 0>
|
436
|
+
FLATBUFFERS_CONSTEXPR_CPP11 span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
|
437
|
+
: data_(arr.data()), count_(N) {}
|
438
|
+
|
439
|
+
//template<class U, std::size_t N,
|
440
|
+
// int = 0>
|
441
|
+
//FLATBUFFERS_CONSTEXPR_CPP11 span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
|
442
|
+
// : data_(arr.data()), count_(N) {}
|
443
|
+
|
444
|
+
template<class U, std::size_t N,
|
445
|
+
typename internal::is_span_convertable<element_type, Extent, U, N>::type = 0>
|
446
|
+
FLATBUFFERS_CONSTEXPR_CPP11 span(const std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT
|
447
|
+
: data_(arr.data()), count_(N) {}
|
448
|
+
|
449
|
+
// Converting constructor from another span s;
|
450
|
+
// the resulting span has size() == s.size() and data() == s.data().
|
451
|
+
// This overload only participates in overload resolution
|
452
|
+
// if extent == std::dynamic_extent || N == extent is true and U (*)[]
|
453
|
+
// is convertible to element_type (*)[].
|
454
|
+
template<class U, std::size_t N,
|
455
|
+
typename internal::is_span_convertable<element_type, Extent, U, N>::type = 0>
|
456
|
+
FLATBUFFERS_CONSTEXPR_CPP11 span(const flatbuffers::span<U, N> &s) FLATBUFFERS_NOEXCEPT
|
457
|
+
: span(s.data(), s.size()) {
|
458
|
+
}
|
459
|
+
|
460
|
+
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
|
461
|
+
|
462
|
+
private:
|
463
|
+
// This is a naive implementation with 'count_' member even if (Extent != dynamic_extent).
|
464
|
+
pointer const data_;
|
465
|
+
const size_type count_;
|
466
|
+
};
|
467
|
+
#endif // defined(FLATBUFFERS_USE_STD_SPAN)
|
468
|
+
|
469
|
+
#if !defined(FLATBUFFERS_SPAN_MINIMAL)
|
470
|
+
template<class U, std::size_t N>
|
471
|
+
FLATBUFFERS_CONSTEXPR_CPP11
|
472
|
+
flatbuffers::span<U, N> make_span(U(&arr)[N]) FLATBUFFERS_NOEXCEPT {
|
473
|
+
return span<U, N>(arr);
|
474
|
+
}
|
475
|
+
|
476
|
+
template<class U, std::size_t N>
|
477
|
+
FLATBUFFERS_CONSTEXPR_CPP11
|
478
|
+
flatbuffers::span<const U, N> make_span(const U(&arr)[N]) FLATBUFFERS_NOEXCEPT {
|
479
|
+
return span<const U, N>(arr);
|
480
|
+
}
|
481
|
+
|
482
|
+
template<class U, std::size_t N>
|
483
|
+
FLATBUFFERS_CONSTEXPR_CPP11
|
484
|
+
flatbuffers::span<U, N> make_span(std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
|
485
|
+
return span<U, N>(arr);
|
486
|
+
}
|
487
|
+
|
488
|
+
template<class U, std::size_t N>
|
489
|
+
FLATBUFFERS_CONSTEXPR_CPP11
|
490
|
+
flatbuffers::span<const U, N> make_span(const std::array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
|
491
|
+
return span<const U, N>(arr);
|
492
|
+
}
|
493
|
+
|
494
|
+
template<class U, std::size_t N>
|
495
|
+
FLATBUFFERS_CONSTEXPR_CPP11
|
496
|
+
flatbuffers::span<U, dynamic_extent> make_span(U *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
|
497
|
+
return span<U, dynamic_extent>(first, count);
|
498
|
+
}
|
499
|
+
|
500
|
+
template<class U, std::size_t N>
|
501
|
+
FLATBUFFERS_CONSTEXPR_CPP11
|
502
|
+
flatbuffers::span<const U, dynamic_extent> make_span(const U *first, std::size_t count) FLATBUFFERS_NOEXCEPT {
|
503
|
+
return span<const U, dynamic_extent>(first, count);
|
504
|
+
}
|
505
|
+
#endif // !defined(FLATBUFFERS_SPAN_MINIMAL)
|
506
|
+
|
507
|
+
} // namespace flatbuffers
|
508
|
+
|
509
|
+
#endif // FLATBUFFERS_STL_EMULATION_H_
|
@@ -0,0 +1,64 @@
|
|
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_STRING_H_
|
18
|
+
#define FLATBUFFERS_STRING_H_
|
19
|
+
|
20
|
+
#include "flatbuffers/base.h"
|
21
|
+
#include "flatbuffers/vector.h"
|
22
|
+
|
23
|
+
namespace flatbuffers {
|
24
|
+
|
25
|
+
struct String : public Vector<char> {
|
26
|
+
const char *c_str() const { return reinterpret_cast<const char *>(Data()); }
|
27
|
+
std::string str() const { return std::string(c_str(), size()); }
|
28
|
+
|
29
|
+
// clang-format off
|
30
|
+
#ifdef FLATBUFFERS_HAS_STRING_VIEW
|
31
|
+
flatbuffers::string_view string_view() const {
|
32
|
+
return flatbuffers::string_view(c_str(), size());
|
33
|
+
}
|
34
|
+
#endif // FLATBUFFERS_HAS_STRING_VIEW
|
35
|
+
// clang-format on
|
36
|
+
|
37
|
+
bool operator<(const String &o) const {
|
38
|
+
return StringLessThan(this->data(), this->size(), o.data(), o.size());
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
42
|
+
// Convenience function to get std::string from a String returning an empty
|
43
|
+
// string on null pointer.
|
44
|
+
static inline std::string GetString(const String *str) {
|
45
|
+
return str ? str->str() : "";
|
46
|
+
}
|
47
|
+
|
48
|
+
// Convenience function to get char* from a String returning an empty string on
|
49
|
+
// null pointer.
|
50
|
+
static inline const char *GetCstring(const String *str) {
|
51
|
+
return str ? str->c_str() : "";
|
52
|
+
}
|
53
|
+
|
54
|
+
#ifdef FLATBUFFERS_HAS_STRING_VIEW
|
55
|
+
// Convenience function to get string_view from a String returning an empty
|
56
|
+
// string_view on null pointer.
|
57
|
+
static inline flatbuffers::string_view GetStringView(const String *str) {
|
58
|
+
return str ? str->string_view() : flatbuffers::string_view();
|
59
|
+
}
|
60
|
+
#endif // FLATBUFFERS_HAS_STRING_VIEW
|
61
|
+
|
62
|
+
} // namespace flatbuffers
|
63
|
+
|
64
|
+
#endif // FLATBUFFERS_STRING_H_
|