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/09/02 05:22:35 UTC

[GitHub] [tvm] guberti commented on a diff in pull request #12495: [microTVM] add the option to open a saved micro project for debugging

guberti commented on code in PR #12495:
URL: https://github.com/apache/tvm/pull/12495#discussion_r961294102


##########
python/tvm/micro/session.py:
##########
@@ -259,6 +259,8 @@ def compile_and_create_micro_session(
     mod_src_bytes: bytes,
     template_project_dir: str,
     project_options: dict = None,
+    build_dir: str = None,
+    debug: bool = False,

Review Comment:
   I like `reuse_project` or `use_existing`. I also agree that deriving this property from `build_dir` would cause confusion.



##########
python/tvm/micro/build.py:
##########
@@ -123,9 +123,15 @@ class AutoTvmModuleLoader:
     """
 
     def __init__(
-        self, template_project_dir: Union[pathlib.Path, str], project_options: dict = None
+        self,
+        template_project_dir: Union[pathlib.Path, str],
+        project_options: dict = None,
+        build_dir: str = None,

Review Comment:
   Can we give `build_dir` a path-like object type instead of just `str`? i.e. `Union[os.PathLike, str]`?



##########
python/tvm/micro/testing/evaluation.py:
##########
@@ -124,21 +124,32 @@ def create_aot_session(
     parameter_size = len(tvm.runtime.save_param_dict(lowered.get_params()))
     print(f"Model parameter size: {parameter_size}")
 
-    project = tvm.micro.generate_project(
-        str(tvm.micro.get_microtvm_template_projects(platform)),
-        lowered,
-        build_dir / "project",
-        {
-            f"{platform}_board": board,
-            "project_type": "host_driven",
-            # {} shouldn't be the default value for project options ({}
-            # is mutable), so we use this workaround
-            **(project_options or {}),
-        },
-    )
-    project.build()
-    project.flash()
+    if debug:
+        project = tvm.micro.GeneratedProject.from_directory(
+            str(build_dir / "project"),
+            options={
+                f"{platform}_board": board,
+                "project_type": "host_driven",
+                **(project_options or {}),
+            },
+        )
 
+    else:
+        project = tvm.micro.generate_project(
+            str(tvm.micro.get_microtvm_template_projects(platform)),
+            lowered,
+            build_dir / "project",
+            {
+                f"{platform}_board": board,
+                "project_type": "host_driven",
+                # {} shouldn't be the default value for project options ({}
+                # is mutable), so we use this workaround
+                **(project_options or {}),

Review Comment:
   Can we store these in a variable (e.g. `project_options`) so this code isn't duplicated between the `if` and `else` statements?



-- 
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