xlnstorch.autograd.find_fanout

Contents

xlnstorch.autograd.find_fanout#

xlnstorch.autograd.find_fanout(root)#

Detect every node in the autograd graph starting from root that has multiple incoming edges (i.e., multiple parents and therefore fan-out).

Parameters:

root (Union[torch.Tensor, torch.autograd.Function]) – A tensor whose .grad_fn is used as the graph root, or a Function node itself.

Returns:

A list of dictionaries, each containing: - ‘child’: the child node with fan-out, - ‘edge_count’: the number of incoming edges to this child, - ‘parents’: a set of parent nodes that reference this child. If no fan-out nodes are found, an empty list is returned.

Return type:

List[Dict[str, Any]]