Skip to content

Commit 4cb6dd0

Browse files
irenabirenab
authored andcommitted
fix test and coverage
1 parent b7fddbc commit 4cb6dd0

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

model_compression_toolkit/core/common/mixed_precision/sensitivity_evaluation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self,
7575
self.fw_impl = fw_impl
7676
self.disable_activation_for_metric = disable_activation_for_metric
7777
if self.quant_config.use_hessian_based_scores:
78-
if not isinstance(hessian_info_service, HessianInfoService):
78+
if not isinstance(hessian_info_service, HessianInfoService): # pragma: no cover
7979
Logger.critical(
8080
f"When using Hessian-based approximations for sensitivity evaluation, a valid HessianInfoService object is required; found {type(hessian_info_service)}.")
8181
self.hessian_info_service = hessian_info_service

model_compression_toolkit/core/common/mixed_precision/set_layer_to_bitwidth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import typing
1616
from typing import Any, Optional
1717

18-
if typing.TYPE_CHECKING:
18+
if typing.TYPE_CHECKING: # pragma: no cover
1919
from model_compression_toolkit.core.common.framework_implementation import FrameworkImplementation
2020

2121

tests_pytest/_fw_tests_common_base/base_sensitivity_eval_integ_test.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,22 @@ def test_configure_mp_model_errors(self):
223223
""" Test errors during model configuration. """
224224
model, g, se = self.model, self.g, self.se
225225
with pytest.raises(ValueError, match='Requested configuration is either empty or contain only None values'):
226-
se._configured_mp_model({}, {})
226+
with se._configured_mp_model({}, {}):
227+
pass
227228

228229
conv, relu, conv_tr = [n.name for n in g.get_topo_sorted_nodes() if n.has_configurable_activation()]
229230
_, fc = [n.name for n in g.get_topo_sorted_nodes() if n.has_any_configurable_weight()]
230231
with pytest.raises(ValueError, match='Requested configuration is either empty or contain only None values'):
231-
se._configured_mp_model({relu: None}, {conv: None})
232+
with se._configured_mp_model({relu: None}, {conv: None}):
233+
pass
232234

233235
with pytest.raises(ValueError, match='Not all mp configs were consumed'):
234-
se._configured_mp_model({conv: 1}, {conv: 0, relu: None})
236+
with se._configured_mp_model({conv: 1}, {conv: 0, relu: None}):
237+
pass
235238

236239
with pytest.raises(ValueError, match='Not all mp configs were consumed'):
237-
se._configured_mp_model({conv: 1, fc: 0}, {conv: 0})
240+
with se._configured_mp_model({conv: 1, fc: 0}, {conv: 0}):
241+
pass
238242

239243
def test_compute_metric_method(self):
240244
""" Test compute_metric method (not the metric computation itself) """

tests_pytest/pytorch_tests/integration_tests/core/mixed_precision/test_sensitivity_evaluation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_configure_mp_model(self):
6868
super().test_configure_mp_model()
6969

7070
def test_configure_mp_model_errors(self):
71-
super().test_configure_mp_model()
71+
super().test_configure_mp_model_errors()
7272

7373
def test_compute_metric_method(self):
7474
super().test_compute_metric_method()

0 commit comments

Comments
 (0)