Skip to content

Commit

Permalink
[TorchFX][MinMax] Use get_input_edge_by_port_id instead of `get_pre…
Browse files Browse the repository at this point in the history
…vious_nodes` (#2895)

### Changes

Edit the weight name retrieval method to check for port id and not get
the weight by index.

### Reason for changes

Retrieval by port id is optimal for cases where the index of node and
port id would not match.
  • Loading branch information
anzr299 authored Sep 5, 2024
1 parent f41df7b commit b99ffde
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nncf/quantization/algorithms/min_max/torch_fx_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def get_weight_tensor_port_ids(node: NNCFNode, graph: NNCFGraph) -> List[Optiona
@staticmethod
def get_weight_name(nncf_graph: NNCFGraph, target_point: PTTargetPoint) -> str:
weighted_node = nncf_graph.get_node_by_name(target_point.target_node_name)
weight = nncf_graph.get_previous_nodes(weighted_node)[target_point.input_port_id]
weight_edge = nncf_graph.get_input_edge_by_port_id(weighted_node, target_point.input_port_id)
weight = weight_edge.from_node
return weight.node_name

@staticmethod
Expand Down

0 comments on commit b99ffde

Please sign in to comment.