Skip to content

Commit

Permalink
[Relay][UnitTest] Removed redundant unit test.
Browse files Browse the repository at this point in the history
test_op_level2.py::test_conv2d should have been removed in the
refactoring in #8947.  All functionality tested by it is in
test_op_level2.py::TestConv2D.
  • Loading branch information
Lunderberg committed Sep 13, 2021
1 parent 1bae425 commit fa28fd2
Showing 1 changed file with 0 additions and 115 deletions.
115 changes: 0 additions & 115 deletions tests/python/relay/test_op_level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,121 +357,6 @@ def test_run(
tvm.testing.assert_allclose(op_res1.numpy(), ref_res, rtol=1e-4, atol=1e-4)


def test_conv2d_run(target, dev):
def run_test_conv2d(
dtype,
out_dtype,
scale,
dshape,
kshape,
padding=(1, 1),
fref=None,
groups=1,
dilation=(1, 1),
channels=32,
kernel_size=(3, 3),
):
x = relay.var("x", shape=dshape, dtype=dtype)
w = relay.var("w", shape=kshape, dtype=dtype)
y = relay.nn.conv2d(
x,
w,
padding=padding,
dilation=dilation,
groups=groups,
channels=channels,
kernel_size=kernel_size,
)
func = relay.Function([x, w], y)
data = np.random.uniform(-scale, scale, size=dshape).astype(dtype)
kernel = np.random.uniform(-scale, scale, size=kshape).astype(dtype)
dkernel = tvm.topi.testing.dilate_python(kernel, (1, 1) + dilation)
ref_res = tvm.topi.testing.conv2d_nchw_python(
data.astype(out_dtype), dkernel.astype(out_dtype), 1, padding, groups=groups
)

op_res1 = relay.create_executor("graph", device=dev, target=target).evaluate(func)(
data, kernel
)
tvm.testing.assert_allclose(op_res1.numpy(), ref_res, rtol=1e-4, atol=1e-4)

# group conv2d
run_test_conv2d(
dtype="float32",
out_dtype="float32",
scale=1,
dshape=(1, 32, 18, 18),
kshape=(32, 4, 3, 3),
padding=(1, 1),
channels=32,
groups=8,
kernel_size=(3, 3),
dilation=(1, 1),
)
# also group conv2d
run_test_conv2d(
dtype="float32",
out_dtype="float32",
scale=1,
dshape=(1, 32, 18, 18),
kshape=(64, 1, 3, 3),
padding=(1, 1),
channels=64,
groups=32,
kernel_size=(3, 3),
dilation=(1, 1),
)

# normal conv2d
run_test_conv2d(
dtype="float32",
out_dtype="float32",
scale=1,
dshape=(1, 3, 224, 224),
kshape=(10, 3, 3, 3),
padding=(1, 1),
channels=10,
kernel_size=(3, 3),
dilation=(1, 1),
)
# mixed precision
run_test_conv2d(
dtype="int8",
out_dtype="int32",
scale=1,
dshape=(1, 3, 224, 224),
kshape=(10, 3, 3, 3),
padding=(1, 1),
channels=10,
kernel_size=(3, 3),
dilation=(1, 1),
)
# mixed precision.
run_test_conv2d(
dtype="int8",
out_dtype="int32",
scale=1,
dshape=(1, 3, 224, 224),
kshape=(10, 3, 1, 3),
padding=(0, 1),
channels=10,
kernel_size=(1, 3),
dilation=(1, 1),
)
# dilated conv2d
run_test_conv2d(
dtype="float32",
out_dtype="float32",
scale=1,
dshape=(1, 3, 18, 18),
kshape=(10, 3, 3, 3),
padding=(1, 1),
channels=10,
kernel_size=(3, 3),
dilation=(3, 3),
)


def test_compile_depthwise_conv2d_arm_cpu():
dtype = "float32"
out_dtype = "float32"
Expand Down

0 comments on commit fa28fd2

Please sign in to comment.