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/07/12 21:51:09 UTC
[GitHub] [tvm] vinx13 commented on a diff in pull request #11936: [TOPI] Allow conv definition to have custom kernel layout
vinx13 commented on code in PR #11936:
URL: https://github.com/apache/tvm/pull/11936#discussion_r919455587
##########
tests/python/topi/python/test_topi_conv2d_nhwc.py:
##########
@@ -95,5 +95,34 @@ def test_conv2d_nhwc(target, dev, ref_data, dtype, stride, padding, dilation):
tvm.testing.assert_allclose(b.numpy(), b_np, rtol=1e-5)
+def test_conv2d_explicit_layout(
+ dtype, batch, in_channel, in_size, num_filter, kernel, stride, padding, dilation
+):
+ in_height = in_width = in_size
+ a_shape = (batch, in_height, in_width, in_channel)
+ w_shape = (kernel, kernel, in_channel, num_filter)
+
+ A = te.placeholder(a_shape, name="A", dtype=dtype)
+ W = te.placeholder(w_shape, name="W", dtype=dtype)
+
+ topi.testing.check_compute_definition_equivalent(
+ [
+ A,
+ W,
+ topi.nn.conv2d(
+ A,
+ W,
+ stride,
+ padding,
+ dilation,
+ data_layout="NHWC",
+ kernel_layout="HWIO",
+ out_dtype="float32",
+ ),
+ ],
+ [A, W, topi.nn.conv2d_nhwc(A, W, stride, padding, dilation, "float32")],
Review Comment:
`topi.nn.conv2d_nhwc` is already covered by existing test cases, but I didn't find any test cases invoke `topi.nn.conv2d` so we just need to check they are the same
Under the hood, both `topi.nn.conv2d_nhwc` and `topi.nn.conv2d` calls `topi.nn.conv` and cover the code path with explicit kernel layout.
--
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