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


##########
tests/micro/zephyr/test_zephyr.py:
##########
@@ -503,5 +512,56 @@ def test_autotune_conv2d(temp_dir, board, west_cmd, 
tvm_debug):
     tvm.testing.assert_allclose(output, expected_output, rtol=1e-4, atol=1e-5)
 
 
[email protected]_micro
+def test_schedule_build_with_cmsis_dependency(temp_dir, board, west_cmd, 
tvm_debug):
+    """Test Relay schedule with CMSIS dependency. This test shows if microTVM 
Auto tuning
+    with Zephyr breaks if CMSIS dependency was required for a schedule.
+    """
+    model = test_utils.ZEPHYR_BOARDS[board]
+    build_config = {"debug": tvm_debug}
+    target = tvm.target.target.micro(model, options=["-keys=arm_cpu,cpu"])
+
+    isa = arm_isa.IsaAnalyzer(target)
+    if not isa.has_dsp_support:
+        pytest.skip(f"ISA does not support DSP. target: {target}")
+
+    # Create a Relay conv2d
+    data_shape = (1, 16, 16, 3)
+    weight_shape = (5, 5, 8, 3)
+    data = relay.var("data", relay.TensorType(data_shape, "int8"))
+    weight = relay.var("weight", relay.TensorType(weight_shape, "int8"))
+    y = relay.nn.conv2d(
+        data,
+        weight,
+        padding=(2, 2),
+        kernel_size=(5, 5),
+        data_layout="NHWC",
+        kernel_layout="HWOI",
+        out_dtype="int32",
+    )
+    func = relay.Function([data, weight], y)
+    ir_mod = tvm.IRModule.from_expr(func)
+
+    runtime = Runtime("crt", {"system-lib": True})
+
+    with tvm.transform.PassContext(opt_level=3, 
config={"tir.disable_vectorize": True}):
+        mod = tvm.relay.build(ir_mod, target=target, runtime=runtime)

Review Comment:
   added.



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -424,6 +423,28 @@ def _get_platform_version(self, zephyr_base: str) -> float:
 
         return float(f"{version_major}.{version_minor}")
 
+    def _load_cmsis(self, lib_path: Union[str, pathlib.Path]):
+        """Copy CMSIS header files to generated project."""
+
+        cmsis_path = pathlib.Path(os.environ["CMSIS_PATH"])

Review Comment:
   I think that should be a project options that I missed. Done!



##########
apps/microtvm/zephyr/template_project/microtvm_api_server.py:
##########
@@ -455,6 +476,15 @@ def generate_project(self, model_library_format_path, 
standalone_crt_dir, projec
             os.makedirs(extract_path)
             tf.extractall(path=extract_path)
 
+        # Add CMSIS libraries if required.
+        if options["project_type"] == "host_driven":

Review Comment:
   I changed it to support both and different module names.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to