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/07/27 22:22:35 UTC

[GitHub] [tvm] mehrdadh opened a new pull request, #12209: [microTVM][Zephyr][projectAPI] Minimize project build commands

mehrdadh opened a new pull request, #12209:
URL: https://github.com/apache/tvm/pull/12209

   This PR changes Zephyr template project to populate all configs in Cmake file and minimize the command to build the project.
   
   Before this PR we had to do this:
   ```
   cmake -DARG1 -DARG2 ..
   cd build
   make -j2
   ```
   
   After this PR:
   ```
   cmake ..
   cd build
   make -j2
   ```
   
   cc @gromero @guberti 


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


[GitHub] [tvm] gromero commented on a diff in pull request #12209: [microTVM][Zephyr][projectAPI] Minimize project build commands

Posted by GitBox <gi...@apache.org>.
gromero commented on code in PR #12209:
URL: https://github.com/apache/tvm/pull/12209#discussion_r932730386


##########
tests/micro/common/test_tvmc.py:
##########
@@ -53,7 +53,10 @@ def test_tvmc_exist(platform, board):
 @tvm.testing.requires_micro
 @pytest.mark.parametrize(
     "output_dir,",
-    [pathlib.Path("./tvmc_relative_path_test"), pathlib.Path(tempfile.mkdtemp())],
+    [
+        pathlib.Path("./tvmc_relative_path_test"),
+        # pathlib.Path(tempfile.mkdtemp())

Review Comment:
   Is that line really to be a comment? 



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


[GitHub] [tvm] mehrdadh commented on a diff in pull request #12209: [microTVM][Zephyr][projectAPI] Minimize project build commands

Posted by GitBox <gi...@apache.org>.
mehrdadh commented on code in PR #12209:
URL: https://github.com/apache/tvm/pull/12209#discussion_r932733790


##########
tests/micro/common/test_tvmc.py:
##########
@@ -53,7 +53,10 @@ def test_tvmc_exist(platform, board):
 @tvm.testing.requires_micro
 @pytest.mark.parametrize(
     "output_dir,",
-    [pathlib.Path("./tvmc_relative_path_test"), pathlib.Path(tempfile.mkdtemp())],
+    [
+        pathlib.Path("./tvmc_relative_path_test"),
+        # pathlib.Path(tempfile.mkdtemp())

Review Comment:
   thanks for catching, fixed it



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


[GitHub] [tvm] gromero commented on a diff in pull request #12209: [microTVM][Zephyr][projectAPI] Minimize project build commands

Posted by GitBox <gi...@apache.org>.
gromero commented on code in PR #12209:
URL: https://github.com/apache/tvm/pull/12209#discussion_r932596942


##########
gallery/how_to/work_with_microtvm/micro_tvmc.sh:
##########
@@ -121,7 +121,9 @@ tvmc compile magic_wand.tflite \
 #
 # To generate a Zephyr project we use TVM Micro subcommand ``create``. We pass the MLF format and the path
 # for the project to ``create`` subcommand along with project options. Project options for each
-# platform (Zephyr/Arduino) are defined in their Project API server file. To generate Zephyr project, run:
+# platform (Zephyr/Arduino) are defined in their Project API server file. To build
+# Zephyr project for a different Zephyr board, change ``zephyr_board`` project option. 

Review Comment:
   Please remove the trailing space in this line.



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -419,7 +419,7 @@ def _create_prj_conf(self, project_dir, options):
             f.write("\n")
 
     API_SERVER_CRT_LIBS_TOKEN = "<API_SERVER_CRT_LIBS>"
-    ENABLE_CMSIS_TOKEN = "<ENABLE_CMSIS>"
+    CMAKE_ARGS = "<CMAKE_ARGS>"

Review Comment:
   I'd like to use  `CMAKE_ARGS_TOKEN` as the var name here , with `_TOKEN` at the end, like it was before for the `ENABLE_CMSIS_TOKEN` var. 



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


[GitHub] [tvm] gromero commented on pull request #12209: [microTVM][Zephyr][projectAPI] Minimize project build commands

Posted by GitBox <gi...@apache.org>.
gromero commented on PR #12209:
URL: https://github.com/apache/tvm/pull/12209#issuecomment-1198556164

   Otherwise, LGTM :+1: 


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


[GitHub] [tvm] gromero commented on a diff in pull request #12209: [microTVM][Zephyr][projectAPI] Minimize project build commands

Posted by GitBox <gi...@apache.org>.
gromero commented on code in PR #12209:
URL: https://github.com/apache/tvm/pull/12209#discussion_r932599885


##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -576,22 +578,33 @@ def build(self, options):
     _KNOWN_QEMU_ZEPHYR_BOARDS = ("mps2_an521", "mps3_an547")
 
     @classmethod
-    def _is_qemu(cls, options):
-        return (
-            "qemu" in options["zephyr_board"]
-            or options["zephyr_board"] in cls._KNOWN_QEMU_ZEPHYR_BOARDS
-        )
+    def _is_qemu(cls, board: str) -> bool:
+        return "qemu" in board or board in cls._KNOWN_QEMU_ZEPHYR_BOARDS
 
     @classmethod
     def _has_fpu(cls, zephyr_board):
         fpu_boards = [name for name, board in BOARD_PROPERTIES.items() if board["fpu"]]
         return zephyr_board in fpu_boards
 
+    @classmethod
+    def _find_board_from_cmake_file(cls) -> str:
+        with open(API_SERVER_DIR / CMAKELIST_FILENAME) as cmake_f:
+            for line in cmake_f:
+                if line.startswith("set(BOARD"):
+                    zephyr_board = line.strip("\n").strip("set(BOARD ").strip(")")
+                    break
+
+        if not zephyr_board:
+            raise RuntimeError(
+                f"Zephyr Board is not found in the {API_SERVER_DIR / CMAKELIST_FILENAME}"

Review Comment:
   Could this message be changed to `"No Zephyr board defined in the {API_SERVER_DIR / CMAKELIST_FILENAME}"` ? Or `"set in the ...`" ?
   



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -576,22 +578,33 @@ def build(self, options):
     _KNOWN_QEMU_ZEPHYR_BOARDS = ("mps2_an521", "mps3_an547")
 
     @classmethod
-    def _is_qemu(cls, options):
-        return (
-            "qemu" in options["zephyr_board"]
-            or options["zephyr_board"] in cls._KNOWN_QEMU_ZEPHYR_BOARDS
-        )
+    def _is_qemu(cls, board: str) -> bool:
+        return "qemu" in board or board in cls._KNOWN_QEMU_ZEPHYR_BOARDS
 
     @classmethod
     def _has_fpu(cls, zephyr_board):
         fpu_boards = [name for name, board in BOARD_PROPERTIES.items() if board["fpu"]]
         return zephyr_board in fpu_boards
 
+    @classmethod
+    def _find_board_from_cmake_file(cls) -> str:
+        with open(API_SERVER_DIR / CMAKELIST_FILENAME) as cmake_f:
+            for line in cmake_f:
+                if line.startswith("set(BOARD"):
+                    zephyr_board = line.strip("\n").strip("set(BOARD ").strip(")")
+                    break
+
+        if not zephyr_board:

Review Comment:
   if no line starting with `set(BOARD`  is found here `zephyr_board` will be left undefined so `if not zephyr_board` will fail with `ErrorName`: var is not defined in `if` in line 597. So `zephyr_board = None` should be set just before `with` statement?



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


[GitHub] [tvm] mehrdadh merged pull request #12209: [microTVM][Zephyr][projectAPI] Minimize project build commands

Posted by GitBox <gi...@apache.org>.
mehrdadh merged PR #12209:
URL: https://github.com/apache/tvm/pull/12209


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


[GitHub] [tvm] mehrdadh commented on a diff in pull request #12209: [microTVM][Zephyr][projectAPI] Minimize project build commands

Posted by GitBox <gi...@apache.org>.
mehrdadh commented on code in PR #12209:
URL: https://github.com/apache/tvm/pull/12209#discussion_r932716050


##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -576,22 +578,33 @@ def build(self, options):
     _KNOWN_QEMU_ZEPHYR_BOARDS = ("mps2_an521", "mps3_an547")
 
     @classmethod
-    def _is_qemu(cls, options):
-        return (
-            "qemu" in options["zephyr_board"]
-            or options["zephyr_board"] in cls._KNOWN_QEMU_ZEPHYR_BOARDS
-        )
+    def _is_qemu(cls, board: str) -> bool:
+        return "qemu" in board or board in cls._KNOWN_QEMU_ZEPHYR_BOARDS
 
     @classmethod
     def _has_fpu(cls, zephyr_board):
         fpu_boards = [name for name, board in BOARD_PROPERTIES.items() if board["fpu"]]
         return zephyr_board in fpu_boards
 
+    @classmethod
+    def _find_board_from_cmake_file(cls) -> str:
+        with open(API_SERVER_DIR / CMAKELIST_FILENAME) as cmake_f:
+            for line in cmake_f:
+                if line.startswith("set(BOARD"):
+                    zephyr_board = line.strip("\n").strip("set(BOARD ").strip(")")
+                    break
+
+        if not zephyr_board:
+            raise RuntimeError(
+                f"Zephyr Board is not found in the {API_SERVER_DIR / CMAKELIST_FILENAME}"

Review Comment:
   done



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -576,22 +578,33 @@ def build(self, options):
     _KNOWN_QEMU_ZEPHYR_BOARDS = ("mps2_an521", "mps3_an547")
 
     @classmethod
-    def _is_qemu(cls, options):
-        return (
-            "qemu" in options["zephyr_board"]
-            or options["zephyr_board"] in cls._KNOWN_QEMU_ZEPHYR_BOARDS
-        )
+    def _is_qemu(cls, board: str) -> bool:
+        return "qemu" in board or board in cls._KNOWN_QEMU_ZEPHYR_BOARDS
 
     @classmethod
     def _has_fpu(cls, zephyr_board):
         fpu_boards = [name for name, board in BOARD_PROPERTIES.items() if board["fpu"]]
         return zephyr_board in fpu_boards
 
+    @classmethod
+    def _find_board_from_cmake_file(cls) -> str:
+        with open(API_SERVER_DIR / CMAKELIST_FILENAME) as cmake_f:
+            for line in cmake_f:
+                if line.startswith("set(BOARD"):
+                    zephyr_board = line.strip("\n").strip("set(BOARD ").strip(")")
+                    break
+
+        if not zephyr_board:

Review Comment:
   great catch!



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -419,7 +419,7 @@ def _create_prj_conf(self, project_dir, options):
             f.write("\n")
 
     API_SERVER_CRT_LIBS_TOKEN = "<API_SERVER_CRT_LIBS>"
-    ENABLE_CMSIS_TOKEN = "<ENABLE_CMSIS>"
+    CMAKE_ARGS = "<CMAKE_ARGS>"

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

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