Skip to content

Commit

Permalink
Cleaning and refactoring test utils (#22653)
Browse files Browse the repository at this point in the history
### Details:
 - Cleaning and refactoring test utils

### Tickets:
 - [CVS-111359](https://jira.devtools.intel.com/browse/CVS-111359)
  • Loading branch information
olpipi authored Feb 7, 2024
1 parent 56719ac commit 8f23227
Show file tree
Hide file tree
Showing 56 changed files with 41 additions and 1,499 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "common_test_utils/common_utils.hpp"
#include "common_test_utils/ov_test_utils.hpp"
#include "common_test_utils/test_common.hpp"
#include "functional_test_utils/plugin_cache.hpp"
#include "openvino/core/model.hpp"
#include "openvino/opsets/opset4.hpp"
#include "openvino/pass/manager.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "ov_models/utils/ov_helpers.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "utils/cpu_test_utils.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"

using namespace CPUTestUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include <common_test_utils/test_constants.hpp>
#include "execution_graph_tests/add_output.hpp"
#include "functional_test_utils/plugin_cache.hpp"
#include "openvino/op/multiply.hpp"
#include "openvino/op/sigmoid.hpp"
#include "openvino/op/constant.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@


#include "common_test_utils/test_common.hpp"
#include "functional_test_utils/plugin_cache.hpp"
#include "functional_test_utils/blob_utils.hpp"
#include "openvino/core/preprocess/pre_post_process.hpp"
#include "transformations/utils/utils.hpp"
#include "common_test_utils/file_utils.hpp"
Expand Down Expand Up @@ -242,20 +240,15 @@ TEST(smoke_InferRequestDeviceMemoryAllocation, usmHostIsNotChanged) {
// Modify tensor somehow and save as a reference values
ov::test::utils::fill_tensor_random(output_tensor2);

std::vector<float> ref_values;
ref_values.resize(output_tensor2.get_byte_size());
std::memcpy(ref_values.data(), output_tensor2.data(), output_tensor2.get_byte_size());
ov::Tensor ref_tensor(output_tensor2.get_element_type(), output_tensor2.get_shape());
output_tensor2.copy_to(ref_tensor);

// Perform second infer() call with a system host memory tensor
infer_request1.set_output_tensor(output_tensor1);
ASSERT_NO_THROW(infer_request1.infer());

// Expect that output_tensor2 will not change it's data after infer() call
FuncTestUtils::compareRawBuffers(ref_values.data(),
output_tensor2.data<float>(),
ref_values.size(),
ov::shape_size(output_tensor2.get_shape()),
1e-4f);
ov::test::utils::compare(ref_tensor, output_tensor2, 1e-4);
}

TEST(smoke_InferRequestDeviceMemoryAllocation, canSetSystemHostTensor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "remote_tensor_tests/helpers.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "common_test_utils/data_utils.hpp"
#include "base/ov_behavior_test_utils.hpp"
#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"
#include "common_test_utils/subgraph_builders/split_multi_conv_concat.hpp"
Expand Down Expand Up @@ -1891,9 +1892,9 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toBGR_image_single_plane) {
ASSERT_EQ(output_tensor_regular.get_size() * num_batch, output_tensor_shared.get_size());
float thr = 0.1f;

FuncTestUtils::compareRawBuffers<float>(static_cast<float*>(output_tensor_shared.data()) + i * output_tensor_regular.get_size(),
ov::test::utils::compare_raw_data(static_cast<float*>(output_tensor_shared.data()) + i * output_tensor_regular.get_size(),
static_cast<float*>(output_tensor_regular.data()),
output_tensor_regular.get_size(), output_tensor_regular.get_size(), thr);
output_tensor_regular.get_size(), thr);
}
}

Expand Down Expand Up @@ -2022,9 +2023,9 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toBGR_image_two_planes) {
ASSERT_EQ(output_tensor_regular.get_size() * num_batch, output_tensor_shared.get_size());
float thr = 0.1f;

FuncTestUtils::compareRawBuffers<float>(static_cast<float*>(output_tensor_shared.data()) + i * output_tensor_regular.get_size(),
ov::test::utils::compare_raw_data(static_cast<float*>(output_tensor_shared.data()) + i * output_tensor_regular.get_size(),
static_cast<float*>(output_tensor_regular.data()),
output_tensor_regular.get_size(), output_tensor_regular.get_size(), thr);
output_tensor_regular.get_size(), thr);
}
}

Expand Down Expand Up @@ -2145,9 +2146,9 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toGray) {
ASSERT_EQ(output_tensor_regular.get_size() * num_batch, output_tensor_shared.get_size());
float thr = 0.1f;

FuncTestUtils::compareRawBuffers<float>(static_cast<float*>(output_tensor_shared.data()) + i * output_tensor_regular.get_size(),
ov::test::utils::compare_raw_data(static_cast<float*>(output_tensor_shared.data()) + i * output_tensor_regular.get_size(),
static_cast<float*>(output_tensor_regular.data()),
output_tensor_regular.get_size(), output_tensor_regular.get_size(), thr);
output_tensor_regular.get_size(), thr);
}
}

