Skip to content

Commit

Permalink
add dilation topi tests FINALLY
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewZhaoLuo committed Apr 26, 2021
1 parent 60f25d5 commit 0881ced
Showing 1 changed file with 120 additions and 0 deletions.
120 changes: 120 additions & 0 deletions tests/python/topi/python/test_topi_pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,46 @@ def test_pool3d():
True,
)

# Test non-1 dilation
verify_pool3d(
[1, 16, 31, 31, 31],
[3, 3, 3],
[3, 3, 3],
[3, 3, 3],
[2, 1, 0, 5, 4, 3],
"avg",
False,
True,
)
verify_pool3d(
[1, 16, 32, 32, 32],
[2, 2, 2],
[2, 2, 2],
[2, 2, 2],
[0, 5, 4, 3, 2, 1],
"avg",
False,
False,
)
verify_pool3d(
[1, 16, 31, 31, 31],
[3, 3, 3],
[3, 3, 3],
[2, 1, 3],
[1, 0, 5, 4, 3, 2],
"max",
False,
)
verify_pool3d(
[1, 16, 31, 31, 31],
[3, 3, 3],
[3, 3, 3],
[2, 2, 3],
[3, 2, 1, 0, 5, 4],
"max",
True,
)


def verify_pool2d(
input_shape, kernel, stride, dilation, padding, pool_type, ceil_mode, count_include_pad=True
Expand Down Expand Up @@ -618,6 +658,46 @@ def test_pool2d():
True,
)

# Test non-1 dilations
verify_pool2d(
[1, 16, 31, 31],
[3, 3],
[3, 3],
[2, 1],
[2, 1, 0, 3],
"avg",
False,
True,
)
verify_pool2d(
[1, 16, 32, 32],
[2, 3],
[2, 2],
[2, 3],
[0, 3, 2, 1],
"avg",
False,
False,
)
verify_pool2d(
[1, 16, 31, 31],
[3, 3],
[3, 3],
[3, 3],
[1, 0, 3, 2],
"max",
False,
)
verify_pool2d(
[1, 16, 31, 31],
[3, 3],
[3, 3],
[2, 2],
[3, 2, 1, 0],
"max",
True,
)


def verify_pool1d(
input_shape,
Expand Down Expand Up @@ -764,6 +844,46 @@ def test_pool1d():
True,
)

# Test non-1 dilations
verify_pool1d(
[1, 16, 31],
[3],
[3],
[2],
[2, 5],
"avg",
False,
True,
)
verify_pool1d(
[1, 16, 32],
[2],
[2],
[3],
[0, 3],
"avg",
False,
False,
)
verify_pool1d(
[1, 16, 31],
[3],
[3],
[2],
[1, 4],
"max",
False,
)
verify_pool1d(
[1, 16, 31],
[3],
[3],
[3],
[3, 0],
"max",
True,
)


if __name__ == "__main__":
test_pool1d()
Expand Down

0 comments on commit 0881ced

Please sign in to comment.