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,289 @@
|
|
1
|
+
/* Copyright 2019 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_CONV_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CONV_H_
|
17
|
+
|
18
|
+
#include <algorithm>
|
19
|
+
|
20
|
+
#include "tensorflow/lite/kernels/internal/common.h"
|
21
|
+
#include "tensorflow/lite/kernels/internal/types.h"
|
22
|
+
|
23
|
+
namespace tflite_micro {
|
24
|
+
|
25
|
+
namespace reference_ops {
|
26
|
+
|
27
|
+
inline void Conv(const ConvParams& params, const RuntimeShape& input_shape,
|
28
|
+
const float* input_data, const RuntimeShape& filter_shape,
|
29
|
+
const float* filter_data, const RuntimeShape& bias_shape,
|
30
|
+
const float* bias_data, const RuntimeShape& output_shape,
|
31
|
+
float* output_data, const RuntimeShape& im2col_shape,
|
32
|
+
float* im2col_data) {
|
33
|
+
const int stride_width = params.stride_width;
|
34
|
+
const int stride_height = params.stride_height;
|
35
|
+
const int dilation_width_factor = params.dilation_width_factor;
|
36
|
+
const int dilation_height_factor = params.dilation_height_factor;
|
37
|
+
const int pad_width = params.padding_values.width;
|
38
|
+
const int pad_height = params.padding_values.height;
|
39
|
+
const float output_activation_min = params.float_activation_min;
|
40
|
+
const float output_activation_max = params.float_activation_max;
|
41
|
+
TFLITE_DCHECK_EQ(input_shape.DimensionsCount(), 4);
|
42
|
+
TFLITE_DCHECK_EQ(filter_shape.DimensionsCount(), 4);
|
43
|
+
TFLITE_DCHECK_EQ(output_shape.DimensionsCount(), 4);
|
44
|
+
|
45
|
+
(void)im2col_data; // only used in optimized code.
|
46
|
+
(void)im2col_shape; // only used in optimized code.
|
47
|
+
const int batches = MatchingDim(input_shape, 0, output_shape, 0);
|
48
|
+
const int input_depth = input_shape.Dims(3);
|
49
|
+
const int output_depth = MatchingDim(filter_shape, 0, output_shape, 3);
|
50
|
+
if (bias_data) {
|
51
|
+
TFLITE_DCHECK_EQ(bias_shape.FlatSize(), output_depth);
|
52
|
+
}
|
53
|
+
const int input_height = input_shape.Dims(1);
|
54
|
+
const int input_width = input_shape.Dims(2);
|
55
|
+
const int filter_height = filter_shape.Dims(1);
|
56
|
+
const int filter_width = filter_shape.Dims(2);
|
57
|
+
const int filter_input_depth = filter_shape.Dims(3);
|
58
|
+
const int groups = input_depth / filter_input_depth;
|
59
|
+
TFLITE_DCHECK_NE(groups, 0);
|
60
|
+
TFLITE_DCHECK_EQ(input_depth % filter_input_depth, 0);
|
61
|
+
const int filters_per_group = output_depth / groups;
|
62
|
+
TFLITE_DCHECK_NE(filters_per_group, 0);
|
63
|
+
const int output_height = output_shape.Dims(1);
|
64
|
+
const int output_width = output_shape.Dims(2);
|
65
|
+
|
66
|
+
for (int batch = 0; batch < batches; ++batch) {
|
67
|
+
for (int out_y = 0; out_y < output_height; ++out_y) {
|
68
|
+
const int in_y_origin = (out_y * stride_height) - pad_height;
|
69
|
+
for (int out_x = 0; out_x < output_width; ++out_x) {
|
70
|
+
const int in_x_origin = (out_x * stride_width) - pad_width;
|
71
|
+
for (int out_channel = 0; out_channel < output_depth; ++out_channel) {
|
72
|
+
auto group = out_channel / filters_per_group;
|
73
|
+
float total = 0.f;
|
74
|
+
for (int filter_y = 0; filter_y < filter_height; ++filter_y) {
|
75
|
+
const int in_y = in_y_origin + dilation_height_factor * filter_y;
|
76
|
+
for (int filter_x = 0; filter_x < filter_width; ++filter_x) {
|
77
|
+
const int in_x = in_x_origin + dilation_width_factor * filter_x;
|
78
|
+
|
79
|
+
// Zero padding by omitting the areas outside the image.
|
80
|
+
const bool is_point_inside_image =
|
81
|
+
(in_x >= 0) && (in_x < input_width) && (in_y >= 0) &&
|
82
|
+
(in_y < input_height);
|
83
|
+
|
84
|
+
if (!is_point_inside_image) {
|
85
|
+
continue;
|
86
|
+
}
|
87
|
+
for (int in_channel = 0; in_channel < filter_input_depth;
|
88
|
+
++in_channel) {
|
89
|
+
float input_value =
|
90
|
+
input_data[Offset(input_shape, batch, in_y, in_x,
|
91
|
+
in_channel + group * filter_input_depth)];
|
92
|
+
float filter_value = filter_data[Offset(
|
93
|
+
filter_shape, out_channel, filter_y, filter_x, in_channel)];
|
94
|
+
total += (input_value * filter_value);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
float bias_value = 0.0f;
|
99
|
+
if (bias_data) {
|
100
|
+
bias_value = bias_data[out_channel];
|
101
|
+
}
|
102
|
+
output_data[Offset(output_shape, batch, out_y, out_x, out_channel)] =
|
103
|
+
ActivationFunctionWithMinMax(total + bias_value,
|
104
|
+
output_activation_min,
|
105
|
+
output_activation_max);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
inline void Conv(const ConvParams& params, const RuntimeShape& input_shape,
|
113
|
+
const uint8_t* input_data, const RuntimeShape& filter_shape,
|
114
|
+
const uint8_t* filter_data, const RuntimeShape& bias_shape,
|
115
|
+
const int32_t* bias_data, const RuntimeShape& output_shape,
|
116
|
+
uint8_t* output_data, const RuntimeShape& im2col_shape,
|
117
|
+
uint8_t* im2col_data, void* cpu_backend_context) {
|
118
|
+
(void)cpu_backend_context; // only used in optimized code.
|
119
|
+
(void)im2col_data; // only used in optimized code.
|
120
|
+
(void)im2col_shape; // only used in optimized code.
|
121
|
+
const int stride_width = params.stride_width;
|
122
|
+
const int stride_height = params.stride_height;
|
123
|
+
const int dilation_width_factor = params.dilation_width_factor;
|
124
|
+
const int dilation_height_factor = params.dilation_height_factor;
|
125
|
+
const int pad_width = params.padding_values.width;
|
126
|
+
const int pad_height = params.padding_values.height;
|
127
|
+
const int32_t input_offset = params.input_offset;
|
128
|
+
const int32_t filter_offset = params.weights_offset;
|
129
|
+
const int32_t output_offset = params.output_offset;
|
130
|
+
const int32_t output_multiplier = params.output_multiplier;
|
131
|
+
const int output_shift = params.output_shift;
|
132
|
+
const int32_t output_activation_min = params.quantized_activation_min;
|
133
|
+
const int32_t output_activation_max = params.quantized_activation_max;
|
134
|
+
TFLITE_DCHECK_LE(output_activation_min, output_activation_max);
|
135
|
+
|
136
|
+
TFLITE_DCHECK_EQ(input_shape.DimensionsCount(), 4);
|
137
|
+
TFLITE_DCHECK_EQ(filter_shape.DimensionsCount(), 4);
|
138
|
+
TFLITE_DCHECK_EQ(output_shape.DimensionsCount(), 4);
|
139
|
+
const int batches = MatchingDim(input_shape, 0, output_shape, 0);
|
140
|
+
const int input_depth = input_shape.Dims(3);
|
141
|
+
const int output_depth = MatchingDim(filter_shape, 0, output_shape, 3);
|
142
|
+
if (bias_data) {
|
143
|
+
TFLITE_DCHECK_EQ(bias_shape.FlatSize(), output_depth);
|
144
|
+
}
|
145
|
+
const int input_height = input_shape.Dims(1);
|
146
|
+
const int input_width = input_shape.Dims(2);
|
147
|
+
const int filter_height = filter_shape.Dims(1);
|
148
|
+
const int filter_width = filter_shape.Dims(2);
|
149
|
+
const int filter_input_depth = filter_shape.Dims(3);
|
150
|
+
const int groups = input_depth / filter_input_depth;
|
151
|
+
TFLITE_DCHECK_EQ(input_depth % filter_input_depth, 0);
|
152
|
+
const int filters_per_group = output_depth / groups;
|
153
|
+
const int output_height = output_shape.Dims(1);
|
154
|
+
const int output_width = output_shape.Dims(2);
|
155
|
+
for (int batch = 0; batch < batches; ++batch) {
|
156
|
+
for (int out_y = 0; out_y < output_height; ++out_y) {
|
157
|
+
const int in_y_origin = (out_y * stride_height) - pad_height;
|
158
|
+
for (int out_x = 0; out_x < output_width; ++out_x) {
|
159
|
+
const int in_x_origin = (out_x * stride_width) - pad_width;
|
160
|
+
for (int out_channel = 0; out_channel < output_depth; ++out_channel) {
|
161
|
+
auto group = out_channel / filters_per_group;
|
162
|
+
int32_t acc = 0;
|
163
|
+
for (int filter_y = 0; filter_y < filter_height; ++filter_y) {
|
164
|
+
const int in_y = in_y_origin + dilation_height_factor * filter_y;
|
165
|
+
for (int filter_x = 0; filter_x < filter_width; ++filter_x) {
|
166
|
+
const int in_x = in_x_origin + dilation_width_factor * filter_x;
|
167
|
+
|
168
|
+
// Zero padding by omitting the areas outside the image.
|
169
|
+
const bool is_point_inside_image =
|
170
|
+
(in_x >= 0) && (in_x < input_width) && (in_y >= 0) &&
|
171
|
+
(in_y < input_height);
|
172
|
+
|
173
|
+
if (!is_point_inside_image) {
|
174
|
+
continue;
|
175
|
+
}
|
176
|
+
|
177
|
+
for (int in_channel = 0; in_channel < filter_input_depth;
|
178
|
+
++in_channel) {
|
179
|
+
int32_t input_val =
|
180
|
+
input_data[Offset(input_shape, batch, in_y, in_x,
|
181
|
+
in_channel + group * filter_input_depth)];
|
182
|
+
int32_t filter_val = filter_data[Offset(
|
183
|
+
filter_shape, out_channel, filter_y, filter_x, in_channel)];
|
184
|
+
acc +=
|
185
|
+
(filter_val + filter_offset) * (input_val + input_offset);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
if (bias_data) {
|
190
|
+
acc += bias_data[out_channel];
|
191
|
+
}
|
192
|
+
acc = MultiplyByQuantizedMultiplier(acc, output_multiplier,
|
193
|
+
output_shift);
|
194
|
+
acc += output_offset;
|
195
|
+
acc = std::max(acc, output_activation_min);
|
196
|
+
acc = std::min(acc, output_activation_max);
|
197
|
+
output_data[Offset(output_shape, batch, out_y, out_x, out_channel)] =
|
198
|
+
static_cast<uint8_t>(acc);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
}
|
204
|
+
|
205
|
+
inline void HybridConvPerChannel(
|
206
|
+
const ConvParams& params, float* scaling_factors_ptr,
|
207
|
+
const RuntimeShape& input_shape, const int8_t* input_data,
|
208
|
+
const RuntimeShape& filter_shape, const int8_t* filter_data,
|
209
|
+
const RuntimeShape& bias_shape, const float* bias_data,
|
210
|
+
const RuntimeShape& output_shape, float* output_data,
|
211
|
+
const RuntimeShape& im2col_shape, int8_t* im2col_data,
|
212
|
+
const float* per_channel_scale, int32_t* input_offset) {
|
213
|
+
(void)im2col_data; // only used in optimized code.
|
214
|
+
(void)im2col_shape; // only used in optimized code.
|
215
|
+
const int stride_width = params.stride_width;
|
216
|
+
const int stride_height = params.stride_height;
|
217
|
+
const int dilation_width_factor = params.dilation_width_factor;
|
218
|
+
const int dilation_height_factor = params.dilation_height_factor;
|
219
|
+
const int pad_width = params.padding_values.width;
|
220
|
+
const int pad_height = params.padding_values.height;
|
221
|
+
const float output_activation_min = params.float_activation_min;
|
222
|
+
const float output_activation_max = params.float_activation_max;
|
223
|
+
TFLITE_DCHECK_EQ(input_shape.DimensionsCount(), 4);
|
224
|
+
TFLITE_DCHECK_EQ(filter_shape.DimensionsCount(), 4);
|
225
|
+
TFLITE_DCHECK_EQ(output_shape.DimensionsCount(), 4);
|
226
|
+
const int batches = MatchingDim(input_shape, 0, output_shape, 0);
|
227
|
+
const int input_depth = input_shape.Dims(3);
|
228
|
+
const int output_depth = MatchingDim(filter_shape, 0, output_shape, 3);
|
229
|
+
if (bias_data) {
|
230
|
+
TFLITE_DCHECK_EQ(bias_shape.FlatSize(), output_depth);
|
231
|
+
}
|
232
|
+
const int input_height = input_shape.Dims(1);
|
233
|
+
const int input_width = input_shape.Dims(2);
|
234
|
+
const int filter_height = filter_shape.Dims(1);
|
235
|
+
const int filter_width = filter_shape.Dims(2);
|
236
|
+
const int filter_input_depth = filter_shape.Dims(3);
|
237
|
+
const int groups = input_depth / filter_input_depth;
|
238
|
+
TFLITE_DCHECK_EQ(input_depth % filter_input_depth, 0);
|
239
|
+
const int filters_per_group = output_depth / groups;
|
240
|
+
const int output_height = output_shape.Dims(1);
|
241
|
+
const int output_width = output_shape.Dims(2);
|
242
|
+
for (int batch = 0; batch < batches; ++batch) {
|
243
|
+
for (int out_y = 0; out_y < output_height; ++out_y) {
|
244
|
+
for (int out_x = 0; out_x < output_width; ++out_x) {
|
245
|
+
for (int out_channel = 0; out_channel < output_depth; ++out_channel) {
|
246
|
+
auto group = out_channel / filters_per_group;
|
247
|
+
const int in_x_origin = (out_x * stride_width) - pad_width;
|
248
|
+
const int in_y_origin = (out_y * stride_height) - pad_height;
|
249
|
+
int32_t acc = 0;
|
250
|
+
for (int filter_y = 0; filter_y < filter_height; ++filter_y) {
|
251
|
+
for (int filter_x = 0; filter_x < filter_width; ++filter_x) {
|
252
|
+
for (int in_channel = 0; in_channel < filter_input_depth;
|
253
|
+
++in_channel) {
|
254
|
+
const int in_x = in_x_origin + dilation_width_factor * filter_x;
|
255
|
+
const int in_y =
|
256
|
+
in_y_origin + dilation_height_factor * filter_y;
|
257
|
+
// If the location is outside the bounds of the input image,
|
258
|
+
// use zero as a default value.
|
259
|
+
if ((in_x >= 0) && (in_x < input_width) && (in_y >= 0) &&
|
260
|
+
(in_y < input_height)) {
|
261
|
+
int32_t input_val = input_data[Offset(
|
262
|
+
input_shape, batch, in_y, in_x,
|
263
|
+
in_channel + group * filter_input_depth)];
|
264
|
+
int32_t filter_val =
|
265
|
+
filter_data[Offset(filter_shape, out_channel, filter_y,
|
266
|
+
filter_x, in_channel)];
|
267
|
+
acc += filter_val * (input_val - input_offset[batch]);
|
268
|
+
}
|
269
|
+
}
|
270
|
+
}
|
271
|
+
}
|
272
|
+
float acc_float =
|
273
|
+
acc * per_channel_scale[out_channel] * scaling_factors_ptr[batch];
|
274
|
+
if (bias_data) {
|
275
|
+
acc_float += bias_data[out_channel];
|
276
|
+
}
|
277
|
+
output_data[Offset(output_shape, batch, out_y, out_x, out_channel)] =
|
278
|
+
ActivationFunctionWithMinMax(acc_float, output_activation_min,
|
279
|
+
output_activation_max);
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
} // namespace reference_ops
|
287
|
+
} // namespace tflite_micro
|
288
|
+
|
289
|
+
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CONV_H_
|
@@ -0,0 +1,175 @@
|
|
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_CUMSUM_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CUMSUM_H_
|
17
|
+
|
18
|
+
#include <algorithm>
|
19
|
+
#include <cstdint>
|
20
|
+
#include <limits>
|
21
|
+
|
22
|
+
#include "tensorflow/lite/kernels/internal/common.h"
|
23
|
+
#include "tensorflow/lite/kernels/internal/compatibility.h"
|
24
|
+
|
25
|
+
namespace tflite_micro {
|
26
|
+
namespace reference_ops {
|
27
|
+
|
28
|
+
template <typename T>
|
29
|
+
inline void CumSum(const T* input_data, const RuntimeShape& shape, int32_t axis,
|
30
|
+
bool exclusive, bool reverse, T* output_data) {
|
31
|
+
const int32_t rank = shape.DimensionsCount();
|
32
|
+
TFLITE_DCHECK_GE(rank, 1);
|
33
|
+
TFLITE_DCHECK_GE(axis, 0);
|
34
|
+
TFLITE_DCHECK_LT(axis, rank);
|
35
|
+
|
36
|
+
size_t inner = 1;
|
37
|
+
size_t outer = 1;
|
38
|
+
size_t depth = 1;
|
39
|
+
for (int32_t i = 0; i < rank; i++) {
|
40
|
+
if (i < axis)
|
41
|
+
inner *= shape.Dims(i);
|
42
|
+
else if (i > axis)
|
43
|
+
outer *= shape.Dims(i);
|
44
|
+
else
|
45
|
+
depth = shape.Dims(i);
|
46
|
+
}
|
47
|
+
|
48
|
+
for (size_t outer_index = 0; outer_index < outer; outer_index++) {
|
49
|
+
size_t outer_index_adj;
|
50
|
+
if (reverse)
|
51
|
+
outer_index_adj = (outer - 1) - outer_index;
|
52
|
+
else
|
53
|
+
outer_index_adj = outer_index;
|
54
|
+
for (size_t inner_index = 0; inner_index < inner; inner_index++) {
|
55
|
+
T accumulator = 0;
|
56
|
+
size_t inner_index_adj;
|
57
|
+
if (reverse)
|
58
|
+
inner_index_adj = (inner - 1) - inner_index;
|
59
|
+
else
|
60
|
+
inner_index_adj = inner_index;
|
61
|
+
for (size_t depth_index = 0; depth_index < depth; depth_index++) {
|
62
|
+
size_t depth_index_adj;
|
63
|
+
if (reverse)
|
64
|
+
depth_index_adj = (depth - 1) - depth_index;
|
65
|
+
else
|
66
|
+
depth_index_adj = depth_index;
|
67
|
+
|
68
|
+
size_t index = outer_index_adj;
|
69
|
+
index += inner_index_adj * depth * outer;
|
70
|
+
index += depth_index_adj * outer;
|
71
|
+
|
72
|
+
if (exclusive) {
|
73
|
+
output_data[index] = accumulator;
|
74
|
+
accumulator += input_data[index];
|
75
|
+
} else {
|
76
|
+
accumulator += input_data[index];
|
77
|
+
output_data[index] = accumulator;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
//
|
85
|
+
// Quantized INT8 CUMSUM
|
86
|
+
//
|
87
|
+
inline void CumSum(const ArithmeticParams& params, const int8_t* input_data,
|
88
|
+
const RuntimeShape& shape, int32_t axis, bool exclusive,
|
89
|
+
bool reverse, int8_t* output_data) {
|
90
|
+
TFLITE_DCHECK_LE(params.quantized_activation_min,
|
91
|
+
params.quantized_activation_max);
|
92
|
+
// Input offset is negative input zero point. Activation tensors are
|
93
|
+
// asymmetric quantized so they span the full int8 range.
|
94
|
+
// All inputs should have same zero-point and scale, this is checked during
|
95
|
+
// Prepare stage.
|
96
|
+
TFLITE_DCHECK_GE(-params.input1_offset, std::numeric_limits<int8_t>::min());
|
97
|
+
TFLITE_DCHECK_LE(-params.input1_offset, std::numeric_limits<int8_t>::max());
|
98
|
+
|
99
|
+
const int32_t rank = shape.DimensionsCount();
|
100
|
+
TFLITE_DCHECK_GE(rank, 1);
|
101
|
+
TFLITE_DCHECK_GE(axis, 0);
|
102
|
+
TFLITE_DCHECK_LT(axis, rank);
|
103
|
+
|
104
|
+
size_t inner = 1;
|
105
|
+
size_t outer = 1;
|
106
|
+
size_t depth = 1;
|
107
|
+
for (int32_t i = 0; i < rank; i++) {
|
108
|
+
if (i < axis)
|
109
|
+
inner *= shape.Dims(i);
|
110
|
+
else if (i > axis)
|
111
|
+
outer *= shape.Dims(i);
|
112
|
+
else
|
113
|
+
depth = shape.Dims(i);
|
114
|
+
}
|
115
|
+
|
116
|
+
for (size_t outer_index = 0; outer_index < outer; outer_index++) {
|
117
|
+
size_t outer_index_adj;
|
118
|
+
if (reverse)
|
119
|
+
outer_index_adj = (outer - 1) - outer_index;
|
120
|
+
else
|
121
|
+
outer_index_adj = outer_index;
|
122
|
+
for (size_t inner_index = 0; inner_index < inner; inner_index++) {
|
123
|
+
int32_t accumulator = params.input1_offset; // accumulator = 0
|
124
|
+
accumulator *= (1 << params.left_shift);
|
125
|
+
accumulator = MultiplyByQuantizedMultiplierSmallerThanOneExp(
|
126
|
+
accumulator, params.input1_multiplier, params.input1_shift);
|
127
|
+
|
128
|
+
size_t inner_index_adj;
|
129
|
+
if (reverse)
|
130
|
+
inner_index_adj = (inner - 1) - inner_index;
|
131
|
+
else
|
132
|
+
inner_index_adj = inner_index;
|
133
|
+
|
134
|
+
for (size_t depth_index = 0; depth_index < depth; depth_index++) {
|
135
|
+
size_t depth_index_adj;
|
136
|
+
if (reverse)
|
137
|
+
depth_index_adj = (depth - 1) - depth_index;
|
138
|
+
else
|
139
|
+
depth_index_adj = depth_index;
|
140
|
+
|
141
|
+
size_t index = outer_index_adj;
|
142
|
+
index += inner_index_adj * depth * outer;
|
143
|
+
index += depth_index_adj * outer;
|
144
|
+
|
145
|
+
const int32_t y = params.input1_offset + input_data[index];
|
146
|
+
const int32_t shifted_y = y * (1 << params.left_shift);
|
147
|
+
const int32_t scaled_y = MultiplyByQuantizedMultiplierSmallerThanOneExp(
|
148
|
+
shifted_y, params.input1_multiplier, params.input1_shift);
|
149
|
+
|
150
|
+
int32_t scaled_output;
|
151
|
+
if (exclusive) {
|
152
|
+
scaled_output = accumulator;
|
153
|
+
accumulator += scaled_y;
|
154
|
+
} else {
|
155
|
+
accumulator += scaled_y;
|
156
|
+
scaled_output = accumulator;
|
157
|
+
}
|
158
|
+
|
159
|
+
const int32_t raw_output =
|
160
|
+
MultiplyByQuantizedMultiplierSmallerThanOneExp(
|
161
|
+
scaled_output, params.output_multiplier, params.output_shift) +
|
162
|
+
params.output_offset;
|
163
|
+
const int32_t clamped_output =
|
164
|
+
std::min(params.quantized_activation_max,
|
165
|
+
std::max(params.quantized_activation_min, raw_output));
|
166
|
+
output_data[index] = static_cast<int8_t>(clamped_output);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
} // namespace reference_ops
|
173
|
+
} // namespace tflite_micro
|
174
|
+
|
175
|
+
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CUMSUM_H_
|
@@ -0,0 +1,79 @@
|
|
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_DEPTH_TO_SPACE_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_DEPTH_TO_SPACE_H_
|
17
|
+
|
18
|
+
#include "tensorflow/lite/kernels/internal/types.h"
|
19
|
+
|
20
|
+
namespace tflite_micro {
|
21
|
+
namespace reference_ops {
|
22
|
+
|
23
|
+
template <typename T>
|
24
|
+
inline void DepthToSpace(const tflite_micro::DepthToSpaceParams& op_params,
|
25
|
+
const RuntimeShape& unextended_input_shape,
|
26
|
+
const T* input_data,
|
27
|
+
const RuntimeShape& unextended_output_shape,
|
28
|
+
T* output_data) {
|
29
|
+
TFLITE_DCHECK_LE(unextended_input_shape.DimensionsCount(), 4);
|
30
|
+
TFLITE_DCHECK_LE(unextended_output_shape.DimensionsCount(), 4);
|
31
|
+
const RuntimeShape input_shape =
|
32
|
+
RuntimeShape::ExtendedShape(4, unextended_input_shape);
|
33
|
+
const RuntimeShape output_shape =
|
34
|
+
RuntimeShape::ExtendedShape(4, unextended_output_shape);
|
35
|
+
|
36
|
+
const int input_depth = input_shape.Dims(3);
|
37
|
+
const int input_width = input_shape.Dims(2);
|
38
|
+
const int input_height = input_shape.Dims(1);
|
39
|
+
const int input_batch = input_shape.Dims(0);
|
40
|
+
|
41
|
+
const int output_depth = output_shape.Dims(3);
|
42
|
+
const int output_width = output_shape.Dims(2);
|
43
|
+
const int output_height = output_shape.Dims(1);
|
44
|
+
const int output_batch = output_shape.Dims(0);
|
45
|
+
|
46
|
+
const int32_t block_size = op_params.block_size;
|
47
|
+
|
48
|
+
TFLITE_DCHECK_EQ(input_width * block_size, output_width);
|
49
|
+
TFLITE_DCHECK_EQ(input_height * block_size, output_height);
|
50
|
+
TFLITE_DCHECK_EQ(input_depth, output_depth * block_size * block_size);
|
51
|
+
TFLITE_DCHECK_EQ(input_batch, output_batch);
|
52
|
+
|
53
|
+
for (int out_b = 0; out_b < output_batch; ++out_b) {
|
54
|
+
for (int out_h = 0; out_h < output_height; ++out_h) {
|
55
|
+
for (int out_w = 0; out_w < output_width; ++out_w) {
|
56
|
+
for (int out_d = 0; out_d < output_depth; ++out_d) {
|
57
|
+
const int in_d =
|
58
|
+
out_d + ((out_h % block_size) * block_size + out_w % block_size) *
|
59
|
+
output_depth;
|
60
|
+
|
61
|
+
const int in_w = out_w / block_size;
|
62
|
+
const int in_h = out_h / block_size;
|
63
|
+
const int in_b = out_b;
|
64
|
+
|
65
|
+
const int input_index = Offset(input_shape, in_b, in_h, in_w, in_d);
|
66
|
+
const int output_index =
|
67
|
+
Offset(output_shape, out_b, out_h, out_w, out_d);
|
68
|
+
|
69
|
+
output_data[output_index] = input_data[input_index];
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
} // namespace reference_ops
|
77
|
+
} // namespace tflite_micro
|
78
|
+
|
79
|
+
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_DEPTH_TO_SPACE_H_
|
xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
/* Copyright 2017 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_DEPTHWISECONV_FLOAT_H_
|
16
|
+
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_DEPTHWISECONV_FLOAT_H_
|
17
|
+
|
18
|
+
#include "tensorflow/lite/kernels/internal/common.h"
|
19
|
+
#include "tensorflow/lite/kernels/internal/compatibility.h"
|
20
|
+
#include "tensorflow/lite/kernels/internal/types.h"
|
21
|
+
|
22
|
+
namespace tflite_micro {
|
23
|
+
namespace reference_ops {
|
24
|
+
|
25
|
+
inline void DepthwiseConv(
|
26
|
+
const DepthwiseParams& params, const RuntimeShape& input_shape,
|
27
|
+
const float* input_data, const RuntimeShape& filter_shape,
|
28
|
+
const float* filter_data, const RuntimeShape& bias_shape,
|
29
|
+
const float* bias_data, const RuntimeShape& output_shape,
|
30
|
+
float* output_data) {
|
31
|
+
const int stride_width = params.stride_width;
|
32
|
+
const int stride_height = params.stride_height;
|
33
|
+
const int dilation_width_factor = params.dilation_width_factor;
|
34
|
+
const int dilation_height_factor = params.dilation_height_factor;
|
35
|
+
const int pad_width = params.padding_values.width;
|
36
|
+
const int pad_height = params.padding_values.height;
|
37
|
+
const int depth_multiplier = params.depth_multiplier;
|
38
|
+
const float output_activation_min = params.float_activation_min;
|
39
|
+
const float output_activation_max = params.float_activation_max;
|
40
|
+
TFLITE_DCHECK_EQ(input_shape.DimensionsCount(), 4);
|
41
|
+
TFLITE_DCHECK_EQ(filter_shape.DimensionsCount(), 4);
|
42
|
+
TFLITE_DCHECK_EQ(output_shape.DimensionsCount(), 4);
|
43
|
+
|
44
|
+
const int batches = MatchingDim(input_shape, 0, output_shape, 0);
|
45
|
+
const int output_depth = MatchingDim(filter_shape, 3, output_shape, 3);
|
46
|
+
const int input_height = input_shape.Dims(1);
|
47
|
+
const int input_width = input_shape.Dims(2);
|
48
|
+
const int input_depth = input_shape.Dims(3);
|
49
|
+
const int filter_height = filter_shape.Dims(1);
|
50
|
+
const int filter_width = filter_shape.Dims(2);
|
51
|
+
const int output_height = output_shape.Dims(1);
|
52
|
+
const int output_width = output_shape.Dims(2);
|
53
|
+
TFLITE_DCHECK_EQ(output_depth, input_depth * depth_multiplier);
|
54
|
+
TFLITE_DCHECK_EQ(bias_shape.FlatSize(), output_depth);
|
55
|
+
|
56
|
+
for (int b = 0; b < batches; ++b) {
|
57
|
+
for (int out_y = 0; out_y < output_height; ++out_y) {
|
58
|
+
for (int out_x = 0; out_x < output_width; ++out_x) {
|
59
|
+
for (int ic = 0; ic < input_depth; ++ic) {
|
60
|
+
for (int m = 0; m < depth_multiplier; m++) {
|
61
|
+
const int oc = m + ic * depth_multiplier;
|
62
|
+
const int in_x_origin = (out_x * stride_width) - pad_width;
|
63
|
+
const int in_y_origin = (out_y * stride_height) - pad_height;
|
64
|
+
float total = 0.f;
|
65
|
+
for (int filter_y = 0; filter_y < filter_height; ++filter_y) {
|
66
|
+
for (int filter_x = 0; filter_x < filter_width; ++filter_x) {
|
67
|
+
const int in_x = in_x_origin + dilation_width_factor * filter_x;
|
68
|
+
const int in_y =
|
69
|
+
in_y_origin + dilation_height_factor * filter_y;
|
70
|
+
// If the location is outside the bounds of the input image,
|
71
|
+
// use zero as a default value.
|
72
|
+
if ((in_x >= 0) && (in_x < input_width) && (in_y >= 0) &&
|
73
|
+
(in_y < input_height)) {
|
74
|
+
float input_value =
|
75
|
+
input_data[Offset(input_shape, b, in_y, in_x, ic)];
|
76
|
+
float filter_value = filter_data[Offset(
|
77
|
+
filter_shape, 0, filter_y, filter_x, oc)];
|
78
|
+
total += (input_value * filter_value);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
float bias_value = 0.0f;
|
83
|
+
if (bias_data) {
|
84
|
+
bias_value = bias_data[oc];
|
85
|
+
}
|
86
|
+
output_data[Offset(output_shape, b, out_y, out_x, oc)] =
|
87
|
+
ActivationFunctionWithMinMax(total + bias_value,
|
88
|
+
output_activation_min,
|
89
|
+
output_activation_max);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
} // end namespace reference_ops
|
98
|
+
} // end namespace tflite
|
99
|
+
|
100
|
+
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_DEPTHWISECONV_FLOAT_H_
|