Repeat tensor using expand

Hi,

I want to expand a tensor tensorA with size: torch.Size([17185, 17185]) to be torch.Size([34370, 34370]) using torch.expand() rather than torch.repeat()

I know how to do it with torch.repeat() by tensorA.expand(2,2) which will give me a tensor of size torch.Size([34370, 34370]) but take much memory.

Any help with doing it using torch.expand() please?

This won’t be possible, as expand works on singleton dimensions. From the docs:

Returns a new view of the :attr:self tensor with singleton dimensions expanded to a larger size. […] Any dimension of size 1 can be expanded to an arbitrary value without allocating new memory.