Skip to content
Advertisement

Tag: contiguous

What does .contiguous() do in PyTorch?

What does x.contiguous() do for a tensor x? Answer There are a few operations on Tensors in PyTorch that do not change the contents of a tensor, but change the way the data is organized. These operations include: narrow(), view(), expand() and transpose() For example: when you call transpose(), PyTorch doesn’t generate a new tensor with a new layout, it

Advertisement