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.
Files changed (376) hide show
  1. mlonmcu/__init__.py +26 -0
  2. mlonmcu/artifact.py +172 -0
  3. mlonmcu/cli/__init__.py +19 -0
  4. mlonmcu/cli/build.py +119 -0
  5. mlonmcu/cli/cleanup.py +75 -0
  6. mlonmcu/cli/common.py +227 -0
  7. mlonmcu/cli/compile.py +87 -0
  8. mlonmcu/cli/env.py +68 -0
  9. mlonmcu/cli/export.py +93 -0
  10. mlonmcu/cli/flow.py +67 -0
  11. mlonmcu/cli/helper/__init__.py +18 -0
  12. mlonmcu/cli/helper/filter.py +25 -0
  13. mlonmcu/cli/helper/parse.py +159 -0
  14. mlonmcu/cli/init.py +130 -0
  15. mlonmcu/cli/load.py +87 -0
  16. mlonmcu/cli/main.py +116 -0
  17. mlonmcu/cli/models.py +48 -0
  18. mlonmcu/cli/run.py +56 -0
  19. mlonmcu/cli/setup.py +136 -0
  20. mlonmcu/cli/tune.py +48 -0
  21. mlonmcu/config.py +219 -0
  22. mlonmcu/context/__init__.py +22 -0
  23. mlonmcu/context/context.py +545 -0
  24. mlonmcu/context/read_write_filelock.py +327 -0
  25. mlonmcu/environment/__init__.py +18 -0
  26. mlonmcu/environment/config.py +214 -0
  27. mlonmcu/environment/environment.py +501 -0
  28. mlonmcu/environment/init.py +191 -0
  29. mlonmcu/environment/list.py +81 -0
  30. mlonmcu/environment/loader.py +250 -0
  31. mlonmcu/environment/templates.py +69 -0
  32. mlonmcu/environment/writer.py +117 -0
  33. mlonmcu/feature/__init__.py +18 -0
  34. mlonmcu/feature/feature.py +230 -0
  35. mlonmcu/feature/features.py +1537 -0
  36. mlonmcu/feature/type.py +33 -0
  37. mlonmcu/flow/__init__.py +61 -0
  38. mlonmcu/flow/backend.py +234 -0
  39. mlonmcu/flow/framework.py +69 -0
  40. mlonmcu/flow/tflm/__init__.py +23 -0
  41. mlonmcu/flow/tflm/backend/__init__.py +23 -0
  42. mlonmcu/flow/tflm/backend/backend.py +47 -0
  43. mlonmcu/flow/tflm/backend/tflmc.py +129 -0
  44. mlonmcu/flow/tflm/backend/tflmi.py +385 -0
  45. mlonmcu/flow/tflm/framework.py +81 -0
  46. mlonmcu/flow/tvm/__init__.py +23 -0
  47. mlonmcu/flow/tvm/backend/__init__.py +26 -0
  48. mlonmcu/flow/tvm/backend/backend.py +282 -0
  49. mlonmcu/flow/tvm/backend/model_info.py +307 -0
  50. mlonmcu/flow/tvm/backend/python_utils.py +36 -0
  51. mlonmcu/flow/tvm/backend/tuner.py +41 -0
  52. mlonmcu/flow/tvm/backend/tvmaot.py +162 -0
  53. mlonmcu/flow/tvm/backend/tvmaotplus.py +51 -0
  54. mlonmcu/flow/tvm/backend/tvmc_utils.py +172 -0
  55. mlonmcu/flow/tvm/backend/tvmcg.py +102 -0
  56. mlonmcu/flow/tvm/backend/tvmllvm.py +106 -0
  57. mlonmcu/flow/tvm/backend/tvmrt.py +151 -0
  58. mlonmcu/flow/tvm/backend/wrapper.py +645 -0
  59. mlonmcu/flow/tvm/framework.py +96 -0
  60. mlonmcu/logging.py +79 -0
  61. mlonmcu/mlonmcu.py +19 -0
  62. mlonmcu/models/__init__.py +31 -0
  63. mlonmcu/models/convert_data.py +107 -0
  64. mlonmcu/models/frontend.py +571 -0
  65. mlonmcu/models/group.py +29 -0
  66. mlonmcu/models/lookup.py +345 -0
  67. mlonmcu/models/metadata.py +133 -0
  68. mlonmcu/models/model.py +104 -0
  69. mlonmcu/models/options.py +64 -0
  70. mlonmcu/models/utils.py +136 -0
  71. mlonmcu/platform/__init__.py +27 -0
  72. mlonmcu/platform/_platform.py +46 -0
  73. mlonmcu/platform/espidf/__init__.py +25 -0
  74. mlonmcu/platform/espidf/espidf.py +489 -0
  75. mlonmcu/platform/espidf/espidf_target.py +257 -0
  76. mlonmcu/platform/lookup.py +126 -0
  77. mlonmcu/platform/microtvm/__init__.py +25 -0
  78. mlonmcu/platform/microtvm/microtvm.py +580 -0
  79. mlonmcu/platform/microtvm/microtvm_arduino_target.py +68 -0
  80. mlonmcu/platform/microtvm/microtvm_backend.py +64 -0
  81. mlonmcu/platform/microtvm/microtvm_espidf_target.py +94 -0
  82. mlonmcu/platform/microtvm/microtvm_etissvp_target.py +98 -0
  83. mlonmcu/platform/microtvm/microtvm_host_target.py +46 -0
  84. mlonmcu/platform/microtvm/microtvm_spike_target.py +230 -0
  85. mlonmcu/platform/microtvm/microtvm_target.py +189 -0
  86. mlonmcu/platform/microtvm/microtvm_template_target.py +55 -0
  87. mlonmcu/platform/microtvm/microtvm_zephyr_target.py +91 -0
  88. mlonmcu/platform/mlif/__init__.py +25 -0
  89. mlonmcu/platform/mlif/mlif.py +300 -0
  90. mlonmcu/platform/mlif/mlif_target.py +86 -0
  91. mlonmcu/platform/platform.py +244 -0
  92. mlonmcu/platform/tvm/__init__.py +25 -0
  93. mlonmcu/platform/tvm/tvm.py +429 -0
  94. mlonmcu/platform/tvm/tvm_backend.py +57 -0
  95. mlonmcu/platform/tvm/tvm_target.py +165 -0
  96. mlonmcu/platform/zephyr/__init__.py +25 -0
  97. mlonmcu/platform/zephyr/zephyr.py +450 -0
  98. mlonmcu/platform/zephyr/zephyr_target.py +110 -0
  99. mlonmcu/plugins.py +26 -0
  100. mlonmcu/report.py +99 -0
  101. mlonmcu/session/__init__.py +18 -0
  102. mlonmcu/session/postprocess/__init__.py +43 -0
  103. mlonmcu/session/postprocess/postprocess.py +62 -0
  104. mlonmcu/session/postprocess/postprocesses.py +487 -0
  105. mlonmcu/session/run.py +1008 -0
  106. mlonmcu/session/session.py +373 -0
  107. mlonmcu/setup/__init__.py +18 -0
  108. mlonmcu/setup/cache.py +147 -0
  109. mlonmcu/setup/gen_requirements.py +619 -0
  110. mlonmcu/setup/setup.py +285 -0
  111. mlonmcu/setup/task.py +380 -0
  112. mlonmcu/setup/tasks/__init__.py +40 -0
  113. mlonmcu/setup/tasks/arm_gcc.py +58 -0
  114. mlonmcu/setup/tasks/cmsisnn.py +151 -0
  115. mlonmcu/setup/tasks/common.py +36 -0
  116. mlonmcu/setup/tasks/corstone300.py +64 -0
  117. mlonmcu/setup/tasks/espidf.py +87 -0
  118. mlonmcu/setup/tasks/etiss.py +147 -0
  119. mlonmcu/setup/tasks/llvm.py +67 -0
  120. mlonmcu/setup/tasks/mlif.py +49 -0
  121. mlonmcu/setup/tasks/muriscvnn.py +166 -0
  122. mlonmcu/setup/tasks/pulp.py +192 -0
  123. mlonmcu/setup/tasks/riscv_gcc.py +146 -0
  124. mlonmcu/setup/tasks/spike.py +190 -0
  125. mlonmcu/setup/tasks/tf.py +92 -0
  126. mlonmcu/setup/tasks/tflite.py +59 -0
  127. mlonmcu/setup/tasks/tflmc.py +141 -0
  128. mlonmcu/setup/tasks/tvm.py +172 -0
  129. mlonmcu/setup/tasks/utvmcg.py +96 -0
  130. mlonmcu/setup/tasks/zephyr.py +119 -0
  131. mlonmcu/setup/utils.py +374 -0
  132. mlonmcu/target/__init__.py +37 -0
  133. mlonmcu/target/_target.py +41 -0
  134. mlonmcu/target/arm/__init__.py +3 -0
  135. mlonmcu/target/arm/corstone300.py +235 -0
  136. mlonmcu/target/arm/util.py +109 -0
  137. mlonmcu/target/common.py +194 -0
  138. mlonmcu/target/elf.py +256 -0
  139. mlonmcu/target/host_x86.py +84 -0
  140. mlonmcu/target/metrics.py +75 -0
  141. mlonmcu/target/riscv/__init__.py +7 -0
  142. mlonmcu/target/riscv/etiss_pulpino.py +462 -0
  143. mlonmcu/target/riscv/gvsoc_pulp.py +215 -0
  144. mlonmcu/target/riscv/ovpsim.py +301 -0
  145. mlonmcu/target/riscv/riscv.py +185 -0
  146. mlonmcu/target/riscv/riscv_qemu.py +166 -0
  147. mlonmcu/target/riscv/spike.py +243 -0
  148. mlonmcu/target/riscv/util.py +134 -0
  149. mlonmcu/target/target.py +200 -0
  150. mlonmcu/utils.py +49 -0
  151. mlonmcu/version.py +21 -0
  152. mlonmcu-0.3.0.dev0.dist-info/LICENSE +202 -0
  153. mlonmcu-0.3.0.dev0.dist-info/METADATA +343 -0
  154. mlonmcu-0.3.0.dev0.dist-info/NOTICE +8 -0
  155. mlonmcu-0.3.0.dev0.dist-info/RECORD +376 -0
  156. mlonmcu-0.3.0.dev0.dist-info/WHEEL +5 -0
  157. mlonmcu-0.3.0.dev0.dist-info/entry_points.txt +3 -0
  158. mlonmcu-0.3.0.dev0.dist-info/top_level.txt +1 -0
  159. resources/frameworks/tvm/crt_config/README.md +7 -0
  160. resources/frameworks/tvm/crt_config/crt_config.h +53 -0
  161. resources/frameworks/tvm/tuning_records/riscv_cpu_v0.01.log.best +46 -0
  162. resources/patches/fix_esp32c3_march.patch +20 -0
  163. resources/patches/pulp_freertos_support.patch +55 -0
  164. resources/platforms/espidf/micro_speech_esp32devboard/CMakeLists.txt +29 -0
  165. resources/platforms/espidf/micro_speech_esp32devboard/README.md +70 -0
  166. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/CMakeLists.txt +78 -0
  167. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/Kconfig +76 -0
  168. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/default_data.c +26 -0
  169. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/default_model_support/process_input.c +35 -0
  170. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/default_model_support/process_output.c +45 -0
  171. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/include/exit.h +26 -0
  172. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/include/ml_interface.h +70 -0
  173. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/include/printing.h +31 -0
  174. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/ml_interface.c +74 -0
  175. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/ml_interface_tflm.cc +64 -0
  176. resources/platforms/espidf/micro_speech_esp32devboard/components/mlif2/ml_interface_tvm.c +53 -0
  177. resources/platforms/espidf/micro_speech_esp32devboard/components/tflite-lib/CMakeLists.txt +140 -0
  178. resources/platforms/espidf/micro_speech_esp32devboard/components/tflite-lib/Kconfig +8 -0
  179. resources/platforms/espidf/micro_speech_esp32devboard/components/tvm-lib/CMakeLists.txt +66 -0
  180. resources/platforms/espidf/micro_speech_esp32devboard/components/tvm-lib/Kconfig +7 -0
  181. resources/platforms/espidf/micro_speech_esp32devboard/example_test.py +38 -0
  182. resources/platforms/espidf/micro_speech_esp32devboard/info.txt +9 -0
  183. resources/platforms/espidf/micro_speech_esp32devboard/main/CMakeLists.txt +58 -0
  184. resources/platforms/espidf/micro_speech_esp32devboard/main/audio_provider.cc +193 -0
  185. resources/platforms/espidf/micro_speech_esp32devboard/main/audio_provider.h +49 -0
  186. resources/platforms/espidf/micro_speech_esp32devboard/main/command_responder.cc +53 -0
  187. resources/platforms/espidf/micro_speech_esp32devboard/main/command_responder.h +35 -0
  188. resources/platforms/espidf/micro_speech_esp32devboard/main/feature_provider.cc +132 -0
  189. resources/platforms/espidf/micro_speech_esp32devboard/main/feature_provider.cc.orig +145 -0
  190. resources/platforms/espidf/micro_speech_esp32devboard/main/feature_provider.h +55 -0
  191. resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/COPYING +11 -0
  192. resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/_kiss_fft_guts.h +168 -0
  193. resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/kiss_fft.c +408 -0
  194. resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/kiss_fft.h +124 -0
  195. resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/tools/kiss_fftr.c +159 -0
  196. resources/platforms/espidf/micro_speech_esp32devboard/main/kissfft/tools/kiss_fftr.h +46 -0
  197. resources/platforms/espidf/micro_speech_esp32devboard/main/main.cc +63 -0
  198. resources/platforms/espidf/micro_speech_esp32devboard/main/main_functions.cc +204 -0
  199. resources/platforms/espidf/micro_speech_esp32devboard/main/main_functions.h +37 -0
  200. resources/platforms/espidf/micro_speech_esp32devboard/main/micro_features_generator.cc +121 -0
  201. resources/platforms/espidf/micro_speech_esp32devboard/main/micro_features_generator.h +38 -0
  202. resources/platforms/espidf/micro_speech_esp32devboard/main/micro_model_settings.cc +23 -0
  203. resources/platforms/espidf/micro_speech_esp32devboard/main/micro_model_settings.h +43 -0
  204. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/bits.h +102 -0
  205. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/fft.cc +52 -0
  206. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/fft.h +50 -0
  207. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/fft_util.cc +69 -0
  208. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/fft_util.h +34 -0
  209. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/filterbank.c +134 -0
  210. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/filterbank.h +63 -0
  211. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/filterbank_util.c +220 -0
  212. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/filterbank_util.h +50 -0
  213. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/frontend.c +72 -0
  214. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/frontend.h +64 -0
  215. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/frontend_util.c +85 -0
  216. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/frontend_util.h +52 -0
  217. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/kiss_fft_common.h +48 -0
  218. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/kiss_fft_int16.cc +8 -0
  219. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/kiss_fft_int16.h +34 -0
  220. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_lut.c +30 -0
  221. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_lut.h +40 -0
  222. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_scale.c +83 -0
  223. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_scale.h +39 -0
  224. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_scale_util.c +27 -0
  225. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/log_scale_util.h +45 -0
  226. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/noise_reduction.c +51 -0
  227. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/noise_reduction.h +46 -0
  228. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/noise_reduction_util.c +45 -0
  229. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/noise_reduction_util.h +50 -0
  230. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/pcan_gain_control.c +56 -0
  231. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/pcan_gain_control.h +47 -0
  232. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/pcan_gain_control_util.c +92 -0
  233. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/pcan_gain_control_util.h +57 -0
  234. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/window.c +70 -0
  235. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/window.h +49 -0
  236. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/window_util.c +73 -0
  237. resources/platforms/espidf/micro_speech_esp32devboard/main/microfrontend/lib/window_util.h +45 -0
  238. resources/platforms/espidf/micro_speech_esp32devboard/main/pins.c +14 -0
  239. resources/platforms/espidf/micro_speech_esp32devboard/main/pins.h +30 -0
  240. resources/platforms/espidf/micro_speech_esp32devboard/main/recognize_commands.cc +150 -0
  241. resources/platforms/espidf/micro_speech_esp32devboard/main/recognize_commands.h +173 -0
  242. resources/platforms/espidf/micro_speech_esp32devboard/main/ringbuf.c +333 -0
  243. resources/platforms/espidf/micro_speech_esp32devboard/main/ringbuf.h +74 -0
  244. resources/platforms/espidf/micro_speech_esp32devboard/sdkconfig.defaults +36 -0
  245. resources/platforms/espidf/project/CMakeLists.txt +29 -0
  246. resources/platforms/espidf/project/README.md +70 -0
  247. resources/platforms/espidf/project/components/mlif/CMakeLists.txt +77 -0
  248. resources/platforms/espidf/project/components/mlif/Kconfig +76 -0
  249. resources/platforms/espidf/project/components/mlif/default_data.c +26 -0
  250. resources/platforms/espidf/project/components/mlif/default_model_support/process_input.c +35 -0
  251. resources/platforms/espidf/project/components/mlif/default_model_support/process_output.c +45 -0
  252. resources/platforms/espidf/project/components/mlif/include/exit.h +26 -0
  253. resources/platforms/espidf/project/components/mlif/include/ml_interface.h +60 -0
  254. resources/platforms/espidf/project/components/mlif/include/printing.h +31 -0
  255. resources/platforms/espidf/project/components/mlif/ml_interface.c +54 -0
  256. resources/platforms/espidf/project/components/mlif/ml_interface_tflm.cc +40 -0
  257. resources/platforms/espidf/project/components/mlif/ml_interface_tvm.c +40 -0
  258. resources/platforms/espidf/project/components/tflite-lib/CMakeLists.txt +142 -0
  259. resources/platforms/espidf/project/components/tflite-lib/Kconfig +8 -0
  260. resources/platforms/espidf/project/components/tvm-lib/CMakeLists.txt +66 -0
  261. resources/platforms/espidf/project/components/tvm-lib/Kconfig +7 -0
  262. resources/platforms/espidf/project/example_test.py +38 -0
  263. resources/platforms/espidf/project/main/CMakeLists.txt +25 -0
  264. resources/platforms/espidf/project/main/main.c +57 -0
  265. resources/platforms/espidf/project/sdkconfig.defaults +26 -0
  266. resources/platforms/zephyr/project/CMakeLists.txt +22 -0
  267. resources/platforms/zephyr/project/Kconfig +101 -0
  268. resources/platforms/zephyr/project/README.rst +33 -0
  269. resources/platforms/zephyr/project/cmake/AddAllSubdirs.cmake +21 -0
  270. resources/platforms/zephyr/project/cmake/ChooseTarget.cmake +22 -0
  271. resources/platforms/zephyr/project/cmake/LinkTFLite.cmake +223 -0
  272. resources/platforms/zephyr/project/cmake/LinkTVM.cmake +68 -0
  273. resources/platforms/zephyr/project/cmake/LookupClang.cmake +41 -0
  274. resources/platforms/zephyr/project/cmake/backends/tflmc.cmake +5 -0
  275. resources/platforms/zephyr/project/cmake/backends/tflmi.cmake +5 -0
  276. resources/platforms/zephyr/project/cmake/backends/tvmaot.cmake +10 -0
  277. resources/platforms/zephyr/project/cmake/backends/tvmaotplus.cmake +10 -0
  278. resources/platforms/zephyr/project/cmake/backends/tvmcg.cmake +10 -0
  279. resources/platforms/zephyr/project/cmake/backends/tvmllvm.cmake +8 -0
  280. resources/platforms/zephyr/project/cmake/backends/tvmrt.cmake +8 -0
  281. resources/platforms/zephyr/project/cmake/extras.cmake +9 -0
  282. resources/platforms/zephyr/project/cmake/features/auto_vectorize_gcc.cmake +65 -0
  283. resources/platforms/zephyr/project/cmake/features/auto_vectorize_llvm.cmake +20 -0
  284. resources/platforms/zephyr/project/cmake/features/cmsisnn.cmake +86 -0
  285. resources/platforms/zephyr/project/cmake/features/muriscvnn.cmake +87 -0
  286. resources/platforms/zephyr/project/cmake/frameworks/tflm.cmake +1 -0
  287. resources/platforms/zephyr/project/cmake/frameworks/tflm_mlif.cmake +8 -0
  288. resources/platforms/zephyr/project/cmake/frameworks/tvm.cmake +1 -0
  289. resources/platforms/zephyr/project/cmake/frameworks/tvm_mlif.cmake +37 -0
  290. resources/platforms/zephyr/project/lib/CMakeLists.txt +13 -0
  291. resources/platforms/zephyr/project/lib/drivers/fake_input.c +10 -0
  292. resources/platforms/zephyr/project/lib/drivers/fake_input.h +8 -0
  293. resources/platforms/zephyr/project/lib/ml_interface/CMakeLists.txt +31 -0
  294. resources/platforms/zephyr/project/lib/ml_interface/default_data.c +8 -0
  295. resources/platforms/zephyr/project/lib/ml_interface/default_model_support/CMakeLists.txt +2 -0
  296. resources/platforms/zephyr/project/lib/ml_interface/default_model_support/process_input.c +17 -0
  297. resources/platforms/zephyr/project/lib/ml_interface/default_model_support/process_output.c +27 -0
  298. resources/platforms/zephyr/project/lib/ml_interface/ml_interface.c +36 -0
  299. resources/platforms/zephyr/project/lib/ml_interface/ml_interface.h +47 -0
  300. resources/platforms/zephyr/project/lib/ml_interface/ml_interface_tflm.cc +22 -0
  301. resources/platforms/zephyr/project/lib/ml_interface/ml_interface_tvm.c +22 -0
  302. resources/platforms/zephyr/project/lib/support/CMakeLists.txt +2 -0
  303. resources/platforms/zephyr/project/lib/support/dummy.c +0 -0
  304. resources/platforms/zephyr/project/lib/support/exit.h +8 -0
  305. resources/platforms/zephyr/project/lib/support/printing.h +11 -0
  306. resources/platforms/zephyr/project/lib/support/quantize.h +23 -0
  307. resources/platforms/zephyr/project/lib/targets/corstone300.c +62 -0
  308. resources/platforms/zephyr/project/lib/targets/default.c +2 -0
  309. resources/platforms/zephyr/project/lib/targets/etiss_pulpino.c +112 -0
  310. resources/platforms/zephyr/project/lib/targets/generic_riscv.c +112 -0
  311. resources/platforms/zephyr/project/lib/targets/riscv_qemu.c +112 -0
  312. resources/platforms/zephyr/project/lib/targets/target.h +2 -0
  313. resources/platforms/zephyr/project/prj.conf +11 -0
  314. resources/platforms/zephyr/project/sample.yaml +19 -0
  315. resources/platforms/zephyr/project/src/main.c +71 -0
  316. resources/platforms/zephyr/project2/CMakeLists.txt +72 -0
  317. resources/platforms/zephyr/project2/Kconfig +101 -0
  318. resources/platforms/zephyr/project2/README.rst +33 -0
  319. resources/platforms/zephyr/project2/cmake/AddAllSubdirs.cmake +21 -0
  320. resources/platforms/zephyr/project2/cmake/ChooseTarget.cmake +22 -0
  321. resources/platforms/zephyr/project2/cmake/LinkTFLite.cmake +223 -0
  322. resources/platforms/zephyr/project2/cmake/LinkTVM.cmake +68 -0
  323. resources/platforms/zephyr/project2/cmake/LookupClang.cmake +41 -0
  324. resources/platforms/zephyr/project2/cmake/backends/tflmc.cmake +5 -0
  325. resources/platforms/zephyr/project2/cmake/backends/tflmi.cmake +5 -0
  326. resources/platforms/zephyr/project2/cmake/backends/tvmaot.cmake +10 -0
  327. resources/platforms/zephyr/project2/cmake/backends/tvmaotplus.cmake +10 -0
  328. resources/platforms/zephyr/project2/cmake/backends/tvmcg.cmake +10 -0
  329. resources/platforms/zephyr/project2/cmake/backends/tvmllvm.cmake +8 -0
  330. resources/platforms/zephyr/project2/cmake/backends/tvmrt.cmake +8 -0
  331. resources/platforms/zephyr/project2/cmake/extras.cmake +9 -0
  332. resources/platforms/zephyr/project2/cmake/features/auto_vectorize_gcc.cmake +65 -0
  333. resources/platforms/zephyr/project2/cmake/features/auto_vectorize_llvm.cmake +20 -0
  334. resources/platforms/zephyr/project2/cmake/features/cmsisnn.cmake +86 -0
  335. resources/platforms/zephyr/project2/cmake/features/muriscvnn.cmake +87 -0
  336. resources/platforms/zephyr/project2/cmake/frameworks/tflm.cmake +1 -0
  337. resources/platforms/zephyr/project2/cmake/frameworks/tflm_mlif.cmake +8 -0
  338. resources/platforms/zephyr/project2/cmake/frameworks/tvm.cmake +1 -0
  339. resources/platforms/zephyr/project2/cmake/frameworks/tvm_mlif.cmake +37 -0
  340. resources/platforms/zephyr/project2/default_data.c +8 -0
  341. resources/platforms/zephyr/project2/default_model_support/CMakeLists.txt +3 -0
  342. resources/platforms/zephyr/project2/default_model_support/process_input.c +17 -0
  343. resources/platforms/zephyr/project2/default_model_support/process_output.c +27 -0
  344. resources/platforms/zephyr/project2/lib/CMakeLists.txt +13 -0
  345. resources/platforms/zephyr/project2/lib/drivers/fake_input.c +10 -0
  346. resources/platforms/zephyr/project2/lib/drivers/fake_input.h +8 -0
  347. resources/platforms/zephyr/project2/lib/support/CMakeLists.txt +2 -0
  348. resources/platforms/zephyr/project2/lib/support/dummy.c +0 -0
  349. resources/platforms/zephyr/project2/lib/support/exit.h +8 -0
  350. resources/platforms/zephyr/project2/lib/support/printing.h +11 -0
  351. resources/platforms/zephyr/project2/lib/support/quantize.h +23 -0
  352. resources/platforms/zephyr/project2/lib/targets/corstone300.c +62 -0
  353. resources/platforms/zephyr/project2/lib/targets/default.c +2 -0
  354. resources/platforms/zephyr/project2/lib/targets/etiss_pulpino.c +112 -0
  355. resources/platforms/zephyr/project2/lib/targets/generic_riscv.c +112 -0
  356. resources/platforms/zephyr/project2/lib/targets/riscv_qemu.c +112 -0
  357. resources/platforms/zephyr/project2/lib/targets/target.h +2 -0
  358. resources/platforms/zephyr/project2/ml_interface.c +36 -0
  359. resources/platforms/zephyr/project2/ml_interface.h +47 -0
  360. resources/platforms/zephyr/project2/ml_interface_tflm.cc +22 -0
  361. resources/platforms/zephyr/project2/ml_interface_tvm.c +22 -0
  362. resources/platforms/zephyr/project2/prj.conf +13 -0
  363. resources/platforms/zephyr/project2/sample.yaml +19 -0
  364. resources/platforms/zephyr/project2/settings.json +6 -0
  365. resources/platforms/zephyr/project2/src/main.c +35 -0
  366. resources/pycharm/.run/README.md +73 -0
  367. resources/pycharm/.run/step1_ init env.run.xml +24 -0
  368. resources/pycharm/.run/step2_ setup.run.xml +25 -0
  369. resources/pycharm/.run/step3_ run resnet on pulpxpulpissimo.run.xml +25 -0
  370. resources/templates/default.yml.j2 +258 -0
  371. resources/templates/dev.yml.j2 +212 -0
  372. resources/templates/minimal.yml.j2 +234 -0
  373. resources/templates/phi.yml.j2 +282 -0
  374. resources/templates/pulp.yml.j2 +267 -0
  375. resources/templates/research.yml.j2 +237 -0
  376. resources/templates/tumeda.yml.j2 +239 -0
