MCPcopy Create free account
hub / github.com/pytorch/executorch / _get_module_hierarchy

Function _get_module_hierarchy

util/activation_memory_profiler.py:39–48  ·  view source on GitHub ↗

Get the module hierarchy of the given node.

(node: torch.fx.Node)

Source from the content-addressed store, hash-verified

37
38
39def _get_module_hierarchy(node: torch.fx.Node) -> str:
40 """
41 Get the module hierarchy of the given node.
42 """
43 module_stack = node.meta.get("nn_module_stack")
44 if module_stack is not None and module_stack:
45 module_values_list = list(module_stack.values())
46 if module_values_list:
47 return module_values_list[-1][0]
48 return ""
49
50
51def create_tensor_allocation_info(graph: torch.fx.Graph) -> List[MemoryTimeline]:

Callers 1

Calls 2

valuesMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected