Repository: pytorch
Issue: RuntimeError: invalid argument 10: ldb should be at least max(1, 0), but have 0 at ../aten/src/TH/generic/THBlas.cpp:36
Labels: module: internals,triaged

## 🐛 Bug

Runtime error when running:

```
loss = loss_func(self.alpha, self.lam, f_loss, ds, x_hat_p, x_hat_n)
optim.zero_grad()
loss.backward()   # <- Error here
```

Error Message:

```
Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1741, in <module>
    main()
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1735, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1135, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 20, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/zayd/repos/uo/double_decoder/driver.py", line 104, in <module>
    _main(_args, _pos_db, _unlabel_db, _enc_dim, [_args.pos_label])
  File "/Users/zayd/repos/uo/double_decoder/driver.py", line 62, in _main
    deep_pu.train_pu(p_db=pos_db, u_db=u_db, f_loss=DeepPU.simple_loss, quiet_mode=args.q)
  File "/Users/zayd/repos/uo/double_decoder/deep_pu.py", line 473, in train_pu
    loss.backward()
  File "/Users/zayd/.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/tensor.py", line 107, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/Users/zayd/.pyenv/versions/3.7.1/Python.framework/Versions/3.7/lib/python3.7/site-packages/torch/autograd/__init__.py", line 93, in backward
    allow_unreachable=True)  # allow_unreachable flag
RuntimeError: invalid argument 10: ldb should be at least max(1, 0), but have 0 at ../aten/src/TH/generic/THBlas.cpp:365
```

## To Reproduce

I do not get this in all cases.  I get it on an autoencoder with two decoders.  I can dig into it more and try to make a streamlined MWE if the devs are unsure what could cause this.

It seems to happen when a linear block has an out dimension of zero.  That was being concatenated with another vector so other checks in my code did not catch it.

## Expected behavior

I think the error message could be clearer.  When I saw this error, it was very unclear what could cause.  I expect the better solution would be prevent linear blocks being created with an output dimension of zero.

## Environment

Collecting environment information...
PyTorch version: 1.1.0
Is debug build: No
CUDA used to build PyTorch: None

OS: Mac OSX 10.14.4
GCC version: Could not collect
CMake version: version 3.13.2

Python version: 3.7
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip3] msgpack-numpy==0.4.3.2
[pip3] numpy==1.16.1
[pip3] torch==1.1.0
[pip3] torchfile==0.1.0
[pip3] torchnet==0.0.4
[pip3] torchtext==0.3.1
[pip3] torchvision==0.2.1
[conda] Could not collect

## Additional context

Confirmed this error can also occur in torch 1.0.0