Mousius commented on a change in pull request #9299:
URL: https://github.com/apache/tvm/pull/9299#discussion_r738329628



##########
File path: tests/python/contrib/test_ethosu/test_replace_depthwise_conv2d.py
##########
@@ -176,3 +244,29 @@ def _visit(stmt):
         "NONE",
     ]
     assert data[0] == answer, data[0]
+
+
+def test_incompatible_weight_data_type():
+    ifm = relay.var("ifm", shape=(1, 8, 8, 3), dtype="int8")
+
+    depthwise = make_ethosu_depthwise_conv2d(
+        ifm=ifm,
+        channels=3,
+        kernel_shape=(3, 2),
+        padding=(0, 0),
+        strides=(1, 1),
+        dilation=(1, 1),
+        activation="NONE",
+        ifm_layout="NHWC",
+        ofm_layout="NHWC",
+        weight_dtype="int16",
+    )
+
+    func = relay.Function(relay.analysis.free_vars(depthwise), depthwise)
+    mod = tvm.IRModule.from_expr(func)
+
+    with pytest.raises(TVMError) as err:
+        mod = relay.transform.InferType()(mod)
+
+    message = "Expected ethosu_depthwise_conv2d type(uint8) or type(int8) for 
weight but was int16"
+    assert message in str(err.value)

Review comment:
       This can be flattened into:
   ```suggestion
       message = "Expected ethosu_depthwise_conv2d type(uint8) or type(int8) 
for weight but was int16"
       with pytest.raises(TVMError, match=message):
           mod = relay.transform.InferType()(mod)
   ```
   Similar to:
   
https://github.com/apache/tvm/blob/5ab22bbf25bed2034b757e4a0175bfd68e8773b6/tests/python/relay/test_name_transforms.py#L37-L38




-- 
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-unsubscr...@tvm.apache.org

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


Reply via email to