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 2021/10/28 12:23:18 UTC
[GitHub] [tvm] Mousius commented on a change in pull request #9299: [microNPU] Fix typo in depthwise to allow int8 weights
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-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org