Skip to content

Commit

Permalink
update method name
Browse files Browse the repository at this point in the history
  • Loading branch information
kshpv committed Oct 9, 2023
1 parent 59b8ad2 commit 11f91f7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions nncf/onnx/graph/model_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from nncf.onnx.graph.onnx_helper import get_children_node_mapping
from nncf.onnx.graph.onnx_helper import get_edge_dtype
from nncf.onnx.graph.onnx_helper import get_edge_info_mapping
from nncf.onnx.graph.onnx_helper import get_name_to_node_map
from nncf.onnx.graph.onnx_helper import get_node_index
from nncf.onnx.graph.onnx_helper import get_node_mapping
from nncf.onnx.graph.onnx_helper import get_tensor
from nncf.onnx.graph.transformations.commands import ONNXBiasCorrectionCommand
from nncf.onnx.graph.transformations.commands import ONNXModelExtractionCommand
Expand Down Expand Up @@ -131,7 +131,7 @@ def _apply_output_insertion_transformations(
:return: New model with inserted outputs.
"""
model_outputs = set(output.name for output in self._model.graph.output)
node_mapping = get_node_mapping(self._model)
node_mapping = get_name_to_node_map(self._model)
for transformation in transformations:
port_id = transformation.target_point.port_id
node_name = transformation.target_point.target_node_name
Expand Down Expand Up @@ -313,7 +313,7 @@ def _insert_quantizer_dequantizer(
:param children_node_mapping: Mapping from edge name to nodes which consume this edge as an input.
:return: Updated model with inserted QuantizeLinear-DequantizeLinear pair.
"""
node_mapping = get_node_mapping(model)
node_mapping = get_name_to_node_map(model)
target_edge_name = self._get_quantizer_dequantizer_edge_name(transformation, node_mapping)
quantizer, dequantizer = self._get_quantize_dequantize_nodes(transformation, target_edge_name)
onnx_scale_tensor, onnx_zero_point_tensor = ONNXModelTransformer._get_scale_zero_point_tensors(
Expand Down Expand Up @@ -363,7 +363,7 @@ def _apply_bias_correction_transformations(
:param transformations: Bias correction transformations.
:return: Copy of original model with updated biases.
"""
node_mapping = get_node_mapping(model)
node_mapping = get_name_to_node_map(model)
for transformation in transformations:
bias_tensor_position = transformation.target_point.port_id
node_name = transformation.target_point.target_node_name
Expand All @@ -383,7 +383,7 @@ def _apply_model_extraction_transformation(self, transformation: ONNXModelExtrac
:return: Extracted sub-model.
"""
input_tensor_names = []
node_mapping = get_node_mapping(self._model)
node_mapping = get_name_to_node_map(self._model)
for input_node_name in transformation.inputs:
input_onnx_node = node_mapping[input_node_name]
input_tensor_names.append(input_onnx_node.input[0])
Expand All @@ -409,7 +409,7 @@ def _apply_qdq_node_removing_transformations(
:return: Model with removed nodes.
"""
for transformation in transformations:
node_mapping = get_node_mapping(model)
node_mapping = get_name_to_node_map(model)
children_node_mapping = get_children_node_mapping(model)
node = node_mapping[transformation.target_point.target_node_name]

Expand Down
4 changes: 2 additions & 2 deletions nncf/onnx/graph/onnx_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
from onnx import numpy_helper


def get_node_mapping(model: onnx.ModelProto) -> Dict[str, onnx.NodeProto]:
def get_name_to_node_map(model: onnx.ModelProto) -> Dict[str, onnx.NodeProto]:
"""
Retuns mapping from node name to the node.
Returns mapping from node name to the node.
:param model: Model from mapping is built.
:return: Mapping.
Expand Down
4 changes: 2 additions & 2 deletions nncf/onnx/statistics/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
from nncf.common.tensor_statistics.statistic_point import StatisticPointsContainer
from nncf.onnx.graph.node_utils import get_input_edge
from nncf.onnx.graph.node_utils import get_input_edges_mapping
from nncf.onnx.graph.onnx_helper import get_node_mapping
from nncf.onnx.graph.onnx_helper import get_name_to_node_map
from nncf.onnx.graph.transformations.commands import ONNXOutputInsertionCommand
from nncf.onnx.tensor import ONNXNNCFTensor


class ONNXStatisticsAggregator(StatisticsAggregator):
def collect_statistics(self, model: onnx.ModelProto, graph: NNCFGraph) -> None:
self.input_edges_mapping = get_input_edges_mapping(graph)
self.node_mapping = get_node_mapping(model)
self.node_mapping = get_name_to_node_map(model)
self._registered_weights = set()
super().collect_statistics(model, graph)

Expand Down
6 changes: 3 additions & 3 deletions nncf/quantization/algorithms/bias_correction/onnx_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from nncf.onnx.graph.node_utils import get_bias_value
from nncf.onnx.graph.node_utils import is_any_weight_quantized
from nncf.onnx.graph.node_utils import is_node_with_bias
from nncf.onnx.graph.onnx_helper import get_node_mapping
from nncf.onnx.graph.onnx_helper import get_name_to_node_map
from nncf.onnx.graph.transformations.command_creation import create_bias_correction_command
from nncf.onnx.graph.transformations.commands import ONNXBiasCorrectionCommand
from nncf.onnx.graph.transformations.commands import ONNXModelExtractionCommand
Expand Down Expand Up @@ -101,12 +101,12 @@ def get_bias_value(node: NNCFNode, model: onnx.ModelProto, nncf_graph: NNCFGraph

@staticmethod
def get_input_name(model: onnx.ModelProto, node_name: str) -> str:
node_mapping = get_node_mapping(model)
node_mapping = get_name_to_node_map(model)
return node_mapping[node_name].input[0]

@staticmethod
def get_output_name(model: onnx.ModelProto, node_name: str, output_id: int) -> List[str]:
node_mapping = get_node_mapping(model)
node_mapping = get_name_to_node_map(model)
return node_mapping[node_name].output[output_id]

@staticmethod
Expand Down

0 comments on commit 11f91f7

Please sign in to comment.