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,81 @@
|
|
|
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
|
+
import os
|
|
20
|
+
import configparser
|
|
21
|
+
from datetime import datetime as dt
|
|
22
|
+
|
|
23
|
+
# TODO: EnvironmentList/Factory/Registry? also via code?
|
|
24
|
+
from .config import get_environments_file
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def validate_name(name):
|
|
28
|
+
# TODO: regex for valid names without spaces etc
|
|
29
|
+
return True
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def get_environments_map():
|
|
33
|
+
result = {}
|
|
34
|
+
environments_file = get_environments_file()
|
|
35
|
+
if os.path.isfile(environments_file):
|
|
36
|
+
parser = configparser.ConfigParser()
|
|
37
|
+
parser.read(environments_file)
|
|
38
|
+
for env_name in parser.sections():
|
|
39
|
+
result[env_name] = parser[env_name]
|
|
40
|
+
return result
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_environment_names():
|
|
44
|
+
envs_dict = get_environments_map()
|
|
45
|
+
return envs_dict.keys()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def get_alternative_name(name, names):
|
|
49
|
+
current = name
|
|
50
|
+
i = -1
|
|
51
|
+
while current in names:
|
|
52
|
+
i = i + 1
|
|
53
|
+
if i == 0:
|
|
54
|
+
current = current + "_" + str(i)
|
|
55
|
+
else:
|
|
56
|
+
temp = current.split("_")
|
|
57
|
+
current = "_".join(temp[:-1]) + "_" + str(i)
|
|
58
|
+
return current
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def register_environment(name, path, overwrite=False):
|
|
62
|
+
validate_name(name)
|
|
63
|
+
if not os.path.isabs(path):
|
|
64
|
+
raise RuntimeError("Not an absolute path")
|
|
65
|
+
|
|
66
|
+
environments_file = get_environments_file()
|
|
67
|
+
if not os.path.isfile(environments_file):
|
|
68
|
+
raise RuntimeError("Environments file does not yet exist")
|
|
69
|
+
|
|
70
|
+
# with open(environments_file, "a") as envs_file:
|
|
71
|
+
# envs_file.write(name + "=" + path)
|
|
72
|
+
config = configparser.ConfigParser()
|
|
73
|
+
config.read(environments_file)
|
|
74
|
+
now = dt.now()
|
|
75
|
+
created = now.strftime("%Y%d%mT%H%M%S")
|
|
76
|
+
if name in config.sections() and not overwrite:
|
|
77
|
+
raise RuntimeError(f"Environment with name {name} does already exist")
|
|
78
|
+
config[name] = {"path": path, "created": created}
|
|
79
|
+
environments_file = get_environments_file()
|
|
80
|
+
with open(environments_file, "w") as handle:
|
|
81
|
+
config.write(handle)
|
|
@@ -0,0 +1,250 @@
|
|
|
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
|
+
import yaml
|
|
20
|
+
import pathlib
|
|
21
|
+
import logging
|
|
22
|
+
|
|
23
|
+
from .config import (
|
|
24
|
+
DefaultsConfig,
|
|
25
|
+
PathConfig,
|
|
26
|
+
RepoConfig,
|
|
27
|
+
FrameworkConfig,
|
|
28
|
+
FrameworkFeatureConfig,
|
|
29
|
+
BackendConfig,
|
|
30
|
+
BackendFeatureConfig,
|
|
31
|
+
TargetConfig,
|
|
32
|
+
TargetFeatureConfig,
|
|
33
|
+
PlatformConfig,
|
|
34
|
+
PlatformFeatureConfig,
|
|
35
|
+
FrontendConfig,
|
|
36
|
+
FrontendFeatureConfig,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# def load_environment_from_file(filename):
|
|
40
|
+
# """Utility to initialize a mlonmcu environment from a YAML file."""
|
|
41
|
+
# if isinstance(filename, str):
|
|
42
|
+
# filename = pathlib.Path(filename)
|
|
43
|
+
# with open(filename, encoding="utf-8") as yaml_file:
|
|
44
|
+
# data = yaml.safe_load(yaml_file)
|
|
45
|
+
# if data:
|
|
46
|
+
# if "home" in data:
|
|
47
|
+
# print(data["home"], filename.parent)
|
|
48
|
+
# assert os.path.realpath(data["home"]) == os.path.realpath(filename.parent)
|
|
49
|
+
# else:
|
|
50
|
+
# data["home"] = filename.parent
|
|
51
|
+
# env = Environment(data)
|
|
52
|
+
# return env
|
|
53
|
+
# raise RuntimeError(f"Error opening environment file: {filename}")
|
|
54
|
+
# return None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def load_environment_from_file(filename, base):
|
|
58
|
+
"""Utility to initialize a mlonmcu environment from a YAML file."""
|
|
59
|
+
if isinstance(filename, str):
|
|
60
|
+
filename = pathlib.Path(filename)
|
|
61
|
+
with open(filename, encoding="utf-8") as yaml_file:
|
|
62
|
+
loaded = yaml.safe_load(yaml_file)
|
|
63
|
+
if not loaded:
|
|
64
|
+
raise RuntimeError("Invalid YAML contents")
|
|
65
|
+
if "home" in loaded:
|
|
66
|
+
home = loaded["home"]
|
|
67
|
+
else:
|
|
68
|
+
home = None
|
|
69
|
+
if "logging" in loaded:
|
|
70
|
+
if "level" in loaded["logging"]:
|
|
71
|
+
log_level = logging.getLevelName(loaded["logging"]["level"])
|
|
72
|
+
else:
|
|
73
|
+
log_level = None
|
|
74
|
+
if "to_file" in loaded["logging"]:
|
|
75
|
+
log_to_file = bool(loaded["logging"]["to_file"])
|
|
76
|
+
else:
|
|
77
|
+
log_to_file = None
|
|
78
|
+
if "rotate" in loaded["logging"]:
|
|
79
|
+
log_rotate = bool(loaded["logging"]["rotate"])
|
|
80
|
+
else:
|
|
81
|
+
log_rotate = None
|
|
82
|
+
else:
|
|
83
|
+
log_level = None
|
|
84
|
+
log_to_file = False
|
|
85
|
+
log_rotate = False
|
|
86
|
+
if "cleanup" in loaded:
|
|
87
|
+
if "auto" in loaded["cleanup"]:
|
|
88
|
+
cleanup_auto = bool(loaded["cleanup"]["auto"])
|
|
89
|
+
else:
|
|
90
|
+
cleanup_auto = False
|
|
91
|
+
if "auto" in loaded["cleanup"]:
|
|
92
|
+
cleanup_keep = int(loaded["cleanup"]["keep"])
|
|
93
|
+
else:
|
|
94
|
+
cleanup_keep = 100
|
|
95
|
+
else:
|
|
96
|
+
cleanup_auto = False
|
|
97
|
+
cleanup_keep = 100
|
|
98
|
+
if "paths" in loaded:
|
|
99
|
+
paths = {}
|
|
100
|
+
for key in loaded["paths"]:
|
|
101
|
+
path = loaded["paths"][key]
|
|
102
|
+
if isinstance(path, list):
|
|
103
|
+
paths[key] = []
|
|
104
|
+
for p in path:
|
|
105
|
+
paths[key].append(PathConfig(p, base=home))
|
|
106
|
+
else:
|
|
107
|
+
paths[key] = PathConfig(path, base=home)
|
|
108
|
+
else:
|
|
109
|
+
paths = None
|
|
110
|
+
if "repos" in loaded:
|
|
111
|
+
repos = {}
|
|
112
|
+
for key in loaded["repos"]:
|
|
113
|
+
repo = loaded["repos"][key]
|
|
114
|
+
if "url" not in repo:
|
|
115
|
+
raise RuntimeError("Missing field 'url' in YAML file")
|
|
116
|
+
if "ref" in repo:
|
|
117
|
+
repos[key] = RepoConfig(repo["url"], ref=repo["ref"])
|
|
118
|
+
else:
|
|
119
|
+
repos[key] = RepoConfig(repo["url"])
|
|
120
|
+
else:
|
|
121
|
+
repos = None
|
|
122
|
+
default_framework = None
|
|
123
|
+
default_backends = {}
|
|
124
|
+
if "frameworks" in loaded:
|
|
125
|
+
frameworks = []
|
|
126
|
+
default_framework = loaded["frameworks"].pop("default", None)
|
|
127
|
+
for key in loaded["frameworks"]:
|
|
128
|
+
framework = loaded["frameworks"][key]
|
|
129
|
+
if "enabled" in framework:
|
|
130
|
+
enabled = bool(framework["enabled"])
|
|
131
|
+
else:
|
|
132
|
+
enabled = False
|
|
133
|
+
backends = []
|
|
134
|
+
if "backends" in framework:
|
|
135
|
+
default_backend = framework["backends"].pop("default", None)
|
|
136
|
+
default_backends[key] = default_backend
|
|
137
|
+
for key2 in framework["backends"]:
|
|
138
|
+
backend = framework["backends"][key2]
|
|
139
|
+
if "enabled" in backend:
|
|
140
|
+
enabled2 = bool(backend["enabled"])
|
|
141
|
+
else:
|
|
142
|
+
enabled2 = True
|
|
143
|
+
backend_features = []
|
|
144
|
+
if "features" in backend:
|
|
145
|
+
for key3 in backend["features"]:
|
|
146
|
+
supported = bool(backend["features"][key3])
|
|
147
|
+
backend_features.append(BackendFeatureConfig(key3, backend=key2, supported=supported))
|
|
148
|
+
backends.append(BackendConfig(key2, enabled=enabled2, features=backend_features))
|
|
149
|
+
framework_features = []
|
|
150
|
+
if "features" in framework:
|
|
151
|
+
for key2 in framework["features"]:
|
|
152
|
+
supported = bool(framework["features"][key2])
|
|
153
|
+
framework_features.append(FrameworkFeatureConfig(key2, framework=key, supported=supported))
|
|
154
|
+
frameworks.append(
|
|
155
|
+
FrameworkConfig(
|
|
156
|
+
key,
|
|
157
|
+
enabled=enabled,
|
|
158
|
+
backends=backends,
|
|
159
|
+
features=framework_features,
|
|
160
|
+
)
|
|
161
|
+
)
|
|
162
|
+
else:
|
|
163
|
+
frameworks = None
|
|
164
|
+
if "frontends" in loaded:
|
|
165
|
+
frontends = []
|
|
166
|
+
for key in loaded["frontends"]:
|
|
167
|
+
frontend = loaded["frontends"][key]
|
|
168
|
+
|
|
169
|
+
if "enabled" in frontend:
|
|
170
|
+
enabled = frontend["enabled"]
|
|
171
|
+
else:
|
|
172
|
+
enabled = True
|
|
173
|
+
frontend_features = []
|
|
174
|
+
if "features" in frontend:
|
|
175
|
+
for key2 in frontend["features"]:
|
|
176
|
+
supported = bool(frontend["features"][key2])
|
|
177
|
+
frontend_features.append(FrontendFeatureConfig(key2, frontend=key, supported=supported))
|
|
178
|
+
frontends.append(FrontendConfig(key, enabled=enabled, features=frontend_features))
|
|
179
|
+
else:
|
|
180
|
+
frontends = None
|
|
181
|
+
if "platforms" in loaded:
|
|
182
|
+
platforms = []
|
|
183
|
+
for key in loaded["platforms"]:
|
|
184
|
+
platform = loaded["platforms"][key]
|
|
185
|
+
if "enabled" in platform:
|
|
186
|
+
enabled = platform["enabled"]
|
|
187
|
+
else:
|
|
188
|
+
enabled = True
|
|
189
|
+
platform_features = []
|
|
190
|
+
if "features" in platform:
|
|
191
|
+
for key2 in platform["features"]:
|
|
192
|
+
supported = bool(platform["features"][key2])
|
|
193
|
+
platform_features.append(PlatformFeatureConfig(key2, platform=key, supported=supported))
|
|
194
|
+
platforms.append(PlatformConfig(key, enabled=enabled, features=platform_features))
|
|
195
|
+
else:
|
|
196
|
+
platforms = None
|
|
197
|
+
if "toolchains" in loaded:
|
|
198
|
+
toolchains = loaded["toolchains"]
|
|
199
|
+
else:
|
|
200
|
+
toolchains = None
|
|
201
|
+
default_target = None
|
|
202
|
+
if "targets" in loaded:
|
|
203
|
+
targets = []
|
|
204
|
+
default_target = loaded["targets"].pop("default", None)
|
|
205
|
+
for key in loaded["targets"]:
|
|
206
|
+
target = loaded["targets"][key]
|
|
207
|
+
if "enabled" in target:
|
|
208
|
+
enabled = target["enabled"]
|
|
209
|
+
else:
|
|
210
|
+
enabled = True
|
|
211
|
+
target_features = []
|
|
212
|
+
if "features" in target:
|
|
213
|
+
for key2 in target["features"]:
|
|
214
|
+
supported = bool(target["features"][key2])
|
|
215
|
+
target_features.append(TargetFeatureConfig(key2, target=key, supported=supported))
|
|
216
|
+
targets.append(TargetConfig(key, enabled=enabled, features=target_features))
|
|
217
|
+
else:
|
|
218
|
+
targets = None
|
|
219
|
+
if "vars" in loaded:
|
|
220
|
+
variables = loaded["vars"]
|
|
221
|
+
else:
|
|
222
|
+
variables = None
|
|
223
|
+
if "flags" in loaded:
|
|
224
|
+
default_flags = loaded["flags"]
|
|
225
|
+
else:
|
|
226
|
+
default_flags = None
|
|
227
|
+
defaults = DefaultsConfig(
|
|
228
|
+
log_level=log_level,
|
|
229
|
+
log_to_file=log_to_file,
|
|
230
|
+
log_rotate=log_rotate,
|
|
231
|
+
default_framework=default_framework,
|
|
232
|
+
default_backends=default_backends,
|
|
233
|
+
default_target=default_target,
|
|
234
|
+
cleanup_auto=cleanup_auto,
|
|
235
|
+
cleanup_keep=cleanup_keep,
|
|
236
|
+
)
|
|
237
|
+
env = base(
|
|
238
|
+
home,
|
|
239
|
+
defaults=defaults,
|
|
240
|
+
paths=paths,
|
|
241
|
+
repos=repos,
|
|
242
|
+
frameworks=frameworks,
|
|
243
|
+
frontends=frontends,
|
|
244
|
+
platforms=platforms,
|
|
245
|
+
toolchains=toolchains,
|
|
246
|
+
targets=targets,
|
|
247
|
+
variables=variables,
|
|
248
|
+
default_flags=default_flags,
|
|
249
|
+
)
|
|
250
|
+
return env
|
|
@@ -0,0 +1,69 @@
|
|
|
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 mlonmcu config templates."""
|
|
20
|
+
import pkgutil
|
|
21
|
+
import os
|
|
22
|
+
import jinja2
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
import pkg_resources
|
|
25
|
+
|
|
26
|
+
from .config import get_config_dir
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_template_names():
|
|
30
|
+
template_files = pkg_resources.resource_listdir("mlonmcu", os.path.join("..", "resources", "templates"))
|
|
31
|
+
names = [name.split(".yml.j2")[0] for name in template_files]
|
|
32
|
+
return names
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_template_text(name):
|
|
36
|
+
return pkgutil.get_data("mlonmcu", os.path.join("..", "resources", "templates", name + ".yml.j2"))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def fill_template(name, data={}):
|
|
40
|
+
if isinstance(name, Path):
|
|
41
|
+
name = str(name)
|
|
42
|
+
if name.endswith(".j2"): # Template from file
|
|
43
|
+
assert Path(name).is_file(), f"Template does not exits: {name}"
|
|
44
|
+
with open(name, "r") as handle:
|
|
45
|
+
template_text = handle.read()
|
|
46
|
+
else: # Template by name
|
|
47
|
+
template_text = get_template_text(name)
|
|
48
|
+
if template_text:
|
|
49
|
+
if not isinstance(template_text, str):
|
|
50
|
+
try:
|
|
51
|
+
template_text = template_text.decode("utf-8")
|
|
52
|
+
except UnicodeDecodeError as e:
|
|
53
|
+
raise e
|
|
54
|
+
tmpl = jinja2.Template(template_text)
|
|
55
|
+
rendered = tmpl.render(**data)
|
|
56
|
+
return rendered
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def fill_environment_yaml(template_name, home_dir, config=None):
|
|
61
|
+
if not config:
|
|
62
|
+
config = {}
|
|
63
|
+
return fill_template(template_name, {"home_dir": str(home_dir), "config_dir": str(get_config_dir()), **config})
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def write_environment_yaml_from_template(path, template_name, home_dir, config=None):
|
|
67
|
+
with open(path, "w") as yaml:
|
|
68
|
+
text = fill_environment_yaml(template_name, home_dir, config=config)
|
|
69
|
+
yaml.write(text)
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
import yaml
|
|
20
|
+
import pathlib
|
|
21
|
+
import logging
|
|
22
|
+
|
|
23
|
+
from .config import PathConfig
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def create_environment_dict(environment):
|
|
27
|
+
data = {}
|
|
28
|
+
data["home"] = environment.home
|
|
29
|
+
data["logging"] = {
|
|
30
|
+
"level": logging.getLevelName(environment.defaults.log_level),
|
|
31
|
+
"to_file": environment.defaults.log_to_file,
|
|
32
|
+
"rotate": environment.defaults.log_rotate,
|
|
33
|
+
}
|
|
34
|
+
data["cleanup"] = {
|
|
35
|
+
"auto": environment.defaults.cleanup_auto,
|
|
36
|
+
"keep": environment.defaults.cleanup_keep,
|
|
37
|
+
}
|
|
38
|
+
data["paths"] = {
|
|
39
|
+
path: str(path_config.path)
|
|
40
|
+
if isinstance(path_config, PathConfig)
|
|
41
|
+
else [str(config.path) for config in path_config]
|
|
42
|
+
for path, path_config in environment.paths.items()
|
|
43
|
+
} # TODO: allow relative paths
|
|
44
|
+
data["repos"] = {repo: vars(repo_config) for repo, repo_config in environment.repos.items()}
|
|
45
|
+
data["frameworks"] = {
|
|
46
|
+
"default": environment.defaults.default_framework if environment.defaults.default_framework else None,
|
|
47
|
+
**{
|
|
48
|
+
framework.name: {
|
|
49
|
+
"enabled": framework.enabled,
|
|
50
|
+
"backends": {
|
|
51
|
+
"default": environment.defaults.default_backends[framework.name]
|
|
52
|
+
if environment.defaults.default_backends and environment.defaults.default_backends[framework.name]
|
|
53
|
+
else None,
|
|
54
|
+
**{
|
|
55
|
+
backend.name: {
|
|
56
|
+
"enabled": backend.enabled,
|
|
57
|
+
"features": {
|
|
58
|
+
backend_feature.name: backend_feature.supported for backend_feature in backend.features
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
for backend in framework.backends
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
"features": {
|
|
65
|
+
framework_feature.name: framework_feature.supported for framework_feature in framework.features
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
for framework in environment.frameworks
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
data["frontends"] = {
|
|
72
|
+
# "default": None, # unimplemented?
|
|
73
|
+
**{
|
|
74
|
+
frontend.name: {
|
|
75
|
+
"enabled": frontend.enabled,
|
|
76
|
+
"features": {
|
|
77
|
+
frontend_feature.name: frontend_feature.supported for frontend_feature in frontend.features
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
for frontend in environment.frontends
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
data["platforms"] = {
|
|
84
|
+
# "default": None, # unimplemented?
|
|
85
|
+
**{
|
|
86
|
+
platform.name: {
|
|
87
|
+
"enabled": platform.enabled,
|
|
88
|
+
"features": {
|
|
89
|
+
platform_feature.name: platform_feature.supported for platform_feature in platform.features
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
for platform in environment.platforms
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
data["toolchains"] = environment.toolchains
|
|
96
|
+
data["targets"] = {
|
|
97
|
+
"default": environment.defaults.default_target,
|
|
98
|
+
**{
|
|
99
|
+
target.name: {
|
|
100
|
+
"enabled": target.enabled,
|
|
101
|
+
"features": {target_feature.name: target_feature.supported for target_feature in target.features},
|
|
102
|
+
}
|
|
103
|
+
for target in environment.targets
|
|
104
|
+
},
|
|
105
|
+
}
|
|
106
|
+
data["vars"] = environment.vars
|
|
107
|
+
data["flags"] = environment.flags
|
|
108
|
+
return data
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def write_environment_to_file(environment, filename):
|
|
112
|
+
"""Utility to initialize a mlonmcu environment from a YAML file."""
|
|
113
|
+
if isinstance(filename, str):
|
|
114
|
+
filename = pathlib.Path(filename)
|
|
115
|
+
data = create_environment_dict(environment)
|
|
116
|
+
with open(filename, "w") as yaml_file:
|
|
117
|
+
yaml.dump(data, yaml_file, default_flow_style=False, sort_keys=False)
|
|
@@ -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
|
+
#
|