Expand Down Expand Up @@ -2304,9 +2305,9 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toBGR_buffer) {
ASSERT_EQ(output_tensor_regular.get_size() * num_batch, out_tensor_new.get_size());
float thr = 0.1f;

FuncTestUtils::compareRawBuffers<float>(static_cast<float*>(out_tensor_new.data()) + i * output_tensor_regular.get_size(),
static_cast<float*>(output_tensor_regular.data()),
output_tensor_regular.get_size(), output_tensor_regular.get_size(), thr);
ov::test::utils::compare_raw_data(static_cast<float*>(out_tensor_new.data()) + i * output_tensor_regular.get_size(),
static_cast<float*>(output_tensor_regular.data()),
output_tensor_regular.get_size(), thr);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ std::vector<ov::Tensor> ReadIRTest::calculate_refs() {
std::ifstream ref_data_ifstream(path_to_ref_tensor, std::ifstream::binary);
ref_data_ifstream.open(path_to_ref_tensor, std::ios::binary);
if (!ref_data_ifstream.is_open())
IE_THROW() << "Weights file " << path_to_ref_tensor << " cannot be opened!";
OPENVINO_THROW("Weights file ", path_to_ref_tensor, " cannot be opened!");

size_t buf_size = 0;
for (const auto& output : functionRefs->outputs()) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
#include "functional_test_utils/crash_handler.hpp"
#include "common_test_utils/file_utils.hpp"

#include "functional_test_utils/plugin_cache.hpp"
#include "functional_test_utils/ov_plugin_cache.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
#include "functional_test_utils/blob_utils.hpp"
#include "functional_test_utils/summary/api_summary.hpp"
#include "openvino/util/file_util.hpp"
#include "common_test_utils/subgraph_builders/split_conv_concat.hpp"
Expand Down Expand Up @@ -147,7 +145,7 @@ class OVInferRequestTests : public testing::WithParamInterface<InferRequestParam

void TearDown() override {
if (!configuration.empty()) {
PluginCache::get().reset();
ov::test::utils::PluginCache::get().reset();
}
APIBaseTest::TearDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "base/ov_behavior_test_utils.hpp"
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/ov_test_utils.hpp"
#include "functional_test_utils/plugin_cache.hpp"
#include "openvino/op/concat.hpp"
#include "openvino/runtime/exec_model_info.hpp"
#include "openvino/runtime/tensor.hpp"
Expand Down Expand Up @@ -362,7 +361,7 @@ TEST_P(OVCompiledModelBaseTestOptional, CheckExecGraphInfoBeforeExecution) {

auto getExecValue = [&rtInfo](const std::string& paramName) -> std::string {
auto it = rtInfo.find(paramName);
IE_ASSERT(rtInfo.end() != it);
OPENVINO_ASSERT(rtInfo.end() != it);
return it->second.as<std::string>();
};

Expand Down Expand Up @@ -414,7 +413,7 @@ TEST_P(OVCompiledModelBaseTestOptional, CheckExecGraphInfoAfterExecution) {

auto getExecValue = [&rtInfo](const std::string& paramName) -> std::string {
auto it = rtInfo.find(paramName);
IE_ASSERT(rtInfo.end() != it);
OPENVINO_ASSERT(rtInfo.end() != it);
return it->second.as<std::string>();
};

Expand Down Expand Up @@ -682,7 +681,7 @@ class CompiledModelSetType : public testing::WithParamInterface<CompiledModelSet
}
void TearDown() override {
if (!configuration.empty()) {
PluginCache::get().reset();
ov::test::utils::PluginCache::get().reset();
}
APIBaseTest::TearDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <gtest/gtest.h>
#include <string>
#include "functional_test_utils/ov_plugin_cache.hpp"
#include <base/behavior_test_utils.hpp>
#include "base/ov_behavior_test_utils.hpp"

namespace ov {
namespace test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
#include "shared_test_classes/base/layer_test_utils.hpp"
#include <string>
#include <thread>
#include <base/behavior_test_utils.hpp>
#include "base/ov_behavior_test_utils.hpp"
#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/plugin_cache.hpp"
#include "functional_test_utils/blob_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"

// TODO [mandrono]: move current test case inside CPU plug-in and return the original tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <gtest/gtest.h>
#include <string>
#include "functional_test_utils/ov_plugin_cache.hpp"
#include <base/behavior_test_utils.hpp>
#include "base/ov_behavior_test_utils.hpp"

namespace ov {
namespace test {
Expand Down
Loading

0 comments on commit 8f23227

Please sign in to comment.