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,18 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2022 TUM Department of Electrical and Computer Engineering.
|
|
3
|
+
#
|
|
4
|
+
# This file is part of MLonMCU.
|
|
5
|
+
# See https://github.com/tum-ei-eda/mlonmcu.git for further info.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2022 TUM Department of Electrical and Computer Engineering.
|
|
3
|
+
#
|
|
4
|
+
# This file is part of MLonMCU.
|
|
5
|
+
# See https://github.com/tum-ei-eda/mlonmcu.git for further info.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
"""MLonMCU postprocess submodule"""
|
|
20
|
+
|
|
21
|
+
from .postprocesses import (
|
|
22
|
+
FilterColumnsPostprocess,
|
|
23
|
+
RenameColumnsPostprocess,
|
|
24
|
+
Features2ColumnsPostprocess,
|
|
25
|
+
Config2ColumnsPostprocess,
|
|
26
|
+
PassConfig2ColumnsPostprocess,
|
|
27
|
+
VisualizePostprocess,
|
|
28
|
+
Bytes2kBPostprocess,
|
|
29
|
+
Artifact2ColumnPostprocess,
|
|
30
|
+
AnalyseInstructionsPostprocess,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
SUPPORTED_POSTPROCESSES = {
|
|
34
|
+
"filter_cols": FilterColumnsPostprocess,
|
|
35
|
+
"rename_cols": RenameColumnsPostprocess,
|
|
36
|
+
"features2cols": Features2ColumnsPostprocess,
|
|
37
|
+
"config2cols": Config2ColumnsPostprocess,
|
|
38
|
+
"passcfg2cols": PassConfig2ColumnsPostprocess,
|
|
39
|
+
"visualize": VisualizePostprocess,
|
|
40
|
+
"bytes2kb": Bytes2kBPostprocess,
|
|
41
|
+
"artifact2cols": Artifact2ColumnPostprocess,
|
|
42
|
+
"analyse_instructions": AnalyseInstructionsPostprocess,
|
|
43
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2022 TUM Department of Electrical and Computer Engineering.
|
|
3
|
+
#
|
|
4
|
+
# This file is part of MLonMCU.
|
|
5
|
+
# See https://github.com/tum-ei-eda/mlonmcu.git for further info.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
"""Definitions of base classes for MLonMCU postprocesses."""
|
|
20
|
+
from mlonmcu.config import filter_config
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Postprocess:
|
|
24
|
+
"""Abstract postprocess."""
|
|
25
|
+
|
|
26
|
+
FEATURES = []
|
|
27
|
+
|
|
28
|
+
DEFAULTS = {}
|
|
29
|
+
|
|
30
|
+
REQUIRED = []
|
|
31
|
+
OPTIONAL = []
|
|
32
|
+
|
|
33
|
+
def __init__(self, name, config=None, features=None):
|
|
34
|
+
self.name = name
|
|
35
|
+
self.config = config if config else {}
|
|
36
|
+
self.features = self.process_features(features)
|
|
37
|
+
self.config = filter_config(self.config, self.name, self.DEFAULTS, self.OPTIONAL, self.REQUIRED)
|
|
38
|
+
|
|
39
|
+
def process_features(self, features):
|
|
40
|
+
"""Utility which handles postprocess_features."""
|
|
41
|
+
# Currently there is no support for postprocess features (FIXME)
|
|
42
|
+
# if features is None:
|
|
43
|
+
return []
|
|
44
|
+
# features = get_matching_features(features, FeatureType.POSTPROCESS)
|
|
45
|
+
# for feature in features:
|
|
46
|
+
# assert feature.name in self.FEATURES, f"Incompatible feature: {feature.name}"
|
|
47
|
+
# feature.add_target_config(self.name, self.config)
|
|
48
|
+
# return features
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class SessionPostprocess(Postprocess):
|
|
52
|
+
"""Session postprocess which is applied to multiple runs at the end of a session. (multi-row)"""
|
|
53
|
+
|
|
54
|
+
def post_session(self, report):
|
|
55
|
+
"""Called at the end of a session."""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class RunPostprocess(Postprocess):
|
|
59
|
+
"""Run postprocess which is applied to a single run."""
|
|
60
|
+
|
|
61
|
+
def post_run(self, report, artifacts):
|
|
62
|
+
"""Called at the end of a run."""
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2022 TUM Department of Electrical and Computer Engineering.
|
|
3
|
+
#
|
|
4
|
+
# This file is part of MLonMCU.
|
|
5
|
+
# See https://github.com/tum-ei-eda/mlonmcu.git for further info.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
"""Collection of (example) postprocesses integrated in MLonMCU."""
|
|
20
|
+
|
|
21
|
+
import re
|
|
22
|
+
import ast
|
|
23
|
+
import tempfile
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
import pandas as pd
|
|
27
|
+
|
|
28
|
+
from mlonmcu.artifact import Artifact, ArtifactFormat, lookup_artifacts
|
|
29
|
+
from mlonmcu.config import str2dict, str2bool
|
|
30
|
+
from mlonmcu.logging import get_logger
|
|
31
|
+
|
|
32
|
+
from .postprocess import SessionPostprocess, RunPostprocess
|
|
33
|
+
|
|
34
|
+
logger = get_logger()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def match_rows(df, cols):
|
|
38
|
+
"""Helper function to group similar rows in a dataframe."""
|
|
39
|
+
groups = df.astype(str).groupby(cols).apply(lambda x: tuple(x.index)).tolist()
|
|
40
|
+
return groups
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class FilterColumnsPostprocess(SessionPostprocess):
|
|
44
|
+
"""Postprocess which can be used to drop unwanted columns from a report."""
|
|
45
|
+
|
|
46
|
+
DEFAULTS = {
|
|
47
|
+
**SessionPostprocess.DEFAULTS,
|
|
48
|
+
"keep": None,
|
|
49
|
+
"drop": None,
|
|
50
|
+
"drop_nan": False,
|
|
51
|
+
"drop_empty": False,
|
|
52
|
+
"drop_const": False,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
def __init__(self, features=None, config=None):
|
|
56
|
+
super().__init__("filter_cols", features=features, config=config)
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def keep(self):
|
|
60
|
+
"""Get keep property."""
|
|
61
|
+
cfg = self.config["keep"]
|
|
62
|
+
if isinstance(cfg, str):
|
|
63
|
+
return ast.literal_eval(cfg)
|
|
64
|
+
return cfg
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def drop(self):
|
|
68
|
+
"""Get drop property."""
|
|
69
|
+
cfg = self.config["drop"]
|
|
70
|
+
if isinstance(cfg, str):
|
|
71
|
+
return ast.literal_eval(cfg)
|
|
72
|
+
return cfg
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def drop_nan(self):
|
|
76
|
+
"""Get drop_nan property."""
|
|
77
|
+
value = self.config["drop_nan"]
|
|
78
|
+
return str2bool(value) if not isinstance(value, (bool, int)) else value
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def drop_empty(self):
|
|
82
|
+
"""Get drop_empty property."""
|
|
83
|
+
value = self.config["drop_empty"]
|
|
84
|
+
return str2bool(value) if not isinstance(value, (bool, int)) else value
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def drop_const(self):
|
|
88
|
+
"""Get drop_const property."""
|
|
89
|
+
value = self.config["drop_const"]
|
|
90
|
+
return str2bool(value) if not isinstance(value, (bool, int)) else value
|
|
91
|
+
|
|
92
|
+
def post_session(self, report):
|
|
93
|
+
"""Called at the end of a session."""
|
|
94
|
+
|
|
95
|
+
def _filter_df(df, keep, drop, drop_nan=False, drop_empty=False, drop_const=False):
|
|
96
|
+
if drop_empty:
|
|
97
|
+
raise NotImplementedError
|
|
98
|
+
if drop_nan:
|
|
99
|
+
df.dropna(axis=1, how="all", inplace=True)
|
|
100
|
+
if drop_const:
|
|
101
|
+
df = df.loc[:, (df != df.iloc[0]).any()]
|
|
102
|
+
if not (keep is None or drop is None):
|
|
103
|
+
raise RuntimeError("'drop' and 'keep' can not be defined at the same time")
|
|
104
|
+
if keep is not None:
|
|
105
|
+
drop_cols = [name for name in df.columns if name not in keep]
|
|
106
|
+
elif drop is not None:
|
|
107
|
+
drop_cols = [name for name in df.columns if name in drop]
|
|
108
|
+
else:
|
|
109
|
+
drop_cols = []
|
|
110
|
+
return df.drop(columns=drop_cols)
|
|
111
|
+
|
|
112
|
+
report.pre_df = _filter_df(
|
|
113
|
+
report.pre_df,
|
|
114
|
+
self.keep,
|
|
115
|
+
self.drop,
|
|
116
|
+
drop_nan=self.drop_nan,
|
|
117
|
+
drop_empty=self.drop_empty,
|
|
118
|
+
drop_const=self.drop_const,
|
|
119
|
+
)
|
|
120
|
+
report.main_df = _filter_df(
|
|
121
|
+
report.main_df, self.keep, self.drop, drop_nan=self.drop_nan, drop_const=self.drop_const
|
|
122
|
+
)
|
|
123
|
+
report.post_df = _filter_df(
|
|
124
|
+
report.post_df, self.keep, self.drop, drop_nan=self.drop_nan, drop_const=self.drop_const
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class RenameColumnsPostprocess(SessionPostprocess): # RunPostprocess?
|
|
129
|
+
"""Postprocess which can rename columns based on a provided mapping."""
|
|
130
|
+
|
|
131
|
+
DEFAULTS = {
|
|
132
|
+
**SessionPostprocess.DEFAULTS,
|
|
133
|
+
"mapping": {},
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
def __init__(self, features=None, config=None):
|
|
137
|
+
super().__init__("rename_cols", features=features, config=config)
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def mapping(self):
|
|
141
|
+
value = self.config["mapping"]
|
|
142
|
+
if not isinstance(value, dict):
|
|
143
|
+
return str2dict(value)
|
|
144
|
+
return value
|
|
145
|
+
|
|
146
|
+
def post_session(self, report):
|
|
147
|
+
"""Called at the end of a session."""
|
|
148
|
+
report.pre_df = report.pre_df.rename(columns=self.mapping)
|
|
149
|
+
report.main_df = report.main_df.rename(columns=self.mapping)
|
|
150
|
+
report.post_df = report.post_df.rename(columns=self.mapping)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class Features2ColumnsPostprocess(SessionPostprocess): # RunPostprocess?
|
|
154
|
+
"""Postprocess which can be used to transform (explode) the 'Features' Column
|
|
155
|
+
in a dataframe for easier filtering."""
|
|
156
|
+
|
|
157
|
+
def __init__(self, features=None, config=None):
|
|
158
|
+
super().__init__("features2cols", features=features, config=config)
|
|
159
|
+
|
|
160
|
+
def post_session(self, report):
|
|
161
|
+
df = report.post_df
|
|
162
|
+
if "Features" not in df.columns:
|
|
163
|
+
return
|
|
164
|
+
feature_df = pd.concat(
|
|
165
|
+
[
|
|
166
|
+
df["Features"].apply(lambda x: pd.Series({"feature_" + feature_name: feature_name in x}))
|
|
167
|
+
for feature_name in list(set(df["Features"].sum()))
|
|
168
|
+
],
|
|
169
|
+
axis=1,
|
|
170
|
+
)
|
|
171
|
+
tmp_df = df.drop(columns=["Features"])
|
|
172
|
+
new_df = pd.concat([tmp_df, feature_df], axis=1)
|
|
173
|
+
report.post_df = new_df
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class Config2ColumnsPostprocess(SessionPostprocess): # RunPostprocess?
|
|
177
|
+
"""Postprocess which can be used to transform (explode) the 'Config' Column in a dataframe for easier filtering."""
|
|
178
|
+
|
|
179
|
+
def __init__(self, features=None, config=None):
|
|
180
|
+
super().__init__("config2cols", features=features, config=config)
|
|
181
|
+
|
|
182
|
+
def post_session(self, report):
|
|
183
|
+
"""Called at the end of a session."""
|
|
184
|
+
df = report.post_df
|
|
185
|
+
if "Config" not in df.columns:
|
|
186
|
+
return
|
|
187
|
+
config_df = df["Config"].apply(pd.Series).add_prefix("config_")
|
|
188
|
+
tmp_df = df.drop(columns=["Config"])
|
|
189
|
+
new_df = pd.concat([tmp_df, config_df], axis=1)
|
|
190
|
+
report.post_df = new_df
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class PassConfig2ColumnsPostprocess(SessionPostprocess):
|
|
194
|
+
"""Postprocess which can be used to transform (explode) the TVM pass_config into separate columns.
|
|
195
|
+
requires prior Config2Columns pass."""
|
|
196
|
+
|
|
197
|
+
def __init__(self, features=None, config=None):
|
|
198
|
+
super().__init__("passcfg2cols", features=features, config=config)
|
|
199
|
+
|
|
200
|
+
def post_session(self, report):
|
|
201
|
+
"""Called at the end of a session."""
|
|
202
|
+
df = report.post_df
|
|
203
|
+
name = "config_tvmaot.extra_pass_config"
|
|
204
|
+
if name not in df.columns:
|
|
205
|
+
return
|
|
206
|
+
config_df = df[name].apply(pd.Series).add_prefix("passcfg_")
|
|
207
|
+
tmp_df = df.drop(columns=[name])
|
|
208
|
+
new_df = pd.concat([tmp_df, config_df], axis=1)
|
|
209
|
+
report.post_df = new_df
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class Bytes2kBPostprocess(SessionPostprocess): # RunPostprocess?
|
|
213
|
+
"""Postprocess which can be used to scale the memory related columns from Bytes to KiloBytes."""
|
|
214
|
+
|
|
215
|
+
def __init__(self, features=None, config=None):
|
|
216
|
+
super().__init__("bytes2kb", features=features, config=config)
|
|
217
|
+
|
|
218
|
+
def post_session(self, report):
|
|
219
|
+
"""Called at the end of a session."""
|
|
220
|
+
df = report.main_df
|
|
221
|
+
match_strs = ["ROM", "RAM"]
|
|
222
|
+
cols = list(
|
|
223
|
+
filter(lambda x: any(s in x for s in match_strs), df.columns)
|
|
224
|
+
) # Only scale columns related to memory
|
|
225
|
+
cols = [col for col in cols if "kB" not in col] # Do not scale columns with are already in kB
|
|
226
|
+
|
|
227
|
+
for col in cols:
|
|
228
|
+
df[col] = df[col] / 1000.0
|
|
229
|
+
df.rename(columns={col: col + " [kB]"}, inplace=True)
|
|
230
|
+
|
|
231
|
+
report.main_df = df
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class VisualizePostprocess(SessionPostprocess):
|
|
235
|
+
"""A very simple example on how to generate a plot of the results using a postprocess."""
|
|
236
|
+
|
|
237
|
+
DEFAULTS = {
|
|
238
|
+
**SessionPostprocess.DEFAULTS,
|
|
239
|
+
"format": "png",
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
def __init__(self, features=None, config=None):
|
|
243
|
+
super().__init__("visualize", features=features, config=config)
|
|
244
|
+
|
|
245
|
+
@property
|
|
246
|
+
def format(self):
|
|
247
|
+
"""Get format property."""
|
|
248
|
+
return self.config["format"]
|
|
249
|
+
|
|
250
|
+
def post_session(self, report):
|
|
251
|
+
"""Called at the end of a session."""
|
|
252
|
+
df = pd.concat([report.pre_df, report.main_df], axis=1)
|
|
253
|
+
|
|
254
|
+
if self.format != "png":
|
|
255
|
+
raise NotImplementedError("Currently only supports PNG")
|
|
256
|
+
|
|
257
|
+
COLS = ["Cycles", "Total ROM", "Total RAM"]
|
|
258
|
+
for col in COLS:
|
|
259
|
+
if col not in report.main_df.columns:
|
|
260
|
+
return []
|
|
261
|
+
|
|
262
|
+
# Local import to deal with optional dependencies
|
|
263
|
+
import matplotlib.pyplot as plt
|
|
264
|
+
|
|
265
|
+
fig, axes = plt.subplots(ncols=len(COLS))
|
|
266
|
+
plt.rcParams["figure.figsize"] = (15, 3) # (w, h)
|
|
267
|
+
for i, col in enumerate(COLS):
|
|
268
|
+
new_df = df[[col]].astype(float)
|
|
269
|
+
bar_names_df = (
|
|
270
|
+
df["Session"].astype(str) + "_" + df["Run"].astype(str)
|
|
271
|
+
) # ideally we would use model/backend/target names here...
|
|
272
|
+
new_df.index = bar_names_df
|
|
273
|
+
new_df.plot(kind="bar", ax=axes[i])
|
|
274
|
+
|
|
275
|
+
data = None
|
|
276
|
+
with tempfile.TemporaryDirectory() as tmpdirname:
|
|
277
|
+
fig_path = Path(tmpdirname) / "plot.png"
|
|
278
|
+
fig.savefig(fig_path)
|
|
279
|
+
with open(fig_path, "rb") as handle:
|
|
280
|
+
data = handle.read()
|
|
281
|
+
|
|
282
|
+
artifacts = [Artifact("plot.png", raw=data, fmt=ArtifactFormat.RAW)]
|
|
283
|
+
return artifacts
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
class Artifact2ColumnPostprocess(RunPostprocess):
|
|
287
|
+
"""Postprocess for converting artifacts to columns in the report."""
|
|
288
|
+
|
|
289
|
+
DEFAULTS = {
|
|
290
|
+
**RunPostprocess.DEFAULTS,
|
|
291
|
+
"file2colname": {},
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
def __init__(self, features=None, config=None):
|
|
295
|
+
super().__init__("artifacts2cols", features=features, config=config)
|
|
296
|
+
|
|
297
|
+
@property
|
|
298
|
+
def file2colname(self):
|
|
299
|
+
"""Get file2colname property."""
|
|
300
|
+
value = self.config["file2colname"]
|
|
301
|
+
if not isinstance(value, dict):
|
|
302
|
+
return str2dict(value)
|
|
303
|
+
return value
|
|
304
|
+
|
|
305
|
+
def post_run(self, report, artifacts):
|
|
306
|
+
"""Called at the end of a run."""
|
|
307
|
+
for filename, colname in self.file2colname.items():
|
|
308
|
+
matches = lookup_artifacts(artifacts, name=filename, first_only=True)
|
|
309
|
+
if not matches:
|
|
310
|
+
report.main_df[colname] = ""
|
|
311
|
+
return
|
|
312
|
+
if matches[0].fmt != ArtifactFormat.TEXT:
|
|
313
|
+
raise RuntimeError("Can only put text into report columns")
|
|
314
|
+
report.main_df[colname] = matches[0].content
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
class AnalyseInstructionsPostprocess(RunPostprocess):
|
|
318
|
+
"""Counting specific types of instructions."""
|
|
319
|
+
|
|
320
|
+
DEFAULTS = {**RunPostprocess.DEFAULTS, "groups": True, "sequences": True, "top": 10}
|
|
321
|
+
|
|
322
|
+
def __init__(self, features=None, config=None):
|
|
323
|
+
super().__init__("analyse_instructions", features=features, config=config)
|
|
324
|
+
|
|
325
|
+
@property
|
|
326
|
+
def groups(self):
|
|
327
|
+
"""Get groups property."""
|
|
328
|
+
value = self.config["groups"]
|
|
329
|
+
return str2bool(value) if not isinstance(value, (bool, int)) else value
|
|
330
|
+
|
|
331
|
+
@property
|
|
332
|
+
def sequences(self):
|
|
333
|
+
"""get sequences property."""
|
|
334
|
+
value = self.config["sequences"]
|
|
335
|
+
return str2bool(value) if not isinstance(value, (bool, int)) else value
|
|
336
|
+
|
|
337
|
+
@property
|
|
338
|
+
def top(self):
|
|
339
|
+
"""get sequences property."""
|
|
340
|
+
return int(self.config["top"])
|
|
341
|
+
|
|
342
|
+
def post_run(self, report, artifacts):
|
|
343
|
+
"""Called at the end of a run."""
|
|
344
|
+
ret_artifacts = []
|
|
345
|
+
log_artifact = lookup_artifacts(artifacts, flags=("log_instrs",), fmt=ArtifactFormat.TEXT, first_only=True)
|
|
346
|
+
assert len(log_artifact) == 1, "To use analyse_instructions process, please enable feature log_instrs."
|
|
347
|
+
log_artifact = log_artifact[0]
|
|
348
|
+
is_spike = "spike" in log_artifact.flags
|
|
349
|
+
is_etiss = "etiss_pulpino" in log_artifact.flags
|
|
350
|
+
is_ovpsim = "ovpsim" in log_artifact.flags
|
|
351
|
+
is_riscv = is_spike or is_etiss or is_ovpsim
|
|
352
|
+
if is_spike:
|
|
353
|
+
content = log_artifact.content
|
|
354
|
+
if self.groups:
|
|
355
|
+
encodings = re.compile(r"\((0x[0-9abcdef]+)\)").findall(content)
|
|
356
|
+
if self.sequences:
|
|
357
|
+
names = re.compile(r"core\s+\d+:\s0x[0-9abcdef]+\s\(0x[0-9abcdef]+\)\s([\w.]+).*").findall(content)
|
|
358
|
+
elif is_etiss:
|
|
359
|
+
content = log_artifact.content
|
|
360
|
+
if self.groups:
|
|
361
|
+
encodings = re.compile(r"0x[0-9abcdef]+:\s\w+\s#\s([01]+)\s.*").findall(content)
|
|
362
|
+
encodings = [f"0b{enc}" for enc in encodings]
|
|
363
|
+
if self.sequences:
|
|
364
|
+
names = re.compile(r"0x[0-9abcdef]+:\s(\w+)\s#\s[01]+\s.*").findall(content)
|
|
365
|
+
elif is_ovpsim:
|
|
366
|
+
content = log_artifact.content
|
|
367
|
+
if self.groups:
|
|
368
|
+
encodings = re.compile(r"riscvOVPsim\/cpu',\s0x[0-9abcdef]+\(.*\):\s([0-9abcdef]+)\s+\w+\s+.*").findall(
|
|
369
|
+
content
|
|
370
|
+
)
|
|
371
|
+
encodings = [f"0x{enc}" for enc in encodings]
|
|
372
|
+
if self.sequences:
|
|
373
|
+
names = re.compile(r"riscvOVPsim\/cpu',\s0x[0-9abcdef]+\(.*\):\s[0-9abcdef]+\s+(\w+)\s+.*").findall(
|
|
374
|
+
content
|
|
375
|
+
)
|
|
376
|
+
else:
|
|
377
|
+
raise RuntimeError("Uable to determine the used target.")
|
|
378
|
+
|
|
379
|
+
def _helper(x, top=100):
|
|
380
|
+
counts = pd.Series(x).value_counts()
|
|
381
|
+
probs = counts / len(x)
|
|
382
|
+
return dict(counts.head(top)), dict(probs.head(top))
|
|
383
|
+
|
|
384
|
+
def _gen_csv(label, counts, probs):
|
|
385
|
+
lines = [f"{label};Count;Probablity"]
|
|
386
|
+
for x in counts:
|
|
387
|
+
line = f"{x};{counts[x]};{probs[x]:.3f}"
|
|
388
|
+
lines.append(line)
|
|
389
|
+
return "\n".join(lines)
|
|
390
|
+
|
|
391
|
+
if self.groups:
|
|
392
|
+
assert is_riscv, "Currently only riscv instrcutions can be analysed by groups"
|
|
393
|
+
|
|
394
|
+
def _extract_major_opcode(enc):
|
|
395
|
+
mapping = {
|
|
396
|
+
0b0010011: "OP-IMM",
|
|
397
|
+
0b0110111: "LUI",
|
|
398
|
+
0b0010111: "AUIPC",
|
|
399
|
+
0b0110011: "OP",
|
|
400
|
+
0b1101111: "JAL",
|
|
401
|
+
0b1100111: "JALR",
|
|
402
|
+
0b1100011: "BRANCH",
|
|
403
|
+
0b0000011: "LOAD",
|
|
404
|
+
0b0100011: "STORE",
|
|
405
|
+
0b0001111: "MISC-MEM",
|
|
406
|
+
0b1110011: "SYSTEM",
|
|
407
|
+
0b1000011: "MADD",
|
|
408
|
+
0b1000111: "MSUB",
|
|
409
|
+
0b1001011: "MNSUB",
|
|
410
|
+
0b1001111: "MNADD",
|
|
411
|
+
0b0000111: "LOAD-FP",
|
|
412
|
+
0b0100111: "STORE-FP",
|
|
413
|
+
0b0001011: "custom-0",
|
|
414
|
+
0b0101011: "custom-1",
|
|
415
|
+
0b1011011: "custom-2/rv128",
|
|
416
|
+
0b1111011: "custom-3/rv128",
|
|
417
|
+
0b1101011: "reserved",
|
|
418
|
+
0b0101111: "AMO",
|
|
419
|
+
0b1010011: "OP-FP",
|
|
420
|
+
0b1010111: "OP-V",
|
|
421
|
+
0b1110111: "OP-P",
|
|
422
|
+
0b0011011: "OP-IMM-32",
|
|
423
|
+
0b0111011: "OP-32",
|
|
424
|
+
}
|
|
425
|
+
enc = int(enc, 0) # Convert from hexadecimal
|
|
426
|
+
opcode = enc & 0b1111111
|
|
427
|
+
lsbs = opcode & 0b11
|
|
428
|
+
if lsbs == 0b11:
|
|
429
|
+
major = mapping.get(opcode, "UNKNOWN")
|
|
430
|
+
else:
|
|
431
|
+
# 16-bit instruction
|
|
432
|
+
msbs = (enc & 0b1110000000000000) >> 13
|
|
433
|
+
rvc_mapping = {
|
|
434
|
+
0b00000: "OP-IMM",
|
|
435
|
+
0b00001: "OP-IMM",
|
|
436
|
+
0b00010: "OP-IMM",
|
|
437
|
+
0b00100: "LOAD",
|
|
438
|
+
0b00101: "JAL",
|
|
439
|
+
0b00110: "LOAD-FP",
|
|
440
|
+
0b01000: "LOAD",
|
|
441
|
+
0b01001: "OP-IMM",
|
|
442
|
+
0b01010: "LOAD",
|
|
443
|
+
0b01100: "LOAD-FP",
|
|
444
|
+
0b01101: "OP-IMM",
|
|
445
|
+
0b01110: "LOAD-FP",
|
|
446
|
+
0b10000: "reserved",
|
|
447
|
+
0b10001: "MISC-ALU",
|
|
448
|
+
0b10010: "JALR",
|
|
449
|
+
0b10100: "STORE-FP",
|
|
450
|
+
0b10101: "JAL",
|
|
451
|
+
0b10110: "STORE-FP",
|
|
452
|
+
0b11000: "STORE",
|
|
453
|
+
0b11001: "BRANCH",
|
|
454
|
+
0b11010: "STORE",
|
|
455
|
+
0b11100: "STORE-FP",
|
|
456
|
+
0b11101: "BRANCH",
|
|
457
|
+
0b11110: "STORE-FP",
|
|
458
|
+
}
|
|
459
|
+
combined = msbs << 2 | lsbs
|
|
460
|
+
assert combined in rvc_mapping.keys()
|
|
461
|
+
return f"{rvc_mapping[combined]} (Compressed)"
|
|
462
|
+
return major
|
|
463
|
+
|
|
464
|
+
majors = list(map(_extract_major_opcode, encodings))
|
|
465
|
+
major_counts, major_probs = _helper(majors, top=self.top)
|
|
466
|
+
majors_csv = _gen_csv("Major", major_counts, major_probs)
|
|
467
|
+
artifact = Artifact("analyse_instructions_majors.csv", content=majors_csv, fmt=ArtifactFormat.TEXT)
|
|
468
|
+
ret_artifacts.append(artifact)
|
|
469
|
+
if self.sequences:
|
|
470
|
+
max_len = 3
|
|
471
|
+
|
|
472
|
+
def _get_sublists(lst, length):
|
|
473
|
+
ret = []
|
|
474
|
+
for i in range(len(lst) - length + 1):
|
|
475
|
+
lst_ = lst[i : i + length]
|
|
476
|
+
ret.append(",".join(lst_))
|
|
477
|
+
return ret
|
|
478
|
+
|
|
479
|
+
for length in range(1, max_len + 1):
|
|
480
|
+
names_ = _get_sublists(names, length)
|
|
481
|
+
counts, probs = _helper(names_, top=self.top)
|
|
482
|
+
sequence_csv = _gen_csv("Sequence", counts, probs)
|
|
483
|
+
artifact = Artifact(
|
|
484
|
+
f"analyse_instructions_seq{length}.csv", content=sequence_csv, fmt=ArtifactFormat.TEXT
|
|
485
|
+
)
|
|
486
|
+
ret_artifacts.append(artifact)
|
|
487
|
+
return ret_artifacts
|