Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-lyakhov committed Jul 4, 2024
1 parent 745e6f0 commit 6ba8a34
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ install-torch-test:
pip install -e .
pip install "git+https://github.com/openvinotoolkit/open_model_zoo.git@37f60eb#egg=accuracy_checker&subdirectory=tools/accuracy_checker"
pip install -r tests/torch/requirements.txt
pip install -r tests/torch/fx/requirements.txt
pip install -r tests/cross_fw/install/requirements.txt
pip install -r tests/cross_fw/examples/requirements.txt

Expand Down
8 changes: 3 additions & 5 deletions nncf/experimental/torch/fx/model_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# limitations under the License.

from collections import defaultdict

# from functools import partial
from typing import Callable, List, Union

import torch
Expand Down Expand Up @@ -63,9 +61,9 @@ def transform(self, transformation_layout: PTTransformationLayout) -> torch.fx.G
if transformations:
model = transformation_fn(model, transformations)

# Do not eliminate dead code as
# the dead code is computing statistics :)
# model.graph.eliminate_dead_code()
# Do not use model.graph.eliminate_dead_code()
# because the computational statistics code
# is interpolated as dead code.
model.recompile()
return model

Expand Down
14 changes: 12 additions & 2 deletions nncf/experimental/torch/fx/quantization/quantize_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,21 @@ def quantize_impl(
advanced_parameters=advanced_parameters,
)

# BatchNorm operations have 3 output ports,
# to make it easier for alorithms to work
# with the target graph BatchNorm operations
# are being fused
_fuse_conv_bn_(copied_model)
# BN fuses to conv bias, conv+bias joined op
# needs to be splited for nncf

# To make it easier for bias correction algorithms,
# biases are being separated by the followng calls.
separate_linear_and_bias(copied_model)
separate_conv_and_bias(copied_model)

# View requires at least one dimension spans
# across two contiguous subspaces and reshape is not.
# To prevent error during statistics collection
# all view operation are translated to reshape.
view_to_reshape(copied_model)

nncf_graph = NNCFGraphFactory.create(copied_model)
Expand Down
2 changes: 1 addition & 1 deletion nncf/experimental/torch/fx/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def insert_one_qdq_before_node(model: torch.fx.GraphModule, target_node: torch.f
# 1. extract information for inserting q/dq node from activation_post_process
node_type = "call_function"
quantize_op: Optional[Callable] = None
# scale, zero_point = activation_post_process.calculate_qparams() # type: ignore[attr-defined, operator]

dtype = torch.int8 if quantizer.quant_min < 0 else torch.uint8
if quantizer.is_per_channel:
qparams = {
Expand Down
7 changes: 0 additions & 7 deletions tests/torch/fx/requirements.txt

This file was deleted.

5 changes: 5 additions & 0 deletions tests/torch/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ datasets==2.14.7
evaluate==0.3.0
openvino
timm==0.9.2


# Required for torch/fx tests
torchvision
fastdownload==0.0.7

0 comments on commit 6ba8a34

Please sign in to comment.