Solved by ptrblck in post #3 
              
              
                Directly reshaping A will unfortunately not work, as it would result in: 
print(A.view(B.size()))
> tensor([[ 1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,  3,  3],
          [ 4,  4,  4,  4,  4,  5,  5,  5,  5,  5,  6,  6,  6,  6,  6],
          [ 7,  7,  7,  7,  7,  8,  8,  8,  8,  8,  9,  9,…