|
4 | 4 |
|
5 | 5 | #include "test_utils.h"
|
6 | 6 |
|
| 7 | +#include <intel_gpu/primitives/concatenation.hpp> |
7 | 8 | #include <intel_gpu/primitives/input_layout.hpp>
|
8 | 9 | #include <intel_gpu/primitives/softmax.hpp>
|
9 | 10 | #include <intel_gpu/primitives/reorder.hpp>
|
@@ -128,6 +129,117 @@ TEST(memory_reuse_realloc_reset_test, basic_conv_with_padding) {
|
128 | 129 | << reorder_mem->get_mem_tracker()->size() << "bytes.";
|
129 | 130 | }
|
130 | 131 |
|
| 132 | +TEST(memory_reuse_realloc_reset_test, basic_conv_with_memory_get_from_padded_pool) { |
| 133 | + auto& engine = get_test_engine(); |
| 134 | + |
| 135 | + layout weight_layout = layout{ov::PartialShape{1, 4, 3, 3}, data_types::f32, format::bfyx}; |
| 136 | + auto weights = engine.allocate_memory(weight_layout); |
| 137 | + set_values<float>(weights, { |
| 138 | + 1.0f, 1.0f, 1.0f, |
| 139 | + 1.0f, 1.0f, 1.0f, |
| 140 | + 1.0f, 1.0f, 1.0f, |
| 141 | + |
| 142 | + 1.0f, 1.0f, 1.0f, |
| 143 | + 1.0f, 1.0f, 1.0f, |
| 144 | + 1.0f, 1.0f, 1.0f, |
| 145 | + |
| 146 | + 1.0f, 1.0f, 1.0f, |
| 147 | + 1.0f, 1.0f, 1.0f, |
| 148 | + 1.0f, 1.0f, 1.0f, |
| 149 | + |
| 150 | + 1.0f, 1.0f, 1.0f, |
| 151 | + 1.0f, 1.0f, 1.0f, |
| 152 | + 1.0f, 1.0f, 1.0f |
| 153 | + }); |
| 154 | + |
| 155 | + layout weight_layout2 = layout{ov::PartialShape{1, 3, 3, 3}, data_types::f32, format::bfyx}; |
| 156 | + auto weights2 = engine.allocate_memory(weight_layout2); |
| 157 | + set_values<float>(weights2, { |
| 158 | + 1.0f, 1.0f, 1.0f, |
| 159 | + 1.0f, 1.0f, 1.0f, |
| 160 | + 1.0f, 1.0f, 1.0f, |
| 161 | + |
| 162 | + 1.0f, 1.0f, 1.0f, |
| 163 | + 1.0f, 1.0f, 1.0f, |
| 164 | + 1.0f, 1.0f, 1.0f, |
| 165 | + |
| 166 | + 1.0f, 1.0f, 1.0f, |
| 167 | + 1.0f, 1.0f, 1.0f, |
| 168 | + 1.0f, 1.0f, 1.0f |
| 169 | + }); |
| 170 | + |
| 171 | + layout elt_layout1 = layout{ov::PartialShape{1, 2, 4, 4}, data_types::f32, format::bfyx}; |
| 172 | + auto elt_mem1 = engine.allocate_memory(elt_layout1); |
| 173 | + set_values<float>(elt_mem1, { |
| 174 | + 10.f, 10.f, 10.f, 10.f, |
| 175 | + 10.f, 10.f, 10.f, 10.f, |
| 176 | + 10.f, 10.f, 10.f, 10.f, |
| 177 | + 10.f, 10.f, 10.f, 10.f, |
| 178 | + |
| 179 | + 10.f, 10.f, 10.f, 10.f, |
| 180 | + 10.f, 10.f, 10.f, 10.f, |
| 181 | + 10.f, 10.f, 10.f, 10.f, |
| 182 | + 10.f, 10.f, 10.f, 10.f |
| 183 | + }); |
| 184 | + |
| 185 | + std::vector<float> ref_output = { |
| 186 | + 1080, 1720, 1720, 1080, |
| 187 | + 1720, 2740, 2740, 1720, |
| 188 | + 1720, 2740, 2740, 1720, |
| 189 | + 1080, 1720, 1720, 1080 |
| 190 | + }; |
| 191 | + |
| 192 | + std::vector<float> subtract_val = {0.f, }; |
| 193 | + auto input_l = layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx}; |
| 194 | + auto elt_input_l = layout{ov::PartialShape::dynamic(4), data_types::f32, format::bfyx}; |
| 195 | + |
| 196 | + topology topology(input_layout("elt_input", elt_input_l), |
| 197 | + data("weights", weights), |
| 198 | + data("weights2", weights2), |
| 199 | + reorder("reorder1-1", input_info("elt_input"), format::bfyx, data_types::f32, subtract_val, reorder_mean_mode::subtract), |
| 200 | + reorder("reorder1-2", input_info("elt_input"), format::bfyx, data_types::f32, subtract_val, reorder_mean_mode::subtract), |
| 201 | + concatenation("concat1", {input_info("reorder1-1"), input_info("reorder1-2")}, 1), |
| 202 | + convolution("conv1", |
| 203 | + input_info("concat1"), |
| 204 | + "weights", |
| 205 | + "", /*bias*/ |
| 206 | + 1, |
| 207 | + {1, 1}, /*stride*/ |
| 208 | + {1, 1}, /*dilation*/ |
| 209 | + {1, 1}, /*pad_above*/ |
| 210 | + {1, 1}, /*pad_below*/ |
| 211 | + false, |
| 212 | + ov::op::PadType::EXPLICIT), |
| 213 | + reorder("reorder2-1", input_info("conv1"), format::bfyx, data_types::f32, subtract_val, reorder_mean_mode::subtract), |
| 214 | + concatenation("concat2", {input_info("reorder1-1"), input_info("reorder2-1")}, 1), |
| 215 | + convolution("conv2", |
| 216 | + input_info("concat2"), |
| 217 | + "weights2", |
| 218 | + "", /*bias*/ |
| 219 | + 1, |
| 220 | + {1, 1}, /*stride*/ |
| 221 | + {1, 1}, /*dilation*/ |
| 222 | + {1, 1}, /*pad_above*/ |
| 223 | + {1, 1}, /*pad_below*/ |
| 224 | + false, |
| 225 | + ov::op::PadType::EXPLICIT), |
| 226 | + reorder("output", input_info("conv2"), format::bfyx, data_types::f32)); |
| 227 | + |
| 228 | + ExecutionConfig config = get_test_default_config(engine); |
| 229 | + config.set_property(ov::intel_gpu::allow_new_shape_infer(true)); |
| 230 | + config.set_property(ov::intel_gpu::queue_type(QueueTypes::in_order)); |
| 231 | + |
| 232 | + network network(engine, topology, config); |
| 233 | + network.set_input_data("elt_input", elt_mem1); |
| 234 | + auto outputs = network.execute(); |
| 235 | + auto output_mem = outputs.begin()->second.get_memory(); |
| 236 | + cldnn::mem_lock<float> output_mem_ptr(output_mem, get_test_stream()); |
| 237 | + |
| 238 | + for (size_t i = 0; i < output_mem->get_layout().get_linear_size(); ++i) { |
| 239 | + ASSERT_EQ(output_mem_ptr[i], ref_output[i]); |
| 240 | + } |
| 241 | +} |
| 242 | + |
131 | 243 | TEST(softmax_gpu_dynamic_f32_test_upper_bound, input_same_values) {
|
132 | 244 | static const int32_t
|
133 | 245 | output_x_1 = 10, output_b_1 = 8,
|
|
0 commit comments