@@ -0,0 +1,62 @@
1
+ #include <stdio.h>
2
+
3
+ // DWT (Data Watchpoint and Trace) registers, only exists on ARM Cortex with a
4
+ // DWT unit.
5
+ #define KIN1_DWT_CONTROL (*((volatile uint32_t*)0xE0001000))
6
+
7
+ // DWT Control register.
8
+ #define KIN1_DWT_CYCCNTENA_BIT (1UL << 0)
9
+
10
+ // CYCCNTENA bit in DWT_CONTROL register.
11
+ #define KIN1_DWT_CYCCNT (*((volatile uint32_t*)0xE0001004))
12
+
13
+ // DWT Cycle Counter register.
14
+ #define KIN1_DEMCR (*((volatile uint32_t*)0xE000EDFC))
15
+
16
+ // DEMCR: Debug Exception and Monitor Control Register.
17
+ #define KIN1_TRCENA_BIT (1UL << 24)
18
+
19
+ // Trace enable bit in DEMCR register.
20
+ #define KIN1_LAR (*((volatile uint32_t*)0xE0001FB0))
21
+
22
+ // Unlock access to DWT (ITM, etc.)registers.
23
+ #define KIN1_UnlockAccessToDWT() KIN1_LAR = 0xC5ACCE55;
24
+
25
+ // TRCENA: Enable trace and debug block DEMCR (Debug Exception and Monitor
26
+ // Control Register.
27
+ #define KIN1_InitCycleCounter() KIN1_DEMCR |= KIN1_TRCENA_BIT
28
+
29
+ #define KIN1_ResetCycleCounter() KIN1_DWT_CYCCNT = 0
30
+ #define KIN1_EnableCycleCounter() KIN1_DWT_CONTROL |= KIN1_DWT_CYCCNTENA_BIT
31
+ #define KIN1_DisableCycleCounter() KIN1_DWT_CONTROL &= ~KIN1_DWT_CYCCNTENA_BIT
32
+ #define KIN1_GetCycleCounter() KIN1_DWT_CYCCNT
33
+
34
+ int32_t ticks_per_second() { return 25e6; }
35
+
36
+ int32_t GetCurrentTimeTicks() { return KIN1_GetCycleCounter(); }
37
+
38
+ extern void uart_init(void);
39
+
40
+ static int32_t start_cycles = 0;
41
+
42
+ void init_target() {
43
+ uart_init();
44
+ KIN1_UnlockAccessToDWT();
45
+ KIN1_InitCycleCounter();
46
+ KIN1_ResetCycleCounter();
47
+ KIN1_EnableCycleCounter();
48
+ int32_t ticks = GetCurrentTimeTicks();
49
+ start_cycles = ticks;
50
+ printf("GetCurrentTimeTicks=%ld\n", ticks);
51
+ }
52
+
53
+ void deinit_target() {
54
+ int32_t stop_cycles = GetCurrentTimeTicks();
55
+ int32_t diff_cycles = stop_cycles - start_cycles;
56
+ // int32_t diff_ms = diff_cycles / (ticks_per_second() / 1000);
57
+ // printf("Total Time: %ld ms\n", diff_ms);
58
+ printf("Total Cycles: %ld\n", diff_cycles);
59
+ printf("EXITTHESIM\n");
60
+ while (1)
61
+ ;
62
+ }
@@ -0,0 +1,2 @@
1
+ __attribute__((weak)) void init_target() {}
2
+ __attribute__((weak)) void deinit_target() {}
@@ -0,0 +1,112 @@
1
+ #include <stdio.h>
2
+
3
+ /* How many cycles (rdcycle) per second (OVPsim and Spike). */
4
+ #define RDCYCLE_PER_SECOND 100000000UL
5
+
6
+ /**
7
+ * @brief Returns the number of clock cycles executed by the processor.
8
+ * Overflows after 42.9 seconds on a 100 MIPS and with CPI = 1 (OVPsim).
9
+ */
10
+ static inline uint32_t rdcycle(void) {
11
+ #if defined(__riscv) || defined(__riscv__)
12
+ uint32_t cycles;
13
+ __asm__ volatile("rdcycle %0" : "=r"(cycles));
14
+ return cycles;
15
+ #else
16
+ return 0;
17
+ #endif
18
+ }
19
+
20
+ /**
21
+ * @brief Returns the full 64bit register cycle register, which holds the
22
+ * number of clock cycles executed by the processor.
23
+ */
24
+ static inline uint64_t rdcycle64() {
25
+ #if defined(__riscv) || defined(__riscv__)
26
+ uint32_t cycles;
27
+ uint32_t cyclesh1;
28
+ uint32_t cyclesh2;
29
+
30
+ /* Reads are not atomic. So ensure, that we are never reading inconsistent
31
+ * values from the 64bit hardware register. */
32
+ do {
33
+ __asm__ volatile("rdcycleh %0" : "=r"(cyclesh1));
34
+ __asm__ volatile("rdcycle %0" : "=r"(cycles));
35
+ __asm__ volatile("rdcycleh %0" : "=r"(cyclesh2));
36
+ } while (cyclesh1 != cyclesh2);
37
+
38
+ return (((uint64_t)cyclesh1) << 32) | cycles;
39
+ #else
40
+ return 0;
41
+ #endif
42
+ }
43
+
44
+ /* How many time cycles (rdtime) per second (OVPsim and Spike). */
45
+ #define RDTIME_PER_SECOND 1000000UL
46
+
47
+ /**
48
+ * @brief Returns wall-clock real time that has passed from an arbitrary start time in the past.
49
+ */
50
+ static inline uint32_t rdtime(void) {
51
+ #if defined(__riscv) || defined(__riscv__)
52
+ uint32_t time;
53
+ __asm__ volatile("rdtime %0" : "=r"(time));
54
+ return time;
55
+ #else
56
+ return 0;
57
+ #endif
58
+ }
59
+
60
+ /**
61
+ * @brief Returns the number of instructions retired by the processor.
62
+ */
63
+ static inline uint32_t rdinstret(void) {
64
+ #if defined(__riscv) || defined(__riscv__)
65
+ uint32_t instret;
66
+ __asm__ volatile("rdinstret %0" : "=r"(instret));
67
+ return instret;
68
+ #else
69
+ return 0;
70
+ #endif
71
+ }
72
+
73
+ /**
74
+ * @brief Enables the vector extension (as well as the floating point extension).
75
+ */
76
+ static inline void enable_fext(void)
77
+ {
78
+ #if defined(__riscv) || defined(__riscv__)
79
+ __asm__ volatile("li t0, 1<<13 \n"
80
+ "csrs mstatus, t0 \n" ::
81
+ : "t0");
82
+ #endif
83
+ }
84
+
85
+ /**
86
+ * @brief Enables the vector extension (as well as the floating point extension).
87
+ */
88
+ static inline void enable_vext(void)
89
+ {
90
+ #if defined(__riscv) || defined(__riscv__)
91
+ __asm__ volatile("li t0, 1<<9+1<<13 \n"
92
+ "csrs mstatus, t0 \n" ::
93
+ : "t0");
94
+ #endif
95
+ }
96
+
97
+ static uint64_t start_cycles = 0;
98
+
99
+ void init_target() {
100
+ // enable_fext();
101
+ #ifdef USE_VEXT
102
+ // enable_vext();
103
+ #endif
104
+ start_cycles = rdcycle64();
105
+ }
106
+
107
+ void deinit_target() {
108
+ uint64_t stop_cycles = rdcycle64();
109
+ uint64_t diff_cycles = stop_cycles - start_cycles;
110
+ float diff_ms = 0; // unimplemented (see RDCYCLE_PER_SECOND)
111
+ printf("Total Cycles: %lld\n", stop_cycles - start_cycles);
112
+ }
@@ -0,0 +1,112 @@
1
+ #include <stdio.h>
2
+
3
+ /* How many cycles (rdcycle) per second (OVPsim and Spike). */
4
+ #define RDCYCLE_PER_SECOND 100000000UL
5
+
6
+ /**
7
+ * @brief Returns the number of clock cycles executed by the processor.
8
+ * Overflows after 42.9 seconds on a 100 MIPS and with CPI = 1 (OVPsim).
9
+ */
10
+ static inline uint32_t rdcycle(void) {
11
+ #if defined(__riscv) || defined(__riscv__)
12
+ uint32_t cycles;
13
+ __asm__ volatile("rdcycle %0" : "=r"(cycles));
14
+ return cycles;
15
+ #else
16
+ return 0;
17
+ #endif
18
+ }
19
+
20
+ /**
21
+ * @brief Returns the full 64bit register cycle register, which holds the
22
+ * number of clock cycles executed by the processor.
23
+ */
24
+ static inline uint64_t rdcycle64() {
25
+ #if defined(__riscv) || defined(__riscv__)
26
+ uint32_t cycles;
27
+ uint32_t cyclesh1;
28
+ uint32_t cyclesh2;
29
+
30
+ /* Reads are not atomic. So ensure, that we are never reading inconsistent
31
+ * values from the 64bit hardware register. */
32
+ do {
33
+ __asm__ volatile("rdcycleh %0" : "=r"(cyclesh1));
34
+ __asm__ volatile("rdcycle %0" : "=r"(cycles));
35
+ __asm__ volatile("rdcycleh %0" : "=r"(cyclesh2));
36
+ } while (cyclesh1 != cyclesh2);
37
+
38
+ return (((uint64_t)cyclesh1) << 32) | cycles;
39
+ #else
40
+ return 0;
41
+ #endif
42
+ }
43
+
44
+ /* How many time cycles (rdtime) per second (OVPsim and Spike). */
45
+ #define RDTIME_PER_SECOND 1000000UL
46
+
47
+ /**
48
+ * @brief Returns wall-clock real time that has passed from an arbitrary start time in the past.
49
+ */
50
+ static inline uint32_t rdtime(void) {
51
+ #if defined(__riscv) || defined(__riscv__)
52
+ uint32_t time;
53
+ __asm__ volatile("rdtime %0" : "=r"(time));
54
+ return time;
55
+ #else
56
+ return 0;
57
+ #endif
58
+ }
59
+
60
+ /**
61
+ * @brief Returns the number of instructions retired by the processor.
62
+ */
63
+ static inline uint32_t rdinstret(void) {
64
+ #if defined(__riscv) || defined(__riscv__)
65
+ uint32_t instret;
66
+ __asm__ volatile("rdinstret %0" : "=r"(instret));
67
+ return instret;
68
+ #else
69
+ return 0;
70
+ #endif
71
+ }
72
+
73
+ /**
74
+ * @brief Enables the vector extension (as well as the floating point extension).
75
+ */
76
+ static inline void enable_fext(void)
77
+ {
78
+ #if defined(__riscv) || defined(__riscv__)
79
+ __asm__ volatile("li t0, 1<<13 \n"
80
+ "csrs mstatus, t0 \n" ::
81
+ : "t0");
82
+ #endif
83
+ }
84
+
85
+ /**
86
+ * @brief Enables the vector extension (as well as the floating point extension).
87
+ */
88
+ static inline void enable_vext(void)
89
+ {
90
+ #if defined(__riscv) || defined(__riscv__)
91
+ __asm__ volatile("li t0, 1<<9+1<<13 \n"
92
+ "csrs mstatus, t0 \n" ::
93
+ : "t0");
94
+ #endif
95
+ }
96
+
97
+ static uint64_t start_cycles = 0;
98
+
99
+ void init_target() {
100
+ // enable_fext();
101
+ #ifdef USE_VEXT
102
+ // enable_vext();
103
+ #endif
104
+ start_cycles = rdcycle64();
105
+ }
106
+
107
+ void deinit_target() {
108
+ uint64_t stop_cycles = rdcycle64();
109
+ uint64_t diff_cycles = stop_cycles - start_cycles;
110
+ float diff_ms = 0; // unimplemented (see RDCYCLE_PER_SECOND)
111
+ printf("Total Cycles: %lld\n", stop_cycles - start_cycles);
112
+ }
@@ -0,0 +1,112 @@
1
+ #include <stdio.h>
2
+
3
+ /* How many cycles (rdcycle) per second (OVPsim and Spike). */
4
+ #define RDCYCLE_PER_SECOND 100000000UL
5
+
6
+ /**
7
+ * @brief Returns the number of clock cycles executed by the processor.
8
+ * Overflows after 42.9 seconds on a 100 MIPS and with CPI = 1 (OVPsim).
9
+ */
10
+ static inline uint32_t rdcycle(void) {
11
+ #if defined(__riscv) || defined(__riscv__)
12
+ uint32_t cycles;
13
+ __asm__ volatile("rdcycle %0" : "=r"(cycles));
14
+ return cycles;
15
+ #else
16
+ return 0;
17
+ #endif
18
+ }
19
+
20
+ /**
21
+ * @brief Returns the full 64bit register cycle register, which holds the
22
+ * number of clock cycles executed by the processor.
23
+ */
24
+ static inline uint64_t rdcycle64() {
25
+ #if defined(__riscv) || defined(__riscv__)
26
+ uint32_t cycles;
27
+ uint32_t cyclesh1;
28
+ uint32_t cyclesh2;
29
+
30
+ /* Reads are not atomic. So ensure, that we are never reading inconsistent
31
+ * values from the 64bit hardware register. */
32
+ do {
33
+ __asm__ volatile("rdcycleh %0" : "=r"(cyclesh1));
34
+ __asm__ volatile("rdcycle %0" : "=r"(cycles));
35
+ __asm__ volatile("rdcycleh %0" : "=r"(cyclesh2));
36
+ } while (cyclesh1 != cyclesh2);
37
+
38
+ return (((uint64_t)cyclesh1) << 32) | cycles;
39
+ #else
40
+ return 0;
41
+ #endif
42
+ }
43
+
44
+ /* How many time cycles (rdtime) per second (OVPsim and Spike). */
45
+ #define RDTIME_PER_SECOND 1000000UL
46
+
47
+ /**
48
+ * @brief Returns wall-clock real time that has passed from an arbitrary start time in the past.
49
+ */
50
+ static inline uint32_t rdtime(void) {
51
+ #if defined(__riscv) || defined(__riscv__)
52
+ uint32_t time;
53
+ __asm__ volatile("rdtime %0" : "=r"(time));
54
+ return time;
55
+ #else
56
+ return 0;
57
+ #endif
58
+ }
59
+
60
+ /**
61
+ * @brief Returns the number of instructions retired by the processor.
62
+ */
63
+ static inline uint32_t rdinstret(void) {
64
+ #if defined(__riscv) || defined(__riscv__)
65
+ uint32_t instret;
66
+ __asm__ volatile("rdinstret %0" : "=r"(instret));
67
+ return instret;
68
+ #else
69
+ return 0;
70
+ #endif
71
+ }
72
+
73
+ /**
74
+ * @brief Enables the vector extension (as well as the floating point extension).
75
+ */
76
+ static inline void enable_fext(void)
77
+ {
78
+ #if defined(__riscv) || defined(__riscv__)
79
+ __asm__ volatile("li t0, 1<<13 \n"
80
+ "csrs mstatus, t0 \n" ::
81
+ : "t0");
82
+ #endif
83
+ }
84
+
85
+ /**
86
+ * @brief Enables the vector extension (as well as the floating point extension).
87
+ */
88
+ static inline void enable_vext(void)
89
+ {
90
+ #if defined(__riscv) || defined(__riscv__)
91
+ __asm__ volatile("li t0, 1<<9+1<<13 \n"
92
+ "csrs mstatus, t0 \n" ::
93
+ : "t0");
94
+ #endif
95
+ }
96
+
97
+ static uint64_t start_cycles = 0;
98
+
99
+ void init_target() {
100
+ enable_fext();
101
+ #ifdef USE_VEXT
102
+ enable_vext();
103
+ #endif
104
+ start_cycles = rdcycle64();
105
+ }
106
+
107
+ void deinit_target() {
108
+ uint64_t stop_cycles = rdcycle64();
109
+ uint64_t diff_cycles = stop_cycles - start_cycles;
110
+ float diff_ms = 0; // unimplemented (see RDCYCLE_PER_SECOND)
111
+ printf("Total Cycles: %lld\n", stop_cycles - start_cycles);
112
+ }
@@ -0,0 +1,2 @@
1
+ void init_target();
2
+ void deinit_target();
@@ -0,0 +1,11 @@
1
+ CONFIG_NEWLIB_LIBC=n
2
+ CONFIG_MLONMCU_FRAMEWORK="tvm"
3
+ CONFIG_MLONMCU_BACKEND="tvmaot"
4
+ CONFIG_TVM_DIR="/nas/ei/share/TUEIEDAscratch/ga87puy/work/mlonmcu/workspace/deps/src/tvm"
5
+ CONFIG_TF_DIR="?"
6
+ CONFIG_MLONMCU_CODEGEN_DIR="/work/tools/zephyr_stuff/run/"
7
+ CONFIG_CPLUSPLUS=y
8
+ CONFIG_STD_CPP17=y
9
+ CONFIG_LIB_CPLUSPLUS=y
10
+ CONFIG_EXCEPTIONS=y
11
+ CONFIG_REBOOT=y
@@ -0,0 +1,19 @@
1
+ sample:
2
+ description: Hello World sample, the simplest Zephyr
3
+ application
4
+ name: hello world
5
+ common:
6
+ tags: introduction
7
+ integration_platforms:
8
+ - native_posix
9
+ harness: console
10
+ harness_config:
11
+ type: one_line
12
+ regex:
13
+ - "Hello World! (.*)"
14
+ tests:
15
+ sample.basic.helloworld:
16
+ tags: introduction
17
+ sample.basic.helloworld.uefi:
18
+ platform_allow: qemu_x86_64
19
+ extra_args: CONF_FILE=prj_uefi.conf
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Copyright (c) 2012-2014 Wind River Systems, Inc.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ #include <zephyr.h>
8
+ #include <stdint.h>
9
+ #include <sys/printk.h>
10
+ #include <sys/reboot.h>
11
+ #include <timing/timing.h>
12
+ // #include <zephyr/kernel.h>
13
+
14
+ // void init_target();
15
+ // void deinit_target();
16
+
17
+ int main() {
18
+ // init_target();
19
+ timing_init();
20
+ timing_start();
21
+ printk("MLonMCU: START\n");
22
+ // uint32_t start_time;
23
+ // uint32_t start_time_;
24
+ // uint32_t stop_time;
25
+ // uint32_t stop_time_;
26
+ // uint32_t cycles_spent;
27
+ // uint64_t cycles_spent_;
28
+ // uint32_t nanoseconds_spent;
29
+ // uint64_t nanoseconds_spent_;
30
+ /* capture initial time stamp */
31
+ // start_time = k_cycle_get_32();
32
+ // start_time_ = k_cycle_get_64();
33
+ timing_t start_time, end_time;
34
+ // printk("start_time_=%llu", start_time_);
35
+ start_time = timing_counter_get();
36
+ mlif_run();
37
+ // stop_time = k_cycle_get_32();
38
+ // stop_time_ = k_cycle_get_64();
39
+ end_time = timing_counter_get();
40
+ uint64_t cycles = timing_cycles_get(&start_time, &end_time);
41
+ uint64_t ns_spent = timing_cycles_to_ns(cycles);
42
+ // printk("stop_time_=%llu", stop_time_);
43
+
44
+ /* compute how long the work took (assumes no counter rollover) */
45
+ // if (start_time >= stop_time) {
46
+ // cycles_spent_ = stop_time - start_time;
47
+ // } else {
48
+ // cycles_spent_ = stop_time + ((1 << 31) - start_time);
49
+ // }
50
+ // cycles_spent_ = stop_time_ - start_time_;
51
+ // nanoseconds_spent = k_cyc_to_ns_ceil32(cycles_spent);
52
+ // nanoseconds_spent_ = k_cyc_to_ns_ceil64(cycles_spent_);
53
+ // printk("Total Time: %u us\n", (uint32_t) (nanoseconds_spent/1000));
54
+ printk("Total Time: %llu us\n", (ns_spent/1000));
55
+ // printk("Total Cycles: %u\n", cycles_spent);
56
+ printk("Total Cycles: %llu\n", cycles);
57
+ printk("MLonMCU: STOP\n");
58
+ // deinit_target();
59
+ sys_reboot(0);
60
+ return 0;
61
+ }
62
+ //
63
+ // /* do work for some (short) period of time */
64
+ // ...
65
+ //
66
+ // /* capture final time stamp */
67
+ // stop_time = k_cycle_get_32();
68
+ //
69
+ // /* compute how long the work took (assumes no counter rollover) */
70
+ // cycles_spent = stop_time - start_time;
71
+ // nanoseconds_spent = SYS_CLOCK_HW_CYCLES_TO_NS(cycles_spent);
@@ -0,0 +1,72 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ cmake_minimum_required(VERSION 3.20.0)
4
+
5
+ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6
+ project(mlonmcu_template)
7
+ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
8
+
9
+ SET(TVM_ALIGNMENT_BYTES 4)
10
+
11
+ # cmake-format: off
12
+ SET(TVM_HEADERS
13
+ ${CONFIG_TVM_DIR}/include
14
+ ${CONFIG_TVM_DIR}/3rdparty/dlpack/include
15
+ ${CONFIG_TVM_DIR}/apps/bundle_deploy
16
+ ${CONFIG_TVM_DIR}/src/runtime/crt/include
17
+ )
18
+ # cmake-format: on
19
+
20
+ IF(CONFIG_TVM_CRT_CONFIG_DIR)
21
+ LIST(APPEND TVM_HEADERS ${CONFIG_TVM_CRT_CONFIG_DIR})
22
+ ELSE()
23
+ LIST(APPEND TVM_HEADERS ${CONFIG_TVM_DIR}/apps/bundle_deploy/crt_config)
24
+ ENDIF()
25
+
26
+ INCLUDE(backends/${CONFIG_MLONMCU_BACKEND})
27
+ INCLUDE(frameworks/${CONFIG_MLONMCU_FRAMEWORK})
28
+
29
+ TARGET_INCLUDE_DIRECTORIES(app PUBLIC ${TVM_HEADERS})
30
+
31
+ TARGET_COMPILE_DEFINITIONS(app PUBLIC
32
+ -DTVM_RUNTIME_ALLOC_ALIGNMENT_BYTES=${TVM_ALIGNMENT_BYTES}
33
+ )
34
+
35
+
36
+
37
+ INCLUDE(extras)
38
+
39
+ INCLUDE(frameworks/${CONFIG_MLONMCU_FRAMEWORK}_mlif)
40
+
41
+ IF(CONFIG_MODEL_DIR)
42
+ GET_FILENAME_COMPONENT(MODEL_SUPPORT_DIR ${CONFIG_MODEL_DIR}/support REALPATH)
43
+ GET_FILENAME_COMPONENT(MODEL_NAME ${CONFIG_MODEL_DIR} NAME)
44
+ ENDIF()
45
+
46
+ IF(MODEL_SUPPORT_DIR AND EXISTS ${MODEL_SUPPORT_DIR})
47
+ ADD_SUBDIRECTORY(${MODEL_SUPPORT_DIR} model_support_bin_${MODEL_NAME})
48
+ ELSE()
49
+ ADD_SUBDIRECTORY(default_model_support)
50
+ ENDIF()
51
+
52
+ IF(NOT CONFIG_DATA_SRC)
53
+ SET(CONFIG_DATA_SRC "default_data.c")
54
+ ENDIF()
55
+
56
+ IF(CONFIG_NUM_RUNS)
57
+ TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PUBLIC NUM_RUNS=${CONFIG_NUM_RUNS})
58
+ ENDIF()
59
+
60
+ TARGET_INCLUDE_DIRECTORIES(app PUBLIC ${TVM_HEADERS} ${TVM_OUT_DIR}/include ${CONFIG_MLONMCU_CODEGEN_DIR} lib/support)
61
+ SET(TVM_WRAPPER_FILENAME aot_wrapper.c)
62
+ SET(EXTRA_SRC ${EXTRA_SRC} ${CONFIG_MLONMCU_CODEGEN_DIR}/${TVM_WRAPPER_FILENAME})
63
+ target_sources(app PRIVATE
64
+ src/main.c
65
+ ml_interface.c
66
+ ${CONFIG_TVM_DIR}/src/runtime/crt/common/crt_backend_api.c
67
+ ${CONFIG_TVM_DIR}/src/runtime/crt/memory/stack_allocator.c
68
+ ${CONFIG_DATA_SRC}
69
+ ${EXTRA_SRC}
70
+ ${TVM_SRCS}
71
+ )
72
+ target_link_libraries(app PRIVATE model_support)
@@ -0,0 +1,101 @@
1
+ mainmenu "MLonMCU"
2
+
3
+ source "Kconfig.zephyr"
4
+ menu "MLonMCU Options"
5
+
6
+ config MLONMCU_CODEGEN_DIR
7
+ string "Codegen Directory"
8
+ default "$(CODEGEN_SRC)"
9
+ help
10
+ Path to the directory with the codegen results.
11
+
12
+ # choice MLONMCU_FRAMEWORK
13
+ # prompt "MLonMCU framework"
14
+ # default MLONMCU_FRAMEWORK_TFLM
15
+ # help
16
+ # Choose a MLonMCU framework from the list.
17
+
18
+ # config MLONMCU_FRAMEWORK_TFLM
19
+ # bool "TFLite Micro"
20
+ # config MLONMCU_FRAMEWORK_TVM
21
+ # bool "TVM"
22
+ # endchoice
23
+
24
+ config MLONMCU_FRAMEWORK
25
+ string "Ued Framework"
26
+ # default "tflm" if MLONMCU_FRAMEWORK_TFLM
27
+ # default "tvm" if MLONMCU_FRAMEWORK_TVM
28
+ default "none"
29
+ help
30
+ TODO
31
+
32
+ # choice MLONMCU_BACKEND
33
+ # prompt "MLonMCU backend"
34
+ # default MLONMCU_BACKEND_TFLMI if MLONMCU_FRAMEWORK_TFLM
35
+ # default MLONMCU_BACKEND_TVMAOT if MLONMCU_FRAMEWORK_TVM
36
+ # help
37
+ # Choose a MLonMCU backend for the chosen framwork.
38
+
39
+ # config MLONMCU_BACKEND_TFLMI
40
+ # bool "TFLite Micro Default Interpreter"
41
+ # depends on MLONMCU_FRAMEWORK_TFLM
42
+ # config MLONMCU_BACKEND_TFLMC
43
+ # bool "TFLite Micro Compiler"
44
+ # depends on MLONMCU_FRAMEWORK_TFLM
45
+ # config MLONMCU_BACKEND_TVMAOT
46
+ # bool "TVM AoT Executor"
47
+ # depends on MLONMCU_FRAMEWORK_TVM
48
+ # config MLONMCU_BACKEND_TVMRT
49
+ # bool "TVM Graph Executor"
50
+ # depends on MLONMCU_FRAMEWORK_TVM
51
+ # config MLONMCU_BACKEND_TVMCG
52
+ # bool "TVM Custom Codegenerator"
53
+ # depends on MLONMCU_FRAMEWORK_TVM
54
+ # endchoice
55
+
56
+ config MLONMCU_BACKEND
57
+ string "Used backend"
58
+ default "none"
59
+ help
60
+ TODO
61
+
62
+ config MLONMCU_NUM_RUNS
63
+ int "Number of inferences"
64
+ default 1
65
+ help
66
+ How many times the network should be invoked. A negative value maps to a infinite number of runs.
67
+
68
+ config MLONMCU_VALIDATE
69
+ bool "Validate model output data"
70
+ default false
71
+ help
72
+ Compare model outputs with expected results (if available). Only works in DEBUG mode.
73
+
74
+ config MLONMCU_MODLE_DIR
75
+ string "Model Directory"
76
+ depends on MLONMCU_VALIDATE
77
+ default "$(MODEL_DIR)"
78
+ help
79
+ Directory where model support code and reference data can be found.
80
+ endmenu
81
+
82
+ menu "TVM Build Options"
83
+ config TVM_DIR
84
+ string "Path to TVM"
85
+ default "$(TVM_SRC)"
86
+ help
87
+ TVM directory path.
88
+ config TVM_CRT_CONFIG_DIR
89
+ string "Path to TVM CRT config directory"
90
+ default ""
91
+ help
92
+ TVM crt path.
93
+ endmenu
94
+ menu "TFLite Micro Build Options"
95
+
96
+ config TF_DIR
97
+ string "Path to TFLite Micro"
98
+ default "$(TF_SRC)"
99
+ help
100
+ TFLite Micro directory path.
101
+ endmenu