mlonmcu 0.3.0.dev0__3-none-any.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.
- mlonmcu/__init__.py +26 -0
- mlonmcu/artifact.py +172 -0
- mlonmcu/cli/__init__.py +19 -0
- mlonmcu/cli/build.py +119 -0
- mlonmcu/cli/cleanup.py +75 -0
- mlonmcu/cli/common.py +227 -0
- mlonmcu/cli/compile.py +87 -0
- mlonmcu/cli/env.py +68 -0
- mlonmcu/cli/export.py +93 -0
- mlonmcu/cli/flow.py +67 -0
- mlonmcu/cli/helper/__init__.py +18 -0
- mlonmcu/cli/helper/filter.py +25 -0
- mlonmcu/cli/helper/parse.py +159 -0
- mlonmcu/cli/init.py +130 -0
- mlonmcu/cli/load.py +87 -0
- mlonmcu/cli/main.py +116 -0
- mlonmcu/cli/models.py +48 -0
- mlonmcu/cli/run.py +56 -0
- mlonmcu/cli/setup.py +136 -0
- mlonmcu/cli/tune.py +48 -0
- mlonmcu/config.py +219 -0
- mlonmcu/context/__init__.py +22 -0
- mlonmcu/context/context.py +545 -0
- mlonmcu/context/read_write_filelock.py +327 -0
- mlonmcu/environment/__init__.py +18 -0
- mlonmcu/environment/config.py +214 -0
- mlonmcu/environment/environment.py +501 -0
- mlonmcu/environment/init.py +191 -0
- mlonmcu/environment/list.py +81 -0
- mlonmcu/environment/loader.py +250 -0
- mlonmcu/environment/templates.py +69 -0
- mlonmcu/environment/writer.py +117 -0
- mlonmcu/feature/__init__.py +18 -0
- mlonmcu/feature/feature.py +230 -0
- mlonmcu/feature/features.py +1537 -0
- mlonmcu/feature/type.py +33 -0
- mlonmcu/flow/__init__.py +61 -0
- mlonmcu/flow/backend.py +234 -0
- mlonmcu/flow/framework.py +69 -0
- mlonmcu/flow/tflm/__init__.py +23 -0
- mlonmcu/flow/tflm/backend/__init__.py +23 -0
- mlonmcu/flow/tflm/backend/backend.py +47 -0
- mlonmcu/flow/tflm/backend/tflmc.py +129 -0
- mlonmcu/flow/tflm/backend/tflmi.py +385 -0
- mlonmcu/flow/tflm/framework.py +81 -0
- mlonmcu/flow/tvm/__init__.py +23 -0
- mlonmcu/flow/tvm/backend/__init__.py +26 -0
- mlonmcu/flow/tvm/backend/backend.py +282 -0
- mlonmcu/flow/tvm/backend/model_info.py +307 -0
- mlonmcu/flow/tvm/backend/python_utils.py +36 -0
- mlonmcu/flow/tvm/backend/tuner.py +41 -0
- mlonmcu/flow/tvm/backend/tvmaot.py +162 -0
- mlonmcu/flow/tvm/backend/tvmaotplus.py +51 -0
- mlonmcu/flow/tvm/backend/tvmc_utils.py +172 -0
- mlonmcu/flow/tvm/backend/tvmcg.py +102 -0
- mlonmcu/flow/tvm/backend/tvmllvm.py +106 -0
- mlonmcu/flow/tvm/backend/tvmrt.py +151 -0
- mlonmcu/flow/tvm/backend/wrapper.py +645 -0
- mlonmcu/flow/tvm/framework.py +96 -0
- mlonmcu/logging.py +79 -0
- mlonmcu/mlonmcu.py +19 -0
- mlonmcu/models/__init__.py +31 -0
- mlonmcu/models/convert_data.py +107 -0
- mlonmcu/models/frontend.py +571 -0
- mlonmcu/models/group.py +29 -0
- mlonmcu/models/lookup.py +345 -0
- mlonmcu/models/metadata.py +133 -0
- mlonmcu/models/model.py +104 -0
- mlonmcu/models/options.py +64 -0
- mlonmcu/models/utils.py +136 -0
- mlonmcu/platform/__init__.py +27 -0
- mlonmcu/platform/_platform.py +46 -0
- mlonmcu/platform/espidf/__init__.py +25 -0
- mlonmcu/platform/espidf/espidf.py +489 -0
- mlonmcu/platform/espidf/espidf_target.py +257 -0
- mlonmcu/platform/lookup.py +126 -0
- mlonmcu/platform/microtvm/__init__.py +25 -0
- mlonmcu/platform/microtvm/microtvm.py +580 -0
- mlonmcu/platform/microtvm/microtvm_arduino_target.py +68 -0
- mlonmcu/platform/microtvm/microtvm_backend.py +64 -0
- mlonmcu/platform/microtvm/microtvm_espidf_target.py +94 -0
- mlonmcu/platform/microtvm/microtvm_etissvp_target.py +98 -0
- mlonmcu/platform/microtvm/microtvm_host_target.py +46 -0
- mlonmcu/platform/microtvm/microtvm_spike_target.py +230 -0
- mlonmcu/platform/microtvm/microtvm_target.py +189 -0
- mlonmcu/platform/microtvm/microtvm_template_target.py +55 -0
- mlonmcu/platform/microtvm/microtvm_zephyr_target.py +91 -0
- mlonmcu/platform/mlif/__init__.py +25 -0
- mlonmcu/platform/mlif/mlif.py +300 -0
- mlonmcu/platform/mlif/mlif_target.py +86 -0
- mlonmcu/platform/platform.py +244 -0
- mlonmcu/platform/tvm/__init__.py +25 -0
- mlonmcu/platform/tvm/tvm.py +429 -0
- mlonmcu/platform/tvm/tvm_backend.py +57 -0
- mlonmcu/platform/tvm/tvm_target.py +165 -0
- mlonmcu/platform/zephyr/__init__.py +25 -0
- mlonmcu/platform/zephyr/zephyr.py +450 -0
- mlonmcu/platform/zephyr/zephyr_target.py +110 -0
- mlonmcu/plugins.py +26 -0
- mlonmcu/report.py +99 -0
- mlonmcu/session/__init__.py +18 -0
- mlonmcu/session/postprocess/__init__.py +43 -0
- mlonmcu/session/postprocess/postprocess.py +62 -0
- mlonmcu/session/postprocess/postprocesses.py +487 -0
- mlonmcu/session/run.py +1008 -0
- mlonmcu/session/session.py +373 -0
- mlonmcu/setup/__init__.py +18 -0
- mlonmcu/setup/cache.py +147 -0
- mlonmcu/setup/gen_requirements.py +619 -0
- mlonmcu/setup/setup.py +285 -0
- mlonmcu/setup/task.py +380 -0
- mlonmcu/setup/tasks/__init__.py +40 -0
- mlonmcu/setup/tasks/arm_gcc.py +58 -0
- mlonmcu/setup/tasks/cmsisnn.py +151 -0
- mlonmcu/setup/tasks/common.py +36 -0
- mlonmcu/setup/tasks/corstone300.py +64 -0
- mlonmcu/setup/tasks/espidf.py +87 -0
- mlonmcu/setup/tasks/etiss.py +147 -0
- mlonmcu/setup/tasks/llvm.py +67 -0
- mlonmcu/setup/tasks/mlif.py +49 -0
- mlonmcu/setup/tasks/muriscvnn.py +166 -0
- mlonmcu/setup/tasks/pulp.py +192 -0
- mlonmcu/setup/tasks/riscv_gcc.py +146 -0
- mlonmcu/setup/tasks/spike.py +190 -0
- mlonmcu/setup/tasks/tf.py +92 -0
- mlonmcu/setup/tasks/tflite.py +59 -0
- mlonmcu/setup/tasks/tflmc.py +141 -0
- mlonmcu/setup/tasks/tvm.py +172 -0
- mlonmcu/setup/tasks/utvmcg.py +96 -0
- mlonmcu/setup/tasks/zephyr.py +119 -0
- mlonmcu/setup/utils.py +374 -0
- mlonmcu/target/__init__.py +37 -0
- mlonmcu/target/_target.py +41 -0
- mlonmcu/target/arm/__init__.py +3 -0
- mlonmcu/target/arm/corstone300.py +235 -0
- mlonmcu/target/arm/util.py +109 -0
- mlonmcu/target/common.py +194 -0
- mlonmcu/target/elf.py +256 -0
- mlonmcu/target/host_x86.py +84 -0
- mlonmcu/target/metrics.py +75 -0
- mlonmcu/target/riscv/__init__.py +7 -0
- mlonmcu/target/riscv/etiss_pulpino.py +462 -0
- mlonmcu/target/riscv/gvsoc_pulp.py +215 -0
- mlonmcu/target/riscv/ovpsim.py +301 -0
- mlonmcu/target/riscv/riscv.py +185 -0
- mlonmcu/target/riscv/riscv_qemu.py +166 -0
- mlonmcu/target/riscv/spike.py +243 -0
- mlonmcu/target/riscv/util.py +134 -0
- mlonmcu/target/target.py +200 -0
- mlonmcu/utils.py +49 -0
- mlonmcu/version.py +21 -0
- mlonmcu-0.3.0.dev0.dist-info/LICENSE +202 -0
- mlonmcu-0.3.0.dev0.dist-info/METADATA +343 -0
- mlonmcu-0.3.0.dev0.dist-info/NOTICE +8 -0
- mlonmcu-0.3.0.dev0.dist-info/RECORD +376 -0
- mlonmcu-0.3.0.dev0.dist-info/WHEEL +5 -0
- mlonmcu-0.3.0.dev0.dist-info/entry_points.txt +3 -0
- mlonmcu-0.3.0.dev0.dist-info/top_level.txt +1 -0
- resources/frameworks/tvm/crt_config/README.md +7 -0
- resources/frameworks/tvm/crt_config/crt_config.h +53 -0
- resources/frameworks/tvm/tuning_records/riscv_cpu_v0.01.log.best +46 -0
- resources/patches/fix_esp32c3_march.patch +20 -0
- resources/patches/pulp_freertos_support.patch +55 -0
- resources/platforms/espidf/micro_speech_esp32devboard/CMakeLists.txt +29 -0
- resources/platforms/espidf/micro_speech_esp32devboard/README.md +70 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/CMakeLists.txt +78 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/Kconfig +76 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/default_data.c +26 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/default_model_support/process_input.c +35 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/default_model_support/process_output.c +45 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/include/exit.h +26 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/include/ml_interface.h +70 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/include/printing.h +31 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/ml_interface.c +74 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/ml_interface_tflm.cc +64 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/ml_interface_tvm.c +53 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/tflite-lib/CMakeLists.txt +140 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/tflite-lib/Kconfig +8 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/tvm-lib/CMakeLists.txt +66 -0
- resources/platforms/espidf/micro_speech_esp32devboard/components/tvm-lib/Kconfig +7 -0
- resources/platforms/espidf/micro_speech_esp32devboard/example_test.py +38 -0
- resources/platforms/espidf/micro_speech_esp32devboard/info.txt +9 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/CMakeLists.txt +58 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/audio_provider.cc +193 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/audio_provider.h +49 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/command_responder.cc +53 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/command_responder.h +35 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/feature_provider.cc +132 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/feature_provider.cc.orig +145 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/feature_provider.h +55 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/COPYING +11 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/_kiss_fft_guts.h +168 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/kiss_fft.c +408 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/kiss_fft.h +124 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/tools/kiss_fftr.c +159 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/tools/kiss_fftr.h +46 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/main.cc +63 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/main_functions.cc +204 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/main_functions.h +37 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/micro_features_generator.cc +121 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/micro_features_generator.h +38 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/micro_model_settings.cc +23 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/micro_model_settings.h +43 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/bits.h +102 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/fft.cc +52 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/fft.h +50 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/fft_util.cc +69 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/fft_util.h +34 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/filterbank.c +134 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/filterbank.h +63 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/filterbank_util.c +220 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/filterbank_util.h +50 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/frontend.c +72 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/frontend.h +64 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/frontend_util.c +85 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/frontend_util.h +52 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/kiss_fft_common.h +48 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/kiss_fft_int16.cc +8 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/kiss_fft_int16.h +34 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_lut.c +30 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_lut.h +40 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_scale.c +83 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_scale.h +39 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_scale_util.c +27 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_scale_util.h +45 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/noise_reduction.c +51 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/noise_reduction.h +46 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/noise_reduction_util.c +45 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/noise_reduction_util.h +50 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/pcan_gain_control.c +56 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/pcan_gain_control.h +47 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/pcan_gain_control_util.c +92 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/pcan_gain_control_util.h +57 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/window.c +70 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/window.h +49 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/window_util.c +73 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/window_util.h +45 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/pins.c +14 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/pins.h +30 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/recognize_commands.cc +150 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/recognize_commands.h +173 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/ringbuf.c +333 -0
- resources/platforms/espidf/micro_speech_esp32devboard/main/ringbuf.h +74 -0
- resources/platforms/espidf/micro_speech_esp32devboard/sdkconfig.defaults +36 -0
- resources/platforms/espidf/project/CMakeLists.txt +29 -0
- resources/platforms/espidf/project/README.md +70 -0
- resources/platforms/espidf/project/components/mlif/CMakeLists.txt +77 -0
- resources/platforms/espidf/project/components/mlif/Kconfig +76 -0
- resources/platforms/espidf/project/components/mlif/default_data.c +26 -0
- resources/platforms/espidf/project/components/mlif/default_model_support/process_input.c +35 -0
- resources/platforms/espidf/project/components/mlif/default_model_support/process_output.c +45 -0
- resources/platforms/espidf/project/components/mlif/include/exit.h +26 -0
- resources/platforms/espidf/project/components/mlif/include/ml_interface.h +60 -0
- resources/platforms/espidf/project/components/mlif/include/printing.h +31 -0
- resources/platforms/espidf/project/components/mlif/ml_interface.c +54 -0
- resources/platforms/espidf/project/components/mlif/ml_interface_tflm.cc +40 -0
- resources/platforms/espidf/project/components/mlif/ml_interface_tvm.c +40 -0
- resources/platforms/espidf/project/components/tflite-lib/CMakeLists.txt +142 -0
- resources/platforms/espidf/project/components/tflite-lib/Kconfig +8 -0
- resources/platforms/espidf/project/components/tvm-lib/CMakeLists.txt +66 -0
- resources/platforms/espidf/project/components/tvm-lib/Kconfig +7 -0
- resources/platforms/espidf/project/example_test.py +38 -0
- resources/platforms/espidf/project/main/CMakeLists.txt +25 -0
- resources/platforms/espidf/project/main/main.c +57 -0
- resources/platforms/espidf/project/sdkconfig.defaults +26 -0
- resources/platforms/zephyr/project/CMakeLists.txt +22 -0
- resources/platforms/zephyr/project/Kconfig +101 -0
- resources/platforms/zephyr/project/README.rst +33 -0
- resources/platforms/zephyr/project/cmake/AddAllSubdirs.cmake +21 -0
- resources/platforms/zephyr/project/cmake/ChooseTarget.cmake +22 -0
- resources/platforms/zephyr/project/cmake/LinkTFLite.cmake +223 -0
- resources/platforms/zephyr/project/cmake/LinkTVM.cmake +68 -0
- resources/platforms/zephyr/project/cmake/LookupClang.cmake +41 -0
- resources/platforms/zephyr/project/cmake/backends/tflmc.cmake +5 -0
- resources/platforms/zephyr/project/cmake/backends/tflmi.cmake +5 -0
- resources/platforms/zephyr/project/cmake/backends/tvmaot.cmake +10 -0
- resources/platforms/zephyr/project/cmake/backends/tvmaotplus.cmake +10 -0
- resources/platforms/zephyr/project/cmake/backends/tvmcg.cmake +10 -0
- resources/platforms/zephyr/project/cmake/backends/tvmllvm.cmake +8 -0
- resources/platforms/zephyr/project/cmake/backends/tvmrt.cmake +8 -0
- resources/platforms/zephyr/project/cmake/extras.cmake +9 -0
- resources/platforms/zephyr/project/cmake/features/auto_vectorize_gcc.cmake +65 -0
- resources/platforms/zephyr/project/cmake/features/auto_vectorize_llvm.cmake +20 -0
- resources/platforms/zephyr/project/cmake/features/cmsisnn.cmake +86 -0
- resources/platforms/zephyr/project/cmake/features/muriscvnn.cmake +87 -0
- resources/platforms/zephyr/project/cmake/frameworks/tflm.cmake +1 -0
- resources/platforms/zephyr/project/cmake/frameworks/tflm_mlif.cmake +8 -0
- resources/platforms/zephyr/project/cmake/frameworks/tvm.cmake +1 -0
- resources/platforms/zephyr/project/cmake/frameworks/tvm_mlif.cmake +37 -0
- resources/platforms/zephyr/project/lib/CMakeLists.txt +13 -0
- resources/platforms/zephyr/project/lib/drivers/fake_input.c +10 -0
- resources/platforms/zephyr/project/lib/drivers/fake_input.h +8 -0
- resources/platforms/zephyr/project/lib/ml_interface/CMakeLists.txt +31 -0
- resources/platforms/zephyr/project/lib/ml_interface/default_data.c +8 -0
- resources/platforms/zephyr/project/lib/ml_interface/default_model_support/CMakeLists.txt +2 -0
- resources/platforms/zephyr/project/lib/ml_interface/default_model_support/process_input.c +17 -0
- resources/platforms/zephyr/project/lib/ml_interface/default_model_support/process_output.c +27 -0
- resources/platforms/zephyr/project/lib/ml_interface/ml_interface.c +36 -0
- resources/platforms/zephyr/project/lib/ml_interface/ml_interface.h +47 -0
- resources/platforms/zephyr/project/lib/ml_interface/ml_interface_tflm.cc +22 -0
- resources/platforms/zephyr/project/lib/ml_interface/ml_interface_tvm.c +22 -0
- resources/platforms/zephyr/project/lib/support/CMakeLists.txt +2 -0
- resources/platforms/zephyr/project/lib/support/dummy.c +0 -0
- resources/platforms/zephyr/project/lib/support/exit.h +8 -0
- resources/platforms/zephyr/project/lib/support/printing.h +11 -0
- resources/platforms/zephyr/project/lib/support/quantize.h +23 -0
- resources/platforms/zephyr/project/lib/targets/corstone300.c +62 -0
- resources/platforms/zephyr/project/lib/targets/default.c +2 -0
- resources/platforms/zephyr/project/lib/targets/etiss_pulpino.c +112 -0
- resources/platforms/zephyr/project/lib/targets/generic_riscv.c +112 -0
- resources/platforms/zephyr/project/lib/targets/riscv_qemu.c +112 -0
- resources/platforms/zephyr/project/lib/targets/target.h +2 -0
- resources/platforms/zephyr/project/prj.conf +11 -0
- resources/platforms/zephyr/project/sample.yaml +19 -0
- resources/platforms/zephyr/project/src/main.c +71 -0
- resources/platforms/zephyr/project2/CMakeLists.txt +72 -0
- resources/platforms/zephyr/project2/Kconfig +101 -0
- resources/platforms/zephyr/project2/README.rst +33 -0
- resources/platforms/zephyr/project2/cmake/AddAllSubdirs.cmake +21 -0
- resources/platforms/zephyr/project2/cmake/ChooseTarget.cmake +22 -0
- resources/platforms/zephyr/project2/cmake/LinkTFLite.cmake +223 -0
- resources/platforms/zephyr/project2/cmake/LinkTVM.cmake +68 -0
- resources/platforms/zephyr/project2/cmake/LookupClang.cmake +41 -0
- resources/platforms/zephyr/project2/cmake/backends/tflmc.cmake +5 -0
- resources/platforms/zephyr/project2/cmake/backends/tflmi.cmake +5 -0
- resources/platforms/zephyr/project2/cmake/backends/tvmaot.cmake +10 -0
- resources/platforms/zephyr/project2/cmake/backends/tvmaotplus.cmake +10 -0
- resources/platforms/zephyr/project2/cmake/backends/tvmcg.cmake +10 -0
- resources/platforms/zephyr/project2/cmake/backends/tvmllvm.cmake +8 -0
- resources/platforms/zephyr/project2/cmake/backends/tvmrt.cmake +8 -0
- resources/platforms/zephyr/project2/cmake/extras.cmake +9 -0
- resources/platforms/zephyr/project2/cmake/features/auto_vectorize_gcc.cmake +65 -0
- resources/platforms/zephyr/project2/cmake/features/auto_vectorize_llvm.cmake +20 -0
- resources/platforms/zephyr/project2/cmake/features/cmsisnn.cmake +86 -0
- resources/platforms/zephyr/project2/cmake/features/muriscvnn.cmake +87 -0
- resources/platforms/zephyr/project2/cmake/frameworks/tflm.cmake +1 -0
- resources/platforms/zephyr/project2/cmake/frameworks/tflm_mlif.cmake +8 -0
- resources/platforms/zephyr/project2/cmake/frameworks/tvm.cmake +1 -0
- resources/platforms/zephyr/project2/cmake/frameworks/tvm_mlif.cmake +37 -0
- resources/platforms/zephyr/project2/default_data.c +8 -0
- resources/platforms/zephyr/project2/default_model_support/CMakeLists.txt +3 -0
- resources/platforms/zephyr/project2/default_model_support/process_input.c +17 -0
- resources/platforms/zephyr/project2/default_model_support/process_output.c +27 -0
- resources/platforms/zephyr/project2/lib/CMakeLists.txt +13 -0
- resources/platforms/zephyr/project2/lib/drivers/fake_input.c +10 -0
- resources/platforms/zephyr/project2/lib/drivers/fake_input.h +8 -0
- resources/platforms/zephyr/project2/lib/support/CMakeLists.txt +2 -0
- resources/platforms/zephyr/project2/lib/support/dummy.c +0 -0
- resources/platforms/zephyr/project2/lib/support/exit.h +8 -0
- resources/platforms/zephyr/project2/lib/support/printing.h +11 -0
- resources/platforms/zephyr/project2/lib/support/quantize.h +23 -0
- resources/platforms/zephyr/project2/lib/targets/corstone300.c +62 -0
- resources/platforms/zephyr/project2/lib/targets/default.c +2 -0
- resources/platforms/zephyr/project2/lib/targets/etiss_pulpino.c +112 -0
- resources/platforms/zephyr/project2/lib/targets/generic_riscv.c +112 -0
- resources/platforms/zephyr/project2/lib/targets/riscv_qemu.c +112 -0
- resources/platforms/zephyr/project2/lib/targets/target.h +2 -0
- resources/platforms/zephyr/project2/ml_interface.c +36 -0
- resources/platforms/zephyr/project2/ml_interface.h +47 -0
- resources/platforms/zephyr/project2/ml_interface_tflm.cc +22 -0
- resources/platforms/zephyr/project2/ml_interface_tvm.c +22 -0
- resources/platforms/zephyr/project2/prj.conf +13 -0
- resources/platforms/zephyr/project2/sample.yaml +19 -0
- resources/platforms/zephyr/project2/settings.json +6 -0
- resources/platforms/zephyr/project2/src/main.c +35 -0
- resources/pycharm/.run/README.md +73 -0
- resources/pycharm/.run/step1_ init env.run.xml +24 -0
- resources/pycharm/.run/step2_ setup.run.xml +25 -0
- resources/pycharm/.run/step3_ run resnet on pulpxpulpissimo.run.xml +25 -0
- resources/templates/default.yml.j2 +258 -0
- resources/templates/dev.yml.j2 +212 -0
- resources/templates/minimal.yml.j2 +234 -0
- resources/templates/phi.yml.j2 +282 -0
- resources/templates/pulp.yml.j2 +267 -0
- resources/templates/research.yml.j2 +237 -0
- resources/templates/tumeda.yml.j2 +239 -0
|
@@ -0,0 +1,45 @@
|
|
|
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_EXPERIMENTAL_MICROFRONTEND_LIB_WINDOW_UTIL_H_
|
|
16
|
+
#define TENSORFLOW_LITE_EXPERIMENTAL_MICROFRONTEND_LIB_WINDOW_UTIL_H_
|
|
17
|
+
|
|
18
|
+
#include "microfrontend/lib/window.h"
|
|
19
|
+
|
|
20
|
+
#ifdef __cplusplus
|
|
21
|
+
extern "C" {
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
struct WindowConfig {
|
|
25
|
+
// length of window frame in milliseconds
|
|
26
|
+
size_t size_ms;
|
|
27
|
+
// length of step for next frame in milliseconds
|
|
28
|
+
size_t step_size_ms;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Populates the WindowConfig with "sane" default values.
|
|
32
|
+
void WindowFillConfigWithDefaults(struct WindowConfig* config);
|
|
33
|
+
|
|
34
|
+
// Allocates any buffers.
|
|
35
|
+
int WindowPopulateState(const struct WindowConfig* config,
|
|
36
|
+
struct WindowState* state, int sample_rate);
|
|
37
|
+
|
|
38
|
+
// Frees any allocated buffers.
|
|
39
|
+
void WindowFreeStateContents(struct WindowState* state);
|
|
40
|
+
|
|
41
|
+
#ifdef __cplusplus
|
|
42
|
+
} // extern "C"
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
#endif // TENSORFLOW_LITE_EXPERIMENTAL_MICROFRONTEND_LIB_WINDOW_UTIL_H_
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#include "pins.h"
|
|
2
|
+
|
|
3
|
+
void gpio_init()
|
|
4
|
+
{
|
|
5
|
+
#if defined(GPIO_LED_RED) && defined(GPIO_LED_GREEN) && defined(GPIO_LED_BLUE)
|
|
6
|
+
gpio_reset_pin(GPIO_LED_RED);
|
|
7
|
+
gpio_set_direction(GPIO_LED_RED, GPIO_MODE_OUTPUT);
|
|
8
|
+
gpio_reset_pin(GPIO_LED_GREEN);
|
|
9
|
+
gpio_set_direction(GPIO_LED_GREEN, GPIO_MODE_OUTPUT);
|
|
10
|
+
gpio_reset_pin(GPIO_LED_BLUE);
|
|
11
|
+
gpio_set_direction(GPIO_LED_BLUE, GPIO_MODE_OUTPUT);
|
|
12
|
+
#endif
|
|
13
|
+
}
|
|
14
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#ifndef MICRO_KWS_PINS_H_
|
|
2
|
+
#define MICRO_KWS_PINS_H_
|
|
3
|
+
|
|
4
|
+
void gpio_init(void);
|
|
5
|
+
|
|
6
|
+
#if defined(CONFIG_IDF_TARGET_ESP32C3)
|
|
7
|
+
|
|
8
|
+
#define I2S_SCK_PIN 32
|
|
9
|
+
#define I2S_WS_PIN 25
|
|
10
|
+
#define I2S_DATA_IN_PIN 33
|
|
11
|
+
#define I2S_PORT_ID 0
|
|
12
|
+
|
|
13
|
+
#define GPIO_LED_RED ((gpio_num_t)3)
|
|
14
|
+
#define GPIO_LED_GREEN ((gpio_num_t)4)
|
|
15
|
+
#define GPIO_LED_BLUE ((gpio_num_t)5)
|
|
16
|
+
|
|
17
|
+
#elif defined(CONFIG_IDF_TARGET_ESP32)
|
|
18
|
+
|
|
19
|
+
#define I2S_SCK_PIN 8
|
|
20
|
+
#define I2S_WS_PIN 9
|
|
21
|
+
#define I2S_DATA_IN_PIN 10
|
|
22
|
+
#define I2S_PORT_ID 0
|
|
23
|
+
|
|
24
|
+
#else
|
|
25
|
+
|
|
26
|
+
#error "ESP-IDF target not supported. Please provide information in pin_def.h"
|
|
27
|
+
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#endif // MICRO_KWS_PINS_H_
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
|
|
16
|
+
#include "recognize_commands.h"
|
|
17
|
+
|
|
18
|
+
#include <limits>
|
|
19
|
+
|
|
20
|
+
// RecognizeCommands::RecognizeCommands(tflite::ErrorReporter* error_reporter,
|
|
21
|
+
// int32_t average_window_duration_ms,
|
|
22
|
+
// uint8_t detection_threshold,
|
|
23
|
+
// int32_t suppression_ms,
|
|
24
|
+
// int32_t minimum_count)
|
|
25
|
+
RecognizeCommands::RecognizeCommands(int32_t average_window_duration_ms,
|
|
26
|
+
uint8_t detection_threshold,
|
|
27
|
+
int32_t suppression_ms,
|
|
28
|
+
int32_t minimum_count)
|
|
29
|
+
//: error_reporter_(error_reporter),
|
|
30
|
+
: average_window_duration_ms_(average_window_duration_ms),
|
|
31
|
+
detection_threshold_(detection_threshold),
|
|
32
|
+
suppression_ms_(suppression_ms),
|
|
33
|
+
minimum_count_(minimum_count),
|
|
34
|
+
// previous_results_(error_reporter) {
|
|
35
|
+
previous_results_() {
|
|
36
|
+
previous_top_label_ = "silence";
|
|
37
|
+
previous_top_label_time_ = std::numeric_limits<int32_t>::min();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// TfLiteStatus RecognizeCommands::ProcessLatestResults(
|
|
41
|
+
// const TfLiteTensor* latest_results, const int32_t current_time_ms,
|
|
42
|
+
// const char** found_command, uint8_t* score, bool* is_new_command) {
|
|
43
|
+
int RecognizeCommands::ProcessLatestResults(
|
|
44
|
+
const int8_t* latest_results, const int32_t current_time_ms,
|
|
45
|
+
const char** found_command, uint8_t* score, bool* is_new_command) {
|
|
46
|
+
// if ((latest_results->dims->size != 2) ||
|
|
47
|
+
// (latest_results->dims->data[0] != 1) ||
|
|
48
|
+
// (latest_results->dims->data[1] != kCategoryCount)) {
|
|
49
|
+
// TF_LITE_REPORT_ERROR(
|
|
50
|
+
// error_reporter_,
|
|
51
|
+
// "The results for recognition should contain %d elements, but there are "
|
|
52
|
+
// "%d in an %d-dimensional shape",
|
|
53
|
+
// kCategoryCount, latest_results->dims->data[1],
|
|
54
|
+
// latest_results->dims->size);
|
|
55
|
+
// return kTfLiteError;
|
|
56
|
+
// }
|
|
57
|
+
|
|
58
|
+
// if (latest_results->type != kTfLiteInt8) {
|
|
59
|
+
// TF_LITE_REPORT_ERROR(
|
|
60
|
+
// error_reporter_,
|
|
61
|
+
// "The results for recognition should be int8_t elements, but are %d",
|
|
62
|
+
// latest_results->type);
|
|
63
|
+
// return kTfLiteError;
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
if ((!previous_results_.empty()) &&
|
|
67
|
+
(current_time_ms < previous_results_.front().time_)) {
|
|
68
|
+
printf(
|
|
69
|
+
"Results must be fed in increasing time order, but received a "
|
|
70
|
+
"timestamp of %d that was earlier than the previous one of %d\n",
|
|
71
|
+
current_time_ms, previous_results_.front().time_);
|
|
72
|
+
return -1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Add the latest results to the head of the queue.
|
|
76
|
+
previous_results_.push_back({current_time_ms, (int8_t*)latest_results});
|
|
77
|
+
|
|
78
|
+
// Prune any earlier results that are too old for the averaging window.
|
|
79
|
+
const int64_t time_limit = current_time_ms - average_window_duration_ms_;
|
|
80
|
+
while ((!previous_results_.empty()) &&
|
|
81
|
+
previous_results_.front().time_ < time_limit) {
|
|
82
|
+
previous_results_.pop_front();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// If there are too few results, assume the result will be unreliable and
|
|
86
|
+
// bail.
|
|
87
|
+
const int64_t how_many_results = previous_results_.size();
|
|
88
|
+
const int64_t earliest_time = previous_results_.front().time_;
|
|
89
|
+
const int64_t samples_duration = current_time_ms - earliest_time;
|
|
90
|
+
if ((how_many_results < minimum_count_) ||
|
|
91
|
+
(samples_duration < (average_window_duration_ms_ / 4))) {
|
|
92
|
+
*found_command = previous_top_label_;
|
|
93
|
+
*score = 0;
|
|
94
|
+
*is_new_command = false;
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Calculate the average score across all the results in the window.
|
|
99
|
+
int32_t average_scores[kCategoryCount];
|
|
100
|
+
for (int offset = 0; offset < previous_results_.size(); ++offset) {
|
|
101
|
+
PreviousResultsQueue::Result previous_result =
|
|
102
|
+
previous_results_.from_front(offset);
|
|
103
|
+
const int8_t* scores = previous_result.scores;
|
|
104
|
+
for (int i = 0; i < kCategoryCount; ++i) {
|
|
105
|
+
if (offset == 0) {
|
|
106
|
+
average_scores[i] = scores[i] + 128;
|
|
107
|
+
} else {
|
|
108
|
+
average_scores[i] += scores[i] + 128;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (int i = 0; i < kCategoryCount; ++i) {
|
|
113
|
+
average_scores[i] /= how_many_results;
|
|
114
|
+
}
|
|
115
|
+
// printf("average_scores %u %u %u %u\n", average_scores[0], average_scores[1], average_scores[2], average_scores[3]);
|
|
116
|
+
|
|
117
|
+
// Find the current highest scoring category.
|
|
118
|
+
int current_top_index = 0;
|
|
119
|
+
int32_t current_top_score = 0;
|
|
120
|
+
for (int i = 0; i < kCategoryCount; ++i) {
|
|
121
|
+
if (average_scores[i] > current_top_score) {
|
|
122
|
+
current_top_score = average_scores[i];
|
|
123
|
+
current_top_index = i;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const char* current_top_label = kCategoryLabels[current_top_index];
|
|
127
|
+
|
|
128
|
+
// If we've recently had another label trigger, assume one that occurs too
|
|
129
|
+
// soon afterwards is a bad result.
|
|
130
|
+
int64_t time_since_last_top;
|
|
131
|
+
if ((previous_top_label_ == kCategoryLabels[0]) ||
|
|
132
|
+
(previous_top_label_time_ == std::numeric_limits<int32_t>::min())) {
|
|
133
|
+
time_since_last_top = std::numeric_limits<int32_t>::max();
|
|
134
|
+
} else {
|
|
135
|
+
time_since_last_top = current_time_ms - previous_top_label_time_;
|
|
136
|
+
}
|
|
137
|
+
if ((current_top_score > detection_threshold_) &&
|
|
138
|
+
((current_top_label != previous_top_label_) ||
|
|
139
|
+
(time_since_last_top > suppression_ms_))) {
|
|
140
|
+
previous_top_label_ = current_top_label;
|
|
141
|
+
previous_top_label_time_ = current_time_ms;
|
|
142
|
+
*is_new_command = true;
|
|
143
|
+
} else {
|
|
144
|
+
*is_new_command = false;
|
|
145
|
+
}
|
|
146
|
+
*found_command = current_top_label;
|
|
147
|
+
*score = current_top_score;
|
|
148
|
+
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
|
|
16
|
+
#ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_RECOGNIZE_COMMANDS_H_
|
|
17
|
+
#define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_RECOGNIZE_COMMANDS_H_
|
|
18
|
+
|
|
19
|
+
#include <cstdint>
|
|
20
|
+
#include <stdio.h>
|
|
21
|
+
|
|
22
|
+
// #include "tensorflow/lite/c/common.h"
|
|
23
|
+
#include "micro_model_settings.h"
|
|
24
|
+
//#include "tensorflow/lite/micro/micro_error_reporter.h"
|
|
25
|
+
|
|
26
|
+
// Partial implementation of std::dequeue, just providing the functionality
|
|
27
|
+
// that's needed to keep a record of previous neural network results over a
|
|
28
|
+
// short time period, so they can be averaged together to produce a more
|
|
29
|
+
// accurate overall prediction. This doesn't use any dynamic memory allocation
|
|
30
|
+
// so it's a better fit for microcontroller applications, but this does mean
|
|
31
|
+
// there are hard limits on the number of results it can store.
|
|
32
|
+
class PreviousResultsQueue {
|
|
33
|
+
public:
|
|
34
|
+
// PreviousResultsQueue(tflite::ErrorReporter* error_reporter)
|
|
35
|
+
PreviousResultsQueue()
|
|
36
|
+
// : error_reporter_(error_reporter), front_index_(0), size_(0) {}
|
|
37
|
+
: front_index_(0), size_(0) {}
|
|
38
|
+
|
|
39
|
+
// Data structure that holds an inference result, and the time when it
|
|
40
|
+
// was recorded.
|
|
41
|
+
struct Result {
|
|
42
|
+
Result() : time_(0), scores() {}
|
|
43
|
+
Result(int32_t time, int8_t* input_scores) : time_(time) {
|
|
44
|
+
for (int i = 0; i < kCategoryCount; ++i) {
|
|
45
|
+
scores[i] = input_scores[i];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
int32_t time_;
|
|
49
|
+
int8_t scores[kCategoryCount];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
int size() { return size_; }
|
|
53
|
+
bool empty() { return size_ == 0; }
|
|
54
|
+
Result& front() { return results_[front_index_]; }
|
|
55
|
+
Result& back() {
|
|
56
|
+
int back_index = front_index_ + (size_ - 1);
|
|
57
|
+
if (back_index >= kMaxResults) {
|
|
58
|
+
back_index -= kMaxResults;
|
|
59
|
+
}
|
|
60
|
+
return results_[back_index];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void push_back(const Result& entry) {
|
|
64
|
+
if (size() >= kMaxResults) {
|
|
65
|
+
// TF_LITE_REPORT_ERROR(
|
|
66
|
+
// error_reporter_,
|
|
67
|
+
// "Couldn't push_back latest result, too many already!");
|
|
68
|
+
printf("Couldn't push_back latest result, too many already!\n");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
size_ += 1;
|
|
72
|
+
back() = entry;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Result pop_front() {
|
|
76
|
+
if (size() <= 0) {
|
|
77
|
+
// TF_LITE_REPORT_ERROR(error_reporter_,
|
|
78
|
+
// "Couldn't pop_front result, none present!");
|
|
79
|
+
printf("Couldn't pop_front result, none present!\n");
|
|
80
|
+
return Result();
|
|
81
|
+
}
|
|
82
|
+
Result result = front();
|
|
83
|
+
front_index_ += 1;
|
|
84
|
+
if (front_index_ >= kMaxResults) {
|
|
85
|
+
front_index_ = 0;
|
|
86
|
+
}
|
|
87
|
+
size_ -= 1;
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Most of the functions are duplicates of dequeue containers, but this
|
|
92
|
+
// is a helper that makes it easy to iterate through the contents of the
|
|
93
|
+
// queue.
|
|
94
|
+
Result& from_front(int offset) {
|
|
95
|
+
if ((offset < 0) || (offset >= size_)) {
|
|
96
|
+
// TF_LITE_REPORT_ERROR(error_reporter_,
|
|
97
|
+
// "Attempt to read beyond the end of the queue!");
|
|
98
|
+
printf("Attempt to read beyond the end of the queue!\n");
|
|
99
|
+
offset = size_ - 1;
|
|
100
|
+
}
|
|
101
|
+
int index = front_index_ + offset;
|
|
102
|
+
if (index >= kMaxResults) {
|
|
103
|
+
index -= kMaxResults;
|
|
104
|
+
}
|
|
105
|
+
return results_[index];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private:
|
|
109
|
+
// tflite::ErrorReporter* error_reporter_;
|
|
110
|
+
static constexpr int kMaxResults = 50;
|
|
111
|
+
Result results_[kMaxResults];
|
|
112
|
+
|
|
113
|
+
int front_index_;
|
|
114
|
+
int size_;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// This class is designed to apply a very primitive decoding model on top of the
|
|
118
|
+
// instantaneous results from running an audio recognition model on a single
|
|
119
|
+
// window of samples. It applies smoothing over time so that noisy individual
|
|
120
|
+
// label scores are averaged, increasing the confidence that apparent matches
|
|
121
|
+
// are real.
|
|
122
|
+
// To use it, you should create a class object with the configuration you
|
|
123
|
+
// want, and then feed results from running a TensorFlow model into the
|
|
124
|
+
// processing method. The timestamp for each subsequent call should be
|
|
125
|
+
// increasing from the previous, since the class is designed to process a stream
|
|
126
|
+
// of data over time.
|
|
127
|
+
class RecognizeCommands {
|
|
128
|
+
public:
|
|
129
|
+
// labels should be a list of the strings associated with each one-hot score.
|
|
130
|
+
// The window duration controls the smoothing. Longer durations will give a
|
|
131
|
+
// higher confidence that the results are correct, but may miss some commands.
|
|
132
|
+
// The detection threshold has a similar effect, with high values increasing
|
|
133
|
+
// the precision at the cost of recall. The minimum count controls how many
|
|
134
|
+
// results need to be in the averaging window before it's seen as a reliable
|
|
135
|
+
// average. This prevents erroneous results when the averaging window is
|
|
136
|
+
// initially being populated for example. The suppression argument disables
|
|
137
|
+
// further recognitions for a set time after one has been triggered, which can
|
|
138
|
+
// help reduce spurious recognitions.
|
|
139
|
+
// explicit RecognizeCommands(tflite::ErrorReporter* error_reporter,
|
|
140
|
+
// int32_t average_window_duration_ms = 1000,
|
|
141
|
+
// uint8_t detection_threshold = 200,
|
|
142
|
+
// int32_t suppression_ms = 1500,
|
|
143
|
+
// int32_t minimum_count = 3);
|
|
144
|
+
explicit RecognizeCommands(int32_t average_window_duration_ms = 500,
|
|
145
|
+
uint8_t detection_threshold = 200,
|
|
146
|
+
int32_t suppression_ms = 1500,
|
|
147
|
+
int32_t minimum_count = 3);
|
|
148
|
+
|
|
149
|
+
// Call this with the results of running a model on sample data.
|
|
150
|
+
// TfLiteStatus ProcessLatestResults(const TfLiteTensor* latest_results,
|
|
151
|
+
// const int32_t current_time_ms,
|
|
152
|
+
// const char** found_command, uint8_t* score,
|
|
153
|
+
// bool* is_new_command);
|
|
154
|
+
int ProcessLatestResults(const int8_t* latest_results,
|
|
155
|
+
const int32_t current_time_ms,
|
|
156
|
+
const char** found_command, uint8_t* score,
|
|
157
|
+
bool* is_new_command);
|
|
158
|
+
|
|
159
|
+
private:
|
|
160
|
+
// Configuration
|
|
161
|
+
// tflite::ErrorReporter* error_reporter_;
|
|
162
|
+
int32_t average_window_duration_ms_;
|
|
163
|
+
uint8_t detection_threshold_;
|
|
164
|
+
int32_t suppression_ms_;
|
|
165
|
+
int32_t minimum_count_;
|
|
166
|
+
|
|
167
|
+
// Working variables
|
|
168
|
+
PreviousResultsQueue previous_results_;
|
|
169
|
+
const char* previous_top_label_;
|
|
170
|
+
int32_t previous_top_label_time_;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
#endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_RECOGNIZE_COMMANDS_H_
|