Seems like a valid approach for me. Currently I don’t know another method for your use case.
Could you check, if this order is right:
N = 9
D2 = 10

x = torch.arange(N).unsqueeze(1).repeat(1, D2)
print(x)
print(x.view(N/3, 3, D2))

As you can see, the D2 dimension is still the same.