Skip to content

Commit d0f6cf0

Browse files
[NPU] Simplify folder structure for NPU functional tests (#32298)
### Details: - Added `folder structure` and `developing convention` sections to the tests README. - Moved headers from `overload` directory to `behavior` directory. - Moved some infer request files from the root `behavior` directory to `behavior/ov_infer_request` dir. - Moved NPU test instantiations from `shared_tests_instances` directory to `behavior` directory. - Added missing `#pragma once` directives to some headers. - Renamed `functions.h` into `functions.hpp`. - Made small nitpicks to the test files that are already modified by one of the actions above. Nitpicks include: removing pointless comments, `SKIP_IF_CURRENT_TEST_IS_DISABLED()` call correctness, removing unused headers, and wrapping test instantiations in anonymous namespaces. ### Tickets: - *C-174556* --------- Signed-off-by: alexandruenache1111 <[email protected]>
1 parent 202cb3e commit d0f6cf0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+333
-317
lines changed

src/plugins/intel_npu/tests/functional/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ ov_add_test_target(
3333
EXCLUDED_SOURCE_PATHS
3434
${EXCLUDED_FUNC_TESTS_DIR}
3535
INCLUDES
36+
# OpenVINO headers need to be added before the NPU headers
37+
# Otherwise, the compiler may mistake OpenVINO headers for the NPU headers
38+
"${OpenVINO_SOURCE_DIR}/src/tests/functional/base_func_tests/include"
3639
${CMAKE_CURRENT_SOURCE_DIR}
3740
${OPTIONAL_FUNC_TESTS_INCLUDES}
3841
"${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances"

src/plugins/intel_npu/tests/functional/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,36 @@ By default, the environment variable `OV_NPU_TESTS_SKIP_CONFIG_FILE` is set to f
5454
Skip filters can be enabled/disabled according to rules defining the device, backend or operating system, depending on where tests are supposed to run.
5555
Rules are optional, multiple rules can be chained together. Users can negate a rule by using "!".
5656
When determining if a skip filter is active, rules across different categories (backend, device, operating_system) are combined using an AND operation. While multiple entries of the same category will use an OR operation.
57+
58+
## Folder structure
59+
60+
### Behavior
61+
The folder structure of the `behavior` directory follows the folder structure of the OpenVINO base tests.
62+
63+
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.
64+
65+
The E2E tests reside here.
66+
67+
### Common
68+
The place of utility functions and `getTestCaseName` base implementations.
69+
70+
### Internal
71+
The folder structure is mirrored from the one in the `intel_npu/src` directory.
72+
73+
The NPU implementations of test classes and their corresponding tests are located here.
74+
75+
### Shared tests instances
76+
OpenVINO test instantiations using NPU Plugin's own arguments.
77+
78+
## Test developing convention
79+
80+
Any test should be split into a `.hpp` and `.cpp` file, with the exception of the tests from `shared_tests_instances`, which don't need `.hpp` files. A test's `.hpp` file should be located in the same directory as its `.cpp` file.
81+
82+
The `.hpp` file should have the entirety of its contents wrapped around the `ov::test::behavior` namespace.
83+
The contents are:
84+
- class declarations
85+
- methods/functions definitions
86+
- test definitions
87+
- aliases
88+
89+
The `.cpp` file contains the test instantiations and the variables passed as arguments. The contents should be wrapped around an anonymous/unnamed namespace.

src/plugins/intel_npu/tests/functional/behavior/batched_tensors_tests/batched_run.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5-
#include "behavior/batched_tensors_tests/batched_run.hpp"
5+
#include "batched_run.hpp"
66

77
#include "common/npu_test_env_cfg.hpp"
88
#include "common/utils.hpp"

src/plugins/intel_npu/tests/functional/behavior/batched_tensors_tests/batched_run.hpp

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@
1010

1111
#include "common/npu_test_env_cfg.hpp"
1212
#include "common/utils.hpp"
13-
#include "functional_test_utils/ov_plugin_cache.hpp"
14-
#include "intel_npu/npu_private_properties.hpp"
1513
#include "openvino/core/any.hpp"
1614
#include "openvino/core/node_vector.hpp"
17-
#include "openvino/core/type/element_iterator.hpp"
18-
#include "openvino/op/op.hpp"
1915
#include "openvino/opsets/opset8.hpp"
2016
#include "openvino/runtime/compiled_model.hpp"
2117
#include "openvino/runtime/core.hpp"
2218
#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"
23-
#include "overload/overload_test_utils_npu.hpp"
2419
#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
2520

2621
using CompilationParams = std::tuple<std::string, // Device name
@@ -66,9 +61,9 @@ class BatchedTensorsRunTests : public ov::test::behavior::OVPluginTestBase,
6661
}
6762

6863
void SetUp() override {
69-
std::tie(target_device, configuration) = this->GetParam();
64+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
7065

71-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
66+
std::tie(target_device, configuration) = this->GetParam();
7267
OVPluginTestBase::SetUp();
7368
ov_model = getDefaultNGraphFunctionForTheDeviceNPU(); // FIXME: E#80555
7469
}
@@ -80,8 +75,7 @@ class BatchedTensorsRunTests : public ov::test::behavior::OVPluginTestBase,
8075
auto hash = std::to_string(std::hash<std::string>()(test_name));
8176
std::stringstream ss;
8277
auto ts = duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch());
83-
ss << hash << "_"
84-
<< "_" << ts.count();
78+
ss << hash << "_" << "_" << ts.count();
8579
return ss.str();
8680
}
8781

@@ -139,8 +133,7 @@ void executeContiguousTensorBatchInfer(ov::InferRequest req,
139133
ov::RemoteContext& context);
140134

141135
TEST_P(BatchedTensorsRunTests, SetInputRemoteTensorsMultipleInfer) {
142-
// Skip test according to plugin specific disabledTestPatterns() (if any)
143-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
136+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
144137

145138
size_t batch = 4;
146139
auto one_shape = Shape{1, 2, 2, 2};
@@ -173,14 +166,12 @@ TEST_P(BatchedTensorsRunTests, SetInputRemoteTensorsMultipleInfer) {
173166
for (size_t j = 0; j < one_shape_size * batch; ++j) {
174167
ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21
175168
<< ", actual=" << actual[j] << " for index " << j;
176-
177169
}
178170
}
179171
}
180172

181173
TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInfer) {
182-
// Skip test according to plugin specific disabledTestPatterns() (if any)
183-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
174+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
184175

185176
size_t batch = 4;
186177
auto one_shape = Shape{1, 2, 2, 2};
@@ -226,8 +217,7 @@ TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInfer) {
226217
}
227218

228219
TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInferMCL) {
229-
// Skip test according to plugin specific disabledTestPatterns() (if any)
230-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
220+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
231221

232222
size_t batch = 4;
233223
auto one_shape = Shape{1, 16, 16, 16};
@@ -310,8 +300,7 @@ TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInferMCL) {
310300
}
311301

312302
TEST_P(BatchedTensorsRunTests, SetInputDifferentRemoteTensorsMultipleInferMCL) {
313-
// Skip test according to plugin specific disabledTestPatterns() (if any)
314-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
303+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
315304

316305
size_t batch = 4;
317306
auto one_shape = Shape{1, 2, 2, 2};
@@ -436,8 +425,7 @@ TEST_P(BatchedTensorsRunTests, SetInputDifferentRemoteTensorsMultipleInferMCL) {
436425
using DynamicBatchedTensorsRunTests = BatchedTensorsRunTests;
437426

438427
TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsMultipleInfer) {
439-
// Skip test according to plugin specific disabledTestPatterns() (if any)
440-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
428+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
441429

442430
size_t batch = 4;
443431
auto one_shape = Shape{1, 2, 2, 2};
@@ -530,8 +518,7 @@ void executeMutlipleTensorsBatchInfer(ov::InferRequest req,
530518
}
531519

532520
TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicBatchInflation) {
533-
// Skip test according to plugin specific disabledTestPatterns() (if any)
534-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
521+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
535522

536523
size_t batch = 4;
537524
auto one_shape = Shape{1, 2, 2, 2};
@@ -559,8 +546,7 @@ TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicBatchIn
559546
}
560547

561548
TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicBatchDeflation) {
562-
// Skip test according to plugin specific disabledTestPatterns() (if any)
563-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
549+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
564550

565551
size_t batch = 4;
566552
auto one_shape = Shape{1, 2, 2, 2};
@@ -588,8 +574,7 @@ TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicBatchDe
588574
}
589575

