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,233 @@
|
|
1
|
+
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_RESIZE_BILINEAR_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_RESIZE_BILINEAR_H_
|
17
|
+
|
18
|
+
#include <algorithm>
|
19
|
+
#include <cmath>
|
20
|
+
#include <cstdint>
|
21
|
+
#include <limits>
|
22
|
+
|
23
|
+
#include "tensorflow/lite/kernels/internal/cppmath.h"
|
24
|
+
#include "tensorflow/lite/kernels/internal/types.h"
|
25
|
+
|
26
|
+
namespace tflite_micro {
|
27
|
+
namespace reference_ops {
|
28
|
+
|
29
|
+
inline void ComputeInterpolationValues(const float value, const float scale,
|
30
|
+
const bool half_pixel_centers,
|
31
|
+
int32_t input_size, float* scaled_value,
|
32
|
+
int32_t* lower_bound,
|
33
|
+
int32_t* upper_bound) {
|
34
|
+
if (half_pixel_centers) {
|
35
|
+
*scaled_value = (value + 0.5f) * scale - 0.5f;
|
36
|
+
} else {
|
37
|
+
*scaled_value = value * scale;
|
38
|
+
}
|
39
|
+
float scaled_value_floor = std::floor(*scaled_value);
|
40
|
+
*lower_bound = std::max(static_cast<int32_t>(scaled_value_floor),
|
41
|
+
static_cast<int32_t>(0));
|
42
|
+
*upper_bound =
|
43
|
+
std::min(static_cast<int32_t>(std::ceil(*scaled_value)), input_size - 1);
|
44
|
+
}
|
45
|
+
|
46
|
+
template <typename T>
|
47
|
+
inline void ResizeBilinear(const tflite_micro::ResizeBilinearParams& op_params,
|
48
|
+
const RuntimeShape& unextended_input_shape,
|
49
|
+
const T* input_data,
|
50
|
+
const RuntimeShape& unextended_output_size_shape,
|
51
|
+
const int32_t* output_size_data,
|
52
|
+
const RuntimeShape& unextended_output_shape,
|
53
|
+
T* output_data) {
|
54
|
+
// If half_pixel_centers is True, align_corners must be False.
|
55
|
+
TFLITE_DCHECK(!op_params.half_pixel_centers || !op_params.align_corners);
|
56
|
+
TFLITE_DCHECK_LE(unextended_input_shape.DimensionsCount(), 4);
|
57
|
+
TFLITE_DCHECK_LE(unextended_output_size_shape.DimensionsCount(), 4);
|
58
|
+
TFLITE_DCHECK_LE(unextended_output_shape.DimensionsCount(), 4);
|
59
|
+
const RuntimeShape input_shape =
|
60
|
+
RuntimeShape::ExtendedShape(4, unextended_input_shape);
|
61
|
+
const RuntimeShape output_size_shape =
|
62
|
+
RuntimeShape::ExtendedShape(4, unextended_output_size_shape);
|
63
|
+
const RuntimeShape output_shape =
|
64
|
+
RuntimeShape::ExtendedShape(4, unextended_output_shape);
|
65
|
+
|
66
|
+
int32_t batches = MatchingDim(input_shape, 0, output_shape, 0);
|
67
|
+
int32_t input_height = input_shape.Dims(1);
|
68
|
+
int32_t input_width = input_shape.Dims(2);
|
69
|
+
int32_t depth = MatchingDim(input_shape, 3, output_shape, 3);
|
70
|
+
|
71
|
+
TFLITE_DCHECK_EQ(output_size_shape.Dims(0), 1);
|
72
|
+
TFLITE_DCHECK_EQ(output_size_shape.Dims(1), 1);
|
73
|
+
TFLITE_DCHECK_EQ(output_size_shape.Dims(2), 1);
|
74
|
+
TFLITE_DCHECK_EQ(output_size_shape.Dims(3), 2);
|
75
|
+
int32_t output_height =
|
76
|
+
output_size_data[Offset(output_size_shape, 0, 0, 0, 0)];
|
77
|
+
int32_t output_width =
|
78
|
+
output_size_data[Offset(output_size_shape, 0, 0, 0, 1)];
|
79
|
+
|
80
|
+
float height_scale = static_cast<float>(input_height) / output_height;
|
81
|
+
float width_scale = static_cast<float>(input_width) / output_width;
|
82
|
+
if (op_params.align_corners && output_height > 1) {
|
83
|
+
height_scale = static_cast<float>(input_height - 1) / (output_height - 1);
|
84
|
+
}
|
85
|
+
if (op_params.align_corners && output_width > 1) {
|
86
|
+
width_scale = static_cast<float>(input_width - 1) / (output_width - 1);
|
87
|
+
}
|
88
|
+
const float rounding_offset = std::numeric_limits<T>::is_integer ? .5f : .0f;
|
89
|
+
|
90
|
+
for (int b = 0; b < batches; ++b) {
|
91
|
+
for (int y = 0; y < output_height; ++y) {
|
92
|
+
float input_y;
|
93
|
+
int32_t y0, y1;
|
94
|
+
ComputeInterpolationValues(y, height_scale, op_params.half_pixel_centers,
|
95
|
+
input_height, &input_y, &y0, &y1);
|
96
|
+
for (int x = 0; x < output_width; ++x) {
|
97
|
+
float input_x;
|
98
|
+
int32_t x0, x1;
|
99
|
+
ComputeInterpolationValues(x, width_scale, op_params.half_pixel_centers,
|
100
|
+
input_width, &input_x, &x0, &x1);
|
101
|
+
for (int c = 0; c < depth; ++c) {
|
102
|
+
T interpolation =
|
103
|
+
static_cast<T>(input_data[Offset(input_shape, b, y0, x0, c)] *
|
104
|
+
(1 - (input_y - y0)) * (1 - (input_x - x0)) +
|
105
|
+
input_data[Offset(input_shape, b, y1, x0, c)] *
|
106
|
+
(input_y - y0) * (1 - (input_x - x0)) +
|
107
|
+
input_data[Offset(input_shape, b, y0, x1, c)] *
|
108
|
+
(1 - (input_y - y0)) * (input_x - x0) +
|
109
|
+
input_data[Offset(input_shape, b, y1, x1, c)] *
|
110
|
+
(input_y - y0) * (input_x - x0) +
|
111
|
+
rounding_offset);
|
112
|
+
output_data[Offset(output_shape, b, y, x, c)] = interpolation;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
inline void ComputeInterpolationValuesInteger(
|
120
|
+
const int32_t value, const int32_t scale_10, const bool half_pixel_centers,
|
121
|
+
int32_t input_size, int32_t* scaled_value, int32_t* lower_bound,
|
122
|
+
int32_t* upper_bound) {
|
123
|
+
if (half_pixel_centers) {
|
124
|
+
*scaled_value = value * scale_10 + scale_10 / 2 - (1 << 9);
|
125
|
+
} else {
|
126
|
+
*scaled_value = value * scale_10;
|
127
|
+
}
|
128
|
+
constexpr int32_t zero = 0;
|
129
|
+
*lower_bound = std::max(*scaled_value / (1 << 10), zero);
|
130
|
+
*upper_bound =
|
131
|
+
std::min((*scaled_value + (1 << 10) - 1) / (1 << 10), input_size - 1);
|
132
|
+
}
|
133
|
+
|
134
|
+
// Same as above but doesn't use any floating-point for the resize
|
135
|
+
template <typename T>
|
136
|
+
inline void ResizeBilinearInteger(
|
137
|
+
const tflite_micro::ResizeBilinearParams& op_params,
|
138
|
+
const RuntimeShape& unextended_input_shape, const T* input_data,
|
139
|
+
const RuntimeShape& unextended_output_size_shape,
|
140
|
+
const int32_t* output_size_data,
|
141
|
+
const RuntimeShape& unextended_output_shape, T* output_data) {
|
142
|
+
// If half_pixel_centers is True, align_corners must be False.
|
143
|
+
TFLITE_DCHECK(!op_params.half_pixel_centers || !op_params.align_corners);
|
144
|
+
TFLITE_DCHECK_LE(unextended_input_shape.DimensionsCount(), 4);
|
145
|
+
TFLITE_DCHECK_LE(unextended_output_size_shape.DimensionsCount(), 4);
|
146
|
+
TFLITE_DCHECK_LE(unextended_output_shape.DimensionsCount(), 4);
|
147
|
+
const RuntimeShape input_shape =
|
148
|
+
RuntimeShape::ExtendedShape(4, unextended_input_shape);
|
149
|
+
const RuntimeShape output_size_shape =
|
150
|
+
RuntimeShape::ExtendedShape(4, unextended_output_size_shape);
|
151
|
+
const RuntimeShape output_shape =
|
152
|
+
RuntimeShape::ExtendedShape(4, unextended_output_shape);
|
153
|
+
|
154
|
+
const int32_t batches = MatchingDim(input_shape, 0, output_shape, 0);
|
155
|
+
const int32_t input_height = input_shape.Dims(1);
|
156
|
+
const int32_t input_width = input_shape.Dims(2);
|
157
|
+
const int32_t depth = MatchingDim(input_shape, 3, output_shape, 3);
|
158
|
+
|
159
|
+
TFLITE_DCHECK_EQ(output_size_shape.Dims(0), 1);
|
160
|
+
TFLITE_DCHECK_EQ(output_size_shape.Dims(1), 1);
|
161
|
+
TFLITE_DCHECK_EQ(output_size_shape.Dims(2), 1);
|
162
|
+
TFLITE_DCHECK_EQ(output_size_shape.Dims(3), 2);
|
163
|
+
const int32_t output_height =
|
164
|
+
output_size_data[Offset(output_size_shape, 0, 0, 0, 0)];
|
165
|
+
const int32_t output_width =
|
166
|
+
output_size_data[Offset(output_size_shape, 0, 0, 0, 1)];
|
167
|
+
|
168
|
+
int32_t height_scale_10 =
|
169
|
+
((1 << 10) * input_height + output_height / 2) / output_height;
|
170
|
+
int32_t width_scale_10 =
|
171
|
+
((1 << 10) * input_width + output_width / 2) / output_width;
|
172
|
+
if (op_params.align_corners && output_height > 1) {
|
173
|
+
height_scale_10 =
|
174
|
+
((1 << 10) * (input_height - 1) + (output_height - 1) / 2) /
|
175
|
+
(output_height - 1);
|
176
|
+
}
|
177
|
+
if (op_params.align_corners && output_width > 1) {
|
178
|
+
width_scale_10 = ((1 << 10) * (input_width - 1) + (output_width - 1) / 2) /
|
179
|
+
(output_width - 1);
|
180
|
+
}
|
181
|
+
|
182
|
+
for (int b = 0; b < batches; ++b) {
|
183
|
+
for (int y = 0; y < output_height; ++y) {
|
184
|
+
int32_t input_y, y0, y1;
|
185
|
+
ComputeInterpolationValuesInteger(y, height_scale_10,
|
186
|
+
op_params.half_pixel_centers,
|
187
|
+
input_height, &input_y, &y0, &y1);
|
188
|
+
for (int x = 0; x < output_width; ++x) {
|
189
|
+
int32_t input_x, x0, x1;
|
190
|
+
ComputeInterpolationValuesInteger(x, width_scale_10,
|
191
|
+
op_params.half_pixel_centers,
|
192
|
+
input_width, &input_x, &x0, &x1);
|
193
|
+
for (int c = 0; c < depth; ++c) {
|
194
|
+
const int64_t output_20_ll =
|
195
|
+
static_cast<int64_t>(
|
196
|
+
input_data[Offset(input_shape, b, y0, x0, c)]) *
|
197
|
+
((1 << 10) - (input_y - (1 << 10) * y0)) *
|
198
|
+
((1 << 10) - (input_x - (1 << 10) * x0));
|
199
|
+
const int64_t output_20_lu =
|
200
|
+
static_cast<int64_t>(
|
201
|
+
input_data[Offset(input_shape, b, y1, x0, c)]) *
|
202
|
+
(input_y - (1 << 10) * y0) *
|
203
|
+
((1 << 10) - (input_x - (1 << 10) * x0));
|
204
|
+
const int64_t output_20_rl =
|
205
|
+
static_cast<int64_t>(
|
206
|
+
input_data[Offset(input_shape, b, y0, x1, c)]) *
|
207
|
+
((1 << 10) - (input_y - (1 << 10) * y0)) *
|
208
|
+
(input_x - (1 << 10) * x0);
|
209
|
+
const int64_t output_20_ru =
|
210
|
+
static_cast<int64_t>(
|
211
|
+
input_data[Offset(input_shape, b, y1, x1, c)]) *
|
212
|
+
(input_y - (1 << 10) * y0) * (input_x - (1 << 10) * x0);
|
213
|
+
const int64_t output_20 =
|
214
|
+
output_20_ll + output_20_lu + output_20_rl + output_20_ru;
|
215
|
+
#if TFLITE_SINGLE_ROUNDING
|
216
|
+
const int64_t round = 1 << 19;
|
217
|
+
const T interpolation = static_cast<T>((output_20 + round) >> 20);
|
218
|
+
#else
|
219
|
+
const int64_t round = (output_20 > 0) ? (1 << 19) : -(1 << 19);
|
220
|
+
const T interpolation =
|
221
|
+
static_cast<T>((output_20 + round) / (1 << 20));
|
222
|
+
#endif // TFLITE_SINGLE_ROUNDING
|
223
|
+
output_data[Offset(output_shape, b, y, x, c)] = interpolation;
|
224
|
+
}
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
230
|
+
} // namespace reference_ops
|
231
|
+
} // namespace tflite_micro
|
232
|
+
|
233
|
+
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_RESIZE_BILINEAR_H_
|
xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_nearest_neighbor.h
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_RESIZE_NEAREST_NEIGHBOR_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_RESIZE_NEAREST_NEIGHBOR_H_
|
17
|
+
|
18
|
+
#include <algorithm>
|
19
|
+
#include <cmath>
|
20
|
+
|
21
|
+
#include "tensorflow/lite/kernels/internal/cppmath.h"
|
22
|
+
#include "tensorflow/lite/kernels/internal/types.h"
|
23
|
+
|
24
|
+
namespace tflite_micro {
|
25
|
+
|
26
|
+
namespace reference_ops {
|
27
|
+
|
28
|
+
inline int32_t GetNearestNeighbor(const int input_value,
|
29
|
+
const int32_t input_size,
|
30
|
+
const int32_t output_size,
|
31
|
+
const bool align_corners,
|
32
|
+
const bool half_pixel_centers) {
|
33
|
+
const float scale =
|
34
|
+
(align_corners && output_size > 1)
|
35
|
+
? (input_size - 1) / static_cast<float>(output_size - 1)
|
36
|
+
: input_size / static_cast<float>(output_size);
|
37
|
+
const float offset = half_pixel_centers ? 0.5f : 0.0f;
|
38
|
+
int32_t output_value = std::min(
|
39
|
+
align_corners
|
40
|
+
? static_cast<int32_t>(TfLiteRound((input_value + offset) * scale))
|
41
|
+
: static_cast<int32_t>(std::floor((input_value + offset) * scale)),
|
42
|
+
input_size - 1);
|
43
|
+
if (half_pixel_centers) {
|
44
|
+
output_value = std::max(static_cast<int32_t>(0), output_value);
|
45
|
+
}
|
46
|
+
return output_value;
|
47
|
+
}
|
48
|
+
|
49
|
+
template <typename T>
|
50
|
+
inline void ResizeNearestNeighbor(
|
51
|
+
const tflite_micro::ResizeNearestNeighborParams& op_params,
|
52
|
+
const RuntimeShape& unextended_input_shape, const T* input_data,
|
53
|
+
const RuntimeShape& output_size_shape, const int32_t* output_size_data,
|
54
|
+
const RuntimeShape& unextended_output_shape, T* output_data) {
|
55
|
+
TFLITE_DCHECK_LE(unextended_input_shape.DimensionsCount(), 4);
|
56
|
+
TFLITE_DCHECK_LE(unextended_output_shape.DimensionsCount(), 4);
|
57
|
+
|
58
|
+
const RuntimeShape input_shape =
|
59
|
+
RuntimeShape::ExtendedShape(4, unextended_input_shape);
|
60
|
+
const RuntimeShape output_shape =
|
61
|
+
RuntimeShape::ExtendedShape(4, unextended_output_shape);
|
62
|
+
|
63
|
+
int32_t batches = MatchingDim(input_shape, 0, output_shape, 0);
|
64
|
+
int32_t input_height = input_shape.Dims(1);
|
65
|
+
int32_t input_width = input_shape.Dims(2);
|
66
|
+
int32_t depth = MatchingDim(input_shape, 3, output_shape, 3);
|
67
|
+
|
68
|
+
// The Tensorflow version of this op allows resize on the width and height
|
69
|
+
// axis only.
|
70
|
+
TFLITE_DCHECK_EQ(output_size_shape.FlatSize(), 2);
|
71
|
+
int32_t output_height = output_size_data[0];
|
72
|
+
int32_t output_width = output_size_data[1];
|
73
|
+
|
74
|
+
const int col_offset = input_shape.Dims(3);
|
75
|
+
const int row_offset = input_shape.Dims(2) * col_offset;
|
76
|
+
const int batch_offset = input_shape.Dims(1) * row_offset;
|
77
|
+
|
78
|
+
const T* input_ptr = input_data;
|
79
|
+
T* output_ptr = output_data;
|
80
|
+
for (int b = 0; b < batches; ++b) {
|
81
|
+
for (int y = 0; y < output_height; ++y) {
|
82
|
+
int32_t in_y = GetNearestNeighbor(y, input_height, output_height,
|
83
|
+
op_params.align_corners,
|
84
|
+
op_params.half_pixel_centers);
|
85
|
+
const T* y_input_ptr = input_ptr + in_y * row_offset;
|
86
|
+
for (int x = 0; x < output_width; ++x) {
|
87
|
+
int32_t in_x = GetNearestNeighbor(x, input_width, output_width,
|
88
|
+
op_params.align_corners,
|
89
|
+
op_params.half_pixel_centers);
|
90
|
+
const T* x_input_ptr = y_input_ptr + in_x * col_offset;
|
91
|
+
memcpy(output_ptr, x_input_ptr, depth * sizeof(T));
|
92
|
+
output_ptr += depth;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
input_ptr += batch_offset;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
} // namespace reference_ops
|
100
|
+
} // namespace tflite_micro
|
101
|
+
|
102
|
+
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_RESIZE_NEAREST_NEIGHBOR_H_
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ROUND_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ROUND_H_
|
17
|
+
|
18
|
+
#include <cmath>
|
19
|
+
|
20
|
+
#include "tensorflow/lite/kernels/internal/types.h"
|
21
|
+
|
22
|
+
namespace tflite_micro {
|
23
|
+
|
24
|
+
namespace reference_ops {
|
25
|
+
|
26
|
+
inline float RoundToNearest(float value) {
|
27
|
+
auto floor_val = std::floor(value);
|
28
|
+
auto diff = value - floor_val;
|
29
|
+
if ((diff < 0.5f) ||
|
30
|
+
((diff == 0.5f) && (static_cast<int>(floor_val) % 2 == 0))) {
|
31
|
+
return floor_val;
|
32
|
+
} else {
|
33
|
+
return floor_val = floor_val + 1.0f;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
inline void Round(const RuntimeShape& input_shape, const float* input_data,
|
38
|
+
const RuntimeShape& output_shape, float* output_data) {
|
39
|
+
const int flat_size = MatchingFlatSize(input_shape, output_shape);
|
40
|
+
for (int i = 0; i < flat_size; ++i) {
|
41
|
+
// Note that this implementation matches that of tensorFlow tf.round
|
42
|
+
// and corresponds to the bankers rounding method.
|
43
|
+
// cfenv (for fesetround) is not yet supported universally on Android, so
|
44
|
+
// using a work around.
|
45
|
+
output_data[i] = RoundToNearest(input_data[i]);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
} // namespace reference_ops
|
50
|
+
} // namespace tflite_micro
|
51
|
+
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ROUND_H_
|
@@ -0,0 +1,151 @@
|
|
1
|
+
/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SELECT_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SELECT_H_
|
17
|
+
|
18
|
+
#include <cmath>
|
19
|
+
|
20
|
+
#include "ruy/profiler/instrumentation.h" // from @ruy
|
21
|
+
#include "tensorflow/lite/kernels/internal/common.h"
|
22
|
+
#include "tensorflow/lite/kernels/internal/types.h"
|
23
|
+
|
24
|
+
namespace tflite_micro {
|
25
|
+
namespace reference_ops {
|
26
|
+
|
27
|
+
template <typename D, typename T>
|
28
|
+
void Select(const RuntimeShape& input_condition_shape,
|
29
|
+
const D* input_condition_data, const RuntimeShape& input_x_shape,
|
30
|
+
const T* input_x_data, const RuntimeShape& input_y_shape,
|
31
|
+
const T* input_y_data, const RuntimeShape& output_shape,
|
32
|
+
T* output_data) {
|
33
|
+
ruy::profiler::ScopeLabel label("Select");
|
34
|
+
int64_t flatsize;
|
35
|
+
// Allow select operator executions on mixed scalar tensors and one element
|
36
|
+
// tensors.
|
37
|
+
if (input_condition_shape.FlatSize() == 1 && input_x_shape.FlatSize() == 1 &&
|
38
|
+
input_y_shape.FlatSize() == 1 && output_shape.FlatSize() == 1) {
|
39
|
+
flatsize = 1;
|
40
|
+
} else {
|
41
|
+
flatsize = MatchingFlatSize(input_condition_shape, input_x_shape,
|
42
|
+
input_y_shape, output_shape);
|
43
|
+
}
|
44
|
+
for (int64_t i = 0; i < flatsize; ++i) {
|
45
|
+
output_data[i] =
|
46
|
+
input_condition_data[i] ? input_x_data[i] : input_y_data[i];
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
template <typename D, typename T>
|
51
|
+
void RankOneSelect(const RuntimeShape& input_condition_shape,
|
52
|
+
const D* input_condition_data,
|
53
|
+
const RuntimeShape& input_x_shape, const T* input_x_data,
|
54
|
+
const RuntimeShape& input_y_shape, const T* input_y_data,
|
55
|
+
const RuntimeShape& output_shape, T* output_data) {
|
56
|
+
ruy::profiler::ScopeLabel label("Select/RankOneSelect");
|
57
|
+
const int64_t outer_size = input_condition_shape.FlatSize();
|
58
|
+
int64_t inner_size;
|
59
|
+
if (input_condition_shape.DimensionsCount() == 0) {
|
60
|
+
inner_size = MatchingFlatSize(input_x_shape, input_y_shape, output_shape);
|
61
|
+
} else {
|
62
|
+
TFLITE_DCHECK_EQ(
|
63
|
+
MatchingDim(input_x_shape, 0, input_y_shape, 0, output_shape, 0),
|
64
|
+
outer_size);
|
65
|
+
inner_size =
|
66
|
+
MatchingFlatSizeSkipDim(input_x_shape, 0, input_y_shape, output_shape);
|
67
|
+
}
|
68
|
+
|
69
|
+
int64_t offset = 0;
|
70
|
+
for (int64_t i = 0; i < outer_size; i++) {
|
71
|
+
const T* input_data = input_condition_data[i] ? input_x_data : input_y_data;
|
72
|
+
memcpy(output_data + offset, input_data + offset, inner_size * sizeof(T));
|
73
|
+
offset += inner_size;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
template <typename D, typename T>
|
78
|
+
void BroadcastSelect5DSlow(const RuntimeShape& input_condition_shape,
|
79
|
+
const D* input_condition_data,
|
80
|
+
const RuntimeShape& input_x_shape,
|
81
|
+
const T* input_x_data,
|
82
|
+
const RuntimeShape& input_y_shape,
|
83
|
+
const T* input_y_data,
|
84
|
+
const RuntimeShape& output_shape, T* output_data) {
|
85
|
+
ruy::profiler::ScopeLabel label("Select/BroadcastSelectSlow");
|
86
|
+
TFLITE_DCHECK_LE(input_condition_shape.DimensionsCount(), 5);
|
87
|
+
TFLITE_DCHECK_LE(input_x_shape.DimensionsCount(), 5);
|
88
|
+
TFLITE_DCHECK_LE(input_y_shape.DimensionsCount(), 5);
|
89
|
+
TFLITE_DCHECK_LE(output_shape.DimensionsCount(), 5);
|
90
|
+
|
91
|
+
NdArrayDesc<5> desc_condition;
|
92
|
+
NdArrayDesc<5> desc_x;
|
93
|
+
NdArrayDesc<5> desc_y;
|
94
|
+
NdArrayDesc<5> desc_output;
|
95
|
+
const RuntimeShape extended_output_shape =
|
96
|
+
RuntimeShape::ExtendedShape(5, output_shape);
|
97
|
+
CopyDimsToDesc(extended_output_shape, &desc_output);
|
98
|
+
NdArrayDescsForElementwiseBroadcast(input_condition_shape, input_x_shape,
|
99
|
+
input_y_shape, &desc_condition, &desc_x,
|
100
|
+
&desc_y);
|
101
|
+
|
102
|
+
// In Tensorflow, the dimensions are canonically named (batch_number, row,
|
103
|
+
// col, channel), with extents (batches, height, width, depth), with the
|
104
|
+
// trailing dimension changing most rapidly (channels has the smallest
|
105
|
+
// stride, typically 1 element).
|
106
|
+
//
|
107
|
+
// In generated C code, we store arrays with the dimensions reversed. The
|
108
|
+
// first dimension has smallest stride.
|
109
|
+
//
|
110
|
+
// We name our variables by their Tensorflow convention, but generate C code
|
111
|
+
// nesting loops such that the innermost loop has the smallest stride for
|
112
|
+
// the best cache behavior.
|
113
|
+
for (int n = 0; n < desc_output.extents[0]; ++n) {
|
114
|
+
int out_idx_n = desc_output.extents[1] * n;
|
115
|
+
int cond_idx_n = desc_condition.strides[0] * n;
|
116
|
+
int in_idx1_n = desc_x.strides[0] * n;
|
117
|
+
int in_idx2_n = desc_y.strides[0] * n;
|
118
|
+
for (int b = 0; b < desc_output.extents[1]; ++b) {
|
119
|
+
int out_idx_b = (out_idx_n + b) * desc_output.extents[2];
|
120
|
+
int cond_idx_b = cond_idx_n + desc_condition.strides[1] * b;
|
121
|
+
int in_idx1_b = in_idx1_n + desc_x.strides[1] * b;
|
122
|
+
int in_idx2_b = in_idx2_n + desc_y.strides[1] * b;
|
123
|
+
for (int y = 0; y < desc_output.extents[2]; ++y) {
|
124
|
+
int out_idx_y = (out_idx_b + y) * desc_output.extents[3];
|
125
|
+
int cond_idx_y = cond_idx_b + desc_condition.strides[2] * y;
|
126
|
+
int in_idx1_y = in_idx1_b + desc_x.strides[2] * y;
|
127
|
+
int in_idx2_y = in_idx2_b + desc_y.strides[2] * y;
|
128
|
+
for (int x = 0; x < desc_output.extents[3]; ++x) {
|
129
|
+
int out_idx = (out_idx_y + x) * desc_output.extents[4];
|
130
|
+
int cond_idx = cond_idx_y + desc_condition.strides[3] * x;
|
131
|
+
int in_idx1 = in_idx1_y + desc_x.strides[3] * x;
|
132
|
+
int in_idx2 = in_idx2_y + desc_y.strides[3] * x;
|
133
|
+
for (int c = 0; c < desc_output.extents[4]; ++c) {
|
134
|
+
output_data[out_idx] = input_condition_data[cond_idx]
|
135
|
+
? input_x_data[in_idx1]
|
136
|
+
: input_y_data[in_idx2];
|
137
|
+
out_idx++;
|
138
|
+
cond_idx += desc_condition.strides[4];
|
139
|
+
in_idx1 += desc_x.strides[4];
|
140
|
+
in_idx2 += desc_y.strides[4];
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
} // namespace reference_ops
|
149
|
+
} // namespace tflite_micro
|
150
|
+
|
151
|
+
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SELECT_H_
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
==============================================================================*/
|
15
|
+
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SLICE_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SLICE_H_
|
17
|
+
|
18
|
+
#include "tensorflow/lite/kernels/internal/portable_tensor.h"
|
19
|
+
#include "tensorflow/lite/kernels/internal/types.h"
|
20
|
+
|
21
|
+
namespace tflite_micro {
|
22
|
+
|
23
|
+
namespace reference_ops {
|
24
|
+
|
25
|
+
template <typename T>
|
26
|
+
inline void Slice(const tflite_micro::SliceParams& op_params,
|
27
|
+
const RuntimeShape& input_shape,
|
28
|
+
const RuntimeShape& output_shape,
|
29
|
+
SequentialTensorWriter<T>* writer) {
|
30
|
+
const RuntimeShape ext_shape = RuntimeShape::ExtendedShape(5, input_shape);
|
31
|
+
TFLITE_DCHECK_LE(op_params.begin_count, 5);
|
32
|
+
TFLITE_DCHECK_LE(op_params.size_count, 5);
|
33
|
+
const int begin_count = op_params.begin_count;
|
34
|
+
const int size_count = op_params.size_count;
|
35
|
+
// We front-pad the begin and size vectors.
|
36
|
+
int start[5];
|
37
|
+
int stop[5];
|
38
|
+
for (int i = 0; i < 5; ++i) {
|
39
|
+
int padded_i = 5 - i;
|
40
|
+
start[i] =
|
41
|
+
begin_count < padded_i ? 0 : op_params.begin[begin_count - padded_i];
|
42
|
+
stop[i] =
|
43
|
+
(size_count < padded_i || op_params.size[size_count - padded_i] == -1)
|
44
|
+
? ext_shape.Dims(i)
|
45
|
+
: start[i] + op_params.size[size_count - padded_i];
|
46
|
+
}
|
47
|
+
|
48
|
+
for (int i0 = start[0]; i0 < stop[0]; ++i0) {
|
49
|
+
for (int i1 = start[1]; i1 < stop[1]; ++i1) {
|
50
|
+
for (int i2 = start[2]; i2 < stop[2]; ++i2) {
|
51
|
+
for (int i3 = start[3]; i3 < stop[3]; ++i3) {
|
52
|
+
for (int i4 = start[4]; i4 < stop[4]; ++i4) {
|
53
|
+
writer->Write(Offset(ext_shape, i0, i1, i2, i3, i4));
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
template <typename T>
|
62
|
+
inline void Slice(const tflite_micro::SliceParams& op_params,
|
63
|
+
const RuntimeShape& input_shape, const T* input_data,
|
64
|
+
const RuntimeShape& output_shape, T* output_data) {
|
65
|
+
SequentialTensorWriter<T> writer(input_data, output_data);
|
66
|
+
return Slice(op_params, input_shape, output_shape, &writer);
|
67
|
+
}
|
68
|
+
|
69
|
+
template <typename T>
|
70
|
+
inline void Slice(const tflite_micro::SliceParams& op_params,
|
71
|
+
const RuntimeShape& input_shape, const TfLiteTensor* input,
|
72
|
+
const RuntimeShape& output_shape, TfLiteTensor* output) {
|
73
|
+
SequentialTensorWriter<T> writer(input, output);
|
74
|
+
return Slice(op_params, input_shape, output_shape, &writer);
|
75
|
+
}
|
76
|
+
|
77
|
+
} // namespace reference_ops
|
78
|
+
} // namespace tflite_micro
|
79
|
+
|
80
|
+
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_SLICE_H_
|