Skip to content

Commit 07f3a86

Browse files
[GPU] Add test for INT4 compressed weights
1 parent a84f79e commit 07f3a86

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/plugins/intel_gpu/tests/unit/transformations/convert_matmul_to_fc_test.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,3 +975,30 @@ TEST_F(TransformationTestsF, ConvertMatMulToFullyConnected_LargeF32_Transposed)
975975
model_ref = std::make_shared<ov::Model>(ov::OutputVector{fc}, ov::ParameterVector{input});
976976
}
977977
}
978+
979+
// Verify that Parameter INT4 compressed weights skip the Transpose and produce FC with transpose_b=false
980+
TEST_F(TransformationTestsF, ConvertMatMulToFullyConnected_ParameterCompressedWeights_NoTranspose) {
981+
{
982+
auto input = std::make_shared<ov::opset1::Parameter>(ov::element::f32, ov::Shape{128, 2048});
983+
auto weights = std::make_shared<ov::opset1::Parameter>(ov::element::u4, ov::Shape{2048, 8192});
984+
auto convert = std::make_shared<ov::opset1::Convert>(weights, ov::element::f32);
985+
auto scale = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 8192}, {0.1f});
986+
auto mul = std::make_shared<ov::opset1::Multiply>(convert, scale);
987+
auto matmul = std::make_shared<ov::opset1::MatMul>(input, mul, false, false);
988+
989+
model = std::make_shared<ov::Model>(ov::OutputVector{matmul}, ov::ParameterVector{input, weights});
990+
manager.register_pass<ConvertMatMulToFullyConnected>();
991+
}
992+
{
993+
auto input = std::make_shared<ov::opset1::Parameter>(ov::element::f32, ov::Shape{128, 2048});
994+
auto weights = std::make_shared<ov::opset1::Parameter>(ov::element::u4, ov::Shape{2048, 8192});
995+
auto convert = std::make_shared<ov::opset1::Convert>(weights, ov::element::f32);
996+
auto scale = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 8192}, {0.1f});
997+
auto mul = std::make_shared<ov::opset1::Multiply>(convert, scale);
998+
auto no_bias = std::make_shared<ov::intel_gpu::op::Placeholder>();
999+
// transpose_b=false: weights stay in [K, N] layout, no Transpose inserted
1000+
auto fc = std::make_shared<op::FullyConnected>(input, mul, no_bias, ov::element::f32, /*transpose_b=*/false);
1001+
1002+
model_ref = std::make_shared<ov::Model>(ov::OutputVector{fc}, ov::ParameterVector{input, weights});
1003+
}
1004+
}

0 commit comments

Comments
 (0)