-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Torch][PTQ] Examples are updated for the new PTQ TORCH backend (#2246)
### Changes - Do not filter constant nodes for torch backend in the inference graph - Fix version in requarements.txt for examples of post_training_quantization - for ssd300_vgg16 is not available to use torch 2.1.0 (failed on export to onnx Unsupported: ONNX export of operator get_pool_ceil_padding, tracing is not supporting too) - Update metrics - Add to PTEngine convert inputs to model's device to sync behavior with `create_compress_model` - Mobilenet_v2 example converting PyTorch model to IR by tracing (without onnx). - nncf.quantize for PyTorch works with copy of the target model ### Reason for changes To make PTQ work properly with disconnected graphs (like in [example](https://github.com/openvinotoolkit/nncf/blob/develop/examples/post_training_quantization/torch/ssd300_vgg16/main.py)) ### Related tickets 124417 ### Tests test_examples build 128 --------- Co-authored-by: Alexander Dokuchaev <[email protected]>
- Loading branch information
1 parent
d5e3942
commit 1493149
Showing
15 changed files
with
160 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
examples/post_training_quantization/torch/mobilenet_v2/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
torchvision>=0.10.1,<0.16 | ||
tqdm | ||
scikit-learn | ||
fastdownload | ||
fastdownload==0.0.7 | ||
openvino-dev==2023.1 | ||
onnx | ||
scikit-learn | ||
torch==2.1.0 | ||
torchvision==0.16.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
examples/post_training_quantization/torch/ssd300_vgg16/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
fastdownload | ||
fastdownload==0.0.7 | ||
onnx==1.13.1 | ||
openvino-dev==2023.1 | ||
pycocotools==2.0.7 | ||
torch==2.0.1 # ssd300_vgg16 can not be exported with 2.1.0, reference: https://github.com/pytorch/pytorch/issues/113155 | ||
torchmetrics==1.0.1 | ||
pycocotools | ||
torchvision~=0.15.1 | ||
tqdm | ||
onnx | ||
torchvision==0.15.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/common/data/reference_graphs/passes/test_constant_filtering_model_after.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
strict digraph { | ||
"0 /Input_1_0" [id=0, type=Input_1]; | ||
"1 /ReadVariable_0" [id=1, type=ReadVariable]; | ||
"4 /Conv_0" [id=4, type=Conv]; | ||
"6 /Conv2_0" [id=6, type=Conv2]; | ||
"7 /Add_0" [id=7, type=Add]; | ||
"8 /Final_node_0" [id=8, type=Final_node]; | ||
"0 /Input_1_0" -> "4 /Conv_0"; | ||
"1 /ReadVariable_0" -> "7 /Add_0"; | ||
"6 /Conv2_0" -> "7 /Add_0"; | ||
"7 /Add_0" -> "8 /Final_node_0"; | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/common/data/reference_graphs/passes/test_constant_filtering_model_before.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
strict digraph { | ||
"0 /Input_1_0" [id=0, type=Input_1]; | ||
"1 /ReadVariable_0" [id=1, type=ReadVariable]; | ||
"2 /Weights_0" [id=2, type=Weights]; | ||
"3 /AnyNodeBetweenWeightAndConv_0" [id=3, type=AnyNodeBetweenWeightAndConv]; | ||
"4 /Conv_0" [id=4, type=Conv]; | ||
"5 /Weights2_0" [id=5, type=Weights2]; | ||
"6 /Conv2_0" [id=6, type=Conv2]; | ||
"7 /Add_0" [id=7, type=Add]; | ||
"8 /Final_node_0" [id=8, type=Final_node]; | ||
"0 /Input_1_0" -> "4 /Conv_0"; | ||
"1 /ReadVariable_0" -> "7 /Add_0"; | ||
"2 /Weights_0" -> "3 /AnyNodeBetweenWeightAndConv_0"; | ||
"3 /AnyNodeBetweenWeightAndConv_0" -> "4 /Conv_0"; | ||
"5 /Weights2_0" -> "6 /Conv2_0"; | ||
"6 /Conv2_0" -> "7 /Add_0"; | ||
"7 /Add_0" -> "8 /Final_node_0"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.