From 47342f2917343ea54e190c3d6b01fd4059bc5222 Mon Sep 17 00:00:00 2001 From: Aleksei Kashapov Date: Tue, 16 Apr 2024 14:52:08 +0200 Subject: [PATCH] Update Yolov8 ignored scope utilizing subgraphs approach (#2610) ### Changes Change ingored_scope utilizing node names to subgraph. ### Reason for changes New ignored_scope is independent on export to OpenVINO format (dynamic, static) ### Related tickets 136835 ### Tests Manually tested --- .../main.py | 25 ++++++++----------- .../openvino/yolov8/main.py | 20 +++++---------- .../main.py | 25 ++++++++----------- 3 files changed, 28 insertions(+), 42 deletions(-) diff --git a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/main.py b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/main.py index 16d7bf53a1f..2109b750b3b 100644 --- a/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/main.py +++ b/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/main.py @@ -195,20 +195,17 @@ def validation_ac( preset=nncf.QuantizationPreset.MIXED, ignored_scope=nncf.IgnoredScope( types=["Mul", "Sub", "Sigmoid"], # ignore operations - names=[ - "/model.22/dfl/conv/Conv", # in the post-processing subgraph - "/model.22/Add", - "/model.22/Add_1", - "/model.22/Add_2", - "/model.22/Add_3", - "/model.22/Add_4", - "/model.22/Add_5", - "/model.22/Add_6", - "/model.22/Add_7", - "/model.22/Add_8", - "/model.22/Add_9", - "/model.22/Add_10", - "/model.22/Add_11", + subgraphs=[ + nncf.Subgraph( + inputs=[ + "/model.22/Concat_3", + "/model.22/Concat_6", + "/model.22/Concat_24", + "/model.22/Concat_5", + "/model.22/Concat_4", + ], + outputs=["/model.22/Concat_29"], + ) ], ), ) diff --git a/examples/post_training_quantization/openvino/yolov8/main.py b/examples/post_training_quantization/openvino/yolov8/main.py index d8513400e4d..5ecdedcb120 100644 --- a/examples/post_training_quantization/openvino/yolov8/main.py +++ b/examples/post_training_quantization/openvino/yolov8/main.py @@ -122,20 +122,12 @@ def transform_fn(data_item: Dict): quantization_dataset, preset=nncf.QuantizationPreset.MIXED, ignored_scope=nncf.IgnoredScope( - types=["Multiply", "Subtract", "Sigmoid"], # ignore operations - names=[ - "/model.22/dfl/conv/Conv", # in the post-processing subgraph - "/model.22/Add", - "/model.22/Add_1", - "/model.22/Add_2", - "/model.22/Add_3", - "/model.22/Add_4", - "/model.22/Add_5", - "/model.22/Add_6", - "/model.22/Add_7", - "/model.22/Add_8", - "/model.22/Add_9", - "/model.22/Add_10", + types=["Multiply", "Subtract", "Sigmoid"], + subgraphs=[ + nncf.Subgraph( + inputs=["/model.22/Concat", "/model.22/Concat_1", "/model.22/Concat_2"], + outputs=["output0/sink_port_0"], + ) ], ), ) diff --git a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py index 79722754ced..255fe9fe5f9 100644 --- a/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py +++ b/examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/main.py @@ -186,20 +186,17 @@ def validation_ac( preset=nncf.QuantizationPreset.MIXED, ignored_scope=nncf.IgnoredScope( types=["Multiply", "Subtract", "Sigmoid"], # ignore operations - names=[ - "/model.22/dfl/conv/Conv", # in the post-processing subgraph - "/model.22/Add", - "/model.22/Add_1", - "/model.22/Add_2", - "/model.22/Add_3", - "/model.22/Add_4", - "/model.22/Add_5", - "/model.22/Add_6", - "/model.22/Add_7", - "/model.22/Add_8", - "/model.22/Add_9", - "/model.22/Add_10", - "/model.22/Add_11", + subgraphs=[ + nncf.Subgraph( + inputs=[ + "/model.22/Concat_3", + "/model.22/Concat_6", + "/model.22/Concat_24", + "/model.22/Concat_5", + "/model.22/Concat_4", + ], + outputs=["output0"], + ) ], ), )