Skip to content

[ONNX] Add support for asymmetric padding for Onnx.AveragePool op #3923

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

vivekkhandelwal1
Copy link
Collaborator

@vivekkhandelwal1 vivekkhandelwal1 commented Dec 19, 2024

This commit adds support for the asymmetric padding for Onnx's AveragePool op.

This commit also extends the Torch->Linalg lowering of the pooling ops to consider asymmetric padding during the output dim computation.

Signed-off-by: Vivek Khandelwal vivekkhandelwal1424@gmail.com

1) *
strides[dimIdx] +
dilatedKernelSize - inputShape[dimIdx + 2];
totalPad = totalPad >= 0 ? totalPad : 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ceilMode used in calculating the padding when using autopad? If not, why? I think the formulas in https://onnx.ai/onnx/operators/onnx__AveragePool.html differ depending on ceilMode.

@tuukkjs
Copy link

tuukkjs commented Dec 20, 2024

Looks very good! I made some comments since I have been working on similar changes. However, I am not very familiar with the project itself so some of my comments may be off.

In general, I would suggest to add more tests to test different cases of auto_pad and asymmetric and symmetric padding.

Also please note that I am out of office until January 7th and likely won't respond during that time. Maybe others can chip in. Previously we have been discussing some changes along these lines with @zjgarvey.

This commit also refactors the code for the Onnx's AveragePool and
MaxPool op by creating a common utility for both the op lowerings
to get the pooling op parameters.

Signed-off-by: Vivek Khandelwal <vivekkhandelwal1424@gmail.com>
@vivekkhandelwal1
Copy link
Collaborator Author

Hi, I have modified the implementation. Can this PR be reviewed again?

Copy link
Collaborator

@jinchen62 jinchen62 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Make sure if @tuukkjs 's comment is addressed before merge.

@vivekkhandelwal1
Copy link
Collaborator Author

@tuukkjs Can you please review the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants