Skip to content

Commit fc5e2be

Browse files
[MinMax] set_ignored_scope method (#3274)
### Changes `set_ignored_scope` method in the MinMax algorithm is introduced ### Reason for changes To allow later ignored scope settings (requires for the executorch implementation) ### Tests tests/cross_fw/test_templates/test_min_max.py: test_set_ignored_scope
1 parent aa3cc95 commit fc5e2be

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

nncf/quantization/algorithms/min_max/algorithm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@ def _init_cache(self) -> None:
334334
)
335335
self._unified_scale_groups = []
336336

337+
def set_ignored_scope(self, ignored_scope: IgnoredScope) -> None:
338+
"""
339+
Set target ignored scope for the MinMax algorithm.
340+
341+
:param ignored_scope: The ignored scope to set to the MinMax algorithm.
342+
"""
343+
self._ignored_scope = ignored_scope
344+
337345
@property
338346
def available_backends(self) -> List[BackendType]:
339347
return [BackendType.ONNX, BackendType.OPENVINO, BackendType.TORCH, BackendType.TORCH_FX]

tests/cross_fw/test_templates/test_min_max.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,24 @@
1313

1414
import pytest
1515

16+
import nncf
1617
from nncf.common.graph.graph import NNCFGraph
1718
from nncf.common.graph.graph import NNCFNode
1819
from nncf.common.graph.layer_attributes import BaseLayerAttributes
1920
from nncf.common.graph.transformations.commands import TargetPoint
2021
from nncf.common.graph.transformations.commands import TargetType
22+
from nncf.quantization.algorithms.min_max.algorithm import MinMaxQuantization
2123
from nncf.quantization.algorithms.min_max.backend import MinMaxAlgoBackend
2224

25+
26+
def test_set_ignored_scope():
27+
algorithm = MinMaxQuantization()
28+
assert algorithm._ignored_scope == nncf.IgnoredScope()
29+
ref_ignored_scope = nncf.IgnoredScope(names=["add_1"], patterns=["linear*"], types=["conv"])
30+
algorithm.set_ignored_scope(ref_ignored_scope)
31+
assert algorithm._ignored_scope is ref_ignored_scope
32+
33+
2334
CONV_WEIGHT_SHAPE = (3, 10, 4, 4)
2435
DEPTHWISECONV_WEIGHT_SHAPE = (5, 10, 20, 7, 7)
2536
MATMUL_WEIGHT_SHAPE = (2, 4)

0 commit comments

Comments
 (0)