diff --git a/src/plugins/intel_gpu/src/graph/eltwise.cpp b/src/plugins/intel_gpu/src/graph/eltwise.cpp index 7805cb575aed9a..7d406237f5cef9 100644 --- a/src/plugins/intel_gpu/src/graph/eltwise.cpp +++ b/src/plugins/intel_gpu/src/graph/eltwise.cpp @@ -410,7 +410,11 @@ eltwise_inst::typed_primitive_inst(network& network, eltwise_node const& node) : auto base_pshape = input0_pshape; if (prim->broadcast_spec == ov::op::AutoBroadcastType::NUMPY && base_pshape.size() < input_pshape.size()) { - base_pshape.insert(base_pshape.begin(), input_pshape.size() - base_pshape.size(), 1); + if (use_new_shape_infer) { + base_pshape.insert(base_pshape.begin(), input_pshape.size() - base_pshape.size(), 1); + } else { + base_pshape.insert(base_pshape.end(), input_pshape.size() - base_pshape.size(), 1); + } } for (size_t d = 0; d < base_pshape.size(); ++d) { diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp index 205f3ffa61a721..5c9a3269cde10f 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp @@ -3439,6 +3439,65 @@ TEST(eltwise_gpu_f32, broadcast_test_dim3_dim4) { } } +TEST(eltwise_gpu_f32, broadcast_test_dim3_dim4_new_shape_infer_false) { + auto& engine = get_test_engine(); + + ov::Shape in2_shape = {1, 4, 1, 1}; + auto input2 = engine.allocate_memory({ ov::PartialShape(in2_shape), data_types::f32, format::bfyx }); + + std::vector const_input = { + 1.f, 0.f, 5.f, 1.5f, + 2.f, 0.f, 6.f, 5.2f, + 3.f, 0.5f, 7.f, 12.f, + 4.f, -0.5f, 8.f, 8.f + }; + + set_values(input2, { + 0.5f, 2.5f, 0.5f, 2.5f + }); + + float answers[16] = { + 1.5, 0.5, 7.5, 4, + 2.5, 0.5, 8.5, 7.7, + 3.5, 1, 9.5, 14.5, + 4.5, 0, 10.5, 10.5 + }; + + ExecutionConfig config = get_test_default_config(engine); + config.set_property(ov::intel_gpu::allow_new_shape_infer(false)); + + // in1:dim3, int2:dim4 + { + ov::Shape in1_shape = {2, 4, 2}; + + auto input = engine.allocate_memory({ ov::PartialShape(in1_shape), data_types::f32, format::bfyx }); + set_values(input, const_input); + + topology topology; + topology.add(input_layout("input", input->get_layout())); + topology.add(input_layout("input2", input2->get_layout())); + topology.add(eltwise("eltwise", { input_info("input"), input_info("input2") }, eltwise_mode::sum)); + + network network(engine, topology, config); + + network.set_input_data("input", input); + network.set_input_data("input2", input2); + auto outputs = network.execute(); + + ASSERT_EQ(outputs.size(), size_t(1)); + ASSERT_EQ(outputs.begin()->first, "eltwise"); + + auto output = outputs.at("eltwise").get_memory(); + + cldnn::mem_lock output_ptr(output, get_test_stream()); + + for (int i = 0; i < 16; i++) + { + ASSERT_TRUE(are_equal(answers[i], output_ptr[i])); + } + } +} + TEST(eltwise_gpu_f16, fs_b_yx_fsv32_basic) { // Inputs are 2x2x2x2