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 2023/01/04 18:07:58 UTC

[GitHub] [tvm] mehrdadh commented on a diff in pull request #13514: [microTVM] tuning on micro targets with meta-schedule

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


##########
python/tvm/contrib/micro/meta_schedule/test_autotune_ms.py:
##########
@@ -0,0 +1,181 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+import numpy as np
+import pytest
+from types import MappingProxyType
+import pathlib
+import json
+
+import tvm
+from tvm import relay
+from tvm.relay.backend import Executor
+from tvm.contrib import graph_executor, utils
+from tvm import meta_schedule as ms
+from tvm.contrib.micro.meta_schedule.local_builder_micro import get_micro_local_builder
+from tvm.contrib.micro.meta_schedule.rpc_runner_micro import get_rpc_runner_micro
+
+
+def get_module():
+    data_shape = (1, 3, 16, 16)
+    weight_shape = (8, 3, 5, 5)
+    data = relay.var("data", relay.TensorType(data_shape, "float32"))
+    weight = relay.var("weight", relay.TensorType(weight_shape, "float32"))
+    y = relay.nn.conv2d(
+        data,
+        weight,
+        padding=(2, 2),
+        kernel_size=(5, 5),
+        kernel_layout="OIHW",
+        out_dtype="float32",
+    )
+    f = relay.Function([data, weight], y)
+    mod = tvm.IRModule.from_expr(f)
+    mod = relay.transform.InferType()(mod)
+
+    weight_sample = np.random.rand(
+        weight_shape[0], weight_shape[1], weight_shape[2], weight_shape[3]
+    ).astype("float32")
+    params = {mod["main"].params[1].name_hint: weight_sample}
+
+    model_info = {
+        "in_tensor": "data",
+        "in_shape": data_shape,
+        "in_dtype": "float32",
+    }
+
+    return mod, params, model_info
+
+
+@tvm.testing.requires_micro
+@pytest.mark.parametrize(
+    "platform, options",
+    [
+        pytest.param("crt", None),
+        pytest.param(
+            "zephyr",
+            {
+                "board": "qemu_x86",
+                "project_type": "host_driven",
+            },
+        ),
+    ],
+)
+def test_micro_tuning_with_meta_schedule(platform, options):
+    if platform == "crt":
+        target = tvm.target.target.micro(model="host")
+    else:
+        boards_file = (
+            pathlib.Path(tvm.micro.get_microtvm_template_projects("zephyr")) / "boards.json"
+        )
+        with open(boards_file) as f:
+            boards = json.load(f)
+        target = tvm.target.target.micro(
+            model=boards[options["board"]]["model"], options="-mcpu=cortex-m4"

Review Comment:
   why `-mcpu=cortex-m4` is fixed here?



##########
python/tvm/contrib/micro/meta_schedule/test_autotune_ms.py:
##########
@@ -0,0 +1,181 @@
+# Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   You need to move this file outside of the python package. Usually we have CRT test and Zephyr/Arduino tests in separate path. CRT test would be in the python unittests and platform specific tests are in `tests/micro`



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