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][Bugfix] Fix stride in LpPool for default #14740

Merged
merged 6 commits into from
May 1, 2023
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
4 changes: 3 additions & 1 deletion python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1988,14 +1988,16 @@ def _impl_v1(cls, inputs, attr, params):
data = inputs[0]
input_shape = infer_shape(data)
ndim = len(input_shape)
num_spatial_dims = ndim - 2
if "auto_pad" in attr:
attr["auto_pad"] = attr["auto_pad"].decode("utf-8")
if attr["auto_pad"] in ("SAME_UPPER", "SAME_LOWER"):
# Warning: LpPool does not yet support dynamic shapes,
# one will need to run dynamic_to_static on this model after import
data = autopad(
data,
attr["strides"],
# this is meant to handle the field 'strides' being optional for opsets 11+
attr.get("strides", [1] * num_spatial_dims),
AndrewZhaoLuo marked this conversation as resolved.
Show resolved Hide resolved
attr["kernel_shape"],
[1] * ndim,
mode=attr["auto_pad"],
Expand Down
11 changes: 11 additions & 0 deletions tests/python/frontend/onnx/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -3939,6 +3939,17 @@ def verify_lppool(x_shape, kernel_shape, p, strides, pads, out_shape, auto_pad="
auto_pad="SAME_UPPER",
)

# Pool2D with empty stride
verify_lppool(
x_shape=[1, 3, 32, 32],
kernel_shape=[2, 2],
p=4,
strides=None,
pads=None,
out_shape=[1, 3, 32, 32],
auto_pad="SAME_LOWER",
)

# Pool3D with stride
verify_lppool(
x_shape=[1, 1, 32, 32, 32],
Expand Down