Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relay][UnitTest] Removed redundant unit test. #8993

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions tests/python/relay/test_any.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,30 +419,6 @@ def test_any_reduce(
check_result([data_np], mod, ref_out_shape, assert_shape=True, targets=[(target, dev)])


def verify_any_reduce(
reduce_op, data_shape, axis, exclude, keepdims, static_data_shape, ref_out_shape
):
mod = tvm.IRModule()
dtype = "bool" if reduce_op == relay.all else "float32"
data = relay.var("data", shape=data_shape, dtype=dtype)
y = reduce_op(data, axis, keepdims, exclude)
mod["main"] = relay.Function([data], y)
data_np = np.random.uniform(size=static_data_shape).astype(dtype)
check_result([data_np], mod, ref_out_shape, assert_shape=True)


@tvm.testing.uses_gpu
def test_any_reduce():
verify_any_reduce(relay.argmax, any_dims(3), None, False, False, (3, 4, 5), ())
verify_any_reduce(relay.argmin, any_dims(4), 1, False, True, (3, 4, 5, 6), (3, 1, 5, 6))
verify_any_reduce(relay.all, any_dims(3), (1, 2), True, False, (3, 4, 5), (4, 5))
verify_any_reduce(relay.max, any_dims(4), -1, True, True, (3, 4, 5, 6), (1, 1, 1, 6))
verify_any_reduce(relay.min, any_dims(3), (0, 1), False, False, (4, 5, 6), (6,))
verify_any_reduce(relay.prod, any_dims(4), 2, True, True, (3, 4, 5, 6), (1, 1, 5, 1))
verify_any_reduce(relay.mean, any_dims(2), 0, False, False, (1, 2), (2,))
verify_any_reduce(relay.variance, any_dims(5), (2, 4), False, False, (3, 4, 5, 6, 7), (3, 4, 6))


def verify_any_layout_transform(
data_shape, src_layout, dst_layout, static_data_shape, ref_out_shape
):
Expand Down
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