-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Description
🐛 Bug
Intermediate empty tensors result in exceptions and segfault.
To Reproduce
import torch
import torch.nn as nn
gg = nn.BatchNorm2d(64).eval()
prob = torch.empty(size=(0, 64, 112, 112))
print(gg(prob))Floating point exception
In the actual model BatchNorm2d is actually trained and then .eval is called. Segfault still happens.
Expected behavior
No segfault. Ideally please do support empty tensors.
I hit these issues with empty tensors during exporting/tracing, and cannot use jit.script because I want to export to ONNX.
Even thought exceptions such as
RuntimeError: non-empty 3D or 4D input tensor expected but got ndim: 4
are not that great, at least we can try-catch and work around it.
Environment
PyTorch version: 1.4.0.dev20191023
Is debug build: No
CUDA used to build PyTorch: 10.0
OS: Ubuntu 16.04.6 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
CMake version: version 3.14.0
Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: GeForce GTX 1070
Nvidia driver version: 418.40.04
cuDNN version: /usr/local/lib/libcudnn.so.5.1.10
Versions of relevant libraries:
[pip] iristorch==0.0.43
[pip] numpy==1.17.2
[pip] torch==1.4.0.dev20191023
[pip] torchvision==0.5.0a0+558beab
[conda] Could not collect
Additional context
The empty tensor is an intermediate tensor, with dynamic batch size. Related to issue #15343 and #12013