You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/08/17 18:00:01 UTC

[GitHub] [tvm] mehrdadh commented on a diff in pull request #12390: [MicroTVM] add heap-size to project options

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


##########
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:
   make error message more clear? `Heap size (options["heap_size"]) is larger than memory size (board_mem_size) on this board.`



##########
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:
   change this value to a global constant with capital letters for better readability.



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org