Skip to content

Commit

Permalink
[GPU] Move functional tests to intel_gpu/tests (openvinotoolkit#17248)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-paramuzov authored Apr 28, 2023
1 parent 62ed45b commit c6ec6d4
Show file tree
Hide file tree
Showing 479 changed files with 231 additions and 344 deletions.
88 changes: 3 additions & 85 deletions src/plugins/intel_gpu/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,88 +1,6 @@
# Copyright (C) 2018-2023 Intel Corporation
# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

# TODO: fix in tests
if(SUGGEST_OVERRIDE_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
ie_add_compiler_flags(/wd4305)
endif()

set(TARGET_NAME "ov_gpu_unit_tests")

file(GLOB_RECURSE SOURCES_MAIN
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/*.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
# ngraph graph transformation
"${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/*.hpp"
"${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/*.cpp"
)

if (NOT ENABLE_ONEDNN_FOR_GPU)
set(EXCLUDE_DIR "/onednn/")
foreach (SOURCE_FILE ${SOURCES_MAIN})
string (FIND ${SOURCE_FILE} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND)
if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
message (Exclude : ${SOURCE_FILE})
list (REMOVE_ITEM SOURCES_MAIN ${SOURCE_FILE})
endif ()
endforeach(SOURCE_FILE)
endif()

if (MSVC)
file(GLOB SOURCES_NATVIS
"${CMAKE_CURRENT_SOURCE_DIR}/float16.natvis"
)
endif()

set(SOURCES_ALL
${SOURCES_MAIN}
${SOURCES_NATVIS}
)

add_executable(${TARGET_NAME} ${SOURCES_ALL})

set_ie_threading_interface_for(${TARGET_NAME})

# Workaround to avoid warnings during LTO build
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS_RELEASE "-Wno-error=maybe-uninitialized -Wno-maybe-uninitialized")
endif()

set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE ${ENABLE_LTO})

target_link_libraries(${TARGET_NAME} PRIVATE openvino_intel_gpu_graph
inference_engine
OpenCL::OpenCL
gtest
gtest_main
gflags
ngraph_reference
inference_engine_transformations
gmock)

target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/test_utils/
$<TARGET_PROPERTY:openvino_intel_gpu_kernels,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:openvino_intel_gpu_runtime,INTERFACE_INCLUDE_DIRECTORIES>
${CMAKE_HOME_DIRECTORY}/src/core/reference/include/)

if(WIN32)
target_link_libraries(${TARGET_NAME} PRIVATE setupapi)
elseif((NOT ANDROID) AND (UNIX))
target_link_libraries(${TARGET_NAME} PRIVATE pthread)
endif()

if(ENABLE_SSE42)
ie_sse42_optimization_flags(sse4_2_flags)
set_source_files_properties(${SOURCES_ALL} PROPERTIES COMPILE_FLAGS "${sse4_2_flags}")
endif()

install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION tests
COMPONENT tests
EXCLUDE_FROM_ALL)
add_subdirectory(unit)
add_subdirectory(functional)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

set(TARGET_NAME ov_gpu_func_tests)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# C4267, 4244 issues from oneDNN headers conversion from 'XXX' to 'YYY', possible loss of data
ie_add_compiler_flags(/wd4267)
ie_add_compiler_flags(/wd4244)
# 'initializing': truncation from 'XXX' to 'YYY'
ie_add_compiler_flags(/wd4305)
endif()

addIeTargetTest(
NAME
${TARGET_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class MemoryDynamicBatch : public ::testing::Test,
auto len = ov::shape_size(shape);
std::vector<int> result {};
result.reserve(len);
for (int i = 0; i < len; i++)
result.push_back(i);
for (size_t i = 0; i < len; i++)
result.push_back(static_cast<int>(i));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class OVConcurrencyTest : public CommonTestUtils::TestsCommon,
ov::ResultVector outputs;
std::vector<ov::InferRequest> irs;
std::vector<std::vector<uint8_t>> ref;
std::vector<int> outElementsCount;
std::vector<size_t> outElementsCount;

for (size_t i = 0; i < fn_ptrs.size(); ++i) {
auto fn = fn_ptrs[i];
Expand All @@ -68,20 +68,20 @@ class OVConcurrencyTest : public CommonTestUtils::TestsCommon,
if (is_caching_test) {
{
auto _dummy_exec_net = ie.compile_model(fn_ptrs[i], CommonTestUtils::DEVICE_GPU,
ov::num_streams(num_streams), ov::hint::inference_precision(ov::element::f32));
ov::num_streams(ov::streams::Num(num_streams)), ov::hint::inference_precision(ov::element::f32));
}
{
exec_net = ie.compile_model(fn_ptrs[i], CommonTestUtils::DEVICE_GPU,
ov::num_streams(num_streams), ov::hint::inference_precision(ov::element::f32));
ov::num_streams(ov::streams::Num(num_streams)), ov::hint::inference_precision(ov::element::f32));
}
} else {
exec_net = ie.compile_model(fn_ptrs[i], CommonTestUtils::DEVICE_GPU,
ov::num_streams(num_streams), ov::hint::inference_precision(ov::element::f32));
ov::num_streams(ov::streams::Num(num_streams)), ov::hint::inference_precision(ov::element::f32));
}

auto output = fn_ptrs[i]->get_results().at(0);

for (int j = 0; j < num_streams * num_requests; j++) {
for (size_t j = 0; j < num_streams * num_requests; j++) {
outputs.push_back(output);

auto inf_req = exec_net.create_infer_request();
Expand Down Expand Up @@ -188,7 +188,7 @@ TEST(canSwapTensorsBetweenInferRequests, inputs) {
thr);
};

for (size_t i = 0; i < infer_requests_num; i++) {
for (int32_t i = 0; i < infer_requests_num; i++) {
FuncTestUtils::fill_tensor(input_tensors[i], 10, -5, 1, i);
calc_ref_results(input_tensors[i]);
}
Expand Down Expand Up @@ -333,7 +333,7 @@ TEST(canSwapTensorsBetweenInferRequests, outputs) {
thr);
};

for (size_t i = 0; i < infer_requests_num; i++) {
for (int32_t i = 0; i < infer_requests_num; i++) {
FuncTestUtils::fill_tensor(input_tensors[i], 10, -5, 1, i);
calc_ref_results(input_tensors[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,9 @@ TEST_P(BatchedBlob_Test, canInputNV12) {
std::vector<InferenceEngine::Blob::Ptr> fake_image_data_y;
std::vector<InferenceEngine::Blob::Ptr> fake_image_data_uv;

for (int i = 0; i < num_batch; i++) {
fake_image_data_y.push_back(FuncTestUtils::createAndFillBlob(y_plane_desc, 50, 0, 1, i));
fake_image_data_uv.push_back(FuncTestUtils::createAndFillBlob(uv_plane_desc, 256, 0, 1, i));
for (size_t i = 0; i < num_batch; i++) {
fake_image_data_y.push_back(FuncTestUtils::createAndFillBlob(y_plane_desc, 50, 0, 1, static_cast<int32_t>(i)));
fake_image_data_uv.push_back(FuncTestUtils::createAndFillBlob(uv_plane_desc, 256, 0, 1, static_cast<int32_t>(i)));
}

auto ie = InferenceEngine::Core();
Expand All @@ -612,7 +612,7 @@ TEST_P(BatchedBlob_Test, canInputNV12) {
std::vector<cl::Image2D> img_y, img_uv;
std::vector<Blob::Ptr> blob_remote;

for (int i = 0; i < num_batch; i++) {
for (size_t i = 0; i < num_batch; i++) {
cl_image_format image_format;
cl_image_desc image_desc = { 0 };
image_format.image_channel_order = CL_R;
Expand Down Expand Up @@ -675,7 +675,7 @@ TEST_P(BatchedBlob_Test, canInputNV12) {
auto inf_req_local = exec_net_b1.CreateInferRequest();

// Run regular input for each image and compare against batched blob
for (int i = 0; i < num_batch; i++) {
for (size_t i = 0; i < num_batch; i++) {
auto y_blob = make_shared_blob<uint8_t>(y_plane_desc, fake_image_data_y[i]->buffer().as<uint8_t *>());
auto uv_blob = make_shared_blob<uint8_t>(uv_plane_desc, fake_image_data_uv[i]->buffer().as<uint8_t *>());
auto blob = make_shared_blob<NV12Blob>(y_blob, uv_blob);
Expand All @@ -687,7 +687,7 @@ TEST_P(BatchedBlob_Test, canInputNV12) {
auto split_shared_blob = make_shared_blob<float_t>(output_blob_local->getTensorDesc(),
outputBlob_shared->buffer().as<float_t *>() + output_blob_local->size() * i);
ASSERT_EQ(output_blob_local->size(), split_shared_blob->size());
float thr = 0.1;
float thr = 0.1f;

FuncTestUtils::compareBlobs(output_blob_local, split_shared_blob, thr, "", false);
}
Expand Down Expand Up @@ -744,7 +744,7 @@ TEST_P(TwoNets_Test, canInferTwoExecNets) {
{{PluginConfigParams::KEY_GPU_THROUGHPUT_STREAMS, std::to_string(num_streams)},
{ov::hint::inference_precision.name(), "f32"}});

for (int j = 0; j < num_streams * num_requests; j++) {
for (size_t j = 0; j < num_streams * num_requests; j++) {
outputs.push_back(net.getOutputsInfo().begin()->first);

auto inf_req = exec_net.CreateInferRequest();
Expand All @@ -754,7 +754,7 @@ TEST_P(TwoNets_Test, canInferTwoExecNets) {
inf_req.SetBlob(net.getInputsInfo().begin()->first, blob);

outElementsCount.push_back(
std::accumulate(begin(fn_ptrs[i]->get_output_shape(0)), end(fn_ptrs[i]->get_output_shape(0)), 1,
std::accumulate(begin(fn_ptrs[i]->get_output_shape(0)), end(fn_ptrs[i]->get_output_shape(0)), (size_t)1,
std::multiplies<size_t>()));
const auto inBlob = inf_req.GetBlob(net.getInputsInfo().begin()->first);
const auto blobSize = inBlob->byteSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class OVRemoteTensor_Test : public CommonTestUtils::TestsCommon {
}
};

namespace {
std::vector<bool> ov_with_auto_batching {true, false};
enum class RemoteTensorSharingType {
USER_CL_TENSOR = 0,
Expand All @@ -56,6 +57,7 @@ std::ostream& operator<<(std::ostream& stream, RemoteTensorSharingType sharing_t

return stream;
}
} // namespace

using RemoteTensorSharingTestOptionsParams = std::tuple<RemoteTensorSharingType, bool /*auto-batching*/>;

Expand Down Expand Up @@ -300,8 +302,9 @@ TEST_P(OVRemoteTensorInputBlob_Test, smoke_canInputRemoteTensor) {
{
ASSERT_NO_THROW(cldnn_tensor.data());
void* shared_buffer = cldnn_tensor.data();
if (ocl_instance->supports_usm())
if (ocl_instance->supports_usm()) {
ASSERT_EQ(ocl_instance->get_allocation_type(shared_buffer), CL_MEM_TYPE_HOST_INTEL);
}
void* buffer = fakeImageData.data();
std::memcpy(shared_buffer, buffer, imSize);
}
Expand Down Expand Up @@ -699,7 +702,7 @@ TEST_P(OVRemoteTensor_TestsWithContext, smoke_canCreateManyTensorsOnSameMem) {
auto input = fn_ptr->get_parameters().at(0);
ov::Shape input_shape = input->get_shape();
auto imSize = ov::shape_size(input_shape);
void* usm_ptr = usm_ptr = ocl_instance->allocate_usm_host_buffer(imSize*sizeof(float));
void* usm_ptr = ocl_instance->allocate_usm_host_buffer(imSize*sizeof(float));

auto ie = ov::Core();
auto remote_context = ov::intel_gpu::ocl::ClContext(ie, ocl_instance->_context.get());
Expand Down Expand Up @@ -818,7 +821,7 @@ TEST_F(OVRemoteTensor_Test, NV12toGray) {
ASSERT_EQ(output_tensor_regular.get_size(), output_tensor_shared.get_size());
ASSERT_NO_THROW(output_tensor_regular.data());
ASSERT_NO_THROW(output_tensor_shared.data());
float thr = 0.1;
float thr = 0.1f;
FuncTestUtils::compare_tensor(output_tensor_shared, output_tensor_regular, thr);
}

Expand Down Expand Up @@ -927,7 +930,7 @@ TEST_F(OVRemoteTensor_Test, NV12toBGR_image_ConvertTranspose) {
ASSERT_EQ(output_tensor_regular.get_size(), output_tensor_shared.get_size());
ASSERT_NO_THROW(output_tensor_regular.data());
ASSERT_NO_THROW(output_tensor_shared.data());
float thr = 0.1;
float thr = 0.1f;
FuncTestUtils::compare_tensor(output_tensor_shared, output_tensor_regular, thr);
}

Expand Down Expand Up @@ -1017,7 +1020,7 @@ TEST_F(OVRemoteTensor_Test, NV12toBGR_image_single_plane) {
ASSERT_EQ(output_tensor_regular.get_size(), output_tensor_shared.get_size());
ASSERT_NO_THROW(output_tensor_regular.data());
ASSERT_NO_THROW(output_tensor_shared.data());
float thr = 0.1;
float thr = 0.1f;
FuncTestUtils::compare_tensor(output_tensor_shared, output_tensor_regular, thr);
}

Expand Down Expand Up @@ -1126,7 +1129,7 @@ TEST_F(OVRemoteTensor_Test, NV12toBGR_image_two_planes) {
ASSERT_EQ(output_tensor_regular.get_size(), output_tensor_shared.get_size());
ASSERT_NO_THROW(output_tensor_regular.data());
ASSERT_NO_THROW(output_tensor_shared.data());
float thr = 0.1;
float thr = 0.1f;
FuncTestUtils::compare_tensor(output_tensor_shared, output_tensor_regular, thr);
}

Expand Down Expand Up @@ -1212,7 +1215,7 @@ TEST_F(OVRemoteTensor_Test, NV12toBGR_buffer) {
ASSERT_EQ(output_tensor_regular.get_size(), out_tensor.get_size());
ASSERT_NO_THROW(output_tensor_regular.data());
ASSERT_NO_THROW(out_tensor.data());
float thr = 0.1;
float thr = 0.1f;
FuncTestUtils::compare_tensor(out_tensor, output_tensor_regular, thr);
}

Expand Down Expand Up @@ -1240,8 +1243,8 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toBGR_image_single_plane) {
// ------------------------------------------------------
// Prepare input data
std::vector<ov::Tensor> fake_image_data_yuv;
for (int i = 0; i < num_batch; i++) {
fake_image_data_yuv.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 1, height * 3 / 2, width}, 50, 0, 1, i));
for (size_t i = 0; i < num_batch; i++) {
fake_image_data_yuv.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 1, height * 3 / 2, width}, 50, 0, 1, static_cast<int32_t>(i)));
}

