Skip to content

Commit 7ffe5ed

Browse files
irenabirenab
authored andcommitted
fix tests
1 parent 247ed43 commit 7ffe5ed

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

tests_pytest/common_tests/unit_tests/core/mixed_precision/search_methods/test_linear_programming_solver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_all_ru_targets(self):
115115
self._run_test(sensitivity, ru, ru_constraints, {'n1': 0, 'n2': 1, 'n3': 1})
116116

117117
# in addition, increase activation ru for one of the cuts of the current optimal candidate of the 3rd layer
118-
ru_constraints[RUTarget.ACTIVATION][6, 2] += 0.1
118+
ru[RUTarget.ACTIVATION][6, 2] += 0.1
119119
self._run_test(sensitivity, ru, ru_constraints, {'n1': 0, 'n2': 1, 'n3': 0})
120120

121121
# in addition, increase total ru for one of the cuts of the optimal candidate of the 2nd layer
@@ -124,7 +124,7 @@ def test_all_ru_targets(self):
124124

125125
# in addition, increase bops for the optimal candidate of 2nd layer above constraint
126126
ru[RUTarget.BOPS][4, 0] += 0.1
127-
self._run_test(sensitivity, ru, ru_constraints, {'n1': 2, 'n2': 2, 'n3': 0})
127+
self._run_test(sensitivity, ru, ru_constraints, {'n1': 2, 'n2': 0, 'n3': 0})
128128

129129
def _run_test(self, sensitivity, ru, ru_constraints, exp_res):
130130
solver = MixedPrecisionIntegerLPSolver(sensitivity, ru, ru_constraints)

tests_pytest/common_tests/unit_tests/core/mixed_precision/test_greedy_solution_refinement.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from typing import Dict, List
1616

1717
from model_compression_toolkit.core import ResourceUtilization
18+
from model_compression_toolkit.core.common.mixed_precision.mixed_precision_search_manager import \
19+
MixedPrecisionSearchManager
1820
from model_compression_toolkit.core.common.mixed_precision.solution_refinement_procedure import greedy_solution_refinement_procedure
1921

2022
import pytest
@@ -27,11 +29,8 @@ def search_manager():
2729
manager = Mock()
2830
manager.mp_topo_configurable_nodes = MagicMock()
2931
manager.fw_info.get_kernel_op_attributes = MagicMock()
30-
manager.replace_config_in_index = MagicMock(
31-
side_effect=lambda config, idx, candidate: (
32-
lambda new_config: (new_config.__setitem__(idx, candidate), new_config)[1]
33-
)(copy.deepcopy(config))
34-
)
32+
manager.copy_config_with_replacement = MixedPrecisionSearchManager.copy_config_with_replacement
33+
manager.using_virtual_graph = False # asserted in refinement
3534
return manager
3635

3736

@@ -99,18 +98,18 @@ def test_greedy_solution_refinement_procedure(
9998
weight_bits_dict_1 = {'kernel': 4}
10099
act_bits_1 = 8
101100

102-
initial_solution = [1]
103-
expected_solution = [1]
104-
105101
node_mock = Mock()
106102
node_mock.candidates_quantization_cfg = candidate_configs(weight_bits_dict_0, act_bits_0, weight_bits_dict_1, act_bits_1)
107103

104+
initial_solution = {node_mock: 1}
105+
expected_solution = {node_mock: 1}
106+
108107
search_manager.mp_topo_configurable_nodes = [node_mock]
109108

110109
search_manager.compute_resource_utilization_for_config = MagicMock(side_effect=lambda config: {
111110
0: ResourceUtilization(**alternative_candidate_resources_usage),
112111
1: ResourceUtilization(weights_memory=50, activation_memory=50),
113-
}[config[-1]])
112+
}[config[node_mock]])
114113

115114
target_resource_utilization = ResourceUtilization(**resource_limit)
116115

0 commit comments

Comments
 (0)