Skip to content

[passes] Introduce LegalizeAvgpool2d#119

Closed
dayo09 wants to merge 1 commit into
Samsung:mainfrom
dayo09:0528-legalize-avgpool
Closed

[passes] Introduce LegalizeAvgpool2d#119
dayo09 wants to merge 1 commit into
Samsung:mainfrom
dayo09:0528-legalize-avgpool

Conversation

@dayo09

@dayo09 dayo09 commented May 28, 2025

Copy link
Copy Markdown
Contributor

This commit is to accept torch.nn.AvgPool2d(count_include_pad = False). count_include_pad must be true for Circle Avgpool2D. Therefore, generate mask to make equivalent operation.

TICO-DCO-1.0-Signed-off-by: Dayoung Lee dayoung.lee@samsung.com


From #93

This commit is to accept torch.nn.AvgPool2d(count_include_pad = False).
count_include_pad must be true for Circle Avgpool2D. Therefore, generate mask to make equivalent operation.

TICO-DCO-1.0-Signed-off-by: Dayoung Lee <dayoung.lee@samsung.com>
@dayo09 dayo09 force-pushed the 0528-legalize-avgpool branch from efdeda6 to 0089868 Compare May 28, 2025 07:53
@dayo09 dayo09 requested a review from a team May 28, 2025 08:44
@mhs4670go

mhs4670go commented May 29, 2025

Copy link
Copy Markdown
Contributor

I think current codes from main branch have a bit wrong assumption.

In short, just setting SAME padding option to the circle node and not creating CirclePad when the SAME padding condition is met will do the trick.

CircleAveragePool2D op has no explicit count_include_pad parameter;it just uses a fixed behavior. Circle's "SAME" padding mode for average pooling excludes the padded area from the average count. It behaves like count_include_pad=False. But, PyTorch uses count_include_pad=True by default.

Therefore, we need to explicitly introduce the padding as part of the computation so that it gets counted in the average. That is why current codes work well.


The example module from this PR can be simply converted like this.

image

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.

2 participants