auto ie = ov::Core();
Expand Down Expand Up @@ -1328,7 +1331,7 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toBGR_image_single_plane) {
auto output_tensor_regular = inf_req_regular.get_tensor(exec_net_regular.output());

ASSERT_EQ(output_tensor_regular.get_size() * num_batch, output_tensor_shared.get_size());
float thr = 0.1;
float thr = 0.1f;

FuncTestUtils::compareRawBuffers<float>(static_cast<float*>(output_tensor_shared.data()) + i * output_tensor_regular.get_size(),
static_cast<float*>(output_tensor_regular.data()),
Expand All @@ -1346,9 +1349,9 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toBGR_image_two_planes) {
// ------------------------------------------------------
// Prepare input data
std::vector<ov::Tensor> fake_image_data_y, fake_image_data_uv;
for (int i = 0; i < num_batch; i++) {
fake_image_data_y.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 1, height, width}, 50, 0, 1, i));
fake_image_data_uv.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 2, height / 2, width / 2}, 256, 0, 1, i));
for (size_t i = 0; i < num_batch; i++) {
fake_image_data_y.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 1, height, width}, 50, 0, 1, static_cast<int32_t>(i)));
fake_image_data_uv.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 2, height / 2, width / 2}, 256, 0, 1, static_cast<int32_t>(i)));
}

