Repository: pytorch
Issue: Creation of too big multidimensional array returns empty tensor.
Labels: module: error checking,triaged,module: tensor creation

## 🐛 Bug

When trying to create a tensor of too many dimensions it simply returns an empty tensor with its shape is the dimensions I passed even though it should have contained the value `1`.

## To Reproduce

Steps to reproduce the behavior:

Number of 2's in the following example is `>63`.
```Python
torch.ones((2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
dtype=torch.uint8)
```
Output: 

```Python
tensor([],
       size=(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
       dtype=torch.uint8)
```

Another related issue

```Python
torch.ones((2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
dtype=torch.uint8)
```

These are `62` 2's. 

Output: 

```Python
RuntimeError: $ Torch: not enough memory: you tried to allocate 0GB. Buy new RAM! at /opt/conda/conda-bld/pytorch_1549628766161/work/aten/src/TH/THGeneral.cpp:201
```

When they're `63` 2's. The output changes to:

```Python
RuntimeError: $ Torch: invalid memory size -- maybe an overflow? at /opt/conda/conda-bld/pytorch_1549628766161/work/aten/src/TH/THGeneral.cpp:188
```

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

## Expected behavior

I expected to see the aforementioned dimensions filled with `1` if it's possible, or an exception that says a value error.

## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```
```
PyTorch version: 1.0.1.post2
Is debug build: No
CUDA used to build PyTorch: 9.0.176

OS: Arch Linux
GCC version: (crosstool-NG 1.23.0.449-a04d0) 7.3.0
CMake version: Could not collect

Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 10.1.105
GPU models and configuration: GPU 0: GeForce GTX 1050 Ti with Max-Q Design
Nvidia driver version: 418.56
cuDNN version: /usr/lib/libcudnn.so.7.5.0

Versions of relevant libraries:
[pip3] numpy==1.16.2
[pip3] torch==1.0.1.post2
[pip3] torchvision==0.2.2.post3
[conda] _tflow_select             2.3.0                       mkl  
[conda] blas                      1.0                         mkl  
[conda] mkl                       2019.1                      144  
[conda] mkl_fft                   1.0.10           py36ha843d7b_0  
[conda] mkl_random                1.0.2            py36hd81dba3_0  
[conda] pytorch                   1.0.1           py3.6_cuda9.0.176_cudnn7.4.2_2    pytorch
[conda] tensorflow                1.12.0          mkl_py36h69b6ba0_0  
[conda] tensorflow-base           1.12.0          mkl_py36h3c3e929_0  
[conda] torchvision               0.2.1                      py_2    pytorch
```
## Additional context

I suspect that the desired behavior is not happening because tensors seem to be basing on NumPy `ndarray` which accepts only `32` dims.

Also, I have just found this [line](https://github.com/pytorch/pytorch/blob/7ddd5d06ed07a50b94aa6b2fdffa2f667d677c4b/aten/src/TH/THGeneral.cpp#L184).

```cpp
THError("$ Torch: not enough memory: you tried to reallocate %dGB. Buy new RAM!", size/1073741824);
```

I think the integer division of those two elements results in the error.