What is memory_format in torch.zeros_like?

In the implementation of Adam theres a line like

state['exp_avg'] = torch.zeros_like(p, memory_format=torch.preserve_format)

Where as the documentation has the following options

torch.zeros_like(input, dtype=None, layout=None, device=None, requires_grad=False)

What is this memory_format argument ? And what does torch.preserve_format do ?

Hi,

You can find it if you look at the latest doc here: https://pytorch.org/docs/master/torch.html#torch.zeros_like (note the master in the top left of the website)

1 Like