auto ie = ov::Core();
Expand Down Expand Up @@ -1453,7 +1456,7 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toBGR_image_two_planes) {
auto output_tensor_regular = inf_req_regular.get_tensor(exec_net_regular.output());

ASSERT_EQ(output_tensor_regular.get_size() * num_batch, output_tensor_shared.get_size());
float thr = 0.1;
float thr = 0.1f;

FuncTestUtils::compareRawBuffers<float>(static_cast<float*>(output_tensor_shared.data()) + i * output_tensor_regular.get_size(),
static_cast<float*>(output_tensor_regular.data()),
Expand All @@ -1473,8 +1476,8 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toGray) {
// Prepare input data
std::vector<ov::Tensor> fake_image;
std::vector<ov::Tensor> fake_image_regular;
for (int i = 0; i < num_batch; i++) {
auto tensor_image = FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, feature, height, width}, 50, 0, 1, i);
for (size_t i = 0; i < num_batch; i++) {
auto tensor_image = FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, feature, height, width}, 50, 0, 1, static_cast<int32_t>(i));
auto tensor_regular = FuncTestUtils::create_and_fill_tensor(ov::element::f32, {1, feature, height, width});
auto image_ptr = static_cast<uint8_t*>(tensor_image.data());
auto image_ptr_regular = static_cast<float*>(tensor_regular.data());
Expand Down Expand Up @@ -1571,7 +1574,7 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toGray) {
auto output_tensor_regular = inf_req_regular.get_tensor(exec_net_regular.output());

ASSERT_EQ(output_tensor_regular.get_size() * num_batch, output_tensor_shared.get_size());
float thr = 0.1;
float thr = 0.1f;

FuncTestUtils::compareRawBuffers<float>(static_cast<float*>(output_tensor_shared.data()) + i * output_tensor_regular.get_size(),
static_cast<float*>(output_tensor_regular.data()),
Expand All @@ -1590,8 +1593,8 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toBGR_buffer) {
// Prepare input data
std::vector<ov::Tensor> fake_image_data_y, fake_image_data_uv;
for (size_t i = 0; i < num_batch * 2; ++i) {
fake_image_data_y.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 1, height, width}, 50, 0, 1, i));
fake_image_data_uv.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 2, height / 2, width / 2}, 256, 0, 1, i));
fake_image_data_y.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 1, height, width}, 50, 0, 1, static_cast<int32_t>(i)));
fake_image_data_uv.push_back(FuncTestUtils::create_and_fill_tensor(ov::element::u8, {1, 2, height / 2, width / 2}, 256, 0, 1, static_cast<int32_t>(i)));
}

auto ie = ov::Core();
Expand Down Expand Up @@ -1724,7 +1727,7 @@ TEST_P(OVRemoteTensorBatched_Test, NV12toBGR_buffer) {
auto output_tensor_regular = inf_req_regular.get_tensor(exec_net_regular.output());

ASSERT_EQ(output_tensor_regular.get_size() * num_batch, out_tensor_new.get_size());
float thr = 0.1;
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()),
Expand Down
Loading

0 comments on commit c6ec6d4

Please sign in to comment.