mkatanbaf commented on code in PR #12390:
URL: https://github.com/apache/tvm/pull/12390#discussion_r948330866


##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -195,6 +195,30 @@ def _get_device_args(options):
     )
 
 
+def _get_board_mem_size(options):
+    board_file_path = (
+        pathlib.Path(get_zephyr_base(options))
+        / "boards"
+        / "arm"
+        / options["zephyr_board"]
+        / (options["zephyr_board"] + ".yaml")
+    )
+    try:
+        with open(board_file_path) as f:
+            board_data = yaml.load(f, Loader=yaml.FullLoader)
+            return int(board_data["ram"]) * 1024
+    except:
+        _LOG.warning("Board memory information is not available.")
+    return None
+
+
+def _get_recommended_heap_size(options):
+    prop = BOARD_PROPERTIES[options["zephyr_board"]]
+    if "recommended_heap_size" in prop:
+        return prop["recommended_heap_size"]
+    return 216 * 1024

Review Comment:
   done



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -589,6 +619,14 @@ def generate_project(self, model_library_format_path, 
standalone_crt_dir, projec
 
                     cmake_f.write(line)
 
+                heap_size = _get_recommended_heap_size(options)
+                if options.get("heap_size"):
+                    board_mem_size = _get_board_mem_size(options)
+                    if board_mem_size is not None:
+                        assert options["heap_size"] < board_mem_size, "heap 
size is too large"

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to