<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<p dir="auto"><code class="notranslate">torch.nn.functional.adaptive_avg_pool2d</code> causes a segmentation fault when the parameter <code class="notranslate">output_size</code> is an empty tuple, <code class="notranslate">()</code> or an empty array <code class="notranslate">[]</code>.</p>
<h2 dir="auto">To Reproduce</h2>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pytorch

torch.nn.functional.adaptive_avg_pool2d(torch.tensor([1,2,3,4,5]), ())"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pytorch</span>

<span class="pl-s1">torch</span>.<span class="pl-s1">nn</span>.<span class="pl-s1">functional</span>.<span class="pl-en">adaptive_avg_pool2d</span>(<span class="pl-s1">torch</span>.<span class="pl-en">tensor</span>([<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">4</span>,<span class="pl-c1">5</span>]), ())</pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">Proper error handling for an empty tuple or empty array like <code class="notranslate">adaptive_avg_pool1d</code>.</p>
<h2 dir="auto">Environment</h2>
<p dir="auto">PyTorch version: 1.5.0<br>
Is debug build: No<br>
CUDA used to build PyTorch: 10.1</p>
<p dir="auto">OS: Ubuntu 18.04.4 LTS<br>
GCC version: Could not collect<br>
CMake version: version 3.14.0</p>
<p dir="auto">Python version: 3.7<br>
Is CUDA available: No<br>
CUDA runtime version: No CUDA<br>
GPU models and configuration: No CUDA<br>
Nvidia driver version: No CUDA<br>
cuDNN version: No CUDA</p>
<p dir="auto">Versions of relevant libraries:<br>
[pip] numpy==1.18.1<br>
[pip] torch==1.5.0<br>
[pip] torchvision==0.6.0a0+82fd1c8<br>
[conda] blas 1.0 mkl<br>
[conda] cudatoolkit 10.1.243 h6bb024c_0<br>
[conda] mkl 2020.1 217<br>
[conda] mkl-include 2020.1 217<br>
[conda] mkl-service 2.3.0 py37he904b0f_0<br>
[conda] mkl_fft 1.0.15 py37ha843d7b_0<br>
[conda] mkl_random 1.1.0 py37hd6b4f25_0<br>
[conda] numpy 1.18.1 py37h4f9e942_0<br>
[conda] numpy-base 1.18.1 py37hde5b4d6_1<br>
[conda] pytorch 1.5.0 py3.7_cuda10.1.243_cudnn7.6.3_0 pytorch<br>
[conda] torchvision 0.6.0 py37_cu101 pytorch</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ezyang/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ezyang">@ezyang</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gchanan/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gchanan">@gchanan</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/zou3519/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/zou3519">@zou3519</a></p>
<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<p dir="auto">In <code class="notranslate">torch.nn.functional.adaptive_avg_pool2d</code> and <code class="notranslate">torch.nn.functional.adaptive_avg_pool3d</code>, a segmentation fault occurs when passing an empty tuple (or an empty array) for <code class="notranslate">output_size</code> parameter. It occurs even though passing a valid 4D tensor for <code class="notranslate">input</code> parameter.</p>
<h2 dir="auto">To Reproduce</h2>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import torch
# for 3d
torch.nn.functional.adaptive_avg_pool3d(torch.randn([2,2,2,2]), []) 
# for 2d
torch.nn.functional.adaptive_avg_pool2d(torch.randn([2,2,2,2]), []) "><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">torch</span>
<span class="pl-c"># for 3d</span>
<span class="pl-s1">torch</span>.<span class="pl-s1">nn</span>.<span class="pl-s1">functional</span>.<span class="pl-en">adaptive_avg_pool3d</span>(<span class="pl-s1">torch</span>.<span class="pl-en">randn</span>([<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>]), []) 
<span class="pl-c"># for 2d</span>
<span class="pl-s1">torch</span>.<span class="pl-s1">nn</span>.<span class="pl-s1">functional</span>.<span class="pl-en">adaptive_avg_pool2d</span>(<span class="pl-s1">torch</span>.<span class="pl-en">randn</span>([<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>]), []) </pre></div>
<h2 dir="auto">Environment</h2>
<p dir="auto">PyTorch version: 1.5.0<br>
Is debug build: No<br>
CUDA used to build PyTorch: 10.1</p>
<p dir="auto">OS: Ubuntu 18.04.4 LTS<br>
GCC version: Could not collect<br>
CMake version: version 3.14.0</p>
<p dir="auto">Python version: 3.7<br>
Is CUDA available: No<br>
CUDA runtime version: No CUDA<br>
GPU models and configuration: No CUDA<br>
Nvidia driver version: No CUDA<br>
cuDNN version: No CUDA</p>
<p dir="auto">Versions of relevant libraries:<br>
[pip] numpy==1.18.1<br>
[pip] torch==1.5.0<br>
[pip] torchvision==0.6.0a0+82fd1c8<br>
[conda] blas 1.0 mkl<br>
[conda] cudatoolkit 10.1.243 h6bb024c_0<br>
[conda] mkl 2020.1 217<br>
[conda] mkl-include 2020.1 217<br>
[conda] mkl-service 2.3.0 py37he904b0f_0<br>
[conda] mkl_fft 1.0.15 py37ha843d7b_0<br>
[conda] mkl_random 1.1.0 py37hd6b4f25_0<br>
[conda] numpy 1.18.1 py37h4f9e942_0<br>
[conda] numpy-base 1.18.1 py37hde5b4d6_1<br>
[conda] pytorch 1.5.0 py3.7_cuda10.1.243_cudnn7.6.3_0 pytorch<br>
[conda] torchvision 0.6.0 py37_cu101 pytorch</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ezyang/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ezyang">@ezyang</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gchanan/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gchanan">@gchanan</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/zou3519/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/zou3519">@zou3519</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/albanD/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/albanD">@albanD</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mruberry/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mruberry">@mruberry</a></p>