|
10 | 10 | #include <intel_gpu/primitives/eltwise.hpp>
|
11 | 11 | #include <intel_gpu/primitives/gather.hpp>
|
12 | 12 | #include <intel_gpu/primitives/reorder.hpp>
|
| 13 | +#include <intel_gpu/primitives/reshape.hpp> |
13 | 14 | #include <intel_gpu/primitives/data.hpp>
|
14 | 15 |
|
15 | 16 | #include "eltwise_inst.h"
|
| 17 | +#include "reshape_inst.h" |
16 | 18 |
|
17 | 19 | using namespace cldnn;
|
18 | 20 | using namespace ::tests;
|
@@ -3439,6 +3441,67 @@ TEST(eltwise_gpu_f32, broadcast_test_dim3_dim4) {
|
3439 | 3441 | }
|
3440 | 3442 | }
|
3441 | 3443 |
|
| 3444 | + |
| 3445 | +TEST(eltwise_gpu_f32, broadcast_test_dim3_dim4_new_shape_infer_false) { |
| 3446 | + auto& engine = get_test_engine(); |
| 3447 | + |
| 3448 | + ov::Shape in2_shape = {1, 1, 4, 1}; |
| 3449 | + auto input2 = engine.allocate_memory({ ov::PartialShape(in2_shape), data_types::f32, format::bfyx }); |
| 3450 | + |
| 3451 | + std::vector<float> const_input = { |
| 3452 | + 1.f, 0.f, 5.f, 1.5f, |
| 3453 | + 2.f, 0.f, 6.f, 5.2f, |
| 3454 | + 3.f, 0.5f, 7.f, 12.f, |
| 3455 | + 4.f, -0.5f, 8.f, 8.f |
| 3456 | + }; |
| 3457 | + |
| 3458 | + set_values(input2, { |
| 3459 | + 0.5f, 2.5f, 0.5f, 2.5f |
| 3460 | + }); |
| 3461 | + |
| 3462 | + float answers[16] = { |
| 3463 | + 1.5, 2.5, 5.5, 4, |
| 3464 | + 2.5, 2.5, 6.5, 7.7, |
| 3465 | + 3.5, 3, 7.5, 14.5, |
| 3466 | + 4.5, 2, 8.5, 10.5 |
| 3467 | + }; |
| 3468 | + |
| 3469 | + ExecutionConfig config = get_test_default_config(engine); |
| 3470 | + config.set_property(ov::intel_gpu::allow_new_shape_infer(false)); |
| 3471 | + |
| 3472 | + // Eltwise in1:dim3, int2:dim4 |
| 3473 | + { |
| 3474 | + ov::Shape in1_shape = {1, 2, 2, 4}; |
| 3475 | + |
| 3476 | + auto input = engine.allocate_memory({ ov::PartialShape(in1_shape), data_types::f32, format::bfyx }); |
| 3477 | + set_values(input, const_input); |
| 3478 | + |
| 3479 | + topology topology; |
| 3480 | + topology.add(input_layout("input", input->get_layout())); |
| 3481 | + topology.add(input_layout("input2", input2->get_layout())); |
| 3482 | + topology.add(reshape("reshape_input1", input_info("input"), false, {}, ov::PartialShape({2, 2, 4}))); |
| 3483 | + topology.add(eltwise("eltwise", { input_info("reshape_input1"), input_info("input2") }, eltwise_mode::sum)); |
| 3484 | + |
| 3485 | + network network(engine, topology, config); |
| 3486 | + |
| 3487 | + network.set_input_data("input", input); |
| 3488 | + network.set_input_data("input2", input2); |
| 3489 | + auto outputs = network.execute(); |
| 3490 | + |
| 3491 | + ASSERT_EQ(outputs.size(), size_t(1)); |
| 3492 | + ASSERT_EQ(outputs.begin()->first, "eltwise"); |
| 3493 | + |
| 3494 | + auto output = outputs.at("eltwise").get_memory(); |
| 3495 | + |
| 3496 | + cldnn::mem_lock<float> output_ptr(output, get_test_stream()); |
| 3497 | + |
| 3498 | + for (int i = 0; i < 16; i++) |
| 3499 | + { |
| 3500 | + ASSERT_TRUE(are_equal(answers[i], output_ptr[i])); |
| 3501 | + } |
| 3502 | + } |
| 3503 | +} |
| 3504 | + |
3442 | 3505 | TEST(eltwise_gpu_f16, fs_b_yx_fsv32_basic)
|
3443 | 3506 | {
|
3444 | 3507 | // Inputs are 2x2x2x2
|
|
0 commit comments