Skip to content

Commit b34c575

Browse files
committed
Apply changes for ONNX
1 parent d0a1be9 commit b34c575

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

src/nncf/onnx/quantization/backend_parameters.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,9 @@ class BackendParameters:
2424
is skipped.
2525
"""
2626

27-
COMPRESS_WEIGHTS = "compress_weights"
2827
EXTERNAL_DATA_DIR = "external_data_dir"
2928

3029

31-
def is_weight_compression_needed(advanced_parameters: Optional[AdvancedQuantizationParameters]) -> bool:
32-
"""
33-
Determines whether weight compression is needed based on the provided
34-
advanced quantization parameters.
35-
36-
:param advanced_parameters: Advanced quantization parameters.
37-
:return: `True` if weight compression is needed, `False` otherwise.
38-
"""
39-
if advanced_parameters is not None and advanced_parameters.backend_params is not None:
40-
return advanced_parameters.backend_params.get(BackendParameters.COMPRESS_WEIGHTS, True)
41-
return True
42-
43-
4430
def get_external_data_dir(
4531
advanced_parameters: Optional[Union[AdvancedQuantizationParameters, AdvancedCompressionParameters]],
4632
) -> Optional[str]:

src/nncf/onnx/quantization/quantize_model.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
from nncf.onnx.graph.nncf_graph_builder import GraphConverter
3333
from nncf.onnx.graph.passes import apply_preprocess_passes
3434
from nncf.onnx.graph.passes import compress_quantize_weights_transformation
35-
from nncf.onnx.quantization.backend_parameters import BackendParameters
3635
from nncf.onnx.quantization.backend_parameters import get_external_data_dir
37-
from nncf.onnx.quantization.backend_parameters import is_weight_compression_needed
3836
from nncf.parameters import BackupMode
3937
from nncf.parameters import CompressionFormat
4038
from nncf.parameters import CompressWeightsMode
@@ -47,6 +45,7 @@
4745
from nncf.quantization.advanced_parameters import AdvancedCompressionParameters
4846
from nncf.quantization.advanced_parameters import AdvancedQuantizationParameters
4947
from nncf.quantization.advanced_parameters import QuantizationParameters
48+
from nncf.quantization.advanced_parameters import is_weight_compression_needed
5049
from nncf.quantization.algorithms.accuracy_control.algorithm import QuantizationAccuracyRestorer
5150
from nncf.quantization.algorithms.accuracy_control.algorithm import calculate_accuracy_drop
5251
from nncf.quantization.algorithms.accuracy_control.evaluator import Evaluator
@@ -215,7 +214,7 @@ def quantize_with_accuracy_control_impl(
215214
copied_parameters = AdvancedQuantizationParameters()
216215
else:
217216
copied_parameters = deepcopy(advanced_quantization_parameters)
218-
copied_parameters.backend_params[BackendParameters.COMPRESS_WEIGHTS] = False
217+
copied_parameters.compress_weights = False
219218

220219
quantized_model = quantize_impl(
221220
model=model,

tests/onnx/test_passes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import nncf
1515
from nncf.onnx.graph.passes import apply_preprocess_passes
1616
from nncf.onnx.graph.passes import compress_quantize_weights_transformation
17-
from nncf.onnx.quantization.backend_parameters import BackendParameters
1817
from tests.onnx.common import ModelBuilder
1918
from tests.onnx.models import build_matmul_model_with_nop_cast
2019

@@ -60,7 +59,7 @@ def test_compress_quantize_weights_transformation():
6059
model,
6160
calibration_dataset,
6261
advanced_parameters=nncf.AdvancedQuantizationParameters(
63-
backend_params={BackendParameters.COMPRESS_WEIGHTS: False}
62+
compress_weights=False,
6463
),
6564
)
6665

0 commit comments

Comments
 (0)