[GPU] set fixed random seed (#18144)
* random_generator * apply random_generator to all tests
This commit is contained in:
1 parent
d6c4e1acc0
commit
6913a5effb
47 files changed
+882
-620
No files matched your search
@@ -2,5 +2,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(unit)
|
||||
add_subdirectory(functional)
|
||||
@@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2023 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
file(GLOB_RECURSE TEMP
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.hpp"
|
||||
)
|
||||
|
||||
set(TEST_COMMON_SOURCE_FILES "${TEMP}" PARENT_SCOPE)
|
||||
set(TEST_COMMON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE)
|
||||
set(TEST_COMMON_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE)
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
// Copyright (C) 2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <random>
|
||||
#include <set>
|
||||
|
||||
#define GET_SUITE_NAME (std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) + \
|
||||
std::string(::testing::UnitTest::GetInstance()->current_test_info()->name()))
|
||||
|
||||
namespace tests {
|
||||
static const uint32_t DEFAULT_SEED = 0;
|
||||
|
||||
class random_generator {
|
||||
public:
|
||||
random_generator() = default;
|
||||
|
||||
random_generator(const std::string& seed) {
|
||||
set_seed(seed);
|
||||
}
|
||||
|
||||
std::default_random_engine& get_generator() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
void set_seed(const std::string& seed) {
|
||||
auto seed_hash = std::hash<std::string>{}(seed);
|
||||
set_seed(static_cast<uint32_t>(seed_hash));
|
||||
}
|
||||
|
||||
void set_seed(const uint32_t seed) {
|
||||
generator = std::default_random_engine{seed};
|
||||
}
|
||||
|
||||
template<typename ReturnType>
|
||||
ReturnType generate_random_val(int min, int max, int k = 8) {
|
||||
// 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
ReturnType val = static_cast<ReturnType>(distribution(this->generator));
|
||||
val /= k;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
template<typename ReturnType>
|
||||
std::vector<ReturnType> generate_random_1d(size_t a, int min, int max, int k = 8) {
|
||||
// 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
std::vector<ReturnType> v(a);
|
||||
|
||||
for (size_t i = 0; i < a; ++i) {
|
||||
v[i] = static_cast<ReturnType>(distribution(this->generator));
|
||||
v[i] /= k;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename ReturnType>
|
||||
std::vector<std::vector<ReturnType>> generate_random_2d(size_t a, size_t b, int min, int max, int k = 8) {
|
||||
std::vector<std::vector<ReturnType>> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_1d<ReturnType>(b, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename ReturnType>
|
||||
std::vector<std::vector<std::vector<ReturnType>>> generate_random_3d(size_t a, size_t b, size_t c, int min, int max, int k = 8) {
|
||||
std::vector<std::vector<std::vector<ReturnType>>> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_2d<ReturnType>(b, c, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
// parameters order is assumed to be bfyx or bfyx
|
||||
template<typename ReturnType>
|
||||
std::vector<std::vector<std::vector<std::vector<ReturnType>>>> generate_random_4d(size_t a, size_t b, size_t c, size_t d, int min, int max, int k = 8) {
|
||||
std::vector<std::vector<std::vector<std::vector<ReturnType>>>> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_3d<ReturnType>(b, c, d, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
// parameters order is assumed to be sbfyx for filters when split > 1
|
||||
template<typename ReturnType>
|
||||
std::vector<std::vector<std::vector<std::vector<std::vector<ReturnType>>>>> generate_random_5d(size_t a, size_t b, size_t c, size_t d, size_t e,
|
||||
int min, int max, int k = 8) {
|
||||
std::vector<std::vector<std::vector<std::vector<std::vector<ReturnType>>>>> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_4d<ReturnType>(b, c, d, e, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename ReturnType>
|
||||
std::vector<std::vector<std::vector<std::vector<std::vector<std::vector<ReturnType>>>>>> generate_random_6d(size_t a, size_t b, size_t c, size_t d,
|
||||
size_t e, size_t f, int min, int max, int k = 8) {
|
||||
std::vector<std::vector<std::vector<std::vector<std::vector<std::vector<ReturnType>>>>>> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_5d<ReturnType>(b, c, d, e, f, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename ReturnType>
|
||||
std::vector<ReturnType> generate_random_norepetitions(size_t size, int min, int max, float bound = 0.45) {
|
||||
// Rerurn repeatless vector with size = size in range(min, max)
|
||||
std::uniform_int_distribution<int> distribution(min, max);
|
||||
std::uniform_real_distribution<float> to_bound_dist(0, bound);
|
||||
std::set<int> repeatless;
|
||||
std::vector<float> v(size, 0);
|
||||
std::vector<ReturnType> res(size);
|
||||
int i = 0;
|
||||
int temp;
|
||||
if (max - min >= static_cast<int>(size) - 1) {
|
||||
while (repeatless.size() < size) {
|
||||
temp = distribution(this->generator);
|
||||
if (repeatless.find(temp) == repeatless.end()) {
|
||||
repeatless.insert(temp);
|
||||
v[i] = static_cast<float>(temp);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
for (size_t k = 0; k < v.size(); k++) {
|
||||
v[k] += to_bound_dist(this->generator);
|
||||
res[k] = static_cast<ReturnType>(v[k]);
|
||||
}
|
||||
} else {
|
||||
throw "Array size is bigger than size of range(min, max). Unable to generate array of unique integer numbers";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
std::default_random_engine generator{DEFAULT_SEED};
|
||||
};
|
||||
|
||||
} // namespace tests
|
||||
@@ -17,9 +17,12 @@ addIeTargetTest(
|
||||
${TARGET_NAME}
|
||||
ROOT
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
ADDITIONAL_SOURCE_DIRS
|
||||
${TEST_COMMON_SOURCE_DIR}
|
||||
INCLUDES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
$<TARGET_PROPERTY:openvino_intel_gpu_plugin,SOURCE_DIR>/include/
|
||||
${TEST_COMMON_INCLUDE_DIR}
|
||||
DEPENDENCIES
|
||||
openvino_intel_gpu_plugin
|
||||
LINK_LIBRARIES
|
||||
|
||||
@@ -39,9 +39,11 @@ if (MSVC)
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
set(SOURCES_ALL
|
||||
${SOURCES_MAIN}
|
||||
${SOURCES_NATVIS}
|
||||
${TEST_COMMON_SOURCE_FILES}
|
||||
)
|
||||
|
||||
add_executable(${TARGET_NAME} ${SOURCES_ALL})
|
||||
@@ -69,7 +71,8 @@ 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/)
|
||||
${CMAKE_HOME_DIRECTORY}/src/core/reference/include/
|
||||
${TEST_COMMON_INCLUDE_DIR})
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE setupapi)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/data.hpp>
|
||||
@@ -30,14 +31,10 @@ public:
|
||||
static const int min_random = -200;
|
||||
static const int max_random = 200;
|
||||
|
||||
std::default_random_engine generator{0};
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
std::string suite_name = std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) +
|
||||
std::string(::testing::UnitTest::GetInstance()->current_test_info()->name());
|
||||
auto seed = std::hash<std::string>{}(suite_name);
|
||||
|
||||
generator = std::default_random_engine{static_cast<uint32_t>(seed)};
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
cfg_fused = get_test_default_config(engine);
|
||||
cfg_not_fused = get_test_default_config(engine);
|
||||
|
||||
@@ -114,63 +111,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ReturnType>
|
||||
std::vector<ReturnType> generate_random(size_t a, int min, int max, int k = 8) {
|
||||
// 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
std::vector<ReturnType> v(a);
|
||||
|
||||
for (size_t i = 0; i < a; ++i) {
|
||||
v[i] = (ReturnType)distribution(this->generator);
|
||||
v[i] /= k;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename ReturnType>
|
||||
std::vector<ReturnType> generate_random_norepetitions(size_t size, int min, int max, float bound = 0.45) {
|
||||
// Rerurn repeatless vector with size = size in range(min, max)
|
||||
std::uniform_int_distribution<int> distribution(min, max);
|
||||
std::uniform_real_distribution<float> to_bound_dist(0, bound);
|
||||
std::set<int> repeatless;
|
||||
std::vector<float> v(size, 0);
|
||||
std::vector<ReturnType> res(size);
|
||||
int i = 0;
|
||||
int temp;
|
||||
if (max - min >= int(size) - 1){
|
||||
while (repeatless.size() < size) {
|
||||
temp = distribution(this->generator);
|
||||
if (repeatless.find(temp) == repeatless.end()) {
|
||||
repeatless.insert(temp);
|
||||
v[i] = (float)temp;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
for (size_t k = 0; k < v.size(); k++) {
|
||||
v[k] += to_bound_dist(this->generator);
|
||||
res[k] = static_cast<ReturnType>(v[k]);
|
||||
}
|
||||
} else {
|
||||
throw "Array size is bigger than size of range(min, max). Unable to generate array of unique integer numbers";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
cldnn::memory::ptr get_mem(cldnn::layout l) {
|
||||
auto prim = engine.allocate_memory(l);
|
||||
tensor s = l.get_tensor();
|
||||
if (l.data_type == data_types::bin) {
|
||||
VF<int32_t> rnd_vec = generate_random<int32_t>(s.count() / 32, min_random, max_random);
|
||||
VF<int32_t> rnd_vec = rg.generate_random_1d<int32_t>(s.count() / 32, min_random, max_random);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::i8 || l.data_type == data_types::u8) {
|
||||
VF<uint8_t> rnd_vec = generate_random<uint8_t>(s.count(), min_random, max_random);
|
||||
VF<uint8_t> rnd_vec = rg.generate_random_1d<uint8_t>(s.count(), min_random, max_random);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::f16) {
|
||||
VF<uint16_t> rnd_vec = generate_random<uint16_t>(s.count(), -1, 1);
|
||||
VF<uint16_t> rnd_vec = rg.generate_random_1d<uint16_t>(s.count(), -1, 1);
|
||||
set_values(prim, rnd_vec);
|
||||
} else {
|
||||
VF<float> rnd_vec = generate_random<float>(s.count(), -1, 1);
|
||||
VF<float> rnd_vec = rg.generate_random_1d<float>(s.count(), -1, 1);
|
||||
set_values(prim, rnd_vec);
|
||||
}
|
||||
|
||||
@@ -206,17 +160,17 @@ public:
|
||||
auto prim = engine.allocate_memory(l);
|
||||
tensor s = l.get_tensor();
|
||||
if (l.data_type == data_types::f32) {
|
||||
VF<float> rnd_vec = generate_random_norepetitions<float>(s.count(), min, max);
|
||||
VF<float> rnd_vec = rg.generate_random_norepetitions<float>(s.count(), min, max);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::f16) {
|
||||
VF<FLOAT16> rnd_vec = generate_random_norepetitions<FLOAT16>(s.count(), min, max);
|
||||
VF<FLOAT16> rnd_vec = rg.generate_random_norepetitions<FLOAT16>(s.count(), min, max);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::i8) {
|
||||
VF<int8_t> rnd_vec = generate_random_norepetitions<int8_t>(s.count(), min, max);
|
||||
VF<int8_t> rnd_vec = rg.generate_random_norepetitions<int8_t>(s.count(), min, max);
|
||||
set_values(prim, rnd_vec);
|
||||
}
|
||||
else if (l.data_type == data_types::bin) {
|
||||
VF<int32_t> rnd_vec = generate_random_norepetitions<int32_t>(s.count(), min, max);
|
||||
VF<int32_t> rnd_vec = rg.generate_random_norepetitions<int32_t>(s.count(), min, max);
|
||||
set_values(prim, rnd_vec);
|
||||
}
|
||||
|
||||
@@ -227,19 +181,19 @@ public:
|
||||
auto prim = engine.allocate_memory(l);
|
||||
tensor s = l.get_tensor();
|
||||
if (l.data_type == data_types::f32) {
|
||||
VF<float> rnd_vec = generate_random<float>(s.count(), min, max);
|
||||
VF<float> rnd_vec = rg.generate_random_1d<float>(s.count(), min, max);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::f16) {
|
||||
VF<FLOAT16> rnd_vec = generate_random<FLOAT16>(s.count(), min, max);
|
||||
VF<FLOAT16> rnd_vec = rg.generate_random_1d<FLOAT16>(s.count(), min, max);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::i8) {
|
||||
VF<int8_t> rnd_vec = generate_random<int8_t>(s.count(), min, max);
|
||||
VF<int8_t> rnd_vec = rg.generate_random_1d<int8_t>(s.count(), min, max);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::u8) {
|
||||
VF<uint8_t> rnd_vec = generate_random<uint8_t>(s.count(), min, max);
|
||||
VF<uint8_t> rnd_vec = rg.generate_random_1d<uint8_t>(s.count(), min, max);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::bin) {
|
||||
VF<int32_t> rnd_vec = generate_random<int32_t>(s.count() / 32, min, max);
|
||||
VF<int32_t> rnd_vec = rg.generate_random_1d<int32_t>(s.count() / 32, min, max);
|
||||
set_values(prim, rnd_vec);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,16 +69,6 @@ public:
|
||||
return cldnn::format::bfwzyx;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T generate_random_val(int min, int max, int k = 8) {
|
||||
// 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
T val = (T)distribution(this->generator);
|
||||
val /= k;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> generate_unique_indices(scatter_nd_update_test_params& p) {
|
||||
std::set<std::vector<T>> unique_indices;
|
||||
@@ -92,7 +82,7 @@ public:
|
||||
while (unique_indices.size() != count) {
|
||||
std::vector<T> indices;
|
||||
for (size_t i = 0; i < static_cast<size_t>(last_indices_dim); i++) {
|
||||
indices.push_back(static_cast<T>(generate_random_val<int>(0, data_shape[i] - 1)));
|
||||
indices.push_back(static_cast<T>(rg.generate_random_val<int>(0, data_shape[i] - 1)));
|
||||
}
|
||||
|
||||
unique_indices.insert(indices);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include "intel_gpu/runtime/engine.hpp"
|
||||
#include "intel_gpu/runtime/memory.hpp"
|
||||
@@ -179,6 +180,7 @@ TEST(add_intermediate_gpu, test2)
|
||||
}
|
||||
|
||||
TEST(processing_order, bfs_order_restoring) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
ExecutionConfig config = get_test_default_config(engine);
|
||||
@@ -194,9 +196,9 @@ TEST(processing_order, bfs_order_restoring) {
|
||||
auto output_low_mem = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } });
|
||||
auto output_high_mem = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } });
|
||||
|
||||
set_values(eltwise_mem, generate_random_1d<float>(1, 0, 10));
|
||||
set_values(input_low_mem, generate_random_1d<float>(3, -10, 0));
|
||||
set_values(input_high_mem, generate_random_1d<float>(3, 1, 10));
|
||||
set_values(eltwise_mem, rg.generate_random_1d<float>(1, 0, 10));
|
||||
set_values(input_low_mem, rg.generate_random_1d<float>(3, -10, 0));
|
||||
set_values(input_high_mem, rg.generate_random_1d<float>(3, 1, 10));
|
||||
set_values(output_low_mem, { -127.0f });
|
||||
set_values(output_high_mem, { 127.0f });
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include "intel_gpu/runtime/engine.hpp"
|
||||
|
||||
@@ -182,6 +183,7 @@ TEST(handle_reshape, correct_parameters_propagation_2_inputs) {
|
||||
}
|
||||
|
||||
TEST(handle_reshape, reshape_input_reorder) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
auto shape_memory = engine.allocate_memory({ ov::PartialShape{5}, data_types::i32, format::bfyx });
|
||||
auto in0_layout = layout{ ov::PartialShape{1, -1, 16, 64, 64}, data_types::f16, format::bfzyx };
|
||||
@@ -189,8 +191,8 @@ TEST(handle_reshape, reshape_input_reorder) {
|
||||
auto in1_layout = layout{ ov::PartialShape{-1, 16, 64, 64}, data_types::f16, format::bfyx };
|
||||
auto in1_memory = engine.allocate_memory({ ov::PartialShape{2, 16, 64, 64}, data_types::f16, format::bfyx });
|
||||
|
||||
auto in0 = generate_random_1d<FLOAT16>(in0_memory->count(), -10, 10);
|
||||
auto in1 = generate_random_1d<FLOAT16>(in1_memory->count(), -10, 10);
|
||||
auto in0 = rg.generate_random_1d<FLOAT16>(in0_memory->count(), -10, 10);
|
||||
auto in1 = rg.generate_random_1d<FLOAT16>(in1_memory->count(), -10, 10);
|
||||
set_values<FLOAT16>(in0_memory, in0);
|
||||
set_values<int32_t>(shape_memory, {1, 2, 16, 64, 64});
|
||||
set_values<FLOAT16>(in1_memory, in1);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include "intel_gpu/runtime/engine.hpp"
|
||||
#include "intel_gpu/graph/program.hpp"
|
||||
@@ -17,9 +18,10 @@ using namespace cldnn;
|
||||
using namespace ::tests;
|
||||
|
||||
TEST(prepare_padding, groupconv_with_output) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
auto in_layout = layout{{1, 18, 76, 135}, data_types::f16, format::bfyx};
|
||||
auto weights_data = generate_random_5d<FLOAT16>(1, 18, 1, 3, 3, -1, 1);
|
||||
auto weights_data = rg.generate_random_5d<FLOAT16>(1, 18, 1, 3, 3, -1, 1);
|
||||
auto weights_mem = engine.allocate_memory({ {18, 1, 1, 3, 3}, data_types::f16, format::bfzyx});
|
||||
set_values(weights_mem, weights_data);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include "intel_gpu/runtime/engine.hpp"
|
||||
|
||||
@@ -460,11 +461,12 @@ TEST(prepare_primitive_fusing, eltwise_fusing_residual_connection) {
|
||||
if (engine.get_device_info().supports_immad)
|
||||
return;
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
topology topology;
|
||||
auto conv_in_layout = layout{ ov::PartialShape{1, 3, -1, -1}, data_types::f16, format::bfyx};
|
||||
auto weight_layout = layout{ ov::PartialShape{10, 3, 3, 3}, data_types::f16, format::bfyx};
|
||||
auto weight_mem = engine.allocate_memory(weight_layout);
|
||||
auto weight_data = generate_random_4d<FLOAT16>(10, 3, 3, 3, -1, 1);
|
||||
auto weight_data = rg.generate_random_4d<FLOAT16>(10, 3, 3, 3, -1, 1);
|
||||
set_values(weight_mem, weight_data);
|
||||
auto elt1_in1_layout = layout{ ov::PartialShape{1, 10, -1, -1}, data_types::f16, format::bfyx};
|
||||
|
||||
@@ -491,11 +493,11 @@ TEST(prepare_primitive_fusing, eltwise_fusing_residual_connection) {
|
||||
cldnn::network net(prog, 0);
|
||||
|
||||
// Valid
|
||||
auto conv_input_data = generate_random_4d<FLOAT16>(1, 3, 7, 7, -1, 1);
|
||||
auto conv_input_data = rg.generate_random_4d<FLOAT16>(1, 3, 7, 7, -1, 1);
|
||||
auto conv_input_mem = engine.allocate_memory(layout{ov::PartialShape{1, 3, 7, 7}, data_types::f16, format::bfyx});
|
||||
set_values(conv_input_mem, conv_input_data);
|
||||
|
||||
auto elt_input_data = generate_random_4d<FLOAT16>(1, 10, 5, 5, -10, 10);
|
||||
auto elt_input_data = rg.generate_random_4d<FLOAT16>(1, 10, 5, 5, -10, 10);
|
||||
auto elt_input_mem = engine.allocate_memory(layout{ov::PartialShape{1, 10, 5, 5}, data_types::f16, format::bfyx});
|
||||
set_values(elt_input_mem, elt_input_data);
|
||||
|
||||
@@ -507,7 +509,7 @@ TEST(prepare_primitive_fusing, eltwise_fusing_residual_connection) {
|
||||
ASSERT_FALSE(conv_inst->has_unfused_subgraph());
|
||||
|
||||
// Invalid => unfusion
|
||||
auto conv_input_data2 = generate_random_4d<FLOAT16>(1, 3, 3, 3, -1, 1);
|
||||
auto conv_input_data2 = rg.generate_random_4d<FLOAT16>(1, 3, 3, 3, -1, 1);
|
||||
auto conv_input_mem2 = engine.allocate_memory(layout{ov::PartialShape{1, 3, 3, 3}, data_types::f16, format::bfyx});
|
||||
set_values(conv_input_mem2, conv_input_data2);
|
||||
net.set_input_data("conv_input", conv_input_mem2);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include "intel_gpu/runtime/engine.hpp"
|
||||
|
||||
@@ -143,6 +144,7 @@ TEST(remove_redundant_reorders, skip_reorder_fusing_when_sibling_not_support_pad
|
||||
}
|
||||
|
||||
TEST(remove_redundant_reorders, not_to_fuse_reshape_with_fused_prims) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
auto data0_layout = engine.allocate_memory({ ov::PartialShape{1, 32, 2, 2}, data_types::f16, format::bfyx });
|
||||
auto in_layout = layout{ ov::PartialShape{1, 32, 2, 2}, data_types::f16, format::bfyx };
|
||||
@@ -172,7 +174,7 @@ TEST(remove_redundant_reorders, not_to_fuse_reshape_with_fused_prims) {
|
||||
network network(engine, topology, config);
|
||||
|
||||
auto input = engine.allocate_memory(in_layout);
|
||||
VVVVF<float> input_all_neg = generate_random_4d<float>(1, 32, 2, 2, -10.f, 0.f);
|
||||
VVVVF<float> input_all_neg = rg.generate_random_4d<float>(1, 32, 2, 2, -10.f, 0.f);
|
||||
set_values(input, input_all_neg);
|
||||
network.set_input_data("input", input);
|
||||
auto outputs = network.execute();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include "intel_gpu/runtime/engine.hpp"
|
||||
#include "intel_gpu/graph/program.hpp"
|
||||
@@ -257,12 +258,13 @@ TEST(reorder_inputs, impl_forcing_basic_format_kernel) {
|
||||
}
|
||||
|
||||
TEST(reorder_inputs, no_add_reorder_infront_of_reshape) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto in_layout = layout{ ov::PartialShape{-1, -1, 2, 7, 7, 384}, data_types::f32, format::bfwzyx };
|
||||
auto in_memory = engine.allocate_memory(layout{ ov::PartialShape{1, 2, 2, 7, 7, 384}, data_types::f32, format::bfwzyx });
|
||||
|
||||
auto in = generate_random_1d<float>(in_memory->count(), -10, 10);
|
||||
auto in = rg.generate_random_1d<float>(in_memory->count(), -10, 10);
|
||||
|
||||
set_values<float>(in_memory, in);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/activation.hpp>
|
||||
@@ -1631,6 +1632,7 @@ TEST(activation_f32_fw_gpu, b_fs_yx_fsv16_prelu) {
|
||||
constexpr int x = 2;
|
||||
constexpr int y = 2;
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& eng = get_test_engine();
|
||||
|
||||
auto in_lay = cldnn::layout(cldnn::data_types::f32, cldnn::format::bfyx, cldnn::tensor(b, f, x, y));
|
||||
@@ -1639,8 +1641,8 @@ TEST(activation_f32_fw_gpu, b_fs_yx_fsv16_prelu) {
|
||||
auto in_mem = eng.allocate_memory(in_lay);
|
||||
auto params_mem = eng.allocate_memory(params_lay);
|
||||
|
||||
auto in_data = generate_random_4d<float>(b, f, y, x, -1, 1);
|
||||
auto params_data = generate_random_1d<float>(f, -1, 1);
|
||||
auto in_data = rg.generate_random_4d<float>(b, f, y, x, -1, 1);
|
||||
auto params_data = rg.generate_random_1d<float>(f, -1, 1);
|
||||
|
||||
set_values(params_mem, params_data);
|
||||
|
||||
@@ -1685,8 +1687,13 @@ using activation_random_test_params = std::tuple<data_types,
|
||||
|
||||
struct activation_random_test : testing::TestWithParam<activation_random_test_params>
|
||||
{
|
||||
tests::random_generator rg;
|
||||
bool enable_profiling = false;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
size_t get_x_pitch(layout& layout) {
|
||||
auto tensor_x0 = tensor(batch(0), feature(0), spatial(0, 0, 0, 0));
|
||||
auto tensor_x1 = tensor(batch(0), feature(0), spatial(1, 0, 0, 0));
|
||||
@@ -1703,7 +1710,7 @@ struct activation_random_test : testing::TestWithParam<activation_random_test_pa
|
||||
size_t x = l.spatial(0);
|
||||
size_t y = l.spatial(1);
|
||||
|
||||
auto data = generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
auto data = rg.generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
mem_lock<T> ptr{mem, get_test_stream()};
|
||||
for (size_t bi = 0; bi < b; ++bi) {
|
||||
for (size_t fi = 0; fi < f; ++fi) {
|
||||
@@ -2003,13 +2010,14 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
::testing::Values(true)));
|
||||
|
||||
TEST(activation_gpu, has_proper_synchronization) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
auto in_layout = layout({1, 2, 2, 4}, data_types::f32, format::bfyx);
|
||||
auto input_mem = engine.allocate_memory(in_layout);
|
||||
auto const_mem = engine.allocate_memory({{1, 2, 2, 4}, data_types::f32, format::bfyx});
|
||||
|
||||
auto in_data = generate_random_4d<float>(1, 2, 2, 4, -1, 1);
|
||||
auto const_data = generate_random_4d<float>(1, 2, 2, 4, -1, 1);
|
||||
auto in_data = rg.generate_random_4d<float>(1, 2, 2, 4, -1, 1);
|
||||
auto const_data = rg.generate_random_4d<float>(1, 2, 2, 4, -1, 1);
|
||||
|
||||
set_values(input_mem, flatten_4d(format::bfyx, in_data));
|
||||
set_values(const_mem, flatten_4d(format::bfyx, const_data));
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
#include "ngraph/runtime/reference/adaptive_avg_pool.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
@@ -65,16 +66,15 @@ ov::Shape tensorToShape(const tensor& t, const format f)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void generateTestData(const AdaptiveAvgPoolingParams& p, const format fmt, std::vector<T>& inputs, std::vector<T>& outputs) {
|
||||
const auto in = generate_random_1d<float>(p.inputTensor.count(), -127, 127, 8);
|
||||
void generateTestData(const AdaptiveAvgPoolingParams& p, const format fmt, const std::vector<float>& random_inputs, std::vector<T>& inputs, std::vector<T>& outputs) {
|
||||
std::vector<float> out(p.outputTensor.count());
|
||||
|
||||
const auto inShape = tensorToShape(p.inputTensor, fmt);
|
||||
const auto outShape = tensorToShape(p.outputTensor, fmt);
|
||||
|
||||
ngraph::runtime::reference::adaptive_avg_pool<float>(in.data(), out.data(), inShape, outShape);
|
||||
ngraph::runtime::reference::adaptive_avg_pool<float>(random_inputs.data(), out.data(), inShape, outShape);
|
||||
|
||||
inputs = getValues<T>(in);
|
||||
inputs = getValues<T>(random_inputs);
|
||||
outputs = getValues<T>(out);
|
||||
}
|
||||
|
||||
@@ -111,6 +111,12 @@ struct PrintToStringParamName {
|
||||
template<typename T>
|
||||
struct adaptive_avg_pooling_test
|
||||
: public ::testing::TestWithParam<AdaptiveAvgPoolingParamsWithLayout> {
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
public:
|
||||
void test() {
|
||||
const auto data_type = type_to_data_type<T>::value;
|
||||
@@ -122,7 +128,8 @@ public:
|
||||
|
||||
std::vector<T> input_data;
|
||||
std::vector<T> expected;
|
||||
generateTestData<T>(params, plain_layout, input_data, expected);
|
||||
const std::vector<float> random_input_data = rg.generate_random_1d<float>(params.inputTensor.count(), -127, 127, 8);
|
||||
generateTestData<T>(params, plain_layout, random_input_data, input_data, expected);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input = engine.allocate_memory({data_type, plain_layout, params.inputTensor});
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
#include "ngraph/runtime/reference/adaptive_avg_pool.hpp"
|
||||
#include "ngraph/runtime/reference/adaptive_max_pool.hpp"
|
||||
|
||||
@@ -67,18 +68,17 @@ ov::Shape tensorToShape(const tensor& t, const format f)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void generateTestData(const AdaptiveMaxPoolingParams& p, const format fmt,
|
||||
void generateTestData(const AdaptiveMaxPoolingParams& p, const format fmt, const std::vector<float>& random_inputs,
|
||||
std::vector<T>& inputs, std::vector<T>& outputs, std::vector<int32_t>& indices) {
|
||||
const auto in = generate_random_1d<float>(p.inputTensor.count(), -127, 127, 8);
|
||||
std::vector<float> out(p.outputTensor.count());
|
||||
std::vector<int32_t> ind(p.outputTensor.count());
|
||||
|
||||
const auto inShape = tensorToShape(p.inputTensor, fmt);
|
||||
const auto outShape = tensorToShape(p.outputTensor, fmt);
|
||||
|
||||
ngraph::runtime::reference::adaptive_max_pool<float, int32_t>(in.data(), out.data(), ind.data(), inShape, outShape);
|
||||
ngraph::runtime::reference::adaptive_max_pool<float, int32_t>(random_inputs.data(), out.data(), ind.data(), inShape, outShape);
|
||||
|
||||
inputs = getValues<T>(in);
|
||||
inputs = getValues<T>(random_inputs);
|
||||
outputs = getValues<T>(out);
|
||||
indices = ind;
|
||||
}
|
||||
@@ -116,6 +116,12 @@ struct PrintToStringParamName {
|
||||
template<typename T>
|
||||
struct adaptive_max_pooling_test
|
||||
: public ::testing::TestWithParam<AdaptiveMaxPoolingParamsWithLayout> {
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
public:
|
||||
void test() {
|
||||
const auto data_type = type_to_data_type<T>::value;
|
||||
@@ -129,7 +135,8 @@ public:
|
||||
std::vector<T> input_data;
|
||||
std::vector<T> expected;
|
||||
std::vector<int32_t> expected_indices;
|
||||
generateTestData<T>(params, plain_layout, input_data, expected, expected_indices);
|
||||
auto random_in = rg.generate_random_1d<float>(params.inputTensor.count(), -127, 127, 8);
|
||||
generateTestData<T>(params, plain_layout, random_in, input_data, expected, expected_indices);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input_mem = engine.allocate_memory({data_type, plain_layout, params.inputTensor});
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/border.hpp>
|
||||
@@ -59,6 +60,7 @@ using border_test_param = std::tuple<ov::op::PadMode, // pad mode
|
||||
template <class T, data_types T_dt>
|
||||
class border_test : public ::testing::TestWithParam<border_test_param<T>> {
|
||||
public:
|
||||
tests::random_generator rg;
|
||||
ov::op::PadMode pad_mode;
|
||||
T pad_value;
|
||||
format::type fmt;
|
||||
@@ -66,13 +68,14 @@ public:
|
||||
bool is_caching_test;
|
||||
void SetUp() override {
|
||||
::testing::TestWithParam<border_test_param<T>>::SetUp();
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
std::tie(pad_mode, pad_value, fmt, sh_in, cd_lt, cd_rb, is_caching_test) = this->GetParam();
|
||||
sh_out = {sh_in[0] + cd_lt[0] + cd_rb[0],
|
||||
sh_in[1] + cd_lt[1] + cd_rb[1],
|
||||
sh_in[2] + cd_lt[2] + cd_rb[2],
|
||||
sh_in[3] + cd_lt[3] + cd_rb[3]};
|
||||
auto& engine = get_test_engine();
|
||||
auto input_data = generate_random_1d<T>(mult(sh_in), -9, 9, 1);
|
||||
auto input_data = rg.generate_random_1d<T>(mult(sh_in), -9, 9, 1);
|
||||
auto input = engine.allocate_memory({T_dt, format::bfyx, {sh_in[0], sh_in[1], sh_in[3], sh_in[2]}});
|
||||
set_values(input, input_data);
|
||||
|
||||
@@ -195,9 +198,10 @@ TEST(border_gpu, bsv16fsv16_without_reorder) {
|
||||
sh_in[1] + cd_lt[1] + cd_rb[1],
|
||||
sh_in[2] + cd_lt[2] + cd_rb[2],
|
||||
sh_in[3] + cd_lt[3] + cd_rb[3]};
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input_data = generate_random_1d<T>(mult(sh_in), -9, 9, 1);
|
||||
auto input_data = rg.generate_random_1d<T>(mult(sh_in), -9, 9, 1);
|
||||
auto input = engine.allocate_memory({T_dt, format::bfyx, {sh_in[0], sh_in[1], sh_in[3], sh_in[2]}});
|
||||
set_values(input, input_data);
|
||||
|
||||
@@ -274,8 +278,9 @@ TEST(border_gpu, zyx_bsv16fsv16) {
|
||||
sh_in[2] + cd_lt[2] + cd_rb[2],
|
||||
sh_in[3] + cd_lt[3] + cd_rb[3],
|
||||
sh_in[4] + cd_lt[4] + cd_rb[4]};
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
auto input_data = generate_random_1d<T>(mult(sh_in), -9, 9, 1);
|
||||
auto input_data = rg.generate_random_1d<T>(mult(sh_in), -9, 9, 1);
|
||||
auto input = engine.allocate_memory({T_dt, format::bfzyx, {sh_in[0], sh_in[1], sh_in[4], sh_in[3], sh_in[2]}});
|
||||
set_values(input, input_data);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
#include "concatenation_inst.h"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
@@ -654,6 +655,12 @@ using TestParamType_concat = ::testing::tuple<size_t, // 0 - Input Batch size
|
||||
|
||||
struct concat_gpu : public ::testing::TestWithParam<TestParamType_concat>
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
static std::string
|
||||
PrintToStringParamName(testing::TestParamInfo<TestParamType_concat> param_info)
|
||||
{
|
||||
@@ -677,6 +684,11 @@ using TestParamType_concat_axis3 = ::testing::tuple<size_t, // 0 - Input Batch
|
||||
|
||||
struct concat_axis3_gpu : public ::testing::TestWithParam<TestParamType_concat_axis3>
|
||||
{
|
||||
tests::random_generator rg;
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
static std::string
|
||||
PrintToStringParamName(testing::TestParamInfo<TestParamType_concat_axis3> param_info)
|
||||
{
|
||||
@@ -762,7 +774,7 @@ public:
|
||||
static_cast<int32_t>(in_features[i]),
|
||||
static_cast<int32_t>(input_x),
|
||||
static_cast<int32_t>(input_y));
|
||||
auto data = generate_random_4d<Type>(batch_num, in_features[i], input_y, input_x, -1, 1);
|
||||
auto data = rg.generate_random_4d<Type>(batch_num, in_features[i], input_y, input_x, -1, 1);
|
||||
auto in_lay = layout(data_type, fmt, size);
|
||||
auto data_flat = std::vector<Type>(in_lay.get_linear_size(), 0);
|
||||
|
||||
@@ -848,7 +860,7 @@ public:
|
||||
static_cast<int32_t>(in_feature),
|
||||
static_cast<int32_t>(input_x[i]),
|
||||
static_cast<int32_t>(input_y));
|
||||
auto data = generate_random_4d<Type>(batch_num, in_feature, input_y, input_x[i], -1, 1);
|
||||
auto data = rg.generate_random_4d<Type>(batch_num, in_feature, input_y, input_x[i], -1, 1);
|
||||
auto in_lay = layout(data_type, fmt, size);
|
||||
auto data_flat = std::vector<Type>(in_lay.get_linear_size(), 0);
|
||||
|
||||
@@ -997,7 +1009,7 @@ public:
|
||||
static_cast<int32_t>(in_features[i]),
|
||||
static_cast<int32_t>(input_x),
|
||||
static_cast<int32_t>(input_y));
|
||||
auto data = generate_random_4d<Type>(batch_num, in_features[i], input_y, input_x, -128, 128);
|
||||
auto data = rg.generate_random_4d<Type>(batch_num, in_features[i], input_y, input_x, -128, 128);
|
||||
auto in_lay = layout(data_type, fmt, size);
|
||||
auto data_flat = std::vector<Type>(in_lay.get_linear_size(), 0);
|
||||
|
||||
@@ -1204,7 +1216,7 @@ public:
|
||||
|
||||
std::vector<std::vector<std::vector<std::vector<std::vector<Type>>>>> input(in_features.size());
|
||||
for (size_t i = 0; i < in_features.size(); ++i) {
|
||||
input[i] = generate_random_4d<Type>(batch_num, in_features[i], input_y, input_x, -1, 1);
|
||||
input[i] = rg.generate_random_4d<Type>(batch_num, in_features[i], input_y, input_x, -1, 1);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
@@ -1425,7 +1437,7 @@ public:
|
||||
|
||||
std::vector<std::vector<std::vector<std::vector<std::vector<Type>>>>> input(in_features.size());
|
||||
for (size_t i = 0; i < in_features.size(); ++i) {
|
||||
input[i] = generate_random_4d<Type>(batch_num, in_features[i], input_y, input_x, -1, 1);
|
||||
input[i] = rg.generate_random_4d<Type>(batch_num, in_features[i], input_y, input_x, -1, 1);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
@@ -1592,7 +1604,7 @@ public:
|
||||
|
||||
std::vector<std::vector<std::vector<std::vector<std::vector<Type>>>>> inputs(4);
|
||||
for (size_t i = 0; i < 4; ++i) {
|
||||
inputs[i] = generate_random_4d<Type>(batch_num, in_features[0], input_y, input_x, -1, 1);
|
||||
inputs[i] = rg.generate_random_4d<Type>(batch_num, in_features[0], input_y, input_x, -1, 1);
|
||||
}
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
#include "opencl_helper_instance.hpp"
|
||||
#include "ocl/ocl_device.hpp"
|
||||
|
||||
@@ -60,6 +61,7 @@ void createReferenceDataNV12(const T* arg_y, const T* arg_uv, U* out_ptr,
|
||||
}
|
||||
|
||||
TEST(convert_color, nv12_to_rgb_two_planes_buffer_fp32) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
int width = 224;
|
||||
int height = 448;
|
||||
@@ -67,8 +69,8 @@ TEST(convert_color, nv12_to_rgb_two_planes_buffer_fp32) {
|
||||
auto input_y = engine.allocate_memory({ data_types::f32, format::byxf, { 1, 1, width, height } });
|
||||
auto input_uv = engine.allocate_memory({ data_types::f32, format::byxf, { 1, 2, width / 2 , height / 2 } });
|
||||
|
||||
std::vector<float> input_y_data = generate_random_1d<float>(width * height, 0, 255);
|
||||
std::vector<float> input_uv_data = generate_random_1d<float>(width * height / 2, 0, 255);
|
||||
std::vector<float> input_y_data = rg.generate_random_1d<float>(width * height, 0, 255);
|
||||
std::vector<float> input_uv_data = rg.generate_random_1d<float>(width * height / 2, 0, 255);
|
||||
|
||||
set_values(input_y, input_y_data);
|
||||
set_values(input_uv, input_uv_data);
|
||||
@@ -99,6 +101,7 @@ TEST(convert_color, nv12_to_rgb_two_planes_buffer_fp32) {
|
||||
}
|
||||
|
||||
TEST(convert_color, nv12_to_bgr_two_planes_buffer_fp32) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
int width = 224;
|
||||
int height = 224;
|
||||
@@ -106,8 +109,8 @@ TEST(convert_color, nv12_to_bgr_two_planes_buffer_fp32) {
|
||||
auto input_y = engine.allocate_memory({ data_types::f32, format::byxf, { 1, 1, width, height } });
|
||||
auto input_uv = engine.allocate_memory({ data_types::f32, format::byxf, { 1, 2, width / 2 , height / 2 } });
|
||||
|
||||
std::vector<float> input_y_data = generate_random_1d<float>(width * height, 0, 255);
|
||||
std::vector<float> input_uv_data = generate_random_1d<float>(width * height / 2, 0, 255);
|
||||
std::vector<float> input_y_data = rg.generate_random_1d<float>(width * height, 0, 255);
|
||||
std::vector<float> input_uv_data = rg.generate_random_1d<float>(width * height / 2, 0, 255);
|
||||
|
||||
set_values(input_y, input_y_data);
|
||||
set_values(input_uv, input_uv_data);
|
||||
@@ -139,6 +142,7 @@ TEST(convert_color, nv12_to_bgr_two_planes_buffer_fp32) {
|
||||
}
|
||||
|
||||
TEST(convert_color, nv12_to_rgb_two_planes_buffer_u8) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
int width = 224;
|
||||
int height = 224;
|
||||
@@ -146,8 +150,8 @@ TEST(convert_color, nv12_to_rgb_two_planes_buffer_u8) {
|
||||
auto input_y = engine.allocate_memory({ data_types::u8, format::byxf, { 1, 1, width, height } });
|
||||
auto input_uv = engine.allocate_memory({ data_types::u8, format::byxf, { 1, 2, width / 2 , height / 2 } });
|
||||
|
||||
std::vector<uint8_t> input_y_data = generate_random_1d<uint8_t>(width * height, 0, 255);
|
||||
std::vector<uint8_t> input_uv_data = generate_random_1d<uint8_t>(width * height / 2, 0, 255);
|
||||
std::vector<uint8_t> input_y_data = rg.generate_random_1d<uint8_t>(width * height, 0, 255);
|
||||
std::vector<uint8_t> input_uv_data = rg.generate_random_1d<uint8_t>(width * height / 2, 0, 255);
|
||||
|
||||
set_values(input_y, input_y_data);
|
||||
set_values(input_uv, input_uv_data);
|
||||
@@ -179,6 +183,7 @@ TEST(convert_color, nv12_to_rgb_two_planes_buffer_u8) {
|
||||
}
|
||||
|
||||
TEST(convert_color, nv12_to_rgb_two_planes_buffer_fp16) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
int width = 224;
|
||||
int height = 224;
|
||||
@@ -186,8 +191,8 @@ TEST(convert_color, nv12_to_rgb_two_planes_buffer_fp16) {
|
||||
auto input_y = engine.allocate_memory({ data_types::f16, format::byxf, { 1, 1, width, height } });
|
||||
auto input_uv = engine.allocate_memory({ data_types::f16, format::byxf, { 1, 2, width / 2 , height / 2 } });
|
||||
|
||||
std::vector<FLOAT16> input_y_data = generate_random_1d<FLOAT16>(width * height, 0, 255);
|
||||
std::vector<FLOAT16> input_uv_data = generate_random_1d<FLOAT16>(width * height / 2, 0, 255);
|
||||
std::vector<FLOAT16> input_y_data = rg.generate_random_1d<FLOAT16>(width * height, 0, 255);
|
||||
std::vector<FLOAT16> input_uv_data = rg.generate_random_1d<FLOAT16>(width * height / 2, 0, 255);
|
||||
|
||||
set_values(input_y, input_y_data);
|
||||
set_values(input_uv, input_uv_data);
|
||||
@@ -219,6 +224,7 @@ TEST(convert_color, nv12_to_rgb_two_planes_buffer_fp16) {
|
||||
}
|
||||
|
||||
TEST(convert_color, nv12_to_rgb_single_plane_buffer_fp32) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
int width = 224;
|
||||
@@ -228,7 +234,7 @@ TEST(convert_color, nv12_to_rgb_single_plane_buffer_fp32) {
|
||||
auto input = engine.allocate_memory({ data_types::f32, format::byxf, { 1, 1, width, input_height } });
|
||||
|
||||
int data_size = width * (height + height / 2);
|
||||
std::vector<float> input_data = generate_random_1d<float>(data_size, 0, 255);
|
||||
std::vector<float> input_data = rg.generate_random_1d<float>(data_size, 0, 255);
|
||||
set_values(input, input_data);
|
||||
|
||||
layout output_layout(data_types::f32, cldnn::format::byxf, { 1, 3, width, height });
|
||||
@@ -255,6 +261,7 @@ TEST(convert_color, nv12_to_rgb_single_plane_buffer_fp32) {
|
||||
}
|
||||
|
||||
TEST(convert_color, nv12_to_rgb_single_plane_buffer_u8) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
int width = 224;
|
||||
@@ -264,7 +271,7 @@ TEST(convert_color, nv12_to_rgb_single_plane_buffer_u8) {
|
||||
auto input = engine.allocate_memory({ data_types::u8, format::byxf, { 1, 1, width, input_height } });
|
||||
|
||||
int data_size = width * (height + height / 2);
|
||||
std::vector<uint8_t> input_data = generate_random_1d<uint8_t>(data_size, 0, 255);
|
||||
std::vector<uint8_t> input_data = rg.generate_random_1d<uint8_t>(data_size, 0, 255);
|
||||
set_values(input, input_data);
|
||||
|
||||
layout output_layout(data_types::u8, cldnn::format::byxf, { 1, 3, width, height });
|
||||
@@ -291,6 +298,7 @@ TEST(convert_color, nv12_to_rgb_single_plane_buffer_u8) {
|
||||
}
|
||||
|
||||
TEST(convert_color, nv12_to_rgb_two_planes_surface_u8) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
int width = 224;
|
||||
int height = 448;
|
||||
|
||||
@@ -309,7 +317,7 @@ TEST(convert_color, nv12_to_rgb_two_planes_surface_u8) {
|
||||
cl_int err;
|
||||
|
||||
int data_size = width * (height + height / 2);
|
||||
std::vector<uint8_t> data = generate_random_1d<uint8_t>(data_size, 0, 255);
|
||||
std::vector<uint8_t> data = rg.generate_random_1d<uint8_t>(data_size, 0, 255);
|
||||
|
||||
cl_image_format image_format;
|
||||
image_format.image_channel_order = CL_R;
|
||||
@@ -371,6 +379,7 @@ TEST(convert_color, nv12_to_rgb_two_planes_surface_u8) {
|
||||
}
|
||||
|
||||
TEST(convert_color, nv12_to_rgb_single_plane_surface_u8) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
int width = 224;
|
||||
int height = 448;
|
||||
int input_height = height + height / 2;
|
||||
@@ -389,7 +398,7 @@ TEST(convert_color, nv12_to_rgb_single_plane_surface_u8) {
|
||||
cl_int err;
|
||||
|
||||
int data_size = width * (height + height / 2);
|
||||
std::vector<uint8_t> input_data = generate_random_1d<uint8_t>(data_size, 0, 255);
|
||||
std::vector<uint8_t> input_data = rg.generate_random_1d<uint8_t>(data_size, 0, 255);
|
||||
|
||||
cl_image_format image_format;
|
||||
image_format.image_channel_order = CL_R;
|
||||
@@ -484,6 +493,7 @@ void createReferenceDataI420(const T* arg_y, const T* arg_u, const T* arg_v, U*
|
||||
}
|
||||
|
||||
TEST(convert_color, i420_to_rgb_three_planes_buffer_fp32) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
int width = 224;
|
||||
int height = 448;
|
||||
@@ -492,9 +502,9 @@ TEST(convert_color, i420_to_rgb_three_planes_buffer_fp32) {
|
||||
auto input_u = engine.allocate_memory({ data_types::f32, format::byxf, { 1, 1, width / 2 , height / 2 } });
|
||||
auto input_v = engine.allocate_memory({ data_types::f32, format::byxf, { 1, 1, width / 2 , height / 2 } });
|
||||
|
||||
std::vector<float> input_y_data = generate_random_1d<float>(width * height, 0, 255);
|
||||
std::vector<float> input_u_data = generate_random_1d<float>(width * height / 4, 0, 255);
|
||||
std::vector<float> input_v_data = generate_random_1d<float>(width * height / 4, 0, 255);
|
||||
std::vector<float> input_y_data = rg.generate_random_1d<float>(width * height, 0, 255);
|
||||
std::vector<float> input_u_data = rg.generate_random_1d<float>(width * height / 4, 0, 255);
|
||||
std::vector<float> input_v_data = rg.generate_random_1d<float>(width * height / 4, 0, 255);
|
||||
|
||||
set_values(input_y, input_y_data);
|
||||
set_values(input_u, input_u_data);
|
||||
@@ -529,6 +539,7 @@ TEST(convert_color, i420_to_rgb_three_planes_buffer_fp32) {
|
||||
|
||||
template <typename T>
|
||||
void test_convert_color_i420_to_rgb_three_planes_surface_u8(bool is_caching_test) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
int width = 224;
|
||||
int height = 448;
|
||||
|
||||
@@ -545,7 +556,7 @@ void test_convert_color_i420_to_rgb_three_planes_surface_u8(bool is_caching_test
|
||||
}
|
||||
|
||||
int data_size = width * (height + height / 2);
|
||||
std::vector<uint8_t> data = generate_random_1d<uint8_t>(data_size, 0, 255);
|
||||
std::vector<uint8_t> data = rg.generate_random_1d<uint8_t>(data_size, 0, 255);
|
||||
|
||||
cl_int err;
|
||||
cl_image_format image_format;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/convolution.hpp>
|
||||
@@ -2396,12 +2397,13 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in4x4x1x1_nopad_random) {
|
||||
// rnd rnd
|
||||
|
||||
size_t batch = 1, input_f = 1, input_y = 4, input_x = 4;
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
VVVVF<float> input_rnd = generate_random_4d<float>(batch, input_f, input_y, input_x, -10, 10);
|
||||
VVVVF<float> input_rnd = rg.generate_random_4d<float>(batch, input_f, input_y, input_x, -10, 10);
|
||||
VF<float> input_rnd_vec = flatten_4d<float>(format::yxfb, input_rnd);
|
||||
VVVVF<float> filter_rnd = generate_random_4d<float>(1, 1, 2, 2, -10, 10);
|
||||
VVVVF<float> filter_rnd = rg.generate_random_4d<float>(1, 1, 2, 2, -10, 10);
|
||||
VF<float> filter_rnd_vec = flatten_4d<float>(format::bfyx, filter_rnd);
|
||||
VF<float> bias_rnd = generate_random_1d<float>(1, -10, 10);
|
||||
VF<float> bias_rnd = rg.generate_random_1d<float>(1, -10, 10);
|
||||
VVVVF<float> output_rnd(batch, VVVF<float>(filter_rnd.size()));
|
||||
for (size_t b = 0; b < output_rnd.size(); ++b) {
|
||||
for (size_t of = 0; of < filter_rnd.size(); ++of) {
|
||||
@@ -2466,12 +2468,13 @@ TEST(convolution_f32_fw_gpu, basic_wsiz2x2_wstr2x2_in2x2x1x2_nopad_random) {
|
||||
// rnd rnd
|
||||
|
||||
size_t batch = 2, input_f = 1, input_y = 2, input_x = 2;
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
VVVVF<float> input_rnd = generate_random_4d<float>(batch, input_f, input_y, input_x, -10, 10);
|
||||
VVVVF<float> input_rnd = rg.generate_random_4d<float>(batch, input_f, input_y, input_x, -10, 10);
|
||||
VF<float> input_rnd_vec = flatten_4d<float>(format::yxfb, input_rnd);
|
||||
VVVVF<float> filter_rnd = generate_random_4d<float>(1, 1, 2, 2, -10, 10);
|
||||
VVVVF<float> filter_rnd = rg.generate_random_4d<float>(1, 1, 2, 2, -10, 10);
|
||||
VF<float> filter_rnd_vec = flatten_4d<float>(format::bfyx, filter_rnd);
|
||||
VF<float> bias_rnd = generate_random_1d<float>(1, -10, 10);
|
||||
VF<float> bias_rnd = rg.generate_random_1d<float>(1, -10, 10);
|
||||
VVVVF<float> output_rnd(batch, VVVF<float>(filter_rnd.size()));
|
||||
for (size_t b = 0; b < output_rnd.size(); ++b) {
|
||||
for (size_t of = 0; of < filter_rnd.size(); ++of) {
|
||||
@@ -5042,6 +5045,7 @@ INSTANTIATE_TEST_SUITE_P(convolution_gpu_test,
|
||||
|
||||
TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -5063,13 +5067,13 @@ TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32)
|
||||
const int output_xy = 1 + (input_xy + 2 * pad - filter_xy) / stride + 2 * output_padding;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -5088,7 +5092,7 @@ TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32)
|
||||
{
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1);
|
||||
auto biases_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -5192,6 +5196,7 @@ TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32)
|
||||
}
|
||||
|
||||
TEST(convolution_f16_fsv_gpu, convolution_f16_fsv_gpu_padding) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -5209,13 +5214,13 @@ TEST(convolution_f16_fsv_gpu, convolution_f16_fsv_gpu_padding) {
|
||||
const int output_xy = 1 + (input_xy - filter_xy) / stride;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -5233,7 +5238,7 @@ TEST(convolution_f16_fsv_gpu, convolution_f16_fsv_gpu_padding) {
|
||||
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1);
|
||||
auto biases_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -5331,6 +5336,7 @@ INSTANTIATE_TEST_SUITE_P(convolution_gpu_with_crop,
|
||||
|
||||
TEST_P(convolution_gpu_fs_byx_fsv32_crop, fs_byx_fsv32_crop)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -5352,13 +5358,13 @@ TEST_P(convolution_gpu_fs_byx_fsv32_crop, fs_byx_fsv32_crop)
|
||||
const int output_xy = 1 + (input_xy + 2 * pad - filter_xy) / stride + 2 * output_padding;
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
|
||||
// ref input
|
||||
auto half_input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto half_input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data = VVVVF<FLOAT16>(batch_num);
|
||||
|
||||
// concatenated cldnn input tensor
|
||||
@@ -5403,7 +5409,7 @@ TEST_P(convolution_gpu_fs_byx_fsv32_crop, fs_byx_fsv32_crop)
|
||||
{
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1);
|
||||
auto biases_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -5533,6 +5539,7 @@ TEST(convolution_f32_fw_gpu, convolution_int8_b_fs_yx_fsv4_to_bfyx) {
|
||||
const int input_size_x = 1280;
|
||||
const int input_size_y = 720;
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (engine.get_device_info().supports_immad) {
|
||||
@@ -5541,20 +5548,20 @@ TEST(convolution_f32_fw_gpu, convolution_int8_b_fs_yx_fsv4_to_bfyx) {
|
||||
}
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_size_x, input_size_y);
|
||||
auto input_data = generate_random_4d<float>(batch_num, input_f, input_size_y, input_size_x, -10, 10);
|
||||
auto input_data = rg.generate_random_4d<float>(batch_num, input_f, input_size_y, input_size_x, -10, 10);
|
||||
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input = engine.allocate_memory({ data_types::f32, format::bfyx, input_size });
|
||||
set_values(input, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy);
|
||||
auto weights_data = generate_random_4d<int8_t>(output_f, input_f, filter_xy, filter_xy, -10, 10);
|
||||
auto weights_data = rg.generate_random_4d<int8_t>(output_f, input_f, filter_xy, filter_xy, -10, 10);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights = engine.allocate_memory({ data_types::i8, format::bfyx, weights_size });
|
||||
set_values(weights, weights_data_bfyx);
|
||||
|
||||
auto biases_size = tensor(1, output_f, 1, 1);
|
||||
auto biases_data = generate_random_4d<int8_t>(1, output_f, 1, 1, -10, 10);
|
||||
auto biases_data = rg.generate_random_4d<int8_t>(1, output_f, 1, 1, -10, 10);
|
||||
auto biases_data_bfyx = flatten_4d(format::bfyx, biases_data);
|
||||
auto biases = engine.allocate_memory({ data_types::i8, format::bfyx, biases_size });
|
||||
set_values(biases, biases_data_bfyx);
|
||||
@@ -5625,7 +5632,7 @@ TEST(convolution_f32_fw_gpu, convolution_int8_b_fs_yx_fsv4_to_bfyx) {
|
||||
|
||||
TEST(convolution_gpu, bfyx_iyxo_5x5_fp16)
|
||||
{
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -5653,14 +5660,14 @@ TEST(convolution_gpu, bfyx_iyxo_5x5_fp16)
|
||||
const int output_y = 1 + (input_size_y + 2 * pad - filter_xy) / stride + 2 * output_padding;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_size_x, input_size_y);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_size_y, input_size_x, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_size_y, input_size_x, -1, 1);
|
||||
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size });
|
||||
|
||||
@@ -5678,7 +5685,7 @@ TEST(convolution_gpu, bfyx_iyxo_5x5_fp16)
|
||||
{
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1);
|
||||
auto biases_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -5865,6 +5872,7 @@ INSTANTIATE_TEST_SUITE_P(convolution_gpu_block3D,
|
||||
|
||||
TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int batch_num = testing::get<0>(GetParam());
|
||||
@@ -5881,13 +5889,13 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32)
|
||||
input_format = format::bs_fs_zyx_bsv16_fsv16;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy, 1);
|
||||
auto input_data = generate_random_4d<float>(batch_num, input_f, input_xy, input_xy, 1, 10);
|
||||
auto input_data = rg.generate_random_4d<float>(batch_num, input_f, input_xy, input_xy, 1, 10);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy, 1);
|
||||
auto weights_data = generate_random_4d<float>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<float>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
|
||||
@@ -5908,7 +5916,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32)
|
||||
{
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1, 1);
|
||||
auto biases_data = generate_random_1d<float>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<float>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -5997,6 +6005,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32)
|
||||
|
||||
TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -6019,14 +6028,14 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16)
|
||||
input_format = format::bs_fs_zyx_bsv16_fsv16;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy, 1);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, 0, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, 0, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfzyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy, 1);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, 0, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, 0, 1);
|
||||
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
|
||||
@@ -6047,7 +6056,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16)
|
||||
{
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1, 1);
|
||||
auto biases_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfzyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -6135,6 +6144,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp16)
|
||||
|
||||
TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32_fused_ops)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int batch_num = testing::get<0>(GetParam());
|
||||
@@ -6151,13 +6161,13 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32_fused_ops)
|
||||
input_format = format::bs_fs_zyx_bsv16_fsv16;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy, 1);
|
||||
auto input_data = generate_random_4d<float>(batch_num, input_f, input_xy, input_xy, 1, 10);
|
||||
auto input_data = rg.generate_random_4d<float>(batch_num, input_f, input_xy, input_xy, 1, 10);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy, 1);
|
||||
auto weights_data = generate_random_4d<float>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<float>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
|
||||
@@ -6178,7 +6188,7 @@ TEST_P(convolution_gpu_block_layout3D, bfzyx_bsv16_fsv16_fp32_fused_ops)
|
||||
{
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1, 1);
|
||||
auto biases_data = generate_random_1d<float>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<float>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f32, format::bfzyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -6299,6 +6309,7 @@ INSTANTIATE_TEST_SUITE_P(convolution_gpu_block,
|
||||
|
||||
TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int batch_num = testing::get<0>(GetParam());
|
||||
@@ -6319,13 +6330,13 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32)
|
||||
}
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy);
|
||||
auto input_data = generate_random_4d<float>(batch_num, input_f, input_xy, input_xy, 1, 10);
|
||||
auto input_data = rg.generate_random_4d<float>(batch_num, input_f, input_xy, input_xy, 1, 10);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f32, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy);
|
||||
auto weights_data = generate_random_4d<float>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<float>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
|
||||
@@ -6346,7 +6357,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32)
|
||||
{
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1);
|
||||
auto biases_data = generate_random_1d<float>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<float>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f32, format::bfyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -6457,15 +6468,16 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp16)
|
||||
return;
|
||||
}
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, 0, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, 0, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, 0, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, filter_xy, filter_xy, 0, 1);
|
||||
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
|
||||
@@ -6486,7 +6498,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp16)
|
||||
{
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1);
|
||||
auto biases_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -6571,6 +6583,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp16)
|
||||
|
||||
TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32_fused_ops)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -6590,13 +6603,13 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32_fused_ops)
|
||||
const int pad = filter_xy / 2;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy);
|
||||
auto input_data = generate_random_4d<float>(batch_num, input_f, input_xy, input_xy, 1, 10);
|
||||
auto input_data = rg.generate_random_4d<float>(batch_num, input_f, input_xy, input_xy, 1, 10);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f32, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_xy, filter_xy, 1);
|
||||
auto weights_data = generate_random_4d<float>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<float>(output_f, input_f, filter_xy, filter_xy, -1, 1);
|
||||
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
|
||||
@@ -6617,7 +6630,7 @@ TEST_P(convolution_gpu_block_layout, bfyx_bsv16_fsv16_fp32_fused_ops)
|
||||
{
|
||||
// Generate bias data
|
||||
auto biases_size = tensor(1, output_f, 1, 1, 1);
|
||||
auto biases_data = generate_random_1d<float>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<float>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f32, format::bfyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -6745,6 +6758,7 @@ INSTANTIATE_TEST_SUITE_P(convolution_depthwise_gpu_fs_b_yx_fsv32,
|
||||
|
||||
TEST_P(convolution_depthwise_gpu, depthwise_conv_fs_b_yx_fsv32)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -6770,13 +6784,13 @@ TEST_P(convolution_depthwise_gpu, depthwise_conv_fs_b_yx_fsv32)
|
||||
const int output_x = 1 + (input_xy + 2 * pad_x - filter_x) / stride + 2 * output_padding;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(group(groups), batch(1), feature(1), spatial(filter_x, filter_y));
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::goiyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -6887,6 +6901,7 @@ INSTANTIATE_TEST_SUITE_P(convolution_depthwise_gpu_b_fs_yx_fsv16,
|
||||
|
||||
TEST_P(convolution_depthwise_gpu_fsv16, depthwise_conv_b_fs_yx_fsv16)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -6913,13 +6928,13 @@ TEST_P(convolution_depthwise_gpu_fsv16, depthwise_conv_b_fs_yx_fsv16)
|
||||
const int output_x = 1 + (input_xy + 2 * pad_x - filter_x) / stride + 2 * output_padding;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(group(output_f), batch(1), feature(1), spatial(filter_x, filter_y));
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::goiyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -7017,6 +7032,7 @@ INSTANTIATE_TEST_SUITE_P(convolution_depthwise_gpu_b_fs_yx_fsv16_1d_depthwise_co
|
||||
|
||||
TEST_P(convolution_depthwise_gpu_fsv16_xy, depthwise_conv_b_fs_yx_fsv16)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -7044,13 +7060,13 @@ TEST_P(convolution_depthwise_gpu_fsv16_xy, depthwise_conv_b_fs_yx_fsv16)
|
||||
const int output_x = 1 + (input_x + 2 * pad_x - filter_x) / stride + 2 * output_padding;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_x, input_y);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(group(output_f), batch(1), feature(1), spatial(filter_x, filter_y));
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::goiyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -7233,6 +7249,7 @@ struct convolution_depthwise_gpu_bfyx : public convolution_depthwise_gpu {};
|
||||
|
||||
TEST_P(convolution_depthwise_gpu_bfyx, depthwise_conv_bfyx)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -7259,13 +7276,13 @@ TEST_P(convolution_depthwise_gpu_bfyx, depthwise_conv_bfyx)
|
||||
const int output_x = 1 + (input_xy + 2 * pad_x - filter_x) / stride + 2 * output_padding;
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(group(output_f), batch(1), feature(1), spatial(filter_x, filter_y));
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::goiyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -7437,6 +7454,7 @@ INSTANTIATE_TEST_SUITE_P(convolution_grouped_fsv4_fsv16,
|
||||
convolution_grouped_gpu::PrintToStringParamName);
|
||||
|
||||
TEST_P(convolution_grouped_gpu, base) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int input_x = testing::get<0>(GetParam()),
|
||||
@@ -7465,7 +7483,7 @@ TEST_P(convolution_grouped_gpu, base) {
|
||||
auto num_in_spatial_dims = input_data_format.spatial_num();
|
||||
|
||||
auto input_size = tensor(batch(batch_num), feature(input_f), spatial(input_x, input_y, input_z));
|
||||
auto input_rnd = generate_random_5d<int8_t>(batch_num, input_f, input_z, input_y, input_x, -127, 127);
|
||||
auto input_rnd = rg.generate_random_5d<int8_t>(batch_num, input_f, input_z, input_y, input_x, -127, 127);
|
||||
|
||||
auto input_lay = layout(data_types::i8, format::bfzyx, input_size);
|
||||
if (num_in_spatial_dims == 2) {
|
||||
@@ -7487,7 +7505,7 @@ TEST_P(convolution_grouped_gpu, base) {
|
||||
auto input_zp_rnd = std::vector<int8_t>(input_f);
|
||||
auto input_zp_prim_name = "";
|
||||
if (has_input_zp) {
|
||||
input_zp_rnd = generate_random_1d<int8_t>(input_f, -127, 127);
|
||||
input_zp_rnd = rg.generate_random_1d<int8_t>(input_f, -127, 127);
|
||||
input_zp_prim_name = "input_zp";
|
||||
}
|
||||
auto input_zp_lay = layout(data_types::i8, format::bfyx, tensor(feature(input_f)));
|
||||
@@ -7496,7 +7514,7 @@ TEST_P(convolution_grouped_gpu, base) {
|
||||
|
||||
auto weights_size = tensor(group(groups), batch(output_f / groups), feature(input_f / groups), spatial(filter_x, filter_y, filter_z));
|
||||
|
||||
VVVVVVF<int8_t> weights_rnd = generate_random_6d<int8_t>(groups, output_f / groups, input_f / groups, filter_z, filter_y, filter_x, -127, 127);
|
||||
VVVVVVF<int8_t> weights_rnd = rg.generate_random_6d<int8_t>(groups, output_f / groups, input_f / groups, filter_z, filter_y, filter_x, -127, 127);
|
||||
auto weights_lay = layout(data_types::i8, format::goizyx, weights_size);
|
||||
if (num_in_spatial_dims == 2) {
|
||||
weights_lay = layout(data_types::i8, format::goiyx, weights_size);
|
||||
@@ -7518,7 +7536,7 @@ TEST_P(convolution_grouped_gpu, base) {
|
||||
auto weights_zp_rnd = std::vector<int8_t>(output_f);
|
||||
auto weights_zp_prim_name = "";
|
||||
if (has_weights_zp) {
|
||||
weights_zp_rnd = generate_random_1d<int8_t>(output_f, -127, 127);
|
||||
weights_zp_rnd = rg.generate_random_1d<int8_t>(output_f, -127, 127);
|
||||
weights_zp_prim_name = "weights_zp";
|
||||
}
|
||||
auto weights_zp_lay = layout(data_types::i8, format::bfyx, tensor(batch(output_f)));
|
||||
@@ -7682,6 +7700,7 @@ INSTANTIATE_TEST_SUITE_P(conv_fp16_cases,
|
||||
convolution_general_gpu::PrintToStringParamName);
|
||||
|
||||
TEST_P(convolution_general_gpu, conv_fp16_cases) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16) {
|
||||
@@ -7707,13 +7726,13 @@ TEST_P(convolution_general_gpu, conv_fp16_cases) {
|
||||
auto with_bias = testing::get<13>(GetParam());
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_x, input_y);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_y, filter_x, 1);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, filter_y, filter_x, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, filter_y, filter_x, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -7725,7 +7744,7 @@ TEST_P(convolution_general_gpu, conv_fp16_cases) {
|
||||
// Calculate reference values
|
||||
if (with_bias) {
|
||||
auto biases_size = tensor(1, output_f, 1, 1);
|
||||
auto biases_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -7844,6 +7863,7 @@ INSTANTIATE_TEST_SUITE_P(conv_b_fs_yx_fsv16_to_bfyx,
|
||||
|
||||
TEST_P(convolution_gpu_fsv16_to_bfyx, conv_b_fs_yx_fsv16_to_bfyx_padding)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16)
|
||||
@@ -7866,13 +7886,13 @@ TEST_P(convolution_gpu_fsv16_to_bfyx, conv_b_fs_yx_fsv16_to_bfyx_padding)
|
||||
const std::ptrdiff_t pad_x = (filter_x - 1) / 2;
|
||||
|
||||
auto input_size = tensor(input_b, input_f, input_x, input_y);
|
||||
auto input_data = generate_random_4d<FLOAT16>(input_b, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(input_b, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(input_b, input_f, filter_x, filter_y, 1);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(input_b, input_f, filter_x, filter_y, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(input_b, input_f, filter_x, filter_y, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::oiyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -7943,6 +7963,7 @@ TEST_P(convolution_gpu_fsv16_to_bfyx, conv_b_fs_yx_fsv16_to_bfyx_padding)
|
||||
|
||||
TEST_P(convolution_gpu_fsv16_to_bfyx, conv_b_fs_yx_fsv16_to_bfyx_different_type)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
if (!engine.get_device_info().supports_fp16)
|
||||
@@ -7965,13 +7986,13 @@ TEST_P(convolution_gpu_fsv16_to_bfyx, conv_b_fs_yx_fsv16_to_bfyx_different_type)
|
||||
const std::ptrdiff_t pad_x = (filter_x - 1) / 2;
|
||||
|
||||
auto input_size = tensor(input_b, input_f, input_x, input_y);
|
||||
auto input_data = generate_random_4d<FLOAT16>(input_b, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(input_b, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(input_b, input_f, filter_x, filter_y, 1);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(input_b, input_f, filter_x, filter_y, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(input_b, input_f, filter_x, filter_y, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::goiyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -8353,22 +8374,24 @@ public:
|
||||
}
|
||||
|
||||
virtual void param_set_up(const convolution_random_test_all_params& params) {
|
||||
auto& rg = get_random_generator();
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
auto wei_in_f = params.input_features / params.groups;
|
||||
|
||||
auto input_data = generate_random_4d<InputT>(
|
||||
auto input_data = rg.template generate_random_4d<InputT>(
|
||||
params.batch, params.input_features, params.input_xy[1], params.input_xy[0], -256, 256);
|
||||
if (params.grouped_weights_shape) {
|
||||
auto weights_data = generate_random_5d<WeightsT>(
|
||||
auto weights_data = rg.template generate_random_5d<WeightsT>(
|
||||
params.groups, (params.output_features / params.groups), wei_in_f, params.filter_xy[1], params.filter_xy[0], -256, 256);
|
||||
this->set_grouped_weights(std::move(weights_data));
|
||||
} else {
|
||||
auto weights_data = generate_random_4d<WeightsT>(
|
||||
auto weights_data = rg.template generate_random_4d<WeightsT>(
|
||||
params.output_features, wei_in_f, params.filter_xy[1], params.filter_xy[0], -256, 256);
|
||||
this->set_weights(std::move(weights_data));
|
||||
}
|
||||
auto bias_data = params.with_bias ? generate_random_1d<OutputT>(params.output_features, -256, 256) : VF<OutputT>();
|
||||
auto weights_zp_data = params.asymmetric_weights ? generate_random_1d<WeightsT>(params.output_features, -256, 256) : VF<WeightsT>();
|
||||
auto input_zp_data = params.asymmetric_data ? generate_random_1d<InputT>(params.input_features, -256, 256) : VF<InputT>();
|
||||
auto bias_data = params.with_bias ? rg.template generate_random_1d<OutputT>(params.output_features, -256, 256) : VF<OutputT>();
|
||||
auto weights_zp_data = params.asymmetric_weights ? rg.template generate_random_1d<WeightsT>(params.output_features, -256, 256) : VF<WeightsT>();
|
||||
auto input_zp_data = params.asymmetric_data ? rg.template generate_random_1d<InputT>(params.input_features, -256, 256) : VF<InputT>();
|
||||
|
||||
this->set_input(params.input_format, std::move(input_data));
|
||||
this->set_bias(std::move(bias_data));
|
||||
@@ -8388,6 +8411,9 @@ public:
|
||||
VVVVF<OutputT> expected = calculate_reference();
|
||||
ASSERT_NO_FATAL_FAILURE(this->run_expect(expected));
|
||||
}
|
||||
|
||||
tests::random_generator _rg;
|
||||
tests::random_generator& get_random_generator() { return _rg; }
|
||||
};
|
||||
|
||||
// construct a readable name in format as follows:
|
||||
@@ -8608,8 +8634,9 @@ public:
|
||||
void param_set_up(const convolution_random_test_all_params& params) override {
|
||||
parent::param_set_up(params);
|
||||
|
||||
_scale = generate_random_1d<OutputT>(this->output_features(), -1, 1);
|
||||
_shift = generate_random_1d<OutputT>(this->output_features(), 128, 128);
|
||||
auto& rg = this->get_random_generator();
|
||||
_scale = rg.template generate_random_1d<OutputT>(this->output_features(), -1, 1);
|
||||
_shift = rg.template generate_random_1d<OutputT>(this->output_features(), -128, 128);
|
||||
}
|
||||
protected:
|
||||
VF<OutputT> _scale;
|
||||
@@ -8834,7 +8861,12 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
|
||||
class convolution_test : public tests::generic_test {
|
||||
public:
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
all_generic_params.clear();
|
||||
all_layer_params.clear();
|
||||
@@ -8974,21 +9006,21 @@ public:
|
||||
// Update inputs.
|
||||
auto input = inputs[0];
|
||||
auto input_size = inputs[0]->get_layout().get_tensor();
|
||||
VVVVF<Type> input_rnd = generate_random_4d<Type>(input_size.batch[0], input_size.feature[0], input_size.spatial[1], input_size.spatial[0], -2, 2, k);
|
||||
VVVVF<Type> input_rnd = rg.generate_random_4d<Type>(input_size.batch[0], input_size.feature[0], input_size.spatial[1], input_size.spatial[0], -2, 2, k);
|
||||
VF<Type> input_rnd_vec = flatten_4d<Type>(input->get_layout().format, input_rnd);
|
||||
set_values(input, input_rnd_vec);
|
||||
|
||||
// Update weights.
|
||||
auto weight_input = inputs[1];
|
||||
auto weight_size = inputs[1]->get_layout().get_tensor();
|
||||
VVVVF<Type> weight_rnd = generate_random_4d<Type>(weight_size.batch[0], weight_size.feature[0], weight_size.spatial[1], weight_size.spatial[0], -2, 2, k);
|
||||
VVVVF<Type> weight_rnd = rg.generate_random_4d<Type>(weight_size.batch[0], weight_size.feature[0], weight_size.spatial[1], weight_size.spatial[0], -2, 2, k);
|
||||
VF<Type> weight_rnd_vec = flatten_4d<Type>(weight_input->get_layout().format, weight_rnd);
|
||||
set_values(weight_input, weight_rnd_vec);
|
||||
|
||||
// Update biases.
|
||||
auto bias_input = inputs[2];
|
||||
auto bias_size = inputs[2]->get_layout().get_tensor();
|
||||
VF<Type> bias_rnd = generate_random_1d<Type>(bias_size.spatial[0], -2, 2, k);
|
||||
VF<Type> bias_rnd = rg.generate_random_1d<Type>(bias_size.spatial[0], -2, 2, k);
|
||||
set_values(bias_input, bias_rnd);
|
||||
}
|
||||
|
||||
@@ -9178,6 +9210,7 @@ INSTANTIATE_TEST_SUITE_P(conv_onednn_cases,
|
||||
|
||||
|
||||
TEST_P(convolution_gpu_onednn, conv_onednn_cases) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
if (!engine.get_device_info().supports_immad)
|
||||
return;
|
||||
@@ -9203,13 +9236,13 @@ TEST_P(convolution_gpu_onednn, conv_onednn_cases) {
|
||||
auto with_bias = testing::get<13>(GetParam());
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_x, input_y);
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(output_f, input_f, filter_y, filter_x, 1);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, filter_y, filter_x, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, filter_y, filter_x, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -9221,7 +9254,7 @@ TEST_P(convolution_gpu_onednn, conv_onednn_cases) {
|
||||
// Calculate reference values
|
||||
if (with_bias) {
|
||||
auto biases_size = tensor(1, output_f, 1, 1);
|
||||
auto biases_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
auto biases_mem = engine.allocate_memory({ data_types::f16, format::bfyx, biases_size });
|
||||
set_values(biases_mem, biases_data);
|
||||
|
||||
@@ -9330,17 +9363,18 @@ TEST(convolution_gpu_onednn, padding_for_cldnn_kernel_after_onednn) {
|
||||
if (!engine.get_device_info().supports_immad)
|
||||
return;
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
int input_b = 1, input_f = 16, input_y = 3, input_x = 3;
|
||||
int output_b = 1, output_f = 16, output_y = 6, output_x = 6;
|
||||
|
||||
auto input_size = tensor(input_b, input_f, input_x, input_y);
|
||||
auto input_data = generate_random_4d<FLOAT16>(input_b, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(input_b, input_f, input_y, input_x, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(16, 16, 1, 1, 1);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, 1, 1, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, 1, 1, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::bfyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
@@ -9409,15 +9443,16 @@ TEST(convolution_gpu_onednn, spatial_1d) {
|
||||
if (!engine.get_device_info().supports_immad)
|
||||
return;
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
ov::PartialShape input_pshape = {1, 16, 6};
|
||||
ov::PartialShape weights_pshape = {16, 16, 3};
|
||||
layout in_layout{ input_pshape, data_types::f16, format::bfyx };
|
||||
layout weights_layout{ weights_pshape, data_types::f16, format::bfyx };
|
||||
auto input_data = generate_random_1d<FLOAT16>(in_layout.count(), -1, 1);
|
||||
auto input_data = rg.generate_random_1d<FLOAT16>(in_layout.count(), -1, 1);
|
||||
auto input_mem = engine.allocate_memory(in_layout);
|
||||
set_values(input_mem, input_data);
|
||||
|
||||
auto weights_data = generate_random_1d<FLOAT16>(weights_layout.count(), -1, 1);
|
||||
auto weights_data = rg.generate_random_1d<FLOAT16>(weights_layout.count(), -1, 1);
|
||||
auto weights_mem = engine.allocate_memory(weights_layout);
|
||||
set_values(weights_mem, weights_data);
|
||||
|
||||
@@ -9663,12 +9698,13 @@ TEST(convolution_gpu_onednn, has_proper_synchronization) {
|
||||
if (!engine.get_device_info().supports_immad)
|
||||
return;
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
layout in_layout{{1, 16, 2, 4}, data_types::f32, format::bfyx};
|
||||
auto input_mem = engine.allocate_memory(in_layout);
|
||||
auto weights_mem = engine.allocate_memory({{16, 16, 1, 1}, data_types::f32, format::bfyx});
|
||||
|
||||
auto in_data = generate_random_4d<float>(1, 16, 2, 4, -1, 1);
|
||||
auto weights_data = generate_random_4d<float>(16, 16, 1, 1, -1, 1);
|
||||
auto in_data = rg.generate_random_4d<float>(1, 16, 2, 4, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<float>(16, 16, 1, 1, -1, 1);
|
||||
|
||||
set_values(input_mem, flatten_4d(format::bfyx, in_data));
|
||||
set_values(weights_mem, flatten_4d(format::bfyx, weights_data));
|
||||
@@ -9721,6 +9757,7 @@ TEST(convolution_gpu_onednn, has_proper_synchronization) {
|
||||
|
||||
template <typename T>
|
||||
void test_convolution_f32_gpu_convolution_gpu_bfyx_f16_depthwise_x_block_size_1(bool is_caching_test) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int batch_num = 1;
|
||||
@@ -9746,13 +9783,13 @@ void test_convolution_f32_gpu_convolution_gpu_bfyx_f16_depthwise_x_block_size_1(
|
||||
}
|
||||
|
||||
auto input_size = tensor(batch_num, input_f, input_xy, input_xy);
|
||||
auto input_data = generate_random_4d<T>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data = rg.generate_random_4d<T>(batch_num, input_f, input_xy, input_xy, -1, 1);
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto input_mem = engine.allocate_memory({ data_types::f16, format::bfyx, input_size });
|
||||
set_values(input_mem, input_data_bfyx);
|
||||
|
||||
auto weights_size = tensor(group(output_f), batch(1), feature(1), spatial(filter_x, filter_y));
|
||||
auto weights_data = generate_random_4d<T>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<T>(output_f, 1, filter_y, filter_x, -1, 1);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
auto weights_mem = engine.allocate_memory({ data_types::f16, format::goiyx, weights_size });
|
||||
set_values(weights_mem, weights_data_bfyx);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/crop.hpp>
|
||||
@@ -13,29 +14,13 @@
|
||||
using namespace cldnn;
|
||||
using namespace ::tests;
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> generate_random_input(size_t b, size_t f, size_t z, size_t y, size_t x, int min, int max) {
|
||||
static std::default_random_engine generator(random_seed);
|
||||
int k = 8; // 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
std::vector<T> v(b*f*x*y*z);
|
||||
for (size_t i = 0; i < b*f*x*y*z; ++i) {
|
||||
v[i] = (T)distribution(generator);
|
||||
v[i] /= k;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> generate_random_input(size_t b, size_t f, size_t y, size_t x, int min, int max) {
|
||||
return generate_random_input<T>(b, f, 1, y, x, -min, max);
|
||||
}
|
||||
|
||||
TEST(crop_gpu, basic_in2x3x2x2_crop_all) {
|
||||
// Reference : 1x2x2x2
|
||||
// Input : 2x3x4x5
|
||||
// Output : 1x2x2x3
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 2;
|
||||
@@ -54,7 +39,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 }));
|
||||
|
||||
std::vector<float> input_vec = generate_random_input<float>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<float> input_vec = rg.generate_random_1d<float>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -131,6 +116,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all) {
|
||||
// Input : 2x3x4x5
|
||||
// Output : 1x2x2x3
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 2;
|
||||
@@ -149,7 +135,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 }));
|
||||
|
||||
std::vector<int32_t> input_vec = generate_random_input<int32_t>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<int32_t> input_vec = rg.generate_random_1d<int32_t>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -179,6 +165,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all) {
|
||||
// Input : 2x3x4x5
|
||||
// Output : 1x2x2x3
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 2;
|
||||
@@ -197,7 +184,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 }));
|
||||
|
||||
std::vector<int64_t> input_vec = generate_random_input<int64_t>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<int64_t> input_vec = rg.generate_random_1d<int64_t>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -227,6 +214,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_bfyx) {
|
||||
// Input : 6x2x4x3
|
||||
// Output : 3x1x2x2
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 6;
|
||||
@@ -245,7 +233,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_bfyx) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, {0, 0, 0, 0} ));
|
||||
|
||||
std::vector<float> input_vec = generate_random_input<float>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<float> input_vec = rg.generate_random_1d<float>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -276,6 +264,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_bfyx) {
|
||||
// Input : 6x2x4x3
|
||||
// Output : 3x1x2x2
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 6;
|
||||
@@ -294,7 +283,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_bfyx) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 }));
|
||||
|
||||
std::vector<int32_t> input_vec = generate_random_input<int32_t>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<int32_t> input_vec = rg.generate_random_1d<int32_t>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -325,6 +314,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_bfyx) {
|
||||
// Input : 6x2x4x3
|
||||
// Output : 3x1x2x2
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 6;
|
||||
@@ -343,7 +333,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_bfyx) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 }));
|
||||
|
||||
std::vector<int64_t> input_vec = generate_random_input<int64_t>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<int64_t> input_vec = rg.generate_random_1d<int64_t>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -374,6 +364,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_fyxb) {
|
||||
// Input : 6x2x4x3
|
||||
// Output : 3x1x2x2
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 6;
|
||||
@@ -392,7 +383,7 @@ TEST(crop_gpu, basic_in2x3x2x2_crop_all_fyxb) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, {0, 0, 0, 0} ));
|
||||
|
||||
std::vector<float> input_vec = generate_random_input<float>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<float> input_vec = rg.generate_random_1d<float>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -421,6 +412,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_fyxb) {
|
||||
// Input : 6x2x4x3
|
||||
// Output : 3x1x2x2
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 6;
|
||||
@@ -439,7 +431,7 @@ TEST(crop_gpu, basic_i32_in2x3x2x2_crop_all_fyxb) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 }));
|
||||
|
||||
std::vector<int32_t> input_vec = generate_random_input<int32_t>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<int32_t> input_vec = rg.generate_random_1d<int32_t>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -468,6 +460,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_fyxb) {
|
||||
// Input : 6x2x4x3
|
||||
// Output : 3x1x2x2
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 6;
|
||||
@@ -486,7 +479,7 @@ TEST(crop_gpu, basic_i64_in2x3x2x2_crop_all_fyxb) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size }, { 0, 0, 0, 0 }));
|
||||
|
||||
std::vector<int64_t> input_vec = generate_random_input<int64_t>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<int64_t> input_vec = rg.generate_random_1d<int64_t>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -1058,6 +1051,7 @@ TEST(crop_gpu, basic_in3x1x2x2x1_crop_all_bfzyx) {
|
||||
// Input : 6x2x4x3x2
|
||||
// Output : 3x1x2x2x1
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 6;
|
||||
@@ -1078,7 +1072,7 @@ TEST(crop_gpu, basic_in3x1x2x2x1_crop_all_bfzyx) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), { crop_batch_num, crop_feature_num, crop_x_size, crop_y_size, crop_z_size }, { 0, 0, 0, 0, 0 }));
|
||||
|
||||
std::vector<float> input_vec = generate_random_input<float>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
std::vector<float> input_vec = rg.generate_random_1d<float>(input->count(), -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -1109,6 +1103,7 @@ TEST(crop_gpu, basic_in3x1x3x2x2x1_crop_all_bfwzyx) {
|
||||
// Input : 6x2x6x4x3x2
|
||||
// Output : 3x1x3x2x2x1
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto batch_num = 6;
|
||||
@@ -1133,7 +1128,7 @@ TEST(crop_gpu, basic_in3x1x3x2x2x1_crop_all_bfwzyx) {
|
||||
topology.add(input_layout("input", input->get_layout()));
|
||||
topology.add(crop("crop", input_info("input"), crop_size, tensor{ 0 }));
|
||||
|
||||
VVVVVVF<float> input_rnd = generate_random_6d<float>(batch_num, feature_num, w_size, z_size, y_size, x_size, -10, 10);
|
||||
VVVVVVF<float> input_rnd = rg.generate_random_6d<float>(batch_num, feature_num, w_size, z_size, y_size, x_size, -10, 10);
|
||||
VF<float> input_vec = flatten_6d<float>(format::bfwzyx, input_rnd);
|
||||
set_values(input, input_vec);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/cum_sum.hpp>
|
||||
@@ -142,6 +143,11 @@ using cum_sum_test_params = std::tuple<int, // batch
|
||||
template <typename cum_sum_params, typename input_type = float, typename output_type = float>
|
||||
class cum_sum_gpu : public ::testing::TestWithParam<cum_sum_params> {
|
||||
public:
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
data_types get_alloc_data_type(void) {
|
||||
if (std::is_same<input_type, float>::value)
|
||||
@@ -176,8 +182,8 @@ public:
|
||||
auto input = engine.allocate_memory({ get_alloc_data_type(), in_out_format, shape });
|
||||
const int inputSize = b * f * w * z * y * x;
|
||||
VF<input_type> inputVals = std::is_same<input_type, FLOAT16>::value ?
|
||||
generate_random_1d<input_type>(inputSize, -1, 1, 1) :
|
||||
generate_random_1d<input_type>(inputSize, -100, 100, 8);
|
||||
rg.generate_random_1d<input_type>(inputSize, -1, 1, 1) :
|
||||
rg.generate_random_1d<input_type>(inputSize, -100, 100, 8);
|
||||
|
||||
set_values(input, inputVals);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils/test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/deconvolution.hpp>
|
||||
@@ -1754,15 +1755,14 @@ TYPED_TEST(deconvolution_basic, basic_f16_k9x9_s2x2_pad4x4) {
|
||||
// Input : 1x32x16x16
|
||||
// Stride : 2x2
|
||||
// Pad : 4x4
|
||||
|
||||
//auto& engine = get_test_engine();
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
VVVVF<FLOAT16> input_rnd = generate_random_4d<FLOAT16>(1, 32, 16, 16, -2, 2);
|
||||
VVVVF<FLOAT16> input_rnd = rg.generate_random_4d<FLOAT16>(1, 32, 16, 16, -2, 2);
|
||||
VF<FLOAT16> input_rnd_vec = flatten_4d<FLOAT16>(format::bfyx, input_rnd);
|
||||
VVVVF<FLOAT16> filter_rnd = generate_random_4d<FLOAT16>(1, 32, 9, 9, -1, 1);
|
||||
VVVVF<FLOAT16> filter_rnd = rg.generate_random_4d<FLOAT16>(1, 32, 9, 9, -1, 1);
|
||||
VF<FLOAT16> filter_rnd_vec = flatten_4d<FLOAT16>(format::bfyx, filter_rnd);
|
||||
VF<FLOAT16> bias_rnd = generate_random_1d<FLOAT16>(1, -1, 1);
|
||||
VF<FLOAT16> bias_rnd = rg.generate_random_1d<FLOAT16>(1, -1, 1);
|
||||
VF<float> filter_rnd_f32_vec, bias_f32_rnd;
|
||||
|
||||
for (unsigned int i = 0; i < filter_rnd_vec.size(); i++)
|
||||
@@ -2631,38 +2631,26 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VVVVVF<T> generate_random(cldnn::tensor size) {
|
||||
return generate_random_5d<T>(
|
||||
size.batch[0],
|
||||
size.feature[0],
|
||||
size.spatial[2],
|
||||
size.spatial[1],
|
||||
size.spatial[0],
|
||||
type_test_ranges<T>::min,
|
||||
type_test_ranges<T>::max);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VVVVVVF<T> generate_random_weights(cldnn::tensor size) {
|
||||
return generate_random_6d<T>(
|
||||
size.group[0],
|
||||
size.batch[0],
|
||||
size.feature[0],
|
||||
size.spatial[2],
|
||||
size.spatial[1],
|
||||
size.spatial[0],
|
||||
type_test_ranges<T>::min,
|
||||
type_test_ranges<T>::max);
|
||||
}
|
||||
|
||||
void run(cldnn::engine& eng, const deconvolution_random_test_params& params, ExecutionConfig config) {
|
||||
void run(cldnn::engine& eng, const deconvolution_random_test_params& params, ExecutionConfig config, tests::random_generator& rg) {
|
||||
uint32_t groups = params.weights_size.group[0];
|
||||
size_t ifm = params.weights_size.feature[0];
|
||||
size_t ofm = params.weights_size.batch[0];
|
||||
|
||||
auto input_data = generate_random<InputT>(params.input_size);
|
||||
auto weights_data = generate_random_weights<WeightsT>(params.weights_size);
|
||||
auto input_data = rg.generate_random_5d<InputT>(params.input_size.batch[0],
|
||||
params.input_size.feature[0],
|
||||
params.input_size.spatial[2],
|
||||
params.input_size.spatial[1],
|
||||
params.input_size.spatial[0],
|
||||
type_test_ranges<InputT>::min,
|
||||
type_test_ranges<InputT>::max);
|
||||
auto weights_data = rg.generate_random_6d<WeightsT>(params.weights_size.group[0],
|
||||
params.weights_size.batch[0],
|
||||
params.weights_size.feature[0],
|
||||
params.weights_size.spatial[2],
|
||||
params.weights_size.spatial[1],
|
||||
params.weights_size.spatial[0],
|
||||
type_test_ranges<WeightsT>::min,
|
||||
type_test_ranges<WeightsT>::max);
|
||||
|
||||
auto in_layout = cldnn::layout(cldnn::type_to_data_type<InputT>::value, params.input_format, params.input_size);
|
||||
auto wei_layout = cldnn::layout(cldnn::type_to_data_type<WeightsT>::value, params.weights_format, params.weights_size);
|
||||
@@ -2684,7 +2672,7 @@ public:
|
||||
auto bias_size = cldnn::tensor(feature(params.weights_size.batch[0] * params.weights_size.group[0]));
|
||||
auto bias_lay = cldnn::layout(cldnn::type_to_data_type<OutputT>::value, cldnn::format::bfyx, bias_size);
|
||||
auto bias_mem = eng.allocate_memory(bias_lay);
|
||||
bias_data = generate_random_1d<OutputT>(bias_lay.feature(), -1, 1);
|
||||
bias_data = rg.generate_random_1d<OutputT>(bias_lay.feature(), -1, 1);
|
||||
set_values(bias_mem, bias_data);
|
||||
topo.add(cldnn::data("bias", bias_mem));
|
||||
topo.add(cldnn::deconvolution("deconv", input_info("input"), { "weights" }, { "bias" }, groups, params.strides, params.pad));
|
||||
@@ -2764,6 +2752,7 @@ public:
|
||||
class deconvolution_random_test : public testing::TestWithParam<deconvolution_random_test_params> {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
config.set_property(ov::intel_gpu::optimize_data(true));
|
||||
}
|
||||
|
||||
@@ -2787,6 +2776,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
tests::random_generator rg;
|
||||
ov::intel_gpu::ExecutionConfig config = get_test_default_config(get_test_engine());
|
||||
|
||||
private:
|
||||
@@ -2794,7 +2784,7 @@ private:
|
||||
void run_typed() {
|
||||
auto& params = GetParam();
|
||||
deconvolution_random_test_base<InputT, WeightsT, OutputT> test;
|
||||
test.run(get_test_engine(), params, config);
|
||||
test.run(get_test_engine(), params, config, rg);
|
||||
}
|
||||
|
||||
template <typename InputT, typename WeightsT>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils/test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/concatenation.hpp>
|
||||
@@ -18,19 +19,6 @@
|
||||
using namespace cldnn;
|
||||
using namespace tests;
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> generate_random_input(size_t b, size_t f, size_t y, size_t x, int min, int max) {
|
||||
static std::default_random_engine generator(random_seed);
|
||||
int k = 8; // 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
std::vector<T> v(b * f * x * y);
|
||||
for (size_t i = 0; i < b * f * x * y; ++i) {
|
||||
v[i] = (T)distribution(generator);
|
||||
v[i] /= k;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
TEST(depth_concatenate_f32_gpu, test01) {
|
||||
// Input count : 2
|
||||
// Input1 : 2x 1x1 x 2
|
||||
@@ -325,13 +313,14 @@ TEST(depth_concatenate_f32_gpu, test03_cascade_concat_opt) {
|
||||
TEST(depth_concatenate_f32_gpu, test04_fused_relu) {
|
||||
// 2 inputs of size 3x10x10 concatenated on f axis with fused relu
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
auto input1 = engine.allocate_memory({data_types::f32, format::bfyx, {1, 3, 10, 10}});
|
||||
auto input2 = engine.allocate_memory({data_types::f32, format::bfyx, {1, 3, 10, 10}});
|
||||
|
||||
std::vector<float> input1_vec = generate_random_input<float>(1, 3, 10, 10, -10, 10);
|
||||
std::vector<float> input1_vec = rg.generate_random_1d<float>(input1->count(), -10, 10);
|
||||
set_values(input1, input1_vec);
|
||||
std::vector<float> input2_vec = generate_random_input<float>(1, 3, 10, 10, -10, 10);
|
||||
std::vector<float> input2_vec = rg.generate_random_1d<float>(input2->count(), -10, 10);
|
||||
set_values(input2, input2_vec);
|
||||
|
||||
topology topology;
|
||||
@@ -423,12 +412,13 @@ TEST(depth_concatenate_f32_gpu, test06_padded_input) {
|
||||
const int32_t input_f = 32;
|
||||
const int32_t output_f = 3 * input_f;
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
auto input1 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} });
|
||||
auto input2 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} });
|
||||
|
||||
auto input1_data = generate_random_4d<FLOAT16>(1, input_f, 1, 1, -1, 1);
|
||||
auto input2_data = generate_random_4d<FLOAT16>(1, input_f, 1, 1, -1, 1);
|
||||
auto input1_data = rg.generate_random_4d<FLOAT16>(1, input_f, 1, 1, -1, 1);
|
||||
auto input2_data = rg.generate_random_4d<FLOAT16>(1, input_f, 1, 1, -1, 1);
|
||||
set_values(input1, flatten_4d(format::bfyx, input1_data));
|
||||
set_values(input2, flatten_4d(format::bfyx, input2_data));
|
||||
|
||||
@@ -500,6 +490,7 @@ TEST(depth_concatenate_f32_gpu, test07_padded_output) {
|
||||
const int32_t input_f = 32;
|
||||
const int32_t output_f = 2 * input_f;
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
if (engine.get_device_info().supports_immad) {
|
||||
// Currently, oneDNN does NOT support input/output padding
|
||||
@@ -509,8 +500,8 @@ TEST(depth_concatenate_f32_gpu, test07_padded_output) {
|
||||
auto input1 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} });
|
||||
auto input2 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} });
|
||||
|
||||
auto input1_data = generate_random_4d<FLOAT16>(1, input_f, 1, 1, -1, 1);
|
||||
auto input2_data = generate_random_4d<FLOAT16>(1, input_f, 1, 1, -1, 1);
|
||||
auto input1_data = rg.generate_random_4d<FLOAT16>(1, input_f, 1, 1, -1, 1);
|
||||
auto input2_data = rg.generate_random_4d<FLOAT16>(1, input_f, 1, 1, -1, 1);
|
||||
set_values(input1, flatten_4d(format::bfyx, input1_data));
|
||||
set_values(input2, flatten_4d(format::bfyx, input2_data));
|
||||
|
||||
@@ -578,12 +569,13 @@ TEST(depth_concatenate_f32_gpu, test07_concat_is_output) {
|
||||
const int32_t input_f = 16;
|
||||
const int32_t output_f = 2 * input_f;
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, {1, input_f, 1, 1} });
|
||||
auto input2 = engine.allocate_memory({ data_types::f32, format::bfyx, {1, input_f, 1, 1} });
|
||||
|
||||
auto input1_data = generate_random_4d<float>(1, input_f, 1, 1, -1, 1);
|
||||
auto input2_data = generate_random_4d<float>(1, input_f, 1, 1, -1, 1);
|
||||
auto input1_data = rg.generate_random_4d<float>(1, input_f, 1, 1, -1, 1);
|
||||
auto input2_data = rg.generate_random_4d<float>(1, input_f, 1, 1, -1, 1);
|
||||
set_values(input1, flatten_4d(format::bfyx, input1_data));
|
||||
set_values(input2, flatten_4d(format::bfyx, input2_data));
|
||||
|
||||
@@ -961,6 +953,7 @@ TEST(depth_concatenate_i32_gpu, optimize_data05) {
|
||||
|
||||
template <typename T>
|
||||
void test_depth_concatenate_f32_gpu_basic_bfwzyx_along_w(bool is_caching_test) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
const int b = 2;
|
||||
const int f = 3;
|
||||
@@ -977,7 +970,7 @@ void test_depth_concatenate_f32_gpu_basic_bfwzyx_along_w(bool is_caching_test) {
|
||||
topology.add(input_layout("input1", input1->get_layout()));
|
||||
topology.add(concatenation("concat", { input_info("input1"), input_info("input1") }, 2));
|
||||
|
||||
auto input_data = generate_random_1d<T>(input1->count(), -1, 1);
|
||||
auto input_data = rg.generate_random_1d<T>(input1->count(), -1, 1);
|
||||
|
||||
auto expected_output = std::vector<T>(input1->count() * 2);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/depth_to_space.hpp>
|
||||
@@ -205,12 +206,13 @@ TEST(depth_to_space_fp32_gpu, d112960540_bs2) {
|
||||
// Output : 1x3x1920x1080
|
||||
// Input values in fp16
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input1 = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 12, 960, 540 } });
|
||||
size_t block_size = 2;
|
||||
|
||||
auto random_input = generate_random_4d<FLOAT16>(1, 12, 540, 960, -1, 1);
|
||||
auto random_input = rg.generate_random_4d<FLOAT16>(1, 12, 540, 960, -1, 1);
|
||||
auto input_rnd_vec = flatten_4d<FLOAT16>(format::bfyx, random_input);
|
||||
set_values(input1, input_rnd_vec);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "intel_gpu/runtime/layout.hpp"
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/eltwise.hpp>
|
||||
@@ -79,9 +80,10 @@ template <typename T>
|
||||
void generic_eltwise_test(cldnn::format test_input_fmt, int input_b, int input_f, int input_y, int input_x, cldnn::eltwise_mode mode,
|
||||
bool relu, T slope, int input_padding_y, int input_padding_x, int output_padding_y, int output_padding_x) {
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
int min_random = -2, max_random = 2;
|
||||
VVVVF<T> input1_rnd = generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VVVVF<T> input2_rnd = generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VVVVF<T> input1_rnd = rg.generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VVVVF<T> input2_rnd = rg.generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VF<T> input1_rnd_vec = flatten_4d<T>(test_input_fmt, input1_rnd);
|
||||
VF<T> input2_rnd_vec = flatten_4d<T>(test_input_fmt, input2_rnd);
|
||||
|
||||
@@ -221,10 +223,11 @@ VVVVF<int8_t> eltwise_bool_reference(VVVVF<T> &input1, VVVVF<T> &input2,
|
||||
template <typename T>
|
||||
void generic_eltwise_bool_test(cldnn::format test_input_fmt, int input_b, int input_f, int input_y, int input_x, cldnn::eltwise_mode mode,
|
||||
int input_padding_y, int input_padding_x, int output_padding_y, int output_padding_x) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
int min_random = -2, max_random = 2;
|
||||
VVVVF<T> input1_rnd = generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VVVVF<T> input2_rnd = generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VVVVF<T> input1_rnd = rg.generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VVVVF<T> input2_rnd = rg.generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VF<T> input1_rnd_vec = flatten_4d<T>(test_input_fmt, input1_rnd);
|
||||
VF<T> input2_rnd_vec = flatten_4d<T>(test_input_fmt, input2_rnd);
|
||||
|
||||
@@ -3251,6 +3254,7 @@ TEST(eltwise_gpu_f16, fs_b_yx_fsv32_basic)
|
||||
|
||||
TEST(eltwise_gpu_f16, fs_b_yx_fsv32_broadcast)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
bool f16_supported = engine.get_device_info().supports_fp16;
|
||||
if (!f16_supported) {
|
||||
@@ -3266,8 +3270,8 @@ TEST(eltwise_gpu_f16, fs_b_yx_fsv32_broadcast)
|
||||
tensor input1_tensor(input_b, input_f, input1_x, input1_y);
|
||||
tensor input2_tensor(input_b, input_f, input2_x, input2_y);
|
||||
|
||||
VVVVF<FLOAT16> input1_rnd = generate_random_4d<FLOAT16>(input_b, input_f, input1_y, input1_x, 1, 3);
|
||||
VVVVF<FLOAT16> input2_rnd = generate_random_4d<FLOAT16>(input_b, input_f, input2_y, input2_x, 1, 3);
|
||||
VVVVF<FLOAT16> input1_rnd = rg.generate_random_4d<FLOAT16>(input_b, input_f, input1_y, input1_x, 1, 3);
|
||||
VVVVF<FLOAT16> input2_rnd = rg.generate_random_4d<FLOAT16>(input_b, input_f, input2_y, input2_x, 1, 3);
|
||||
|
||||
VF<FLOAT16> input1_flatten = flatten_4d<FLOAT16>(format::bfyx, input1_rnd);
|
||||
VF<FLOAT16> input2_flatten = flatten_4d<FLOAT16>(format::bfyx, input2_rnd);
|
||||
@@ -3316,6 +3320,7 @@ TEST(eltwise_gpu_f16, fs_b_yx_fsv32_broadcast)
|
||||
|
||||
TEST(eltwise_gpu_f16, fs_b_yx_fsv32_broadcast_bfyx)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
bool f16_supported = engine.get_device_info().supports_fp16;
|
||||
if (!f16_supported) {
|
||||
@@ -3330,8 +3335,8 @@ TEST(eltwise_gpu_f16, fs_b_yx_fsv32_broadcast_bfyx)
|
||||
tensor input1_tensor(input_b, input_f, input1_x, input1_y);
|
||||
tensor input2_tensor(1, input_f, 1, 1);
|
||||
|
||||
VVVVF<FLOAT16> input1_rnd = generate_random_4d<FLOAT16>(input_b, input_f, input1_y, input1_x, 1, 3);
|
||||
VVVVF<FLOAT16> input2_rnd = generate_random_4d<FLOAT16>(1, input_f, 1, 1, 1, 3);
|
||||
VVVVF<FLOAT16> input1_rnd = rg.generate_random_4d<FLOAT16>(input_b, input_f, input1_y, input1_x, 1, 3);
|
||||
VVVVF<FLOAT16> input2_rnd = rg.generate_random_4d<FLOAT16>(1, input_f, 1, 1, 1, 3);
|
||||
|
||||
VF<FLOAT16> input1_flatten = flatten_4d<FLOAT16>(format::bfyx, input1_rnd);
|
||||
VF<FLOAT16> input2_flatten = flatten_4d<FLOAT16>(format::bfyx, input2_rnd);
|
||||
@@ -3434,9 +3439,9 @@ TEST(eltwise_gpu_f32, broadcast_test_in4x4x2x2x2) {
|
||||
TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_basic)
|
||||
{
|
||||
// Inputs are 32x96x2x2
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
tensor input_tensor(32, 96, 20, 20);
|
||||
VVVVF<FLOAT16> input_rnd = generate_random_4d<FLOAT16>(32, 96, 20, 20, 1, 3);
|
||||
VVVVF<FLOAT16> input_rnd = rg.generate_random_4d<FLOAT16>(32, 96, 20, 20, 1, 3);
|
||||
VF<FLOAT16> fp16_bfyx_32x96x2x2_input = flatten_4d<FLOAT16>(format::bfyx, input_rnd);
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
@@ -3514,9 +3519,9 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_basic)
|
||||
|
||||
TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) {
|
||||
// Inputs are 32x96x2x2
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
tensor input_tensor(32, 96, 20, 20);
|
||||
VVVVF<FLOAT16> input_rnd = generate_random_4d<FLOAT16>(32, 96, 20, 20, 1, 3);
|
||||
VVVVF<FLOAT16> input_rnd = rg.generate_random_4d<FLOAT16>(32, 96, 20, 20, 1, 3);
|
||||
VF<FLOAT16> fp16_bfyx_32x96x2x2_input = flatten_4d<FLOAT16>(format::bfyx, input_rnd);
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
@@ -3597,9 +3602,9 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) {
|
||||
TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_input_padding)
|
||||
{
|
||||
// Inputs are 32x96x20x20
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
tensor input_tensor(32, 96, 20, 20);
|
||||
VVVVF<FLOAT16> input_rnd = generate_random_4d<FLOAT16>(32, 96, 20, 20, 1, 3);
|
||||
VVVVF<FLOAT16> input_rnd = rg.generate_random_4d<FLOAT16>(32, 96, 20, 20, 1, 3);
|
||||
VF<FLOAT16> fp16_bfyx_32x96x2x2_input = flatten_4d<FLOAT16>(format::bfyx, input_rnd);
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
@@ -3919,6 +3924,12 @@ struct eltwise_same_input_test_params {
|
||||
|
||||
struct eltwise_same_input_test : testing::TestWithParam<eltwise_same_input_test_params>
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fill_random_typed(memory::ptr mem, int min, int max, int k) {
|
||||
auto l = mem->get_layout();
|
||||
@@ -3927,7 +3938,7 @@ struct eltwise_same_input_test : testing::TestWithParam<eltwise_same_input_test_
|
||||
size_t x = l.spatial(0);
|
||||
size_t y = l.spatial(1);
|
||||
|
||||
auto data = generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
auto data = rg.generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
mem_lock<T> ptr{mem, get_test_stream()};
|
||||
for (size_t bi = 0; bi < b; ++bi) {
|
||||
for (size_t fi = 0; fi < f; ++fi) {
|
||||
@@ -4122,6 +4133,7 @@ class eltwise_test : public BaseEltwiseTest<eltwise_test_params> {
|
||||
|
||||
TEST_P(eltwise_test, fsv16) {
|
||||
auto p = GetParam();
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
ASSERT_EQ(std::get<2>(p).size(), 2);
|
||||
|
||||
@@ -4143,8 +4155,8 @@ TEST_P(eltwise_test, fsv16) {
|
||||
int x1 = input1_size[input1_size.size() == 4 ? 3 : 4];
|
||||
|
||||
int min_random = -2, max_random = 2;
|
||||
VVVVVVF<float> input1_rnd = generate_random_6d<float>(b0, f0, 1, z0, y0, x0, min_random, max_random);
|
||||
VVVVVVF<float> input2_rnd = generate_random_6d<float>(b1, f1, 1, z1, y1, x1, min_random, max_random);
|
||||
VVVVVVF<float> input1_rnd = rg.generate_random_6d<float>(b0, f0, 1, z0, y0, x0, min_random, max_random);
|
||||
VVVVVVF<float> input2_rnd = rg.generate_random_6d<float>(b1, f1, 1, z1, y1, x1, min_random, max_random);
|
||||
VF<float> input1_rnd_vec = flatten_6d<float>(format::bfwzyx, input1_rnd);
|
||||
VF<float> input2_rnd_vec = flatten_6d<float>(format::bfwzyx, input2_rnd);
|
||||
|
||||
@@ -4229,6 +4241,7 @@ INSTANTIATE_TEST_SUITE_P(eltwise, eltwise_test,
|
||||
class eltwise_test_6d : public eltwise_test {};
|
||||
TEST_P(eltwise_test_6d, bfwzyx) {
|
||||
auto p = GetParam();
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
ASSERT_EQ(std::get<2>(p).size(), 2);
|
||||
|
||||
@@ -4252,8 +4265,8 @@ TEST_P(eltwise_test_6d, bfwzyx) {
|
||||
int x1 = input1_size[5];
|
||||
|
||||
int min_random = -2, max_random = 2;
|
||||
VVVVVVF<float> input1_rnd = generate_random_6d<float>(b0, f0, w0, z0, y0, x0, min_random, max_random);
|
||||
VVVVVVF<float> input2_rnd = generate_random_6d<float>(b1, f1, w1, z1, y1, x1, min_random, max_random);
|
||||
VVVVVVF<float> input1_rnd = rg.generate_random_6d<float>(b0, f0, w0, z0, y0, x0, min_random, max_random);
|
||||
VVVVVVF<float> input2_rnd = rg.generate_random_6d<float>(b1, f1, w1, z1, y1, x1, min_random, max_random);
|
||||
VF<float> input1_rnd_vec = flatten_6d<float>(format::bfwzyx, input1_rnd);
|
||||
VF<float> input2_rnd_vec = flatten_6d<float>(format::bfwzyx, input2_rnd);
|
||||
|
||||
@@ -4311,6 +4324,7 @@ INSTANTIATE_TEST_SUITE_P(eltwise, eltwise_test_6d,
|
||||
class eltwise_test_mixed_precision : public eltwise_test {};
|
||||
TEST_P(eltwise_test_mixed_precision, fsv16) {
|
||||
auto p = GetParam();
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
ASSERT_EQ(std::get<2>(p).size(), 2);
|
||||
|
||||
@@ -4334,8 +4348,8 @@ TEST_P(eltwise_test_mixed_precision, fsv16) {
|
||||
|
||||
int min_random = input1_dt == data_types::u8 ? 0 : -2;
|
||||
int max_random = input1_dt == data_types::u8 ? 4 : 2;
|
||||
VVVVVVF<float> input1_rnd = generate_random_6d<float>(b0, f0, 1, z0, y0, x0, min_random, max_random);
|
||||
VVVVVVF<int> input2_rnd = generate_random_6d<int>(b1, f1, 1, z1, y1, x1, min_random, max_random);
|
||||
VVVVVVF<float> input1_rnd = rg.generate_random_6d<float>(b0, f0, 1, z0, y0, x0, min_random, max_random);
|
||||
VVVVVVF<int> input2_rnd = rg.generate_random_6d<int>(b1, f1, 1, z1, y1, x1, min_random, max_random);
|
||||
VF<float> input1_rnd_vec = flatten_6d<float>(format::bfwzyx, input1_rnd);
|
||||
VF<int> input2_rnd_vec = flatten_6d<int>(format::bfwzyx, input2_rnd);
|
||||
|
||||
@@ -4423,6 +4437,7 @@ public:
|
||||
class eltwise_test_mixed_layout : public eltwise_layout_test {};
|
||||
TEST_P(eltwise_test_mixed_layout, mixed_layout) {
|
||||
auto p = GetParam();
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
auto mode = p.mode;
|
||||
auto input0_size = p.input0_size;
|
||||
@@ -4442,8 +4457,8 @@ TEST_P(eltwise_test_mixed_layout, mixed_layout) {
|
||||
int x1 = input1_size[3];
|
||||
|
||||
int min_random = -2, max_random = 2;
|
||||
VVVVVVF<float> input1_rnd = generate_random_6d<float>(b0, f0, 1, 1, y0, x0, min_random, max_random);
|
||||
VVVVVVF<float> input2_rnd = generate_random_6d<float>(b1, f1, 1, 1, y1, x1, min_random, max_random);
|
||||
VVVVVVF<float> input1_rnd = rg.generate_random_6d<float>(b0, f0, 1, 1, y0, x0, min_random, max_random);
|
||||
VVVVVVF<float> input2_rnd = rg.generate_random_6d<float>(b1, f1, 1, 1, y1, x1, min_random, max_random);
|
||||
VF<float> input1_rnd_vec = flatten_6d<float>(format::bfwzyx, input1_rnd);
|
||||
VF<float> input2_rnd_vec = flatten_6d<float>(format::bfwzyx, input2_rnd);
|
||||
|
||||
@@ -4514,6 +4529,12 @@ struct eltwise_random_test_params {
|
||||
|
||||
struct eltwise_random_test : testing::TestWithParam<eltwise_random_test_params>
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
static std::string PrintToString(const eltwise_random_test_params& params) {
|
||||
std::string res = " data (" + cldnn::data_type_traits::name(params.input_type) + "), ";
|
||||
res += " format (" + format::traits(params.in_format).str + ") input1 : ";
|
||||
@@ -4531,7 +4552,7 @@ struct eltwise_random_test : testing::TestWithParam<eltwise_random_test_params>
|
||||
size_t x = l.spatial(0);
|
||||
size_t y = l.spatial(1);
|
||||
|
||||
auto data = generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
auto data = rg.generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
mem_lock<T> ptr{mem, get_test_stream()};
|
||||
for (size_t bi = 0; bi < b; ++bi) {
|
||||
for (size_t fi = 0; fi < f; ++fi) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/non_zero.hpp>
|
||||
@@ -26,13 +27,14 @@ struct empty_tensor_test_params {
|
||||
class test_empty_tensor : public testing::TestWithParam<empty_tensor_test_params> {};
|
||||
|
||||
TEST_P(test_empty_tensor, concat_two_inputs) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto p = GetParam();
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto nonzero_input_mem = engine.allocate_memory(p.nonzero_input_layout);
|
||||
auto concat_data_mem = engine.allocate_memory(p.concat_input_layout);
|
||||
|
||||
std::vector<int32_t> concat_another_input_data = generate_random_1d<int32_t>(p.concat_input_layout.count(), 0, 100);
|
||||
std::vector<int32_t> concat_another_input_data = rg.generate_random_1d<int32_t>(p.concat_input_layout.count(), 0, 100);
|
||||
|
||||
set_values(concat_data_mem, concat_another_input_data);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
#include "network_test.h"
|
||||
#include <intel_gpu/runtime/utils.hpp>
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
@@ -60,10 +61,11 @@ VVVVF<T> fully_connected_reference(VVVVF<T> &input, VVVVF<T> &weights, VF<T> &bi
|
||||
template <typename T>
|
||||
void generic_fully_connected_test(cldnn::format test_input_fmt, cldnn::format test_weights_fmt,
|
||||
int input_b, int f, int y, int x, int output_f, bool relu, T slope = 0) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
int min_random = -2, max_random = 2;
|
||||
VVVVF<T> input_rnd = generate_random_4d<T>(input_b, f, y, x, min_random, max_random);
|
||||
VVVVF<T> weights_rnd = generate_random_4d<T>(output_f, f, y, x, min_random, max_random);
|
||||
VF<T> bias_rnd_vec = generate_random_1d<T>(output_f, min_random, max_random);
|
||||
VVVVF<T> input_rnd = rg.generate_random_4d<T>(input_b, f, y, x, min_random, max_random);
|
||||
VVVVF<T> weights_rnd = rg.generate_random_4d<T>(output_f, f, y, x, min_random, max_random);
|
||||
VF<T> bias_rnd_vec = rg.generate_random_1d<T>(output_f, min_random, max_random);
|
||||
VF<T> input_rnd_vec = flatten_4d<T>(test_input_fmt, input_rnd);
|
||||
VF<T> weights_rnd_vec = flatten_4d<T>(test_weights_fmt, weights_rnd);
|
||||
|
||||
@@ -716,6 +718,7 @@ TEST(fully_connected_gpu, x_f32_relu_with_negative_slope) {
|
||||
|
||||
TEST(fully_connected_gpu, b_fs_yx_fsv4)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int in_B = 2;
|
||||
@@ -781,8 +784,8 @@ TEST(fully_connected_gpu, b_fs_yx_fsv4)
|
||||
auto input_high_mem = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, W_B, 1, 1 } });
|
||||
auto output_low_mem = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } });
|
||||
auto output_high_mem = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 1, 1, 1 } });
|
||||
set_values(input_low_mem, generate_random_1d<float>(W_B, -200, 0));
|
||||
set_values(input_high_mem, generate_random_1d<float>(W_B, 1, 200));
|
||||
set_values(input_low_mem, rg.generate_random_1d<float>(W_B, -200, 0));
|
||||
set_values(input_high_mem, rg.generate_random_1d<float>(W_B, 1, 200));
|
||||
set_values(output_low_mem, { -127.0f });
|
||||
set_values(output_high_mem, { 127.0f });
|
||||
|
||||
@@ -846,9 +849,10 @@ TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b12) {
|
||||
auto bias_prim = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, output_f, 1 } });
|
||||
|
||||
// Generate random input data and set values
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, input_y, input_x, -1, 1);
|
||||
auto bias_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, input_y, input_x, -1, 1);
|
||||
auto bias_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
@@ -922,9 +926,10 @@ TEST(fully_connected_gpu, DISABLED_fs_byx_fsv32_b34)
|
||||
auto bias_prim = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 1, output_f, 1 } });
|
||||
|
||||
// Generate random input data and set values
|
||||
auto input_data = generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto weights_data = generate_random_4d<FLOAT16>(output_f, input_f, input_y, input_x, -1, 1);
|
||||
auto bias_data = generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto input_data = rg.generate_random_4d<FLOAT16>(batch_num, input_f, input_y, input_x, -1, 1);
|
||||
auto weights_data = rg.generate_random_4d<FLOAT16>(output_f, input_f, input_y, input_x, -1, 1);
|
||||
auto bias_data = rg.generate_random_1d<FLOAT16>(output_f, -1, 1);
|
||||
|
||||
auto input_data_bfyx = flatten_4d(format::bfyx, input_data);
|
||||
auto weights_data_bfyx = flatten_4d(format::bfyx, weights_data);
|
||||
@@ -988,6 +993,12 @@ using fully_connected_test_params = std::tuple<
|
||||
|
||||
template <typename InputT, typename WeightsT, typename BiasT, typename OutputT>
|
||||
struct fully_connected_random_test : ::testing::TestWithParam<fully_connected_test_params> {
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
void run_test() {
|
||||
shared_dims dims;
|
||||
size_t batch, input_f, input_x, input_y, output_f;
|
||||
@@ -998,9 +1009,9 @@ struct fully_connected_random_test : ::testing::TestWithParam<fully_connected_te
|
||||
std::tie(batch, dims, output_f, input_format, output_format, kernel, is_caching_test) = GetParam();
|
||||
std::tie(input_f, input_x, input_y) = dims;
|
||||
|
||||
auto input_data = generate_smart_random_4d<InputT>(batch, input_f, input_y, input_x);
|
||||
auto weights_data = generate_smart_random_4d<WeightsT>(output_f, input_f, input_y, input_x);
|
||||
auto bias_data = generate_smart_random_2d<BiasT>(1, output_f);
|
||||
auto input_data = rg.generate_random_4d<InputT>(batch, input_f, input_y, input_x, type_test_ranges<InputT>::min, type_test_ranges<InputT>::max, type_test_ranges<InputT>::k);
|
||||
auto weights_data = rg.generate_random_4d<WeightsT>(output_f, input_f, input_y, input_x, type_test_ranges<WeightsT>::min, type_test_ranges<WeightsT>::max, type_test_ranges<WeightsT>::k);
|
||||
auto bias_data = rg.generate_random_2d<BiasT>(1, output_f, type_test_ranges<BiasT>::min, type_test_ranges<BiasT>::max, type_test_ranges<BiasT>::k);
|
||||
|
||||
auto& eng = get_test_engine();
|
||||
auto net = network_test(eng);
|
||||
@@ -1111,6 +1122,12 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
|
||||
template <typename InputT, typename WeightsT, typename BiasT, typename OutputT>
|
||||
struct fully_connected_random_test_3d : ::testing::TestWithParam<fully_connected_test_params> {
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
void run_test() {
|
||||
shared_dims dims;
|
||||
size_t batch, input_f, input_x, input_y, output_y;
|
||||
@@ -1121,9 +1138,9 @@ struct fully_connected_random_test_3d : ::testing::TestWithParam<fully_connected
|
||||
std::tie(batch, dims, output_y, input_format, output_format, kernel, is_caching_test) = GetParam();
|
||||
std::tie(input_f, input_x, input_y) = dims;
|
||||
|
||||
auto input_data = generate_smart_random_4d<InputT>(batch, input_f, input_y, input_x);
|
||||
auto weights_data = generate_smart_random_4d<WeightsT>(output_y, input_y, 1, 1);
|
||||
auto bias_data = generate_smart_random_2d<BiasT>(1, output_y);
|
||||
auto input_data = rg.generate_random_4d<InputT>(batch, input_f, input_y, input_x, type_test_ranges<InputT>::min, type_test_ranges<InputT>::max, type_test_ranges<InputT>::k);
|
||||
auto weights_data = rg.generate_random_4d<WeightsT>(output_y, input_y, 1, 1, type_test_ranges<WeightsT>::min, type_test_ranges<WeightsT>::max, type_test_ranges<WeightsT>::k);
|
||||
auto bias_data = rg.generate_random_2d<BiasT>(1, output_y, type_test_ranges<BiasT>::min, type_test_ranges<BiasT>::max, type_test_ranges<BiasT>::k);
|
||||
|
||||
auto& eng = get_test_engine();
|
||||
auto net = network_test(eng);
|
||||
@@ -1481,25 +1498,17 @@ VVF<OutputT> ref_fully_connected(
|
||||
return output;
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename T>
|
||||
std::vector<T> generate_random_values(size_t a, int min, int max) {
|
||||
static std::default_random_engine generator(random_seed);
|
||||
// 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(min, max);
|
||||
std::vector<T> v(a);
|
||||
|
||||
for (size_t i = 0; i < a; ++i) {
|
||||
v[i] = (T)distribution(generator);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
template <typename InputT, typename OutputT>
|
||||
class fc_quantized_random_test
|
||||
: public fully_connected_quantized_test<InputT, OutputT>
|
||||
, public ::testing::WithParamInterface< fully_connected_quantized_test_params> {
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
public:
|
||||
void run_random_test() {
|
||||
size_t b, in_f, in_x, in_y, out_f;
|
||||
@@ -1507,13 +1516,13 @@ public:
|
||||
|
||||
std::tie(b, in_f, in_x, in_y, out_f, in_fmt) = GetParam();
|
||||
|
||||
VVVVF<InputT> input_data = generate_random_4d<InputT>(b, in_f, in_y, in_x, -127, 127);
|
||||
VVVVF<int8_t> weights_data = generate_random_4d<int8_t>(out_f, in_f, in_y, in_x, -127, 127);
|
||||
VF<int> bias_data = generate_random_1d<int>(out_f, -127, 127);
|
||||
VVVVF<InputT> input_data = rg.generate_random_4d<InputT>(b, in_f, in_y, in_x, -127, 127);
|
||||
VVVVF<int8_t> weights_data = rg.generate_random_4d<int8_t>(out_f, in_f, in_y, in_x, -127, 127);
|
||||
VF<int> bias_data = rg.generate_random_1d<int>(out_f, -127, 127);
|
||||
bool is_unsigned = std::is_same<OutputT, uint8_t>::value;
|
||||
quantization_t quant_data;
|
||||
quant_data.input_low = generate_random_values<float>(out_f, -200, 0);
|
||||
quant_data.input_high = generate_random_values<float>(out_f, 1, 200);
|
||||
quant_data.input_low = rg.generate_random_1d<float>(out_f, -200, 0);
|
||||
quant_data.input_high = rg.generate_random_1d<float>(out_f, 1, 200);
|
||||
quant_data.output_low = is_unsigned ? 0.0f : -127.0f;
|
||||
quant_data.output_high = is_unsigned ? 255.0f : 127.0f;
|
||||
quant_data.levels = is_unsigned ? 256 : 255;
|
||||
@@ -2286,6 +2295,12 @@ using fully_connected_dynamic_test_params = std::tuple<
|
||||
|
||||
template <typename InputT, typename WeightsT, typename BiasT, typename OutputT>
|
||||
struct dynamic_fully_connected_gpu : ::testing::TestWithParam<fully_connected_dynamic_test_params> {
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
void run_test() {
|
||||
std::vector<ov::Dimension::value_type> batch_sizes;
|
||||
ov::Dimension::value_type input_f;
|
||||
@@ -2304,10 +2319,10 @@ struct dynamic_fully_connected_gpu : ::testing::TestWithParam<fully_connected_dy
|
||||
input_dyn_layout = layout{ ov::PartialShape{ ov::Dimension(), ov::Dimension(), input_f }, input_dt, format::bfyx };
|
||||
|
||||
auto weights_mem = engine.allocate_memory({ ov::PartialShape{ output_f, input_f }, weights_dt, format::bfyx });
|
||||
auto weights_data_vec = generate_random_1d<WeightsT>(output_f * input_f, -1, 1);
|
||||
auto weights_data_vec = rg.generate_random_1d<WeightsT>(output_f * input_f, -1, 1);
|
||||
|
||||
auto bias_mem = engine.allocate_memory({ ov::PartialShape{ output_f }, output_dt, format::bfyx });
|
||||
auto bias_data_vec = generate_random_1d<OutputT>(output_f, 0, 1);
|
||||
auto bias_data_vec = rg.generate_random_1d<OutputT>(output_f, 0, 1);
|
||||
|
||||
set_values(weights_mem, weights_data_vec);
|
||||
set_values(bias_mem, bias_data_vec);
|
||||
@@ -2333,7 +2348,7 @@ struct dynamic_fully_connected_gpu : ::testing::TestWithParam<fully_connected_dy
|
||||
if (fc_3d)
|
||||
input_actual_layout = layout{ ov::PartialShape{ 1, batch_size, input_f }, input_dt, format::bfyx };
|
||||
cldnn::memory_ptr input_mem = engine.allocate_memory(input_actual_layout);
|
||||
std::vector<InputT> input_data_vec = generate_random_1d<InputT>(batch_size * input_f, 0, 1);
|
||||
std::vector<InputT> input_data_vec = rg.generate_random_1d<InputT>(batch_size * input_f, 0, 1);
|
||||
set_values(input_mem, input_data_vec);
|
||||
network.set_input_data("input", input_mem);
|
||||
|
||||
@@ -2672,6 +2687,7 @@ class fc_random_types_test
|
||||
, public ::testing::WithParamInterface< fully_connected_types_test_params> {
|
||||
public:
|
||||
void run_random_test() {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
size_t b, in_f, in_x, in_y, out_f;
|
||||
format::type in_fmt;
|
||||
|
||||
@@ -2681,9 +2697,9 @@ public:
|
||||
quant_data.output_low = std::numeric_limits<WeightsT>::lowest();
|
||||
quant_data.output_high = std::numeric_limits<WeightsT>::max();
|
||||
|
||||
VVVVF<InputT> input_data = generate_random_4d<InputT>(b, in_f, in_y, in_x, 0, 127);
|
||||
VVVVF<WeightsT> weights_data = generate_random_4d<WeightsT>(out_f, in_f, in_y, in_x, quant_data.output_low , quant_data.output_high);
|
||||
VF<WeightsT> bias_data = generate_random_1d<WeightsT>(out_f, quant_data.output_low , quant_data.output_high);
|
||||
VVVVF<InputT> input_data = rg.template generate_random_4d<InputT>(b, in_f, in_y, in_x, 0, 127);
|
||||
VVVVF<WeightsT> weights_data = rg.template generate_random_4d<WeightsT>(out_f, in_f, in_y, in_x, quant_data.output_low , quant_data.output_high);
|
||||
VF<WeightsT> bias_data = rg.template generate_random_1d<WeightsT>(out_f, quant_data.output_low , quant_data.output_high);
|
||||
|
||||
this->set_input(input_data);
|
||||
this->set_weights(weights_data);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/gather.hpp>
|
||||
@@ -47,6 +48,7 @@ public:
|
||||
impl_types impl_type;
|
||||
|
||||
void SetUp() override {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
std::tie(batch_dim, axis, fmt[0], fmt[1], shape_in[0], shape_in[1], impl_type) = GetParam();
|
||||
@@ -64,14 +66,14 @@ public:
|
||||
for (int i = axis + 1; i < get_not_one_dim(shape_in[0]); i++) // after axis = shape_in[0][..]
|
||||
shape_out[axis + get_not_one_dim(shape_in[1]) - batch_dim + (i - axis - 1)] = shape_in[0][i];
|
||||
|
||||
auto dat = generate_random_1d<T_dat>(get_linear_size(shape_in[0]), -99, 99);
|
||||
auto dat = rg.generate_random_1d<T_dat>(get_linear_size(shape_in[0]), -99, 99);
|
||||
auto input0_layout =
|
||||
layout(ov::Shape(shape_in[0].begin(), shape_in[0].end()), T_dat_dt, format::get_default_format(shape_in[0].size()));
|
||||
auto input0 = engine.allocate_memory(input0_layout);
|
||||
set_values(input0, dat);
|
||||
|
||||
auto ind =
|
||||
generate_random_1d<T_ind>(get_linear_size(shape_in[1]), -shape_in[0][axis], shape_in[0][axis] - 1, 1);
|
||||
rg.generate_random_1d<T_ind>(get_linear_size(shape_in[1]), -shape_in[0][axis], shape_in[0][axis] - 1, 1);
|
||||
auto input1_layout =
|
||||
layout(ov::Shape(shape_in[1].begin(), shape_in[1].end()), T_ind_dt, format::get_default_format(shape_in[1].size()));
|
||||
auto input1 = engine.allocate_memory(input1_layout);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/gemm.hpp>
|
||||
@@ -166,21 +167,16 @@ class GemmGPUTestRandom : public GemmGPUTest {
|
||||
ov::Shape input1_shape;
|
||||
ov::Shape output_shape;
|
||||
|
||||
float generate_random_value() {
|
||||
static std::default_random_engine generator(random_seed);
|
||||
std::uniform_int_distribution<int> distribution(-10, 10);
|
||||
float val = distribution(generator);
|
||||
return val;
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
void generated_inputs() {
|
||||
for (size_t i = 0; i < shapes.size(); ++i) {
|
||||
size_t size = ngraph::shape_size(shapes[i]);
|
||||
auto &v = input_data[i];
|
||||
v.resize(size);
|
||||
for(size_t i = 0; i < size; ++i) {
|
||||
v[i] = generate_random_value() / 20.f;
|
||||
}
|
||||
input_data[i] = rg.generate_random_1d<float>(size, -1, 1, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1202,6 +1198,12 @@ public:
|
||||
return { format::bfyx, p.kernel_name };
|
||||
}
|
||||
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
inline size_t getGemmIndex(size_t x, size_t y, size_t f, size_t b, size_t x_size, size_t y_size, size_t f_num, size_t b_num,
|
||||
size_t x_pitch, size_t y_pitch, size_t f_pitch, size_t b_pitch) {
|
||||
return (x % x_size) * x_pitch + (y % y_size) * y_pitch + (f % f_num) * f_pitch + (b % b_num) * b_pitch;
|
||||
@@ -1252,19 +1254,19 @@ public:
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
auto input0_size = tensor((int)p.b0_num, (int)p.f0_num, (int)x0_size, (int)y0_size);
|
||||
VVVVF<input0_type> input0_data = generate_random_4d<input0_type>(p.b0_num, p.f0_num, x0_size, y0_size, p.range0[0], p.range0[1], p.range0[2]);
|
||||
VVVVF<input0_type> input0_data = rg.generate_random_4d<input0_type>(p.b0_num, p.f0_num, x0_size, y0_size, p.range0[0], p.range0[1], p.range0[2]);
|
||||
auto input0_data_bfyx = flatten_4d(format::bfyx, input0_data);
|
||||
auto input0_mem = engine.allocate_memory({ p.allocate0_type, format::bfyx, input0_size });
|
||||
set_values(input0_mem, input0_data_bfyx);
|
||||
|
||||
auto input1_size = tensor((int)p.b1_num, (int)p.f1_num, (int)x1_size, (int)y1_size);
|
||||
VVVVF<input1_type> input1_data = generate_random_4d<input1_type>(p.b1_num, p.f1_num, x1_size, y1_size, p.range1[0], p.range1[1], p.range1[2]);
|
||||
VVVVF<input1_type> input1_data = rg.generate_random_4d<input1_type>(p.b1_num, p.f1_num, x1_size, y1_size, p.range1[0], p.range1[1], p.range1[2]);
|
||||
auto input1_data_bfyx = flatten_4d(format::bfyx, input1_data);
|
||||
auto input1_mem = engine.allocate_memory({ p.allocate1_type, format::bfyx, input1_size });
|
||||
set_values(input1_mem, input1_data_bfyx);
|
||||
|
||||
auto input2_size = tensor((int)p.b2_num, (int)p.f2_num, (int)x2_size, (int)y2_size);
|
||||
VVVVF<input2_type> input2_data = generate_random_4d<input2_type>(p.b2_num, p.f2_num, x2_size, y2_size, p.range2[0], p.range2[1], p.range2[2]);
|
||||
VVVVF<input2_type> input2_data = rg.generate_random_4d<input2_type>(p.b2_num, p.f2_num, x2_size, y2_size, p.range2[0], p.range2[1], p.range2[2]);
|
||||
auto input2_data_bfyx = flatten_4d(format::bfyx, input2_data);
|
||||
auto input2_mem = engine.allocate_memory({ p.allocate2_type, format::bfyx, input2_size });
|
||||
set_values(input2_mem, input2_data_bfyx);
|
||||
@@ -1361,6 +1363,7 @@ struct gemm_onednn_test_params {
|
||||
template <typename T>
|
||||
class GemmOneDNNTest : public ::testing::TestWithParam<T> {
|
||||
public:
|
||||
tests::random_generator rg;
|
||||
cldnn::engine& engine = get_test_engine();
|
||||
topology topology_ocl;
|
||||
topology topology_onednn;
|
||||
@@ -1371,6 +1374,7 @@ public:
|
||||
float tolerance = 0.0f;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
config_ocl.set_property(ov::intel_gpu::optimize_data(true));
|
||||
config_ocl.set_property(ov::intel_gpu::queue_type(QueueTypes::in_order));
|
||||
if (engine.get_device_info().supports_immad) {
|
||||
@@ -1425,6 +1429,23 @@ public:
|
||||
else
|
||||
return layout{ p.data_type_in2, p.input_format, p.in_shapes.at(2), padding{ pad_ } };
|
||||
}
|
||||
|
||||
cldnn::memory::ptr get_generated_random_1d_mem(cldnn::engine& engine, cldnn::layout l) {
|
||||
auto prim = engine.allocate_memory(l);
|
||||
cldnn::tensor s = l.get_tensor();
|
||||
if (l.data_type == cldnn::data_types::i8 || l.data_type == cldnn::data_types::u8) {
|
||||
VF<uint8_t> rnd_vec = rg.generate_random_1d<uint8_t>(s.count(), -200, 200);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == cldnn::data_types::f16) {
|
||||
VF<FLOAT16> rnd_vec = rg.generate_random_1d<FLOAT16>(s.count(), -1, 1);
|
||||
set_values(prim, rnd_vec);
|
||||
} else {
|
||||
VF<float> rnd_vec = rg.generate_random_1d<float>(s.count(), -1, 1);
|
||||
set_values(prim, rnd_vec);
|
||||
}
|
||||
|
||||
return prim;
|
||||
}
|
||||
};
|
||||
|
||||
class gemm_onednn_ndims : public GemmOneDNNTest<gemm_onednn_test_params> {};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/mutable_data.hpp>
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
@@ -201,13 +202,19 @@ VVVVF<T> lstm_dynamic_input_ref(VVVVF<T>& input, VVVVF<T>& weights, VVVVF<T>& bi
|
||||
template <typename T>
|
||||
struct lstm_dynamic_input_layer_test : public ::testing::Test
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
void input_single_layer_generic_test(int32_t direction, int32_t batch_size, int32_t max_sequence_len, int32_t input_size, int32_t hidden_size, std::vector<float> dynamic_lengths,
|
||||
bool has_bias = false)
|
||||
{
|
||||
auto min_random = -2, max_random = 2;
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, max_sequence_len, direction, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = generate_random_4d<T>(1, direction, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, max_sequence_len, direction, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = rg.generate_random_4d<T>(1, direction, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = rg.generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random);
|
||||
|
||||
VF<T> ref_input_vec = flatten_4d<T>(cldnn::format::bfyx, ref_input);
|
||||
VF<T> ref_weights_vec = flatten_4d<T>(cldnn::format::bfyx, ref_weights);
|
||||
@@ -304,6 +311,12 @@ struct lstm_dynamic_input_layer_test : public ::testing::Test
|
||||
template <typename T>
|
||||
struct lstm_dynamic_single_layer_test : public ::testing::Test
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
void single_layer_generic_test(int32_t direction, int32_t batch_size, int32_t max_sequence_len, int32_t input_size, int32_t hidden_size, std::vector<float> dynamic_lengths,
|
||||
bool has_bias = false, bool has_initial_hidden = false, bool has_initial_cell = false, bool has_last_hidden_state = false, bool has_last_cell_state = false, float epsilon = 1e-3f)
|
||||
{
|
||||
@@ -311,12 +324,12 @@ struct lstm_dynamic_single_layer_test : public ::testing::Test
|
||||
bool input_forget = false;
|
||||
|
||||
auto min_random = 0, max_random = 2;
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, max_sequence_len, direction, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = generate_random_4d<T>(1, direction, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, max_sequence_len, direction, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = rg.generate_random_4d<T>(1, direction, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = rg.generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = rg.generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = rg.generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = rg.generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_output_hidden = VVVVF<T>(batch_size, VVVF<T>(max_sequence_len, VVF<T>(direction, VF<T>(hidden_size))));
|
||||
VVVVF<T> ref_output_cell = VVVVF<T>(batch_size, VVVF<T>(max_sequence_len, VVF<T>(direction, VF<T>(hidden_size))));
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/lstm.hpp>
|
||||
@@ -194,11 +195,13 @@ void generic_lstm_gemm_gpu_test(int sequence_len, int direction, int batch_size,
|
||||
bool hasBias, bool hasHidden, bool is_caching_test = false) {
|
||||
int min_random = -2, max_random = 2;
|
||||
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = generate_random_4d<T>(1, direction, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = generate_random_4d<T>(batch_size, direction, 1, hidden_size, min_random, max_random);
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = rg.generate_random_4d<T>(1, direction, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = rg.generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = rg.generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = rg.generate_random_4d<T>(batch_size, direction, 1, hidden_size, min_random, max_random);
|
||||
VF<T> ref_input_vec = flatten_4d<T>(cldnn::format::bfyx, ref_input);
|
||||
VF<T> ref_weights_vec = flatten_4d<T>(cldnn::format::bfyx, ref_weights);
|
||||
VF<T> ref_recurrent_vec = flatten_4d<T>(cldnn::format::bfyx, ref_recurrent);
|
||||
@@ -270,9 +273,10 @@ void generic_lstm_elt_gpu_test(int /* sequence_len */, int direction, int batch_
|
||||
// cell = [ 1, direction, batch, hidden_size ] optional
|
||||
// output = [ 2, direction, batch, hidden_size ] output concat[hidden, cell]
|
||||
int min_random = -2, max_random = 2;
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
VVVVF<T> ref_tempGEMM = generate_random_4d<T>(batch_size, direction, 1, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = generate_random_4d<T>(batch_size, direction, 1, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_tempGEMM = rg.generate_random_4d<T>(batch_size, direction, 1, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = rg.generate_random_4d<T>(batch_size, direction, 1, hidden_size, min_random, max_random);
|
||||
VF<T> ref_tempGEMM_vec = flatten_4d<T>(cldnn::format::bfyx, ref_tempGEMM);
|
||||
VF<T> ref_cell_vec = flatten_4d<T>(cldnn::format::bfyx, ref_cell);
|
||||
|
||||
@@ -393,12 +397,13 @@ void generic_lstm_custom_gpu_test(int sequence_len, int direction, int batch_siz
|
||||
bool hasBias, bool hasInitialHidden, bool hasInitialCell, bool is_caching_test = false) {
|
||||
std::cout << "Input Size = " << input_size << " Hidden Size = " << hidden_size << " Sequence Len = " << sequence_len << " Batch Size = " << batch_size << std::endl;
|
||||
int min_random = -2, max_random = 2;
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = generate_random_4d<T>(1, direction, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = generate_random_4d<T>(batch_size, direction, 1, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = generate_random_4d<T>(batch_size, direction, 1, hidden_size, min_random, max_random);
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = rg.generate_random_4d<T>(1, direction, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = rg.generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = rg.generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = rg.generate_random_4d<T>(batch_size, direction, 1, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = rg.generate_random_4d<T>(batch_size, direction, 1, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_output(batch_size, VVVF<T>(sequence_len, VVF<T>(direction, VF<T>(hidden_size))));
|
||||
VVVVF<T> last_hidden(batch_size, VVVF<T>(direction, VVF<T>(1, VF<T>(hidden_size))));
|
||||
VVVVF<T> last_cell(batch_size, VVVF<T>(direction, VVF<T>(1, VF<T>(hidden_size))));
|
||||
@@ -462,8 +467,9 @@ void generic_lstm_gpu_test(int layers, int sequence_len, int direction, int batc
|
||||
std::cout << "Layers = " << layers << " Input Size = " << input_size << " Hidden Size = " << hidden_size
|
||||
<< " Sequence Len = " << sequence_len << " Direction = " << direction << " Batch Size = " << batch_size << std::endl;
|
||||
int min_random = -2, max_random = 2;
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
|
||||
std::vector<VVVVF<T>> ref_weights;
|
||||
std::vector<VVVVF<T>> ref_recurrent;
|
||||
@@ -473,11 +479,11 @@ void generic_lstm_gpu_test(int layers, int sequence_len, int direction, int batc
|
||||
std::vector<VVVVF<T>> ref_output;
|
||||
|
||||
for (int i = 0; i < layers; ++i) {
|
||||
ref_weights.push_back(generate_random_4d<T>(1, direction, 4 * hidden_size, i==0 ? input_size : hidden_size, min_random, max_random));
|
||||
ref_recurrent.push_back(generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random));
|
||||
ref_bias.push_back(generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random));
|
||||
ref_hidden.push_back(generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random));
|
||||
ref_cell.push_back(generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random));
|
||||
ref_weights.push_back(rg.generate_random_4d<T>(1, direction, 4 * hidden_size, i==0 ? input_size : hidden_size, min_random, max_random));
|
||||
ref_recurrent.push_back(rg.generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random));
|
||||
ref_bias.push_back(rg.generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random));
|
||||
ref_hidden.push_back(rg.generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random));
|
||||
ref_cell.push_back(rg.generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random));
|
||||
ref_output.push_back(VVVVF<T>(batch_size, VVVF<T>(sequence_len, VVF<T>(direction, VF<T>(hidden_size)))));
|
||||
}
|
||||
|
||||
@@ -648,13 +654,14 @@ void lstm_gpu_output_test(const lstm_output_selection& output_selection, int dir
|
||||
<< " Sequence Len = " << sequence_len << " Directions = " << directions << " Batch Size = " << batch_size
|
||||
<< " Output selection: " << static_cast<int>(output_selection) << std::endl;
|
||||
int min_random = -2, max_random = 2;
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = generate_random_4d<T>(1, directions, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = generate_random_4d<T>(1, directions, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = generate_random_4d<T>(1, 1, directions, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = rg.generate_random_4d<T>(1, directions, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = rg.generate_random_4d<T>(1, directions, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = rg.generate_random_4d<T>(1, 1, directions, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = rg.generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = rg.generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_output = VVVVF<T>(batch_size, VVVF<T>(sequence_len, VVF<T>(directions, VF<T>(hidden_size))));
|
||||
|
||||
VF<T> ref_input_vec = flatten_4d<T>(cldnn::format::bfyx, ref_input);
|
||||
@@ -811,13 +818,14 @@ void lstm_gpu_format_test(const cldnn::format& format, int directions, bool is_c
|
||||
<< " Sequence Len = " << sequence_len << " Directions = " << directions << " Batch Size = " << batch_size
|
||||
<< " Output selection: " << static_cast<int>(output_selection) << std::endl;
|
||||
int min_random = -2, max_random = 2;
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = generate_random_4d<T>(1, directions, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = generate_random_4d<T>(1, directions, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = generate_random_4d<T>(1, 1, directions, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = rg.generate_random_4d<T>(1, directions, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = rg.generate_random_4d<T>(1, directions, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = rg.generate_random_4d<T>(1, 1, directions, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = rg.generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = rg.generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_output = VVVVF<T>(batch_size, VVVF<T>(sequence_len, VVF<T>(directions, VF<T>(hidden_size))));
|
||||
|
||||
VF<T> ref_input_vec = flatten_4d<T>(format, ref_input);
|
||||
@@ -987,6 +995,7 @@ void lstm_gpu_users_test(bool is_caching_test = false) {
|
||||
int hidden_size = 1;
|
||||
int directions = 1;
|
||||
int min_random = -2, max_random = 2;
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
// The following test is designed to test the user dependencies of an LSTM node when replaced by subcomponents
|
||||
// by the graph compiler.
|
||||
@@ -996,12 +1005,12 @@ void lstm_gpu_users_test(bool is_caching_test = false) {
|
||||
// If the replacing is is done correctly then the initial_hidden tensor should match the output of the concatenation
|
||||
// by an offset along the sequence.
|
||||
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = generate_random_4d<T>(1, directions, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = generate_random_4d<T>(1, directions, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = generate_random_4d<T>(1, 1, directions, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_weights = rg.generate_random_4d<T>(1, directions, 4 * hidden_size, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_recurrent = rg.generate_random_4d<T>(1, directions, 4 * hidden_size, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_bias = rg.generate_random_4d<T>(1, 1, directions, 4 * hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_hidden = rg.generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_cell = rg.generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random);
|
||||
VVVVF<T> ref_output = VVVVF<T>(batch_size, VVVF<T>(sequence_len, VVF<T>(directions, VF<T>(hidden_size))));
|
||||
|
||||
VF<T> ref_input_vec = flatten_4d<T>(format::bfyx, ref_input);
|
||||
@@ -1087,11 +1096,12 @@ void lstm_gpu_concatenated_input_test(int layers, int sequence_len, int directio
|
||||
bool has_initial_cell, float clip_threshold,
|
||||
bool input_forget, bool is_caching_test = false)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
std::cout << "Layers = " << layers << " Input Size = " << input_size << " Hidden Size = " << hidden_size
|
||||
<< " Sequence Len = " << sequence_len << " Direction = " << direction << " Batch Size = " << batch_size << std::endl;
|
||||
int min_random = -2, max_random = 2;
|
||||
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
|
||||
std::vector<VVVVF<T>> ref_weights;
|
||||
std::vector<VVVVF<T>> ref_recurrent;
|
||||
@@ -1101,11 +1111,11 @@ void lstm_gpu_concatenated_input_test(int layers, int sequence_len, int directio
|
||||
std::vector<VVVVF<T>> ref_output;
|
||||
|
||||
for (int i = 0; i < layers; ++i) {
|
||||
ref_weights.push_back(generate_random_4d<T>(1, direction, 4 * hidden_size, i == 0 ? input_size : hidden_size, min_random, max_random));
|
||||
ref_recurrent.push_back(generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random));
|
||||
ref_bias.push_back(generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random));
|
||||
ref_hidden.push_back(generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random));
|
||||
ref_cell.push_back(generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random));
|
||||
ref_weights.push_back(rg.generate_random_4d<T>(1, direction, 4 * hidden_size, i == 0 ? input_size : hidden_size, min_random, max_random));
|
||||
ref_recurrent.push_back(rg.generate_random_4d<T>(1, direction, 4 * hidden_size, hidden_size, min_random, max_random));
|
||||
ref_bias.push_back(rg.generate_random_4d<T>(1, 1, direction, 4 * hidden_size, min_random, max_random));
|
||||
ref_hidden.push_back(rg.generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random));
|
||||
ref_cell.push_back(rg.generate_random_4d<T>(batch_size, 1, direction, hidden_size, min_random, max_random));
|
||||
ref_output.push_back(VVVVF<T>(batch_size, VVVF<T>(sequence_len, VVF<T>(direction, VF<T>(hidden_size)))));
|
||||
}
|
||||
|
||||
@@ -1258,6 +1268,7 @@ void lstm_gpu_chain_test(int batch_size, int input_size, int hidden_size,
|
||||
int directions, size_t layers, size_t chains, int sequence_len,
|
||||
const lstm_output_selection& output_selection, bool is_caching_test = false)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
int min_random = -2, max_random = 2;
|
||||
bool has_bias = false;
|
||||
bool has_initial_hidden = false;
|
||||
@@ -1269,7 +1280,7 @@ void lstm_gpu_chain_test(int batch_size, int input_size, int hidden_size,
|
||||
<< " Sequence Len = " << sequence_len << " Directions = " << directions << " Batch Size = " << batch_size
|
||||
<< " Output selection: " << static_cast<int>(output_selection) << std::endl;
|
||||
|
||||
VVVVF<T> ref_input = generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
VVVVF<T> ref_input = rg.generate_random_4d<T>(batch_size, sequence_len, 1, input_size, min_random, max_random);
|
||||
std::vector<std::vector< VVVVF<T>>> ref_weights;
|
||||
std::vector<std::vector< VVVVF<T>>> ref_recurrent;
|
||||
std::vector<std::vector< VVVVF<T>>> ref_bias;
|
||||
@@ -1288,11 +1299,11 @@ void lstm_gpu_chain_test(int batch_size, int input_size, int hidden_size,
|
||||
std::vector<VVVVF<T>> per_chain_ref_output;
|
||||
|
||||
for (size_t layer = 0; layer < layers; layer++) {
|
||||
per_chain_ref_weights.push_back(generate_random_4d<T>(1, directions, 4 * hidden_size, (layer == 0) ? input_size : hidden_size, min_random, max_random));
|
||||
per_chain_ref_recurrent.push_back(generate_random_4d<T>(1, directions, 4 * hidden_size, hidden_size, min_random, max_random));
|
||||
per_chain_ref_bias.push_back(generate_random_4d<T>(1, 1, directions, 4 * hidden_size, min_random, max_random));
|
||||
per_chain_ref_hidden.push_back(generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random));
|
||||
per_chain_ref_cell.push_back(generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random));
|
||||
per_chain_ref_weights.push_back(rg.generate_random_4d<T>(1, directions, 4 * hidden_size, (layer == 0) ? input_size : hidden_size, min_random, max_random));
|
||||
per_chain_ref_recurrent.push_back(rg.generate_random_4d<T>(1, directions, 4 * hidden_size, hidden_size, min_random, max_random));
|
||||
per_chain_ref_bias.push_back(rg.generate_random_4d<T>(1, 1, directions, 4 * hidden_size, min_random, max_random));
|
||||
per_chain_ref_hidden.push_back(rg.generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random));
|
||||
per_chain_ref_cell.push_back(rg.generate_random_4d<T>(batch_size, 1, directions, hidden_size, min_random, max_random));
|
||||
per_chain_ref_output.push_back(VVVVF<T>(batch_size, VVVF<T>(sequence_len, VVF<T>(directions, VF<T>(hidden_size)))));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/activation.hpp>
|
||||
@@ -361,6 +362,7 @@ public:
|
||||
}
|
||||
|
||||
void test_shared_mem_pool_diff_batches(bool is_caching_test) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
// We need a new engine here to get correct get_max_used_device_memory() result
|
||||
// If we reuse common engine, then max memory value will be taken from some previously executed tests
|
||||
// as it's tracked within engine instance
|
||||
@@ -378,8 +380,8 @@ public:
|
||||
auto input_8 = engine->allocate_memory(lay_batch_8);
|
||||
auto weights = engine->allocate_memory({ dt, fmt, { 1, 3, 3, 2 } });
|
||||
|
||||
std::vector<float> dummy_input_data_1 = generate_random_1d<float>(batch_1 * feature_num * inp_x_size * inp_y_size, 0, 1);
|
||||
std::vector<float> dummy_input_data_8 = generate_random_1d<float>(batch_8 * feature_num * inp_x_size * inp_y_size, 0, 1);
|
||||
std::vector<float> dummy_input_data_1 = rg.generate_random_1d<float>(batch_1 * feature_num * inp_x_size * inp_y_size, 0, 1);
|
||||
std::vector<float> dummy_input_data_8 = rg.generate_random_1d<float>(batch_8 * feature_num * inp_x_size * inp_y_size, 0, 1);
|
||||
|
||||
set_values(input_1, dummy_input_data_1);
|
||||
set_values(input_8, dummy_input_data_8);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/mvn.hpp>
|
||||
@@ -585,6 +586,12 @@ struct mvn_basic_test_params {
|
||||
};
|
||||
|
||||
struct mvn_random_test : ::testing::TestWithParam<mvn_basic_test_params> {
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fill_data(memory::ptr mem, const tests::VVVVVF<T>& data) {
|
||||
auto l = mem->get_layout();
|
||||
@@ -607,14 +614,14 @@ struct mvn_random_test : ::testing::TestWithParam<mvn_basic_test_params> {
|
||||
template <typename T>
|
||||
void fill_random_data(memory::ptr mem, int min, int max, int k = 8) {
|
||||
auto l = mem->get_layout();
|
||||
auto input_data = tests::generate_random_5d<T>(l.batch(),
|
||||
l.feature(),
|
||||
l.spatial(0),
|
||||
l.spatial(1),
|
||||
l.spatial(2),
|
||||
min,
|
||||
max,
|
||||
k);
|
||||
auto input_data = rg.generate_random_5d<T>(l.batch(),
|
||||
l.feature(),
|
||||
l.spatial(0),
|
||||
l.spatial(1),
|
||||
l.spatial(2),
|
||||
min,
|
||||
max,
|
||||
k);
|
||||
fill_data(mem, input_data);
|
||||
}
|
||||
|
||||
@@ -753,6 +760,12 @@ INSTANTIATE_TEST_SUITE_P(extended,
|
||||
.extended_tests(format::b_fs_yx_fsv16, data_types::u8)));
|
||||
|
||||
struct mvn_random_test_bsv32 : ::testing::TestWithParam<mvn_basic_test_params> {
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fill_data(cldnn::memory::ptr mem, const tests::VVVVVF<T>& data) {
|
||||
auto l = mem->get_layout();
|
||||
@@ -775,14 +788,14 @@ struct mvn_random_test_bsv32 : ::testing::TestWithParam<mvn_basic_test_params> {
|
||||
template <typename T>
|
||||
void fill_random_data(cldnn::memory::ptr mem, int min, int max, int k = 8) {
|
||||
auto l = mem->get_layout();
|
||||
auto input_data = tests::generate_random_5d<T>(l.batch(),
|
||||
l.feature(),
|
||||
l.spatial(0),
|
||||
l.spatial(1),
|
||||
l.spatial(2),
|
||||
min,
|
||||
max,
|
||||
k);
|
||||
auto input_data = rg.generate_random_5d<T>(l.batch(),
|
||||
l.feature(),
|
||||
l.spatial(0),
|
||||
l.spatial(1),
|
||||
l.spatial(2),
|
||||
min,
|
||||
max,
|
||||
k);
|
||||
fill_data(mem, input_data);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/non_zero.hpp>
|
||||
@@ -17,16 +18,7 @@ using namespace cldnn;
|
||||
using namespace ::tests;
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> generate_random_input(const size_t input_size, int min, int max, int min_num_zero = 0) {
|
||||
static std::default_random_engine generator(random_seed);
|
||||
int k = 8; // 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
std::vector<T> vec(input_size);
|
||||
for (size_t i = 0; i < input_size; ++i) {
|
||||
vec[i] = (T)distribution(generator);
|
||||
vec[i] /= k;
|
||||
}
|
||||
|
||||
void make_min_num_zero(std::vector<T>& vec, std::default_random_engine& generator, int min_num_zero) {
|
||||
auto num_zero = std::count_if(vec.begin(), vec.end(), [](T val) {
|
||||
return (val == 0);
|
||||
});
|
||||
@@ -44,7 +36,6 @@ std::vector<T> generate_random_input(const size_t input_size, int min, int max,
|
||||
}
|
||||
}
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -86,26 +77,34 @@ TEST(test_count_non_zero, 5d_fp16_1_3_2_1_2) {
|
||||
}
|
||||
|
||||
TEST(test_count_non_zero, 2d_int32_1_256) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
layout in_layout = {ov::PartialShape{1, 256}, data_types::i32, format::bfyx};
|
||||
auto in_data = generate_random_input<int32_t>(in_layout.count(), -2, 2, 100);
|
||||
auto in_data = rg.generate_random_1d<int32_t>(in_layout.count(), -2, 2);
|
||||
make_min_num_zero(in_data, rg.get_generator(), 100);
|
||||
test_count_non_zero<int32_t>(in_layout, in_data);
|
||||
}
|
||||
|
||||
TEST(test_count_non_zero, 2d_f32_1_513) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
layout in_layout = {ov::PartialShape{1, 513}, data_types::f32, format::bfyx};
|
||||
auto in_data = generate_random_input<float>(in_layout.count(), -2, 2, 40);
|
||||
auto in_data = rg.generate_random_1d<float>(in_layout.count(), -2, 2);
|
||||
make_min_num_zero(in_data, rg.get_generator(), 40);
|
||||
test_count_non_zero<float>(in_layout, in_data);
|
||||
}
|
||||
|
||||
TEST(test_count_non_zero, 6d_f32_21_18_1_5_3_2) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
layout in_layout = {ov::PartialShape{21, 18, 1, 5, 3, 2}, data_types::f32, format::bfwzyx};
|
||||
auto in_data = generate_random_input<float>(in_layout.count(), -2, 2, 172);
|
||||
auto in_data = rg.generate_random_1d<float>(in_layout.count(), -2, 2);
|
||||
make_min_num_zero(in_data, rg.get_generator(), 172);
|
||||
test_count_non_zero<float>(in_layout, in_data);
|
||||
}
|
||||
|
||||
TEST(test_count_non_zero, 5d_f32_1_16_4_2_24) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
layout in_layout = {ov::PartialShape{1, 16, 4, 2, 24}, data_types::f32, format::bfzyx};
|
||||
auto in_data = generate_random_input<float>(in_layout.count(), -2, 2, 128);
|
||||
auto in_data = rg.generate_random_1d<float>(in_layout.count(), -2, 2);
|
||||
make_min_num_zero(in_data, rg.get_generator(), 128);
|
||||
test_count_non_zero<float>(in_layout, in_data);
|
||||
}
|
||||
|
||||
@@ -139,10 +138,14 @@ TEST(test_count_non_zero, dynamic_2d_f32_bfyx) {
|
||||
dyn_nonzero_count_net _test;
|
||||
_test.create_network(engine, topology, config);
|
||||
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
|
||||
for (size_t& input_length : input_shapes) {
|
||||
auto in_layout = layout({1, static_cast<long int>(input_length)}, data_types::f32, format::bfyx);
|
||||
auto input_mem = engine.allocate_memory(in_layout);
|
||||
auto in_data = generate_random_input<float>(in_layout.count(), -2, 2, 50);
|
||||
|
||||
auto in_data = rg.generate_random_1d<float>(in_layout.count(), -2, 2);
|
||||
make_min_num_zero(in_data, rg.get_generator(), 50);
|
||||
|
||||
set_values(input_mem, in_data);
|
||||
auto outputs = _test.execute(input_mem);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/one_hot.hpp>
|
||||
@@ -67,12 +68,13 @@ VVVVF<T> one_hot_cpu(VVVVF<T> &input, uint16_t axis,
|
||||
template <typename T>
|
||||
void generic_one_hot_test_int(cldnn::format test_input_fmt, int input_b, int input_f, int input_y, int input_x, tensor shape,
|
||||
uint16_t one_hot_axis, int input_padding_y, int input_padding_x, int output_padding_y, int output_padding_x, bool is_caching_test) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
std::vector<tensor::value_type> output_dims = { shape.batch[0], shape.feature[0],
|
||||
shape.spatial[1], shape.spatial[0] };
|
||||
int32_t one_hot_limit = output_dims[one_hot_axis];
|
||||
|
||||
int min_random = 0, max_random = one_hot_limit + 2;
|
||||
VVVVF<T> input_rnd = generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VVVVF<T> input_rnd = rg.generate_random_4d<T>(input_b, input_f, input_y, input_x, min_random, max_random);
|
||||
VF<T> input_rnd_vec = flatten_4d<T>(test_input_fmt, input_rnd);
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/permute.hpp>
|
||||
@@ -691,6 +692,7 @@ TEST(fc_permute_gpu, basic_permute_bfyx)
|
||||
|
||||
TEST(permute_gpu_f32, permute_bfwzyx)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
const int b = 1;
|
||||
const int f = 2;
|
||||
@@ -702,7 +704,7 @@ TEST(permute_gpu_f32, permute_bfwzyx)
|
||||
|
||||
auto input_size = cldnn::tensor(batch(b), feature(f), spatial(x, y, z, w));
|
||||
auto input_mem = engine.allocate_memory({ data_types::f32, format::bfwzyx, input_size });
|
||||
auto input_data = generate_random_1d<float>(input_mem->get_layout().count(), -1, 1);
|
||||
auto input_data = rg.generate_random_1d<float>(input_mem->get_layout().count(), -1, 1);
|
||||
|
||||
set_values(input_mem, input_data);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/pooling.hpp>
|
||||
@@ -2070,6 +2071,8 @@ public:
|
||||
using parent = pooling_test_base<InputT, Mode>;
|
||||
using output_t = typename parent::output_t;
|
||||
|
||||
tests::random_generator rg;
|
||||
|
||||
virtual VVVVVF<output_t> calculate_reference() {
|
||||
VVVVVF<output_t> reference(this->batch_num(), VVVVF<output_t>(this->input_features()));
|
||||
for (size_t bi = 0; bi < this->batch_num(); ++bi) {
|
||||
@@ -2091,6 +2094,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void param_set_up(const pooling_random_test_params& params) {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
size_t b, f, in_x, in_y, in_z, p_x, p_y, p_z;
|
||||
int s_x, s_y, s_z, o_x, o_y, o_z;
|
||||
format::type in_fmt;
|
||||
@@ -2105,7 +2109,7 @@ public:
|
||||
in_fmt
|
||||
) = params;
|
||||
|
||||
auto input_data = generate_random_5d<InputT>(b, f, in_z, in_y, in_x, -256, 256);
|
||||
auto input_data = rg.generate_random_5d<InputT>(b, f, in_z, in_y, in_x, -256, 256);
|
||||
|
||||
this->set_input(in_fmt, std::move(input_data));
|
||||
this->set_pool_size(p_x, p_y, p_z);
|
||||
@@ -2195,6 +2199,8 @@ public:
|
||||
using parent = pooling_random_test_base<InputT, Mode>;
|
||||
using output_t = typename parent::output_t;
|
||||
|
||||
tests::random_generator rg;
|
||||
|
||||
topology build_topology(engine& eng) override {
|
||||
topology topo = parent::build_topology(eng);
|
||||
|
||||
@@ -2228,8 +2234,8 @@ public:
|
||||
|
||||
void param_set_up(const pooling_random_test_params& params) override {
|
||||
parent::param_set_up(params);
|
||||
_scale = generate_random_1d<output_t>(this->input_features(), -1, 1);
|
||||
_shift = generate_random_1d<output_t>(this->input_features(), -32, 32);
|
||||
_scale = rg.generate_random_1d<output_t>(this->input_features(), -1, 1);
|
||||
_shift = rg.generate_random_1d<output_t>(this->input_features(), -32, 32);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -2279,6 +2285,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
|
||||
TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int features = 16;
|
||||
@@ -2293,7 +2300,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride)
|
||||
|
||||
const tensor input_tensor(batches, features, x_input, y_input);
|
||||
|
||||
auto input_data = generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
auto input_data = rg.generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
|
||||
auto input_prim = engine.allocate_memory({data_types::f32, format::bfyx, input_tensor});
|
||||
set_values(input_prim, input_data);
|
||||
@@ -2363,6 +2370,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x8x8_input_2x2_pool_2x2_stride)
|
||||
|
||||
TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x1_inpad)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int features = 16;
|
||||
@@ -2377,7 +2385,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x
|
||||
|
||||
const tensor input_tensor(batches, features, x_input, y_input);
|
||||
|
||||
auto input_data = generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
auto input_data = rg.generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
|
||||
auto input_prim = engine.allocate_memory({data_types::f32, format::bfyx, input_tensor});
|
||||
set_values(input_prim, input_data);
|
||||
@@ -2446,6 +2454,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x2x2_input_4x4_pool_1x1_stride_1x
|
||||
|
||||
TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int features = 16;
|
||||
@@ -2460,7 +2469,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride)
|
||||
|
||||
const tensor input_tensor(batches, features, x_input, y_input);
|
||||
|
||||
auto input_data = generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
auto input_data = rg.generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
|
||||
auto input_prim = engine.allocate_memory({data_types::f32, format::bfyx, input_tensor});
|
||||
set_values(input_prim, input_data);
|
||||
@@ -2530,6 +2539,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x3_stride)
|
||||
|
||||
TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int features = 16;
|
||||
@@ -2545,7 +2555,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride)
|
||||
|
||||
const tensor input_tensor(batches, features, x_input, y_input);
|
||||
|
||||
auto input_data = generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
auto input_data = rg.generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
|
||||
auto input_prim = engine.allocate_memory({data_types::f32, format::bfyx, input_tensor});
|
||||
set_values(input_prim, input_data);
|
||||
@@ -2613,6 +2623,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_avg_16x16x20x20_input_5x5_pool_3x1_stride)
|
||||
|
||||
TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int features = 16;
|
||||
@@ -2628,7 +2639,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride)
|
||||
|
||||
const tensor input_tensor(batches, features, x_input, y_input);
|
||||
|
||||
auto input_data = generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
auto input_data = rg.generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
|
||||
auto input_prim = engine.allocate_memory({ data_types::f32,format::bfyx,input_tensor });
|
||||
set_values(input_prim, input_data);
|
||||
@@ -2698,6 +2709,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_16x16x20x20_input_5x5_pool_3x1_stride)
|
||||
|
||||
TEST(pooling_forward_gpu, bsv16_fsv16_max_32x32x20x20_input_5x5_pool_3x1_stride)
|
||||
{
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
const int features = 32;
|
||||
@@ -2713,7 +2725,7 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x32x20x20_input_5x5_pool_3x1_stride)
|
||||
|
||||
const tensor input_tensor(batches, features, x_input, y_input);
|
||||
|
||||
auto input_data = generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
auto input_data = rg.generate_random_1d<float>(batches * features * x_input * y_input, -10, 10);
|
||||
|
||||
auto input_prim = engine.allocate_memory({ data_types::f32,format::bfyx,input_tensor });
|
||||
set_values(input_prim, input_data);
|
||||
@@ -2872,6 +2884,11 @@ TEST(pooling_forward_gpu, bsv16_fsv16_max_32x16x20x20_input_5x5_pool_3x1_stride)
|
||||
|
||||
class pooling_test : public tests::generic_test
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -2953,7 +2970,7 @@ public:
|
||||
int k = (generic_params->data_type == data_types::f32) ? 8 : 4;
|
||||
auto input = inputs[0];
|
||||
auto l = inputs[0]->get_layout();
|
||||
VVVVF<Type> input_rnd = generate_random_4d<Type>(l.batch(), l.feature(), l.spatial(1), l.spatial(0), -10, 10, k);
|
||||
VVVVF<Type> input_rnd = rg.generate_random_4d<Type>(l.batch(), l.feature(), l.spatial(1), l.spatial(0), -10, 10, k);
|
||||
VF<Type> input_rnd_vec = flatten_4d<Type>(input->get_layout().format, input_rnd);
|
||||
set_values(input, input_rnd_vec);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/quantize.hpp>
|
||||
@@ -699,6 +700,12 @@ struct quantize_random_test_params {
|
||||
|
||||
struct quantize_random_test : testing::TestWithParam<quantize_random_test_params>
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fill_typed(memory::ptr src, memory::ptr dst) {
|
||||
auto l = dst->get_layout();
|
||||
@@ -731,7 +738,7 @@ struct quantize_random_test : testing::TestWithParam<quantize_random_test_params
|
||||
size_t x = l.spatial(0);
|
||||
size_t y = l.spatial(1);
|
||||
|
||||
auto data = generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
auto data = rg.generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
mem_lock<T> ptr{mem, get_test_stream()};
|
||||
for (size_t bi = 0; bi < b; ++bi) {
|
||||
for (size_t fi = 0; fi < f; ++fi) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/reduce.hpp>
|
||||
@@ -464,6 +465,11 @@ protected:
|
||||
|
||||
static std::vector<std::tuple<cldnn::reduce_mode,double, double, double>> perf_data;
|
||||
|
||||
tests::random_generator rg;
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
ReduceTestBase() {
|
||||
this->batch_num = testing::get<0>(GetParam());
|
||||
this->input_f = testing::get<1>(GetParam());
|
||||
@@ -497,7 +503,7 @@ public:
|
||||
using output_t = typename output_data_type<OutputT>::type;
|
||||
|
||||
auto input_size = tensor(batch(batch_num), feature(input_f), spatial(input_x, input_y, input_z, input_w));
|
||||
auto input_data = generate_random_6d<input_t>(batch_num, input_f, input_x, input_y, input_z, input_w, 1, 10);
|
||||
auto input_data = rg.generate_random_6d<input_t>(batch_num, input_f, input_x, input_y, input_z, input_w, 1, 10);
|
||||
auto input_lay = layout(input_dt, layout_format, input_size);
|
||||
auto input_mem = engine.allocate_memory(input_lay);
|
||||
|
||||
@@ -1809,6 +1815,11 @@ protected:
|
||||
|
||||
static std::vector<std::tuple<cldnn::reduce_mode,double, double, double>> perf_data;
|
||||
|
||||
tests::random_generator rg;
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
ReduceXYWithBigTensorTestBase() {
|
||||
this->batch_num = testing::get<0>(GetParam());
|
||||
this->input_f = testing::get<1>(GetParam());
|
||||
@@ -1843,7 +1854,7 @@ public:
|
||||
using output_t = typename output_data_type<OutputT>::type;
|
||||
|
||||
auto input_size = tensor(batch(batch_num), feature(input_f), spatial(input_x, input_y, input_z, input_w));
|
||||
auto input_data = generate_random_6d<input_t>(batch_num, input_f, input_x, input_y, input_z, input_w, 1, 5, 9);
|
||||
auto input_data = rg.generate_random_6d<input_t>(batch_num, input_f, input_x, input_y, input_z, input_w, 1, 5, 9);
|
||||
auto input_lay = layout(input_dt, layout_format, input_size);
|
||||
auto input_mem = engine.allocate_memory(input_lay);
|
||||
|
||||
@@ -1978,9 +1989,14 @@ protected:
|
||||
cldnn::data_types input_dt;
|
||||
cldnn::data_types output_dt;
|
||||
bool force_output_dt;
|
||||
tests::random_generator rg;
|
||||
|
||||
static std::vector<std::tuple<cldnn::reduce_mode,double, double, double>> perf_data;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
ReduceOnednnTestBase() {
|
||||
this->batch_num = testing::get<0>(GetParam());
|
||||
this->input_f = testing::get<1>(GetParam());
|
||||
@@ -2016,7 +2032,7 @@ public:
|
||||
using output_t = typename output_data_type<OutputT>::type;
|
||||
|
||||
auto input_size = tensor(batch(batch_num), feature(input_f), spatial(input_x, input_y, input_z, input_w));
|
||||
auto input_data = generate_random_6d<input_t>(batch_num, input_f, input_x, input_y, input_z, input_w, 1, 10);
|
||||
auto input_data = rg.generate_random_6d<input_t>(batch_num, input_f, input_x, input_y, input_z, input_w, 1, 10);
|
||||
auto input_lay = layout(input_dt, layout_format, input_size);
|
||||
auto input_mem = engine.allocate_memory(input_lay);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/region_yolo.hpp>
|
||||
@@ -166,9 +167,10 @@ struct region_yolo_test_params {
|
||||
|
||||
template <typename T>
|
||||
void runRegionTest(region_yolo_test_params& params, bool is_caching_test = false) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
const tensor kInputTensor(params.tensor[0], params.tensor[1], params.tensor[2], params.tensor[3]);
|
||||
auto inputData = generate_random_1d<T>(params.tensor[0] * params.tensor[1] * params.tensor[2] * params.tensor[3], -1, 1);
|
||||
auto inputData = rg.generate_random_1d<T>(params.tensor[0] * params.tensor[1] * params.tensor[2] * params.tensor[3], -1, 1);
|
||||
|
||||
auto inputPrim = engine.allocate_memory({ params.dataType, format::bfyx, kInputTensor });
|
||||
set_values(inputPrim, inputData);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/reshape.hpp>
|
||||
@@ -2445,6 +2446,7 @@ TEST(reorder_gpu_f32, b_fs_yx_fsv16_to_bfyx_opt_padded)
|
||||
}
|
||||
|
||||
TEST(reorder_gpu, any_format) {
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input = engine.allocate_memory(layout(data_types::f32, format::yxfb, tensor(5, 7, 13, 9)));
|
||||
@@ -2455,7 +2457,7 @@ TEST(reorder_gpu, any_format) {
|
||||
|
||||
network net(engine, topo, get_test_default_config(engine));
|
||||
|
||||
auto data = generate_random_1d<float>(input->count(), -1, 1);
|
||||
auto data = rg.generate_random_1d<float>(input->count(), -1, 1);
|
||||
set_values(input, data);
|
||||
net.set_input_data("in", input);
|
||||
|
||||
@@ -2705,6 +2707,7 @@ struct reorder_test_param {
|
||||
template<typename T>
|
||||
class ReorderTest : public ::testing::TestWithParam<T> {
|
||||
public:
|
||||
tests::random_generator rg;
|
||||
cldnn::engine& engine = get_test_engine();
|
||||
cldnn::topology topology_test;
|
||||
ExecutionConfig config = get_test_default_config(engine);
|
||||
@@ -2747,6 +2750,7 @@ public:
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
config.set_property(ov::intel_gpu::optimize_data(true));
|
||||
}
|
||||
|
||||
@@ -2758,16 +2762,16 @@ public:
|
||||
auto prim = engine.allocate_memory(l);
|
||||
tensor s = l.get_tensor();
|
||||
if (l.data_type == data_types::bin) {
|
||||
VF<int32_t> rnd_vec = generate_random_1d<int32_t>(s.count() / 32, min_random, max_random);
|
||||
VF<int32_t> rnd_vec = rg.generate_random_1d<int32_t>(s.count() / 32, min_random, max_random);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::i8 || l.data_type == data_types::u8) {
|
||||
VF<uint8_t> rnd_vec = generate_random_1d<uint8_t>(s.count(), min_random, max_random);
|
||||
VF<uint8_t> rnd_vec = rg.generate_random_1d<uint8_t>(s.count(), min_random, max_random);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == data_types::f16) {
|
||||
VF<uint16_t> rnd_vec = generate_random_1d<uint16_t>(s.count(), -1, 1);
|
||||
VF<uint16_t> rnd_vec = rg.generate_random_1d<uint16_t>(s.count(), -1, 1);
|
||||
set_values(prim, rnd_vec);
|
||||
} else {
|
||||
VF<float> rnd_vec = generate_random_1d<float>(s.count(), -1, 1);
|
||||
VF<float> rnd_vec = rg.generate_random_1d<float>(s.count(), -1, 1);
|
||||
set_values(prim, rnd_vec);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/resample.hpp>
|
||||
@@ -307,6 +308,12 @@ struct resample_random_test_params {
|
||||
};
|
||||
|
||||
struct resample_random_test : testing::TestWithParam<resample_random_test_params>{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fill_random_typed(memory::ptr mem, int min, int max, int k) {
|
||||
auto l = mem->get_layout();
|
||||
@@ -315,7 +322,7 @@ struct resample_random_test : testing::TestWithParam<resample_random_test_params
|
||||
size_t x = l.spatial(0);
|
||||
size_t y = l.spatial(1);
|
||||
|
||||
auto data = generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
auto data = rg.generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
cldnn::mem_lock<T> ptr(mem, get_test_stream());
|
||||
for (size_t bi = 0; bi < b; ++bi) {
|
||||
for (size_t fi = 0; fi < f; ++fi) {
|
||||
@@ -545,6 +552,12 @@ struct caffe_resample_random_test_params {
|
||||
|
||||
struct caffe_resample_random_test : testing::TestWithParam<caffe_resample_random_test_params>
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fill_random_typed(memory::ptr mem, int min, int max, int k) {
|
||||
auto l = mem->get_layout();
|
||||
@@ -553,7 +566,7 @@ struct caffe_resample_random_test : testing::TestWithParam<caffe_resample_random
|
||||
size_t x = l.spatial(0);
|
||||
size_t y = l.spatial(1);
|
||||
|
||||
auto data = generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
auto data = rg.generate_random_4d<T>(b, f, y, x, min, max, k);
|
||||
cldnn::mem_lock<T> ptr(mem, get_test_stream());
|
||||
for (size_t bi = 0; bi < b; ++bi) {
|
||||
for (size_t fi = 0; fi < f; ++fi) {
|
||||
@@ -1930,6 +1943,12 @@ struct resample_opt_random_test_params {
|
||||
|
||||
struct resample_opt_random_test : testing::TestWithParam<resample_opt_random_test_params>
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
rg.set_seed(GET_SUITE_NAME);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void fill_random_typed(memory::ptr mem, int min, int max, int k) {
|
||||
auto l = mem->get_layout();
|
||||
@@ -1939,7 +1958,7 @@ struct resample_opt_random_test : testing::TestWithParam<resample_opt_random_tes
|
||||
size_t y = l.spatial(1);
|
||||
size_t z = l.spatial(2);
|
||||
|
||||
auto data = generate_random_5d<T>(b, f, z, y, x, min, max, k);
|
||||
auto data = rg.generate_random_5d<T>(b, f, z, y, x, min, max, k);
|
||||
mem_lock<T> ptr{mem, get_test_stream()};
|
||||
for (size_t bi = 0; bi < b; ++bi) {
|
||||
for (size_t fi = 0; fi < f; ++fi) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
#include "ngraph/runtime/reference/scatter_nd_update.hpp"
|
||||
#include "scatter_nd_update_inst.h"
|
||||
|
||||
@@ -22,18 +23,6 @@
|
||||
using namespace cldnn;
|
||||
using namespace ::tests;
|
||||
|
||||
namespace {
|
||||
template<typename T>
|
||||
T generate_random_val(int min, int max, int k = 8) {
|
||||
static std::default_random_engine generator(random_seed);
|
||||
// 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
T val = (T)distribution(generator);
|
||||
val /= k;
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
struct scatter_nd_update_basic_test_params
|
||||
{
|
||||
@@ -54,6 +43,14 @@ struct scatter_nd_update_basic_test_params
|
||||
|
||||
struct scatter_nd_update_random_test : testing::TestWithParam<scatter_nd_update_basic_test_params>
|
||||
{
|
||||
tests::random_generator rg;
|
||||
|
||||
void SetUp() override {
|
||||
std::string suite_name = std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) +
|
||||
std::string(::testing::UnitTest::GetInstance()->current_test_info()->name());
|
||||
rg.set_seed(suite_name);
|
||||
}
|
||||
|
||||
format get_default_format(int rank = 4) {
|
||||
if (rank <= 4)
|
||||
return cldnn::format::bfyx;
|
||||
@@ -76,7 +73,7 @@ struct scatter_nd_update_random_test : testing::TestWithParam<scatter_nd_update_
|
||||
while (unique_indices.size() != count) {
|
||||
std::vector<T> indices;
|
||||
for (size_t i = 0; i < last_indices_dim; i++) {
|
||||
indices.push_back(static_cast<T>(generate_random_val<int>(0, data_shape[i] - 1)));
|
||||
indices.push_back(static_cast<T>(rg.generate_random_val<int>(0, data_shape[i] - 1)));
|
||||
}
|
||||
|
||||
unique_indices.insert(indices);
|
||||
@@ -116,9 +113,9 @@ struct scatter_nd_update_random_test : testing::TestWithParam<scatter_nd_update_
|
||||
std::reverse(indices_vec.begin() + 2, indices_vec.end());
|
||||
indices_vec.resize(params.indices_rank);
|
||||
|
||||
auto input_data_fp16 = generate_random_1d<T>(params.input_size.count(), -127, 127);
|
||||
auto input_data_fp16 = rg.generate_random_1d<T>(params.input_size.count(), -127, 127);
|
||||
auto indices_data_fp16 = generate_unique_indices<T>(params);
|
||||
auto updates_data_fp16 = generate_random_1d<T>(params.updates_size.count(), -127, 127);
|
||||
auto updates_data_fp16 = rg.generate_random_1d<T>(params.updates_size.count(), -127, 127);
|
||||
|
||||
std::vector<float> input_data(params.input_size.count());
|
||||
for (size_t i = 0; i < params.input_size.count(); ++i)
|
||||
@@ -196,9 +193,9 @@ struct scatter_nd_update_random_test : testing::TestWithParam<scatter_nd_update_
|
||||
std::reverse(indices_vec.begin() + 2, indices_vec.end());
|
||||
indices_vec.resize(params.indices_rank);
|
||||
|
||||
auto input_data = generate_random_1d<T>(params.input_size.count(), -127, 127);
|
||||
auto input_data = rg.generate_random_1d<T>(params.input_size.count(), -127, 127);
|
||||
auto indices_data = generate_unique_indices<T>(params);
|
||||
auto updates_data = generate_random_1d<T>(params.updates_size.count(), -127, 127);
|
||||
auto updates_data = rg.generate_random_1d<T>(params.updates_size.count(), -127, 127);
|
||||
|
||||
set_values(input1, input_data);
|
||||
set_values(input2, indices_data);
|
||||
@@ -4462,6 +4459,9 @@ TEST(scatter_nd_update_gpu, dynamic) {
|
||||
}
|
||||
|
||||
TEST(scatter_nd_update_gpu, dynamic_5d) {
|
||||
tests::random_generator rg(std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) +
|
||||
std::string(::testing::UnitTest::GetInstance()->current_test_info()->name()));
|
||||
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input1_layout = layout{{ 8, -1, -1, 384}, data_types::f32, format::bfyx };
|
||||
@@ -4498,7 +4498,7 @@ TEST(scatter_nd_update_gpu, dynamic_5d) {
|
||||
};
|
||||
|
||||
|
||||
auto generate_unique_indices = [](ov::Shape data_shape, ov::Shape indices_shape) -> std::vector<int32_t>{
|
||||
auto generate_unique_indices = [&rg](ov::Shape data_shape, ov::Shape indices_shape) -> std::vector<int32_t>{
|
||||
std::set<std::vector<int32_t>> unique_indices;
|
||||
std::vector<int32_t> result;
|
||||
size_t last_indices_dim = indices_shape.at(indices_shape.size() - 1);
|
||||
@@ -4513,7 +4513,7 @@ TEST(scatter_nd_update_gpu, dynamic_5d) {
|
||||
for (size_t i = 0; i < last_indices_dim; i++) {
|
||||
const int min = 0;
|
||||
const int max = static_cast<int>(data_shape[i]) - 1;
|
||||
indices.push_back(static_cast<int32_t>(generate_random_val<int>(min, max)));
|
||||
indices.push_back(static_cast<int32_t>(rg.generate_random_val<int>(min, max)));
|
||||
}
|
||||
|
||||
unique_indices.insert(indices);
|
||||
@@ -4541,9 +4541,9 @@ TEST(scatter_nd_update_gpu, dynamic_5d) {
|
||||
auto input2 = engine.allocate_memory({ in2_shape, data_types::i32, format::bfzyx }); // Indexes
|
||||
auto input3 = engine.allocate_memory({ in3_shape, data_types::f32, format::bfyx }); // Updates
|
||||
|
||||
std::vector<float> input_data = generate_random_1d<float>(input1->count(), 1, 100);
|
||||
std::vector<float> input_data = rg.generate_random_1d<float>(input1->count(), 1, 100);
|
||||
std::vector<int32_t> indices = generate_unique_indices(in1_shape, in2_shape);
|
||||
std::vector<float> updates = generate_random_1d<float>(input3->count(), 100, 200);
|
||||
std::vector<float> updates = rg.generate_random_1d<float>(input3->count(), 100, 200);
|
||||
auto expected_res = get_expected_res(input_data, indices, updates, in1_shape, in2_shape, in3_shape);
|
||||
|
||||
set_values<float>(input1, input_data);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "test_utils.h"
|
||||
#include "random_generator.hpp"
|
||||
|
||||
#include <intel_gpu/primitives/input_layout.hpp>
|
||||
#include <intel_gpu/primitives/split.hpp>
|
||||
@@ -15,19 +16,6 @@
|
||||
using namespace cldnn;
|
||||
using namespace ::tests;
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> generate_random_input(size_t b, size_t f, size_t y, size_t x, int min, int max) {
|
||||
static std::default_random_engine generator(random_seed);
|
||||
int k = 8; // 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
std::vector<T> v(b*f*x*y);
|
||||
for (size_t i = 0; i < b*f*x*y; ++i) {
|
||||
v[i] = (T)distribution(generator);
|
||||
v[i] /= k;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void check_feature_map(T* output_ptr, std::vector<T> &input_vec, size_t batch_num, size_t feature_num, size_t y_size, size_t x_size, size_t feature_id, size_t factor)
|
||||
{
|
||||
@@ -71,7 +59,8 @@ void split_test(int batch_num, int feature_num, int x_size, int y_size, std::vec
|
||||
|
||||
topology.add(split("split", input_info("input"), input_ids_offsets));
|
||||
|
||||
std::vector<T> input_vec = generate_random_input<T>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
std::vector<T> input_vec = rg.generate_random_1d<T>(batch_num * feature_num * y_size * x_size, -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
cldnn::network::ptr network = get_network(engine, topology, get_test_default_config(engine), get_test_stream_ptr(), is_caching_test);
|
||||
@@ -537,7 +526,8 @@ TEST(split_gpu_f32, basic_in2x3x2x2_split_feature_bfyx) {
|
||||
{ "out2", { 0, 2, 0, 0 } }
|
||||
} ));
|
||||
|
||||
std::vector<float> input_vec = generate_random_input<float>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
std::vector<float> input_vec = rg.generate_random_1d<float>(batch_num * feature_num * y_size * x_size, -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -583,7 +573,8 @@ TEST(split_gpu_i64, basic_in2x3x2x2_split_feature_bfyx) {
|
||||
{ "out2", { 0, 2, 0, 0 } }
|
||||
} ));
|
||||
|
||||
std::vector<int64_t> input_vec = generate_random_input<int64_t>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
std::vector<int64_t> input_vec = rg.generate_random_1d<int64_t>(batch_num * feature_num * y_size * x_size, -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
@@ -646,7 +637,8 @@ TEST(split_gpu_f32, basic_in2x3x2x2_split_scale_feature_bfyx) {
|
||||
std::vector<float> scale_input_vec2 = { 3.f };
|
||||
set_values(scale_input2, scale_input_vec2);
|
||||
|
||||
std::vector<float> input_vec = generate_random_input<float>(batch_num, feature_num, y_size, x_size, -10, 10);
|
||||
tests::random_generator rg(GET_SUITE_NAME);
|
||||
std::vector<float> input_vec = rg.generate_random_1d<float>(batch_num * feature_num * y_size * x_size, -10, 10);
|
||||
set_values(input, input_vec);
|
||||
|
||||
network network(engine, topology, get_test_default_config(engine));
|
||||
|
||||
@@ -421,19 +421,4 @@ struct type_test_ranges<int8_t> {
|
||||
static constexpr int k = 1;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
VF<T> generate_smart_random_1d(size_t a) {
|
||||
return generate_random_1d<T>(a, type_test_ranges<T>::min, type_test_ranges<T>::max, type_test_ranges<T>::k);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VVF<T> generate_smart_random_2d(size_t a, size_t b) {
|
||||
return generate_random_2d<T>(a, b, type_test_ranges<T>::min, type_test_ranges<T>::max, type_test_ranges<T>::k);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
VVVVF<T> generate_smart_random_4d(size_t a, size_t b, size_t c, size_t d) {
|
||||
return generate_random_4d<T>(a, b, c, d, type_test_ranges<T>::min, type_test_ranges<T>::max, type_test_ranges<T>::k);
|
||||
}
|
||||
|
||||
} // namespace tests
|
||||
@@ -219,62 +219,6 @@ inline VF<T> flatten_6d(cldnn::format input_format, VVVVVVF<T> &data) {
|
||||
return vec;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> generate_random_1d(size_t a, int min, int max, int k = 8) {
|
||||
static std::default_random_engine generator(random_seed);
|
||||
// 1/k is the resolution of the floating point numbers
|
||||
std::uniform_int_distribution<int> distribution(k * min, k * max);
|
||||
std::vector<T> v(a);
|
||||
|
||||
for (size_t i = 0; i < a; ++i) {
|
||||
v[i] = (T)distribution(generator);
|
||||
v[i] /= k;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<std::vector<T>> generate_random_2d(size_t a, size_t b, int min, int max, int k = 8) {
|
||||
std::vector<std::vector<T>> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_1d<T>(b, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<std::vector<std::vector<T>>> generate_random_3d(size_t a, size_t b, size_t c, int min, int max, int k = 8) {
|
||||
std::vector<std::vector<std::vector<T>>> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_2d<T>(b, c, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
// parameters order is assumed to be bfyx or bfyx
|
||||
template<typename T>
|
||||
std::vector<std::vector<std::vector<std::vector<T>>>> generate_random_4d(size_t a, size_t b, size_t c, size_t d, int min, int max, int k = 8) {
|
||||
std::vector<std::vector<std::vector<std::vector<T>>>> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_3d<T>(b, c, d, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
// parameters order is assumed to be sbfyx for filters when split > 1
|
||||
template<typename T>
|
||||
std::vector<std::vector<std::vector<std::vector<std::vector<T>>>>> generate_random_5d(size_t a, size_t b, size_t c, size_t d, size_t e, int min, int max, int k = 8) {
|
||||
std::vector<std::vector<std::vector<std::vector<std::vector<T>>>>> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_4d<T>(b, c, d, e, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
VVVVVVF<T> generate_random_6d(size_t a, size_t b, size_t c, size_t d, size_t e, size_t f, int min, int max, int k = 8) {
|
||||
VVVVVVF<T> v(a);
|
||||
for (size_t i = 0; i < a; ++i)
|
||||
v[i] = generate_random_5d<T>(b, c, d, e, f, min, max, k);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <class T> void set_value(T* ptr, uint32_t index, T value) { ptr[index] = value; }
|
||||
template <class T> T get_value(T* ptr, uint32_t index) { return ptr[index]; }
|
||||
|
||||
@@ -610,23 +554,6 @@ inline std::vector<float> get_output_values_to_float(cldnn::network& net, const
|
||||
}
|
||||
}
|
||||
|
||||
inline cldnn::memory::ptr get_generated_random_1d_mem(cldnn::engine& engine, cldnn::layout l) {
|
||||
auto prim = engine.allocate_memory(l);
|
||||
cldnn::tensor s = l.get_tensor();
|
||||
if (l.data_type == cldnn::data_types::i8 || l.data_type == cldnn::data_types::u8) {
|
||||
VF<uint8_t> rnd_vec = generate_random_1d<uint8_t>(s.count(), -200, 200);
|
||||
set_values(prim, rnd_vec);
|
||||
} else if (l.data_type == cldnn::data_types::f16) {
|
||||
VF<FLOAT16> rnd_vec = generate_random_1d<FLOAT16>(s.count(), -1, 1);
|
||||
set_values(prim, rnd_vec);
|
||||
} else {
|
||||
VF<float> rnd_vec = generate_random_1d<float>(s.count(), -1, 1);
|
||||
set_values(prim, rnd_vec);
|
||||
}
|
||||
|
||||
return prim;
|
||||
}
|
||||
|
||||
double default_tolerance(cldnn::data_types dt);
|
||||
// inline void print_bin_blob(cldnn::memory& mem, std::string name)
|
||||
// {
|
||||
|
||||
Reference in new issue
Block a user