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

Method unflatten

imperative/python/megengine/traced_module/pytree.py:246–256  ·  view source on GitHub ↗

r"""Given a list of values and a ``TreeDef``, builds a pytree. This is the inverse operation of ``tree_flatten``.

(self, leaves)

Source from the content-addressed store, hash-verified

244 self.num_leaves = sum(ch.num_leaves for ch in children_defs)
245
246 def unflatten(self, leaves):
247 r"""Given a list of values and a ``TreeDef``, builds a pytree.
248 This is the inverse operation of ``tree_flatten``.
249 """
250 assert len(leaves) == self.num_leaves
251 start = 0
252 children = []
253 for ch in self.children_defs:
254 children.append(ch.unflatten(leaves[start : start + ch.num_leaves]))
255 start += ch.num_leaves
256 return SUPPORTED_TYPE[self.type].unflatten(children, self.aux_data)
257
258 def __hash__(self):
259 return hash(

Callers 15

unflatten_argsMethod · 0.45
return_valMethod · 0.45
__repr__Method · 0.45
__repr__Method · 0.45
_node_to_tensorFunction · 0.45
_tensor_to_nodeFunction · 0.45
add_input_nodeMethod · 0.45
add_output_nodeMethod · 0.45
wrapped_fnFunction · 0.45
__call__Method · 0.45
forwardMethod · 0.45
executeMethod · 0.45

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected