summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJan Schlüter <github@jan-schlueter.de>2018-11-27 09:36:11 -0800
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2018-11-27 09:38:06 -0800
commitc19af59a6edd9567d5fb5712ca22cc8e22c7f8fc (patch)
tree59cc8e89281a87f753174857c8c6bd0dd981f173 /docs
parentc5cc1e3ab28380d1e1a4a1a0db8a295bd45c0bd8 (diff)
downloadpytorch-c19af59a6edd9567d5fb5712ca22cc8e22c7f8fc.tar.gz
pytorch-c19af59a6edd9567d5fb5712ca22cc8e22c7f8fc.tar.bz2
pytorch-c19af59a6edd9567d5fb5712ca22cc8e22c7f8fc.zip
Use integer math to compute output size of pooling operations (#14405)
Summary: As reported in #13386, the pooling operations can return wrong results for large inputs. The root of the problem is that while the output shape is initially being computed with integer operations, it is converted to float32 for division by the stride and applying either a `ceil` or a `floor` depending on the `ceil_mode`. Since even moderately large integers (the smallest being 16,777,217) cannot be expressed exactly in float32, this leads to wrong result shapes. This PR relies purely on integer operations to perform the shape computation, including the ceil/floor distinction. Since I could not stand all that duplicated code, I pulled it out into a `pooling_shape.h` header, similar to the existing `linear_upsampling.h` header. I hope this is acceptable, let me know if you'd like to see it solved differently. I've also added tests to `test_nn.py` that fail without my changes and pass with my changes. They cover `{max,avg}_pool{1,2,3}d()` for CPU and GPU. Fixes #13386. Pull Request resolved: https://github.com/pytorch/pytorch/pull/14405 Differential Revision: D13215260 Pulled By: soumith fbshipit-source-id: 802588ce6cba8db6c346448c3b3c0dac14d12b2d
Diffstat (limited to 'docs')
0 files changed, 0 insertions, 0 deletions