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

Method named_tensors

imperative/python/megengine/module/module.py:312–330  ·  view source on GitHub ↗

Returns an iterable for key tensor pairs of the module, where ``key`` is the dotted path from this module to the tensor. :param prefix: prefix prepended to the keys. :param recursive: if ``True``, returns all tensors within this module, else only returns

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

Source from the content-addressed store, hash-verified

310 )
311
312 def named_tensors(
313 self, prefix: Optional[str] = None, recursive: bool = True, **kwargs
314 ) -> Iterable[Tuple[str, Tensor]]:
315 """
316 Returns an iterable for key tensor pairs of the module, where
317 ``key`` is the dotted path from this module to the tensor.
318
319 :param prefix: prefix prepended to the keys.
320 :param recursive: if ``True``, returns all tensors within this
321 module, else only returns tensors that are direct attributes
322 of this module.
323 """
324 yield from self._flatten(
325 with_key=True,
326 prefix=prefix,
327 predicate=_is_tensor,
328 recursive=recursive,
329 **kwargs,
330 )
331
332 def children(self, **kwargs) -> "Iterable[Module]":
333 r"""Returns an iterable for all the submodules that are direct attributes of this

Callers 5

convert_module_formatFunction · 0.80
test_module_apiFunction · 0.80
test_convert_moduleFunction · 0.80

Calls 1

_flattenMethod · 0.95

Tested by 3

test_module_apiFunction · 0.64
test_convert_moduleFunction · 0.64