Skip to content

Commit f35396b

Browse files
[GPU] Add test for INT4 compressed weights
1 parent 1dfec72 commit f35396b

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
@@ -1000,3 +1000,30 @@ TEST_F(TransformationTestsF, ConvertMatMulToFullyConnected_LargeF16_NoXMX_Transp
10001000
model_ref = std::make_shared<ov::Model>(ov::OutputVector{fc}, ov::ParameterVector{input});
10011001
}
10021002
}
1003+
1004+
// Verify that Parameter INT4 compressed weights skip the Transpose and produce FC with transpose_b=false
1005+
TEST_F(TransformationTestsF, ConvertMatMulToFullyConnected_ParameterCompressedWeights_NoTranspose) {
1006+
{
1007+
auto input = std::make_shared<ov::opset1::Parameter>(ov::element::f32, ov::Shape{128, 2048});
1008+
auto weights = std::make_shared<ov::opset1::Parameter>(ov::element::u4, ov::Shape{2048, 8192});
1009+
auto convert = std::make_shared<ov::opset1::Convert>(weights, ov::element::f32);
1010+
auto scale = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 8192}, {0.1f});
1011+
auto mul = std::make_shared<ov::opset1::Multiply>(convert, scale);
1012+
auto matmul = std::make_shared<ov::opset1::MatMul>(input, mul, false, false);
1013+
1014+
model = std::make_shared<ov::Model>(ov::OutputVector{matmul}, ov::ParameterVector{input, weights});
1015+
manager.register_pass<ConvertMatMulToFullyConnected>();
1016+
}
1017+
{
1018+
auto input = std::make_shared<ov::opset1::Parameter>(ov::element::f32, ov::Shape{128, 2048});
1019+
auto weights = std::make_shared<ov::opset1::Parameter>(ov::element::u4, ov::Shape{2048, 8192});
1020+
auto convert = std::make_shared<ov::opset1::Convert>(weights, ov::element::f32);
1021+
auto scale = ov::opset1::Constant::create(ov::element::f32, ov::Shape{1, 8192}, {0.1f});
1022+
auto mul = std::make_shared<ov::opset1::Multiply>(convert, scale);
1023+
auto no_bias = std::make_shared<ov::intel_gpu::op::Placeholder>();
1024+
// transpose_b=false: weights stay in [K, N] layout, no Transpose inserted
1025+
auto fc = std::make_shared<op::FullyConnected>(input, mul, no_bias, ov::element::f32, /*transpose_b=*/false);
1026+
1027+
model_ref = std::make_shared<ov::Model>(ov::OutputVector{fc}, ov::ParameterVector{input, weights});
1028+
}
1029+
}

0 commit comments

Comments
 (0)