590576
TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorSingleInfer) {
591-
// Skip test according to plugin specific disabledTestPatterns() (if any)
592-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
577+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
593578

594579
size_t batch = 4;
595580
size_t tensor_batch = 3;
@@ -674,8 +659,7 @@ void executeContiguousTensorBatchInfer(ov::InferRequest req,
674659
}
675660

676661
TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBatchInflation) {
677-
// Skip test according to plugin specific disabledTestPatterns() (if any)
678-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
662+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
679663

680664
size_t batch = 4;
681665
auto one_shape = Shape{1, 2, 2, 2};
@@ -705,8 +689,7 @@ TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBa
705689
}
706690

707691
TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBatchDeflation) {
708-
// Skip test according to plugin specific disabledTestPatterns() (if any)
709-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
692+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
710693

711694
size_t batch = 4;
712695
auto one_shape = Shape{1, 2, 2, 2};
@@ -736,8 +719,7 @@ TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBa
736719
}
737720

738721
TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputDifferentTensorsMultipleInfer) {
739-
// Skip test according to plugin specific disabledTestPatterns() (if any)
740-
SKIP_IF_CURRENT_TEST_IS_DISABLED()
722+
SKIP_IF_CURRENT_TEST_IS_DISABLED();
741723

742724
size_t batch = 4;
743725
auto one_shape = Shape{1, 2, 2, 2};

src/plugins/intel_npu/tests/functional/behavior/compiled_model/blob_compatibility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5-
#include "overload/compiled_model/blob_compatibility.hpp"
5+
#include "blob_compatibility.hpp"
66

77
#include <gtest/gtest.h>
88

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,8 @@
77
#include <gtest/gtest.h>
88

99
#include "common/npu_test_env_cfg.hpp"
10-
#include "openvino/core/except.hpp"
11-
#include "openvino/core/version.hpp"
1210
#include "shared_test_classes/base/ov_behavior_test_utils.hpp"
1311

14-
// models generation
15-
#include "openvino/op/abs.hpp"
16-
#include "openvino/op/add.hpp"
17-
#include "openvino/op/concat.hpp"
18-
#include "openvino/op/constant.hpp"
19-
#include "openvino/op/convolution.hpp"
20-
#include "openvino/op/matmul.hpp"
21-
#include "openvino/op/max_pool.hpp"
22-
#include "openvino/op/relu.hpp"
23-
#include "openvino/op/reshape.hpp"
24-
#include "openvino/op/softmax.hpp"
25-
#include "openvino/op/split.hpp"
26-
2712
namespace {
2813

2914
const char* const BLOB_PREFIX = "blob_compatibility_";

src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5-
#include "overload/compiled_model/import_export.hpp"
5+
#include "import_export.hpp"
66

77
#include <gtest/gtest.h>
88

9-
#include <map>
10-
#include <string>
11-
129
#include "common/utils.hpp"
1310

1411
using namespace ov::test::behavior;
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5+
#pragma once
6+
7+
#include <behavior/compiled_model/import_export.hpp>
58
#include <sstream>
69

7-
#include "behavior/compiled_model/import_export.hpp"
810
#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"
911
#include "intel_npu/npu_private_properties.hpp"
1012
#include "openvino/runtime/make_tensor.hpp"

src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5-
#include "internal/overload/compiled_model/property.hpp"
5+
#include "property.hpp"
66

77
#include <openvino/runtime/intel_npu/properties.hpp>
88
#include <vector>
99

10-
#include "behavior/compiled_model/properties.hpp"
1110
#include "common/npu_test_env_cfg.hpp"
12-
#include "common/utils.hpp"
13-
#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"
14-
#include "intel_npu/config/options.hpp"
1511

1612
using namespace ov::test::behavior;
1713

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5+
#pragma once
6+
57
#include <openvino/runtime/intel_npu/properties.hpp>
68
#include <vector>
79

810
#include "behavior/compiled_model/properties.hpp"
911
#include "common/npu_test_env_cfg.hpp"
10-
#include "common/utils.hpp"
1112
#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"
12-
#include "intel_npu/config/options.hpp"
13-
#include "openvino/util/log.hpp"
1413

1514
using namespace ov::test::behavior;
1615

0 commit comments

Comments
 (0)