-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remote/develop' into onnx_BC_fix
- Loading branch information
Showing
91 changed files
with
28,114 additions
and
28,723 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) 2024 Intel Corporation | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
""" | ||
This script generates a summary table in Markdown format from an XML report generated by pytest. | ||
Usage in GitHub workflow: | ||
- name: Test Summary | ||
if: ${{ !cancelled() }} | ||
run: | | ||
python .github/scripts/generate_examples_summary.py pytest-results.xml >> $GITHUB_STEP_SUMMARY | ||
""" | ||
|
||
import sys | ||
import xml.etree.ElementTree as ET | ||
|
||
# Load the XML report generated by pytest | ||
xml_file = sys.argv[1] | ||
|
||
try: | ||
tree = ET.parse(xml_file) | ||
except FileNotFoundError: | ||
sys.exit(1) | ||
|
||
root = tree.getroot() | ||
|
||
# Build the summary table in Markdown format | ||
table_lines = [] | ||
table_lines.append("| Test Name | Status | Time | Message |") | ||
table_lines.append("|:----------|:------:|-----:|:--------|") | ||
|
||
# Iterate over test cases | ||
for testcase in root.findall(".//testcase"): | ||
test_name = testcase.get("name") | ||
time_duration = float(testcase.get("time", "0")) | ||
message = "" | ||
if testcase.find("failure") is not None: | ||
status = "$${\color{red}Failed}$$" | ||
message = testcase.find("failure").get("message", "") | ||
elif testcase.find("error") is not None: | ||
status = "$${\color{red}Error}$$" | ||
elif testcase.find("skipped") is not None: | ||
status = "$${\color{orange}Skipped}$$" | ||
message = testcase.find("skipped").get("message", "") | ||
else: | ||
status = "$${\color{green}Ok}$$" | ||
|
||
# Append each row to the table | ||
table_lines.append(f"| {test_name} | {status} | {time_duration:.0f} | {message} |") | ||
|
||
print("\n".join(table_lines)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
tests/cross_fw/test_templates/test_weights_compression_backends.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Copyright (c) 2024 Intel Corporation | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from abc import abstractmethod | ||
|
||
import pytest | ||
|
||
from nncf.experimental.common.tensor_statistics.collectors import HAWQAggregator | ||
from nncf.experimental.common.tensor_statistics.collectors import MaxVarianceReducer | ||
from nncf.experimental.common.tensor_statistics.collectors import MeanAbsMaxReducer | ||
from nncf.experimental.common.tensor_statistics.collectors import MeanAggregator | ||
from nncf.experimental.common.tensor_statistics.collectors import MeanVarianceReducer | ||
from nncf.experimental.common.tensor_statistics.collectors import NoopReducer | ||
from nncf.experimental.common.tensor_statistics.collectors import TensorCollector | ||
|
||
|
||
class TemplateTestMixedPrecisionAlgoBackend: | ||
@abstractmethod | ||
def get_hawq_with_backend(self, subset_size: int): | ||
"""Returns a HAWQ instance of the algorithm.""" | ||
|
||
@abstractmethod | ||
def get_mean_variance_with_backend(self, subset_size: int): | ||
"""Returns a Mean Variance instance of the algorithm.""" | ||
|
||
@abstractmethod | ||
def get_max_variance_with_backend(self, subset_size: int): | ||
"""Returns a Max Variance instance of the algorithm.""" | ||
|
||
@abstractmethod | ||
def get_mean_max_with_backend(self, subset_size: int): | ||
"""Returns a Mean Max instance of the algorithm.""" | ||
|
||
def check_aggregator(self, collector: TensorCollector, expected_aggregator_type, subset_size: int): | ||
assert len(collector.aggregators) == 1, "Collector should have exactly one aggregator." | ||
_, aggregator = collector.aggregators.popitem() | ||
assert isinstance( | ||
aggregator, expected_aggregator_type | ||
), f"Expected aggregator of type {expected_aggregator_type.__name__}, got {type(aggregator).__name__}." | ||
assert aggregator.num_samples == subset_size, "Aggregator num_samples does not match the provided subset size." | ||
|
||
def check_reducer(self, collector: TensorCollector, expected_reducer_type): | ||
assert len(collector.reducers) == 1 | ||
reducer = collector.reducers.pop() | ||
assert isinstance( | ||
reducer, expected_reducer_type | ||
), f"Expected reducer of type {expected_reducer_type.__name__}, got {type(reducer).__name__}." | ||
|
||
@pytest.mark.parametrize("subset_size", [1, 10, None]) | ||
@pytest.mark.parametrize( | ||
"algo_func, aggregator_type, reducer_type", | ||
[ | ||
("get_hawq_with_backend", HAWQAggregator, NoopReducer), | ||
("get_mean_variance_with_backend", MeanAggregator, MeanVarianceReducer), | ||
("get_max_variance_with_backend", MeanAggregator, MaxVarianceReducer), | ||
("get_mean_max_with_backend", MeanAggregator, MeanAbsMaxReducer), | ||
], | ||
) | ||
def test_statistic_collector(self, subset_size, algo_func, aggregator_type, reducer_type): | ||
"""Test function to validate statistic collectors.""" | ||
algo = getattr(self, algo_func)(subset_size) | ||
collector = algo._get_statistic_collector() | ||
|
||
# Verify the collector instance and properties | ||
assert isinstance(collector, TensorCollector), "Collector is not an instance of TensorCollector." | ||
|
||
# Validate the aggregator and reducer types | ||
self.check_aggregator(collector, aggregator_type, subset_size) | ||
self.check_reducer(collector, reducer_type) |
Oops, something went wrong.