From 297219a42ef9a9167024e7c5886537b0e30159cf Mon Sep 17 00:00:00 2001 From: fishbell Date: Mon, 25 Nov 2024 22:53:42 +0800 Subject: [PATCH] add tests Signed-off-by: fishbell --- .../tests/unit/fusions/gemm_fusion_test.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/plugins/intel_gpu/tests/unit/fusions/gemm_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/gemm_fusion_test.cpp index 659ccaf9d8a723..08b63e0a8326b8 100644 --- a/src/plugins/intel_gpu/tests/unit/fusions/gemm_fusion_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/fusions/gemm_fusion_test.cpp @@ -398,6 +398,36 @@ TEST_P(gemm_2in_add, eltwise_postop_cached) { execute(p, false, true); } +TEST_P(gemm_2in_add, eltwise_postop_scalar) { + auto p = GetParam(); + + if (engine.get_device_info().supports_immad) { + ov::intel_gpu::ImplementationDesc gemmv_impl = { cldnn::format::type::any, "", impl_types::onednn }; + cfg_fused.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ { "gemm_prim", gemmv_impl } })); + } + + auto add_data_layout = get_output_layout(p); + auto add_data_size = add_data_layout.get_partial_shape(); + for (size_t i = 0; i < add_data_size.size(); i++) + add_data_size[i] = 1; + add_data_layout.set_partial_shape(add_data_size); + + auto in_layout0 = get_input_layout(p, 0); + auto in_layout1 = get_input_layout(p, 1); + + create_topologies( + input_layout("input0", in_layout0), + input_layout("input1", in_layout1), + data("add_data", get_mem(add_data_layout, 0.5f)), + gemm("gemm_prim", { input_info("input0"), input_info("input1") }, data_types::f32, false, false, 1.f, 0.f, in_layout0.get_rank(), in_layout1.get_rank()), + eltwise("add_prim", { input_info("gemm_prim"), input_info("add_data") }, p.eltwise_m, p.default_type), + reorder("reorder_bfyx", input_info("add_prim"), p.default_format, data_types::f32) + ); + + tolerance = default_tolerance(p.default_type); + execute(p, false, true); +} + INSTANTIATE_TEST_SUITE_P(fusings_gpu, gemm_2in_add, ::testing::ValuesIn(std::vector{ // gemm_test_params{ CASE_GEMM_2IN_FP16_3, 3, 4, "", broadcast_kinds::none, eltwise_mode::sum }, // TODO: check why failed in eltwise_postop_dynamic gemm_test_params{ CASE_GEMM_2IN_FP16_4, 3, 4, "", broadcast_kinds::none, eltwise_mode::sum },