The torch.cat function is giving ‘RuntimeError: out of range’ when concatenating an empty variable and a non-empty variable. Please see the example below:
import torch
x = Variable(torch.randn(1, 5).cuda())
y = Variable(torch.randn(4, 5).cuda())
z = torch.cat([x,y], 0) #works fine

The below code gives runtime error:
import torch
x = Variable(torch.randn(0, 5).cuda())
y = Variable(torch.randn(4, 5).cuda())
z = torch.cat([x,y], 0) #'RuntimeError: out of range'

I checked the same scenario with tensors. It works fine.
import torch
x = torch.randn(0, 5).cuda()
y = torch.randn(4, 5).cuda()
z = torch.cat([x,y], 0)