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

Function remove_node

torch/ao/quantization/fx/_equalize.py:555–566  ·  view source on GitHub ↗

Removes the given node from the model by replacing all of its users with the given previous node

(model: GraphModule, node: Node, prev_node: Node)

Source from the content-addressed store, hash-verified

553 weight_quant_obs.reset_min_max_vals() # type: ignore[operator]
554
555def remove_node(model: GraphModule, node: Node, prev_node: Node):
556 """ Removes the given node from the model by replacing all of its users with
557 the given previous node
558 """
559 # For all of the current node's users, replace the current node with
560 # the input quantization observer node
561 orig_users = list(node.users.keys())
562 for user_node in orig_users:
563 user_node.replace_input_with(node, prev_node)
564
565 # Erase the InputEqualizationObserver node
566 model.graph.erase_node(node)
567
568def update_obs_for_equalization(model: GraphModule, modules: Dict[str, nn.Module]) -> Dict[str, _WeightEqualizationObserver]:
569 """ Update all of the observer's equalization scale. For each

Callers 1

convert_eq_obsFunction · 0.85

Calls 4

listFunction · 0.85
replace_input_withMethod · 0.80
keysMethod · 0.45
erase_nodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…