MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / named_buffers

Method named_buffers

imperative/python/megengine/module/module.py:277–298  ·  view source on GitHub ↗

r"""Returns an iterable for key buffer pairs of the module, where ``key`` is the dotted path from this module to the buffer. Buffer is defined to be :class:`~.Tensor` excluding :class:`~.Parameter`. Args: prefix: prefix prepended to the keys. recursi

(
        self, prefix: Optional[str] = None, recursive: bool = True, **kwargs
    )

Source from the content-addressed store, hash-verified

275 )
276
277 def named_buffers(
278 self, prefix: Optional[str] = None, recursive: bool = True, **kwargs
279 ) -> Iterable[Tuple[str, Tensor]]:
280 r"""Returns an iterable for key buffer pairs of the module, where
281 ``key`` is the dotted path from this module to the buffer.
282
283 Buffer is defined to be :class:`~.Tensor` excluding :class:`~.Parameter`.
284
285 Args:
286 prefix: prefix prepended to the keys.
287 recursive: if ``True``, returns all buffers within this
288 module, else only returns buffers that are direct attributes
289 of this module.
290 prefix: Optional[str]:
291 """
292 yield from self._flatten(
293 with_key=True,
294 prefix=prefix,
295 predicate=_is_buffer,
296 recursive=recursive,
297 **kwargs,
298 )
299
300 def tensors(self, recursive: bool = True, **kwargs) -> Iterable[Parameter]:
301 r"""

Callers 2

test_module_apiFunction · 0.80
_check_paramFunction · 0.80

Calls 1

_flattenMethod · 0.95

Tested by 2

test_module_apiFunction · 0.64
_check_paramFunction · 0.64