Let’s say I have two tensors:
A = torch.empty([N, M]).to(device)
B = torch.empty([batch_size, M]).to(device)

The desired effect I want to achieve is this:
A = torch.cat((B.to(device), A[:-batch_size])).to(device)
In plain English, I just want to insert B into the front of A but keep A the same size.
However, when I do it with the following code:
A[batch_size:].data = A[:-batch_size].data.to(device)
A[batch_size:].data = B.data.to(device)

Now I get a CUDA error:
RuntimeError: CUDA error: device-side assert triggered
The assert it’s referring seems to be:
Assertion index >= -sizes[i] && index < sizes[i] && “index out of bounds” failed.