MCPcopy Create free account
hub / github.com/pytorch/pytorch / inserting_after

Method inserting_after

torch/fx/graph.py:979–1000  ·  view source on GitHub ↗

Set the point at which create_node and companion methods will insert into the graph. When used within a 'with' statement, this will temporary set the insert point and then restore it when the with statement exits:: with g.inserting_after(n): ... # inserti

(self, n: Optional[Node] = None)

Source from the content-addressed store, hash-verified

977
978 @compatibility(is_backward_compatible=True)
979 def inserting_after(self, n: Optional[Node] = None):
980 """Set the point at which create_node and companion methods will insert into the graph.
981 When used within a 'with' statement, this will temporary set the insert point and
982 then restore it when the with statement exits::
983
984 with g.inserting_after(n):
985 ... # inserting after node n
986 ... # insert point restored to what it was previously
987 g.inserting_after(n) # set the insert point permanently
988
989 Args:
990
991 n (Optional[Node]): The node before which to insert. If None this will insert after
992 the beginning of the entire graph.
993
994 Returns:
995 A resource manager that will restore the insert point on ``__exit__``.
996 """
997 if n is None:
998 return self.inserting_before(self._root)
999 assert n.graph == self, "Node to insert after is not in graph."
1000 return _InsertPoint(self, n.append)
1001
1002 @compatibility(is_backward_compatible=True)
1003 def placeholder(self, name: str, type_expr: Optional[Any] = None,

Callers 15

inserting_beforeMethod · 0.95
optimize_for_inferenceFunction · 0.45
__init__Method · 0.45
_sink_paramsFunction · 0.45
callMethod · 0.45
convert_eq_obsFunction · 0.45
_insert_dequant_stubFunction · 0.45

Calls 2

inserting_beforeMethod · 0.95
_InsertPointClass · 0.70

Tested by 1