Consider the following method related to buffers in PyTorch
buffers(recurse=True) Returns an iterator over module buffers. Parameters recurse (bool) – if True, then yields buffers of this module and all submodules. Otherwise, yields only buffers that are direct members of this module. Yields torch.Tensor – module buffer
buffers() is a method used for models (say neural networks) in PyTorch.
model.buffers() contains the tensors related to the model and you can see it from the example provided below.
>>> for buf in model.buffers(): >>> print(type(buf), buf.size()) <class 'torch.Tensor'> (20L,) <class 'torch.Tensor'> (20L, 1L, 5L, 5L)
The following method informs that a model in PyTorch has both parameters and buffers. So, buffers cannot be same as the parameters (say weights) of the model.
cpu() Moves all model parameters and buffers to the CPU.
I am not aware of any numbers to store for a model other than its parameters. So, I have no idea on what buffers of a model in PyTorch store. But, this implies that there are some other numbers related to model need to be stored for efficiency or other purposes.
What are those numbers, other than parameters, need to be stored for a model?