forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
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 'upstream/master' into es/lpt/lpt_to_ngr…
…aph_integration
- Loading branch information
Showing
10 changed files
with
203 additions
and
19 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
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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
# Security Policy | ||
|
||
## Reporting a Vulnerability | ||
## Report a Vulnerability | ||
|
||
Please report about security issues or vulnerabilities you find to Intel | ||
[Security Center]. | ||
Please report security issues or vulnerabilities to the [Intel® Security Center]. | ||
|
||
For more information on how Intel works to resolve security issues, see: | ||
[Vulnerability Handling Guidelines] | ||
For more information on how Intel® works to resolve security issues, see | ||
[Vulnerability Handling Guidelines]. | ||
|
||
[Security Center]:https://www.intel.com/security | ||
[Intel® Security Center]:https://www.intel.com/security | ||
|
||
[Vulnerability Handling Guidelines] https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html | ||
[Vulnerability Handling Guidelines]:https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PyYAML==5.3.1 |
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,98 @@ | ||
# Copyright (C) 2020 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
""" | ||
Basic high-level plugin file for pytest. | ||
See [Writing plugins](https://docs.pytest.org/en/latest/writing_plugins.html) | ||
for more information. | ||
This plugin adds the following command-line options: | ||
* `--test_conf` - Path to test configuration file. Used to parametrize tests. | ||
Format: YAML file. | ||
* `--exe` - Path to a timetest binary to execute. | ||
* `--niter` - Number of times to run executable. | ||
""" | ||
|
||
# pylint:disable=import-error | ||
import pytest | ||
from pathlib import Path | ||
import yaml | ||
|
||
from test_runner.utils import expand_env_vars | ||
|
||
|
||
# -------------------- CLI options -------------------- | ||
|
||
def pytest_addoption(parser): | ||
"""Specify command-line options for all plugins""" | ||
parser.addoption( | ||
"--test_conf", | ||
type=Path, | ||
help="Path to test config", | ||
default=Path(__file__).parent / "test_config.yml" | ||
) | ||
parser.addoption( | ||
"--exe", | ||
required=True, | ||
dest="executable", | ||
type=Path, | ||
help="Path to a timetest binary to execute", | ||
) | ||
parser.addoption( | ||
"--niter", | ||
type=int, | ||
help="Number of iterations to run executable and aggregate results", | ||
default=3 | ||
) | ||
# TODO: add support of --mo, --omz etc. required for OMZ support | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def test_conf(request): | ||
"""Fixture function for command-line option.""" | ||
return request.config.getoption('test_conf') | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def executable(request): | ||
"""Fixture function for command-line option.""" | ||
return request.config.getoption('executable') | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def niter(request): | ||
"""Fixture function for command-line option.""" | ||
return request.config.getoption('niter') | ||
|
||
# -------------------- CLI options -------------------- | ||
|
||
|
||
def pytest_generate_tests(metafunc): | ||
"""Pytest hook for test generation. | ||
Generate parameterized tests from discovered modules and test config | ||
parameters. | ||
""" | ||
with open(metafunc.config.getoption('test_conf'), "r") as file: | ||
test_cases = expand_env_vars(yaml.safe_load(file)) | ||
if test_cases: | ||
metafunc.parametrize("instance", test_cases) | ||
|
||
|
||
def pytest_make_parametrize_id(config, val, argname): | ||
"""Pytest hook for user-friendly test name representation""" | ||
|
||
def get_dict_values(d): | ||
"""Unwrap dictionary to get all values of nested dictionaries""" | ||
if isinstance(d, dict): | ||
for v in d.values(): | ||
yield from get_dict_values(v) | ||
else: | ||
yield d | ||
|
||
keys = val.keys() | ||
values = list(get_dict_values(val)) | ||
|
||
return "-".join(["_".join([key, val]) for key, val in zip(keys, values)]) |
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,3 @@ | ||
pytest==4.0.1 | ||
attrs==19.1.0 # required for pytest==4.0.1 to resolve compatibility issues | ||
PyYAML==5.3.1 |
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,8 @@ | ||
- device: | ||
name: CPU | ||
model: | ||
path: ${SHARE}/stress_tests/master_04d6f112132f92cab563ae7655747e0359687dc9/caffe/FP32/alexnet/alexnet.xml # TODO: add link to `test_data` repo model | ||
- device: | ||
name: GPU | ||
model: | ||
path: ${SHARE}/stress_tests/master_04d6f112132f92cab563ae7655747e0359687dc9/caffe/FP32/alexnet/alexnet.xml |
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 |
---|---|---|
@@ -1 +1,42 @@ | ||
#TODO: fill | ||
# Copyright (C) 2020 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
"""Main entry-point to run timetests tests. | ||
Default run: | ||
$ pytest test_timetest.py | ||
Options[*]: | ||
--test_conf Path to test config | ||
--exe Path to timetest binary to execute | ||
--niter Number of times to run executable | ||
[*] For more information see conftest.py | ||
""" | ||
|
||
from pathlib import Path | ||
import logging | ||
|
||
from scripts.run_timetest import run_timetest | ||
|
||
|
||
def test_timetest(instance, executable, niter): | ||
"""Parameterized test. | ||
:param instance: test instance | ||
:param executable: timetest executable to run | ||
:param niter: number of times to run executable | ||
""" | ||
# Prepare model to get model_path | ||
model_path = instance["model"].get("path") | ||
assert model_path, "Model path is empty" | ||
|
||
# Run executable | ||
exe_args = { | ||
"executable": Path(executable), | ||
"model": Path(model_path), | ||
"device": instance["device"]["name"], | ||
"niter": niter | ||
} | ||
retcode, aggr_stats = run_timetest(exe_args, log=logging) | ||
assert retcode == 0, "Run of executable failed" |
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,20 @@ | ||
# Copyright (C) 2020 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
"""Utility module.""" | ||
|
||
import os | ||
|
||
|
||
def expand_env_vars(obj): | ||
"""Expand environment variables in provided object.""" | ||
|
||
if isinstance(obj, list): | ||
for i, value in enumerate(obj): | ||
obj[i] = expand_env_vars(value) | ||
elif isinstance(obj, dict): | ||
for name, value in obj.items(): | ||
obj[name] = expand_env_vars(value) | ||
else: | ||
obj = os.path.expandvars(obj) | ||
return obj |