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,327 @@
|
|
|
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
|
+
"""
|
|
20
|
+
This file contains read lock and write lock classes based on filelock
|
|
21
|
+
The locks are non-blocking.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from filelock import FileLock
|
|
25
|
+
import uuid # this is used to create a identifier for every ReadFileLock and WriteFileLock instance.
|
|
26
|
+
import datetime # this is used to track the lock actions
|
|
27
|
+
import os
|
|
28
|
+
import yaml
|
|
29
|
+
from pathlib import Path
|
|
30
|
+
import atexit
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class RWLockTimeout(TimeoutError):
|
|
34
|
+
"""Raised when the lock could not be acquired."""
|
|
35
|
+
|
|
36
|
+
def __init__(self, lock) -> None:
|
|
37
|
+
#: The Read or Write lock instance.
|
|
38
|
+
self.lock = lock
|
|
39
|
+
|
|
40
|
+
def __str__(self) -> str:
|
|
41
|
+
return f"The lock with id '{self.lock.id}' in env '{self.lock.filepath.parent}' could not be acquired."
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ReadFileLock:
|
|
45
|
+
def __init__(self, filepath):
|
|
46
|
+
self.filepath = Path(filepath)
|
|
47
|
+
self.trackfilepath = self.filepath.parent / (str(self.filepath.stem) + "_track")
|
|
48
|
+
self.lock = FileLock(self.filepath)
|
|
49
|
+
self.id = str(uuid.uuid4())
|
|
50
|
+
|
|
51
|
+
def acquire(self, raise_exception=True):
|
|
52
|
+
"""
|
|
53
|
+
This function tried to acquire a ReadFileLock.
|
|
54
|
+
The process is the following:
|
|
55
|
+
1. acquire filelock
|
|
56
|
+
2. read the lock occupation situation
|
|
57
|
+
3. check if the lock is already occupied by another write process
|
|
58
|
+
4.1. release filelock and raise exception(or return 0) if the lock is already occupied by another write process
|
|
59
|
+
4.2. otherwise write the updated lock occupation situation back, release filelock and return
|
|
60
|
+
|
|
61
|
+
Parameters:
|
|
62
|
+
raise_exception (bool): whether an exception should be raised when failed (default: True)
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
success (bool): whether succeeded or not.
|
|
66
|
+
True means succeeded, False means failed (if the param raiseException is set to False).
|
|
67
|
+
A RWLockTimeout exception will be raised if failed (if the param raiseException is set to True).
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
# 1. acquire filelock
|
|
71
|
+
self.lock.acquire(timeout=2)
|
|
72
|
+
|
|
73
|
+
# 2. read the lock occupation situation
|
|
74
|
+
if not os.path.exists(self.trackfilepath):
|
|
75
|
+
# create a file to tack the lock occupation situation
|
|
76
|
+
with open(self.trackfilepath, "w") as track_file:
|
|
77
|
+
pass
|
|
78
|
+
|
|
79
|
+
with open(self.trackfilepath, "r") as stream:
|
|
80
|
+
# read the current lock occupation situation
|
|
81
|
+
try:
|
|
82
|
+
lock_occupy_info = yaml.safe_load(stream) or {}
|
|
83
|
+
except yaml.YAMLError as exc:
|
|
84
|
+
print(exc)
|
|
85
|
+
|
|
86
|
+
# 3. check if the lock is already occupied by another write process
|
|
87
|
+
write_occupied = False
|
|
88
|
+
for k, v in lock_occupy_info.items():
|
|
89
|
+
if v["type"] == "write":
|
|
90
|
+
write_occupied = True
|
|
91
|
+
break
|
|
92
|
+
|
|
93
|
+
# 4
|
|
94
|
+
if write_occupied:
|
|
95
|
+
lock_acquire_success = False
|
|
96
|
+
self.lock.release()
|
|
97
|
+
if raise_exception:
|
|
98
|
+
raise RWLockTimeout(self)
|
|
99
|
+
else:
|
|
100
|
+
time_info = datetime.datetime.now().replace(microsecond=0).isoformat()
|
|
101
|
+
lock_occupy_info[self.id] = {"time": f"{time_info}", "type": "read"}
|
|
102
|
+
with open(self.trackfilepath, "w") as track_file:
|
|
103
|
+
yaml.dump(lock_occupy_info, track_file, default_flow_style=False)
|
|
104
|
+
lock_acquire_success = True
|
|
105
|
+
|
|
106
|
+
self.lock.release()
|
|
107
|
+
atexit.register(self.release)
|
|
108
|
+
return lock_acquire_success
|
|
109
|
+
|
|
110
|
+
def release(self):
|
|
111
|
+
"""
|
|
112
|
+
This function releases a ReadFileLock.
|
|
113
|
+
the process is the following:
|
|
114
|
+
1. acquire filelock
|
|
115
|
+
2. read the lock occupation situation
|
|
116
|
+
3. delete the record of self.id (no exception will be raised if self.id is not found in the record)
|
|
117
|
+
4. write the updated lock occupation situation back, release filelock and return
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
# 1. acquire filelock
|
|
121
|
+
self.lock.acquire(timeout=2)
|
|
122
|
+
|
|
123
|
+
# 2. read the lock occupation situation
|
|
124
|
+
if not os.path.exists(self.trackfilepath):
|
|
125
|
+
# raise error if file does not exist
|
|
126
|
+
raise RuntimeError("track file for read write log is missing.")
|
|
127
|
+
|
|
128
|
+
with open(self.trackfilepath, "r") as stream:
|
|
129
|
+
# read the current lock occupation situation
|
|
130
|
+
try:
|
|
131
|
+
lock_occupy_info = yaml.safe_load(stream) or {}
|
|
132
|
+
except yaml.YAMLError as exc:
|
|
133
|
+
print(exc)
|
|
134
|
+
|
|
135
|
+
# 3. delete the record of self.id
|
|
136
|
+
if self.id in lock_occupy_info.keys():
|
|
137
|
+
lock_occupy_info.pop(self.id)
|
|
138
|
+
|
|
139
|
+
# 4. write the updated lock occupation situation back, release filelock and return
|
|
140
|
+
with open(self.trackfilepath, "w") as track_file:
|
|
141
|
+
if lock_occupy_info:
|
|
142
|
+
yaml.dump(lock_occupy_info, track_file, default_flow_style=False)
|
|
143
|
+
|
|
144
|
+
self.lock.release()
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def is_locked(self):
|
|
148
|
+
"""
|
|
149
|
+
This property returns if a lock is occupied(locked) by other processes.
|
|
150
|
+
the process is the following:
|
|
151
|
+
1. acquire filelock
|
|
152
|
+
2. read the lock occupation situation
|
|
153
|
+
3. check if the lock is already occupied(locked) by another write process
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
is_locked (bool): whether the lock is already occupied(locked) by another write process
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
# 1. acquire filelock
|
|
160
|
+
self.lock.acquire(timeout=2)
|
|
161
|
+
|
|
162
|
+
# 2. read the lock occupation situation
|
|
163
|
+
if not os.path.exists(self.trackfilepath):
|
|
164
|
+
# create a file to tack the lock occupation situation
|
|
165
|
+
with open(self.trackfilepath, "w"):
|
|
166
|
+
pass
|
|
167
|
+
|
|
168
|
+
with open(self.trackfilepath, "r") as stream:
|
|
169
|
+
# read the current lock occupation situation
|
|
170
|
+
try:
|
|
171
|
+
lock_occupy_info = yaml.safe_load(stream) or {}
|
|
172
|
+
except yaml.YAMLError as exc:
|
|
173
|
+
print(exc)
|
|
174
|
+
|
|
175
|
+
# 3. check if the lock is already occupied by another write process
|
|
176
|
+
write_occupied = False
|
|
177
|
+
for k, v in lock_occupy_info.items():
|
|
178
|
+
if v["type"] == "write":
|
|
179
|
+
write_occupied = True
|
|
180
|
+
break
|
|
181
|
+
|
|
182
|
+
self.lock.release()
|
|
183
|
+
return write_occupied
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class WriteFileLock:
|
|
187
|
+
def __init__(self, filepath):
|
|
188
|
+
self.filepath = Path(filepath)
|
|
189
|
+
self.trackfilepath = self.filepath.parent / (str(self.filepath.stem) + "_track")
|
|
190
|
+
self.lock = FileLock(self.filepath)
|
|
191
|
+
self.id = str(uuid.uuid4())
|
|
192
|
+
|
|
193
|
+
def acquire(self, raise_exception=True):
|
|
194
|
+
"""
|
|
195
|
+
This function tried to acquire a WriteFileLock.
|
|
196
|
+
The process is the following:
|
|
197
|
+
1. acquire filelock
|
|
198
|
+
2. read the lock occupation situation
|
|
199
|
+
3. check if the lock is already occupied by another write process
|
|
200
|
+
4.1. release filelock and raise exception(or return 0) if the lock is already occupied by another write process
|
|
201
|
+
4.2. otherwise write the updated lock occupation situation back, release filelock and return
|
|
202
|
+
|
|
203
|
+
Parameters:
|
|
204
|
+
raise_exception (bool): whether raises an exception when failed (default: True)
|
|
205
|
+
|
|
206
|
+
Returns:
|
|
207
|
+
success (bool): whether succeeded or not.
|
|
208
|
+
True means succeeded, False means failed (if the param raiseException is set to False).
|
|
209
|
+
A RWLockTimeout exception will be raised if failed (if the param raiseException is set to True).
|
|
210
|
+
"""
|
|
211
|
+
|
|
212
|
+
# 1. acquire filelock
|
|
213
|
+
self.lock.acquire(timeout=2)
|
|
214
|
+
|
|
215
|
+
# 2. read the lock occupation situation
|
|
216
|
+
if not os.path.exists(self.trackfilepath):
|
|
217
|
+
# create a file to tack the lock occupation situation
|
|
218
|
+
with open(self.trackfilepath, "w") as track_file:
|
|
219
|
+
pass
|
|
220
|
+
|
|
221
|
+
with open(self.trackfilepath, "r") as stream:
|
|
222
|
+
# read the current lock occupation situation
|
|
223
|
+
try:
|
|
224
|
+
lock_occupy_info = yaml.safe_load(stream) or {}
|
|
225
|
+
except yaml.YAMLError as exc:
|
|
226
|
+
print(exc)
|
|
227
|
+
|
|
228
|
+
# 3. check if the lock is already occupied by another process
|
|
229
|
+
occupied = False
|
|
230
|
+
for k, v in lock_occupy_info.items():
|
|
231
|
+
if v["type"] == "write" or "read":
|
|
232
|
+
occupied = True
|
|
233
|
+
break
|
|
234
|
+
|
|
235
|
+
# 4
|
|
236
|
+
if occupied:
|
|
237
|
+
lock_acquire_success = False
|
|
238
|
+
self.lock.release()
|
|
239
|
+
if raise_exception:
|
|
240
|
+
raise RWLockTimeout(self)
|
|
241
|
+
else:
|
|
242
|
+
time_info = datetime.datetime.now().replace(microsecond=0).isoformat()
|
|
243
|
+
lock_occupy_info[self.id] = {"time": f"{time_info}", "type": "write"}
|
|
244
|
+
with open(self.trackfilepath, "w") as track_file:
|
|
245
|
+
yaml.dump(lock_occupy_info, track_file, default_flow_style=False)
|
|
246
|
+
lock_acquire_success = True
|
|
247
|
+
|
|
248
|
+
self.lock.release()
|
|
249
|
+
atexit.register(self.release)
|
|
250
|
+
return lock_acquire_success
|
|
251
|
+
|
|
252
|
+
def release(self):
|
|
253
|
+
"""
|
|
254
|
+
This function releases a WriteFileLock.
|
|
255
|
+
the process is the following:
|
|
256
|
+
1. acquire filelock
|
|
257
|
+
2. read the lock occupation situation
|
|
258
|
+
3. delete the record of self.id (no exception will be raised if self.id is not found in the record)
|
|
259
|
+
4. write the updated lock occupation situation back, release filelock and return
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
# 1. acquire filelock
|
|
263
|
+
self.lock.acquire(timeout=2)
|
|
264
|
+
|
|
265
|
+
# 2. read the lock occupation situation
|
|
266
|
+
if not os.path.exists(self.trackfilepath):
|
|
267
|
+
# raise error if file does not exist
|
|
268
|
+
raise RuntimeError("track file for read write log is missing.")
|
|
269
|
+
|
|
270
|
+
with open(self.trackfilepath, "r") as stream:
|
|
271
|
+
# read the current lock occupation situation
|
|
272
|
+
try:
|
|
273
|
+
lock_occupy_info = yaml.safe_load(stream) or {}
|
|
274
|
+
if lock_occupy_info is None:
|
|
275
|
+
lock_occupy_info = {}
|
|
276
|
+
except yaml.YAMLError as exc:
|
|
277
|
+
print(exc)
|
|
278
|
+
|
|
279
|
+
# 3. delete the record of self.id
|
|
280
|
+
if self.id in lock_occupy_info.keys():
|
|
281
|
+
lock_occupy_info.pop(self.id)
|
|
282
|
+
|
|
283
|
+
# 4. write the updated lock occupation situation back, release filelock and return
|
|
284
|
+
with open(self.trackfilepath, "w") as track_file:
|
|
285
|
+
if lock_occupy_info:
|
|
286
|
+
yaml.dump(lock_occupy_info, track_file, default_flow_style=False)
|
|
287
|
+
|
|
288
|
+
self.lock.release()
|
|
289
|
+
|
|
290
|
+
@property
|
|
291
|
+
def is_locked(self):
|
|
292
|
+
"""
|
|
293
|
+
This property returns if a lock is occupied(locked) by other processes.
|
|
294
|
+
the process is the following:
|
|
295
|
+
1. acquire filelock
|
|
296
|
+
2. read the lock occupation situation
|
|
297
|
+
3. check if the lock is already occupied(locked) by another write process
|
|
298
|
+
|
|
299
|
+
Returns:
|
|
300
|
+
is_locked (bool): whether the lock is already occupied(locked) by another write process
|
|
301
|
+
"""
|
|
302
|
+
|
|
303
|
+
# 1. acquire filelock
|
|
304
|
+
self.lock.acquire(timeout=2)
|
|
305
|
+
|
|
306
|
+
# 2. read the lock occupation situation
|
|
307
|
+
if not os.path.exists(self.trackfilepath):
|
|
308
|
+
# create a file to tack the lock occupation situation
|
|
309
|
+
with open(self.trackfilepath, "w"):
|
|
310
|
+
pass
|
|
311
|
+
|
|
312
|
+
with open(self.trackfilepath, "r") as stream:
|
|
313
|
+
# read the current lock occupation situation
|
|
314
|
+
try:
|
|
315
|
+
lock_occupy_info = yaml.safe_load(stream) or {}
|
|
316
|
+
except yaml.YAMLError as exc:
|
|
317
|
+
print(exc)
|
|
318
|
+
|
|
319
|
+
# 3. check if the lock is already occupied by another write process
|
|
320
|
+
occupied = False
|
|
321
|
+
for k, v in lock_occupy_info.items():
|
|
322
|
+
if v["type"] == "write" or "read":
|
|
323
|
+
occupied = True
|
|
324
|
+
break
|
|
325
|
+
|
|
326
|
+
self.lock.release()
|
|
327
|
+
return occupied
|
|
@@ -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,214 @@
|
|
|
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
|
+
|
|
20
|
+
# TODO: rename to paths.py or user.py?
|
|
21
|
+
|
|
22
|
+
import os
|
|
23
|
+
import xdg
|
|
24
|
+
import logging
|
|
25
|
+
from enum import Enum
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_config_dir():
|
|
30
|
+
config_dir = os.path.join(xdg.xdg_config_home(), "mlonmcu")
|
|
31
|
+
return config_dir
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def init_config_dir():
|
|
35
|
+
config_dir = Path(get_config_dir())
|
|
36
|
+
config_dir.mkdir(parents=True, exist_ok=True)
|
|
37
|
+
subdirs = ["environments", "models", "plugins"]
|
|
38
|
+
files = ["environments.ini"]
|
|
39
|
+
for subdir in subdirs:
|
|
40
|
+
environments_dir = config_dir / subdir
|
|
41
|
+
environments_dir.mkdir(exist_ok=True)
|
|
42
|
+
for file in files:
|
|
43
|
+
filepath = config_dir / file
|
|
44
|
+
filepath.touch(exist_ok=True)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_environments_dir():
|
|
48
|
+
environments_dir = os.path.join(get_config_dir(), "environments")
|
|
49
|
+
return environments_dir
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def get_environments_file():
|
|
53
|
+
environments_file = os.path.join(get_config_dir(), "environments.ini")
|
|
54
|
+
return environments_file
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def get_plugins_dir():
|
|
58
|
+
environments_dir = os.path.join(get_config_dir(), "plugins")
|
|
59
|
+
return environments_dir
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
DEFAULTS = {
|
|
63
|
+
"environment": "default",
|
|
64
|
+
"template": "default",
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
env_subdirs = ["deps", "plugins"]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# class LogLevel(Enum):
|
|
71
|
+
# DEBUG = 0
|
|
72
|
+
# VERBOSE = 1
|
|
73
|
+
# INFO = 2
|
|
74
|
+
# WARNING = 3
|
|
75
|
+
# ERROR = 4
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class BaseConfig:
|
|
79
|
+
def __repr__(self):
|
|
80
|
+
return self.__class__.__name__ + "(" + str(vars(self)) + ")"
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class DefaultsConfig(BaseConfig):
|
|
84
|
+
# TODO: loglevels enum
|
|
85
|
+
|
|
86
|
+
def __init__(
|
|
87
|
+
self,
|
|
88
|
+
log_level=logging.INFO,
|
|
89
|
+
log_to_file=False,
|
|
90
|
+
log_rotate=False,
|
|
91
|
+
default_framework=None,
|
|
92
|
+
default_backends={},
|
|
93
|
+
default_target=None,
|
|
94
|
+
cleanup_auto=False,
|
|
95
|
+
cleanup_keep=100,
|
|
96
|
+
):
|
|
97
|
+
self.log_level = log_level
|
|
98
|
+
self.log_to_file = log_to_file
|
|
99
|
+
self.log_rotate = log_rotate
|
|
100
|
+
self.default_framework = default_framework
|
|
101
|
+
self.default_backends = default_backends
|
|
102
|
+
self.default_target = default_target
|
|
103
|
+
self.cleanup_auto = cleanup_auto
|
|
104
|
+
self.cleanup_keep = cleanup_keep
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class PathConfig(BaseConfig):
|
|
108
|
+
def __init__(self, path, base=None):
|
|
109
|
+
if isinstance(path, str):
|
|
110
|
+
self.path = Path(path)
|
|
111
|
+
else:
|
|
112
|
+
self.path = path
|
|
113
|
+
if isinstance(base, str):
|
|
114
|
+
self.base = Path(base)
|
|
115
|
+
else:
|
|
116
|
+
self.base = base
|
|
117
|
+
if base:
|
|
118
|
+
if not self.path.is_absolute():
|
|
119
|
+
assert base is not None
|
|
120
|
+
self.path = self.base / self.path
|
|
121
|
+
# Resolve symlinks
|
|
122
|
+
self.path = self.path.resolve()
|
|
123
|
+
|
|
124
|
+
def __repr(self):
|
|
125
|
+
return f"PathConfig({self.path})"
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class RepoConfig(BaseConfig):
|
|
129
|
+
def __init__(self, url, ref=None):
|
|
130
|
+
self.url = url
|
|
131
|
+
self.ref = ref
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
class BackendConfig(BaseConfig):
|
|
135
|
+
def __init__(self, name, enabled=True, features={}):
|
|
136
|
+
self.name = name
|
|
137
|
+
self.enabled = enabled
|
|
138
|
+
self.features = features
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class FeatureKind(Enum):
|
|
142
|
+
UNKNOWN = 0
|
|
143
|
+
FRAMEWORK = 1
|
|
144
|
+
BACKEND = 2
|
|
145
|
+
TARGET = 3
|
|
146
|
+
FRONTEND = 4
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class FeatureConfig:
|
|
150
|
+
def __init__(self, name, kind=FeatureKind.UNKNOWN, supported=True):
|
|
151
|
+
self.name = name
|
|
152
|
+
self.supported = supported
|
|
153
|
+
|
|
154
|
+
def __repr__(self):
|
|
155
|
+
return self.__class__.__name__ + "(" + str(vars(self)) + ")"
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class FrameworkFeatureConfig(FeatureConfig):
|
|
159
|
+
def __init__(self, name, framework, supported=True):
|
|
160
|
+
super().__init__(name=name, kind=FeatureKind.FRONTEND, supported=supported)
|
|
161
|
+
self.framework = framework
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class BackendFeatureConfig(FeatureConfig):
|
|
165
|
+
def __init__(self, name, backend, supported=True):
|
|
166
|
+
super().__init__(name=name, kind=FeatureKind.FRONTEND, supported=supported)
|
|
167
|
+
self.backend = backend
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class PlatformFeatureConfig(FeatureConfig):
|
|
171
|
+
def __init__(self, name, platform, supported=True):
|
|
172
|
+
super().__init__(name=name, kind=FeatureKind.TARGET, supported=supported)
|
|
173
|
+
self.platform = platform
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class TargetFeatureConfig(FeatureConfig):
|
|
177
|
+
def __init__(self, name, target, supported=True):
|
|
178
|
+
super().__init__(name=name, kind=FeatureKind.TARGET, supported=supported)
|
|
179
|
+
self.target = target
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class FrontendFeatureConfig(FeatureConfig):
|
|
183
|
+
def __init__(self, name, frontend, supported=True):
|
|
184
|
+
super().__init__(name=name, kind=FeatureKind.FRONTEND, supported=supported)
|
|
185
|
+
self.frontend = frontend
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class FrameworkConfig(BaseConfig):
|
|
189
|
+
def __init__(self, name, enabled=True, backends={}, features={}):
|
|
190
|
+
self.name = name
|
|
191
|
+
self.enabled = enabled
|
|
192
|
+
self.backends = backends
|
|
193
|
+
self.features = features
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class FrontendConfig(BaseConfig):
|
|
197
|
+
def __init__(self, name, enabled=True, features={}):
|
|
198
|
+
self.name = name
|
|
199
|
+
self.enabled = enabled
|
|
200
|
+
self.features = features
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class PlatformConfig(BaseConfig):
|
|
204
|
+
def __init__(self, name, enabled=True, features={}):
|
|
205
|
+
self.name = name
|
|
206
|
+
self.enabled = enabled
|
|
207
|
+
self.features = features
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
class TargetConfig(BaseConfig):
|
|
211
|
+
def __init__(self, name, enabled=True, features={}):
|
|
212
|
+
self.name = name
|
|
213
|
+
self.enabled = enabled
|
|
214
|
+
self.features = features
|