Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

7.0 KB
Raw Blame

OpenVINO Functional test suite

Test binary ov_npu_func_tests is built with GTest framework and includes test instances which are common for other OpenVINO plugins as well as test instances specific for this plugin. ov_npu_func_tests --help will show the usage.

Command line arguments

ov_npu_func_tests accepts the following command line arguments (alongside the standard GTest flags):

  • --driver_release={pv|release|latest} - declares which driver flavour the tests are running against. It does not detect the driver; it only records what the caller states, so skip rules and in-test guards can react to it. When omitted, it defaults to latest. An unrecognised value is ignored with a warning and the default is kept.

The declared driver type feeds two mechanisms:

  • the <driver_release> skip rule in the skip config file (see below);

  • the in-code skip macros in common/npu_driver_aware_test.hpp:

    • NPU_SKIP_IF_DRIVER_TYPE_IS(type, reason) - GTEST_SKIP() when the declared driver type matches type;
    • NPU_SKIP_UNLESS_DRIVER_TYPE_IS(type, reason) - GTEST_SKIP() when it does not match type;
    • ov::test::behavior::isDriverType(DriverType::type) - predicate for branching inside a test.

    type is one of PV, RELEASE, LATEST. Because the default is LATEST, a test guarded by NPU_SKIP_IF_DRIVER_TYPE_IS(LATEST, ...) is skipped even when no --driver_release argument is passed.

Environment variables

The following environment variables can be set up for the run of test binary ov_npu_func_tests. Values for boolean variables are specified as 1 or 0.

  • IE_NPU_TESTS_DUMP_PATH - string type, target directory for the exported artifacts and source directory for imported artifacts
  • IE_NPU_TESTS_DEVICE_NAME - string type, passed to the Inference Engine as the name of device for loading the appropriate plugin. Default - NPU
  • IE_NPU_TESTS_LOG_LEVEL - string type, passed to the plugin and allows additional debug output to the console. Sample value - LOG_DEBUG
  • IE_NPU_TESTS_RUN_EXPORT - bool type, denotes whether to export produced networks as artifacts to the files matching current test case
  • IE_NPU_TESTS_RUN_IMPORT - bool type, denotes whether to import the networks from the files matching current test case (instead of compiling them on the fly)
  • IE_NPU_TESTS_RUN_INFER - bool type, denotes whether to execute infer request which as part of the test case or not
  • IE_NPU_TESTS_EXPORT_INPUT - bool type, denotes whether to export produced input data as artifacts to the files matching current test case
  • IE_NPU_TESTS_EXPORT_REF - bool type, denotes whether to export calculated reference values as artifacts to the files matching current test case
  • IE_NPU_TESTS_IMPORT_INPUT - bool type, denotes whether to read input data from the files matching current test case (instead of using generated data)
  • IE_NPU_TESTS_IMPORT_REF - bool type, denotes whether to read reference values from the files matching current test case (instead of calculating them)
  • IE_NPU_TESTS_RAW_EXPORT - bool type, denotes whether to use header for exported network file or not
  • IE_NPU_TESTS_LONG_FILE_NAME - bool type, denotes whether to allow longer file names for the exported artifacts. By default shorter file names are used for all operating systems
  • IE_NPU_TESTS_PLATFORM - string type, enable compiler config option NPU_PLATFORM with value from the environment. Sample value - NPU3720. For more information about possible values, refer to the NPU plugin README file.
  • OV_NPU_TESTS_SKIP_CONFIG_FILE - string type, path to skip filters file

Skip filter

Skip filters are used to select which tests can run on specific devices, backends or Operating Systems. By default ov_npu_func_tests does not have any skips filters configured, to enable them it's necessary to set an environment variable with the path to the skip config file.

By default, the environment variable OV_NPU_TESTS_SKIP_CONFIG_FILE is set to find skip_tests.xml in the current working folder. OV_NPU_TESTS_SKIP_CONFIG_FILE has to be set with a valid path to an .xml file containing filters with the following structure:

<skip_configs>
    <skip_config>
        <message>skip_message_xxxxxx</message>
        <enable_rules>
            <backend>LEVEL0</backend>
            <backend></backend> (empty brackets denote no backend)
            <device>3720</device>
            <device>!4000</device> (using "!" to negate rule)
            <driver_version>9999</driver_version> (exact build number, safe only for PV drivers)
            <driver_release>PV</driver_release> (driver type from --driver_release CLI arg: PV | RELEASE | LATEST)
            <driver_release>!LATEST</driver_release> (negate: applies on PV and RELEASE)
            <operating_system>windows</operating_system>
            <operating_system>linux</operating_system>
        </enable_rules>
        <filters>
            <filter>skip_filter_xxxxxxxxxx</filter>
            <filter>skip_filter_xxxxxxxxxx</filter>
            <filter>skip_filter_xxxxxxxxxx</filter>
        </filters>
    </skip_config>
</skip_configs>

Skip filters can be enabled/disabled according to rules defining the device, backend, driver version, driver type or operating system, depending on where tests are supposed to run. Rules are optional, multiple rules can be chained together. Users can negate a rule by using "!". When determining if a skip filter is active, rules across different categories (backend, device, driver_version, driver_release, operating_system) are combined using an AND operation. While multiple entries of the same category will be evaluated using the OR operation.

Folder structure

Behavior

The folder structure of the behavior directory follows the folder structure of the OpenVINO base tests.

The OpenVINO convention requires the tests to be organized in at least three directories: compiled_model, ov_infer_request, and ov_plugin. If the scope of NPU Plugin tests becomes broader, additional directories may be created.

The E2E tests reside here.

Common

The place of utility functions and getTestCaseName base implementations.

Internal

The folder structure is mirrored from the one in the intel_npu/src directory.

The NPU implementations of test classes and their corresponding tests are located here.

Shared tests instances

OpenVINO test instantiations using NPU Plugin's own arguments.

Test developing convention

File naming

Test files do not need the _test suffix, their location is self explanatory.

File layout

Functional tests are defined in a single *.cpp file.

For parameterized tests, keep class declarations/definitions and INSTANTIATE_TEST_SUITE_P calls in the same *.cpp file.

Do not introduce paired *.hpp files for new functional tests unless the header is shared by multiple translation units as a utility/header-only helper.

Tests from shared_tests_instances also do not need paired *.hpp files.