MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / buffers

Method buffers

python/oneflow/nn/modules/module.py:582–604  ·  view source on GitHub ↗

r""" buffers(recurse=True) -> Iterator[Tensor] Returns an iterator over module buffers. Args: recurse (bool): if True, then yields buffers of this module and all submodules. Otherwise, yields only buffers that are direct m

(self, recurse: bool = True)

Source from the content-addressed store, hash-verified

580 yield elem
581
582 def buffers(self, recurse: bool = True) -> Iterator[Tensor]:
583 r"""
584 buffers(recurse=True) -> Iterator[Tensor]
585
586 Returns an iterator over module buffers.
587
588 Args:
589 recurse (bool): if True, then yields buffers of this module
590 and all submodules. Otherwise, yields only buffers that
591 are direct members of this module.
592
593 Yields:
594 oneflow.Tensor: module buffer
595
596 Example::
597
598 >>> for buf in model.buffers(): # doctest: +SKIP
599 ... print(type(buf), buf.size()) # doctest: +SKIP
600 <class 'oneflow.Tensor'> oneflow.Size([10])
601
602 """
603 for (name, buf) in self.named_buffers(recurse=recurse):
604 yield buf
605
606 def named_buffers(
607 self, prefix: str = "", recurse: bool = True

Callers 5

post_forward_hookFunction · 0.45
pre_forward_hookFunction · 0.45
update_parametersMethod · 0.45

Calls 1

named_buffersMethod · 0.95