Solved by ptrblck in post #2 
              
              
                This code should work: 
x = torch.tensor([[1, 2, 3], [4, 5, 6]]).float()
idx = torch.arange(3).view(1, 1, 3).repeat(2, 1, 1)
res = torch.zeros(2, 3, 3).scatter_(1, idx , x.unsqueeze(1))