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/05/24 08:47:24 UTC

[GitHub] [tvm] Mousius commented on a diff in pull request #11427: [TVMC] Workspace Pools Parameters

Mousius commented on code in PR #11427:
URL: https://github.com/apache/tvm/pull/11427#discussion_r880228493


##########
tests/python/driver/tvmc/test_command_line.py:
##########
@@ -155,3 +162,39 @@ def test_tvmc_tune_file_check(capsys, invalid_input):
     )
     on_assert_error = f"'tvmc tune' failed to check invalid FILE: {invalid_input}"
     assert captured.err == expected_err, on_assert_error
+
+
+@mock.patch("tvm.relay.build")
+@mock.patch("tvm.driver.tvmc.load")
+@mock.patch("tvm.transform.PassContext")
+@mock.patch("tvm.driver.tvmc.model.TVMCPackage.__init__", return_value=None)
+@mock.patch("tvm.driver.tvmc.composite_target.get_codegen_by_target")
+def test_compile_check_workspace_pools(mock_ct, mock_pkg, mock_pc, mock_fe, mock_relay):
+    mock_codegen = {}
+    mock_codegen["config_key"] = "relay.ext.mock.options"
+    mock_codegen["pass_pipeline"] = lambda *args, **kwargs: None
+
+    mock_fe.return_value = mock.MagicMock()
+    mock_ct.return_value = mock_codegen
+    mock_relay.return_value = mock.MagicMock()
+
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-target-access=sram:llvm:ro",
+        ]
+    )
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets)
+
+    tvmc_model = tvmc.load("no_file_needed")
+    tvmc.compile(
+        tvmc_model,
+        target="mockcodegen -testopt=value, llvm",
+        workspace_pools=memory_pools,
+    )
+
+    assert mock_relay.call_count == 1

Review Comment:
   We should add an `assert mock_relay.call_args_list[0].workspace_pools == memory_pools` to ensure `relay.build` is called with the right thing as well as being called.



##########
tests/python/driver/tvmc/test_command_line.py:
##########
@@ -155,3 +162,39 @@ def test_tvmc_tune_file_check(capsys, invalid_input):
     )
     on_assert_error = f"'tvmc tune' failed to check invalid FILE: {invalid_input}"
     assert captured.err == expected_err, on_assert_error
+
+
+@mock.patch("tvm.relay.build")
+@mock.patch("tvm.driver.tvmc.load")
+@mock.patch("tvm.transform.PassContext")
+@mock.patch("tvm.driver.tvmc.model.TVMCPackage.__init__", return_value=None)
+@mock.patch("tvm.driver.tvmc.composite_target.get_codegen_by_target")
+def test_compile_check_workspace_pools(mock_ct, mock_pkg, mock_pc, mock_fe, mock_relay):
+    mock_codegen = {}
+    mock_codegen["config_key"] = "relay.ext.mock.options"
+    mock_codegen["pass_pipeline"] = lambda *args, **kwargs: None
+
+    mock_fe.return_value = mock.MagicMock()
+    mock_ct.return_value = mock_codegen
+    mock_relay.return_value = mock.MagicMock()
+
+    parser = argparse.ArgumentParser()
+    generate_workspace_pools_args(parser)
+    parsed, _ = parser.parse_known_args(
+        [
+            "--workspace-pools=sram",
+            "--workspace-pools-target-access=sram:llvm:ro",
+        ]
+    )
+
+    targets = [Target("llvm")]
+    memory_pools = workspace_pools_recombobulate(parsed, targets)

Review Comment:
   Could we create this with `memory_pools = WorkspacePoolInfo(...)` directly rather than re-parsing it here?



##########
tests/python/driver/tvmc/test_command_line.py:
##########
@@ -155,3 +162,39 @@ def test_tvmc_tune_file_check(capsys, invalid_input):
     )
     on_assert_error = f"'tvmc tune' failed to check invalid FILE: {invalid_input}"
     assert captured.err == expected_err, on_assert_error
+
+
+@mock.patch("tvm.relay.build")
+@mock.patch("tvm.driver.tvmc.load")
+@mock.patch("tvm.transform.PassContext")
+@mock.patch("tvm.driver.tvmc.model.TVMCPackage.__init__", return_value=None)
+@mock.patch("tvm.driver.tvmc.composite_target.get_codegen_by_target")
+def test_compile_check_workspace_pools(mock_ct, mock_pkg, mock_pc, mock_fe, mock_relay):

Review Comment:
   This would be better suited to `test_compiler.py` and another test here which calls `_main` with the workspace parameters in argument form.



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