Skip to content

Conversation

ksemianov
Copy link
Contributor

Add AdaptiveAvgPool2d and AdaptiveMaxPool2d to ONNX.symbolic
Due to limitations in ONNX only output_size=1 is supported.
AdaptiveAvgPool2d -> GlobalAveragePool
AdaptiveMaxPool2d -> GlobalMaxPool
Fixes #5310

@li-roy li-roy added the ready for review (this tag is deprecated) All PRs are ready for review unless they are draft, WIP, or have undismissed requested changes label Jul 24, 2018
@weiyangfb weiyangfb added the module: onnx Related to torch.onnx label Aug 28, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@weihua04
Copy link

weihua04 commented May 5, 2019

@ksemianov , my pytorch model has a nn.AdaptiveAvgPool2d((3, 3)), and i can't export onnx model with error " only output_size=1 is supported",do u have any good idea to solve the problem?
thank u very much

@ksemianov
Copy link
Contributor Author

@weihua04 GlobalAveragePool in ONNX doesn't have output_size attribute. It implicitly assumes that output_size=1. You might want to workaround with nn.AvgPool2d(input_size - (output_size - 1) * (input_size // output_size), stride=input_size // output_size). If input_size is divisible by output_size, it will give exactly the same result. Otherwise, there'll be some prediction error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: onnx Related to torch.onnx open source ready for review (this tag is deprecated) All PRs are ready for review unless they are draft, WIP, or have undismissed requested changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ONNX support for AdaptiveMax/AvgPool ?

6 participants