@@ -100,24 +100,11 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface<MatMulDec
100
100
std::tie (inputShapes, transpose, weiElemType, additionalConfig, cpuParams) = obj.param ;
101
101
102
102
std::ostringstream result;
103
- for (const auto & shape : inputShapes) {
104
- result << ov::test::utils::partialShape2str ({shape.first }) << " _" ;
105
- }
106
- result << " TS=" ;
107
- for (const auto & shape : inputShapes) {
108
- result << " (" ;
109
- if (!shape.second .empty ()) {
110
- auto itr = shape.second .begin ();
111
- do {
112
- result << ov::test::utils::vec2str (*itr);
113
- } while (++itr != shape.second .end () && result << " _" );
114
- }
115
- result << " )_" ;
116
- }
103
+ for (size_t i = 0 ; i < inputShapes.size (); ++i)
104
+ result << " IS[" << i << " ]=" << inputShapes[i] << " _" ;
117
105
result << " transpose_a=" << transpose.first << " _" ;
118
106
result << " transpose_b=" << transpose.second << " _" ;
119
-
120
- result << " weiLemType=" << weiElemType << " _" ;
107
+ result << " weiElemType=" << weiElemType << " _" ;
121
108
122
109
result << " config=(" ;
123
110
for (const auto & configEntry : additionalConfig) {
@@ -137,25 +124,6 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface<MatMulDec
137
124
std::swap (*(shape.end () - 1 ), *(shape.end () - 2 ));
138
125
}
139
126
140
- void check_fc_weights_precision (ElementType expectedWeiElemType) const {
141
- auto getExecValue = [](const ov::Node::RTMap& rtInfo, const std::string& paramName) -> std::string {
142
- auto it = rtInfo.find (paramName);
143
- OPENVINO_ASSERT (rtInfo.end () != it);
144
- return it->second .as <std::string>();
145
- };
146
-
147
- const auto execFunction = compiledModel.get_runtime_model ();
148
- ASSERT_NE (nullptr , execFunction);
149
- for (const auto & fcNode : execFunction->get_ops ()) {
150
- if (getExecValue (fcNode->get_rt_info (), ov::exec_model_info::LAYER_TYPE) == " FullyConnected" ) {
151
- const auto & constNode = fcNode->get_input_node_shared_ptr (1 );
152
- ov::element::Type expectedType (
153
- getExecValue (constNode->get_rt_info (), ov::exec_model_info::OUTPUT_PRECISIONS));
154
- ASSERT_EQ (expectedType, expectedWeiElemType);
155
- }
156
- }
157
- }
158
-
159
127
void SetUp () override {
160
128
targetDevice = ov::test::utils::DEVICE_CPU;
161
129
@@ -196,23 +164,23 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface<MatMulDec
196
164
197
165
configuration.insert (additionalConfig.begin (), additionalConfig.end ());
198
166
199
- ElementType netType = ElementType::f32 ;
200
- ElementType convertOutType = ElementType::f32 ;
167
+ inType = outType = netType = ElementType::f32 ;
201
168
auto it = additionalConfig.find (ov::hint::inference_precision.name ());
202
169
if (it != additionalConfig.end () && it->second .as <ov::element::Type>() == ov::element::bf16 ) {
203
- convertOutType = inType = outType = netType = ElementType::bf16 ;
170
+ netType = ElementType::bf16 ;
204
171
weiConstElemType = (weiConstElemType != ElementType::f32 ) ? weiConstElemType : ElementType::bf16 ;
205
- } else {
206
- inType = outType = netType;
172
+ // Reorder between parameter and FullyConnected
173
+ // Note: reorder between FC and Result is not needed since FC primitive supports f32 output natively
174
+ reorderCount++;
207
175
}
208
176
209
177
std::string cpuNodeType = " FullyConnected" ;
210
- selectedType = makeSelectedTypeStr (selectedType, outType );
178
+ selectedType = makeSelectedTypeStr (selectedType, netType );
211
179
212
180
ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(inType, inShapeA)};
213
181
std::shared_ptr<ov::Node> inputB = ov::test::utils::make_constant (weiConstElemType, inShapeB.get_shape ());
214
- if (weiConstElemType == ElementType:: f16 || weiConstElemType == ElementType:: bf16 ) {
215
- inputB = std::make_shared<ov::op::v0::Convert>(inputB, convertOutType );
182
+ if (weiConstElemType != inType ) {
183
+ inputB = std::make_shared<ov::op::v0::Convert>(inputB, inType );
216
184
mark_as_decompression (inputB);
217
185
}
218
186
expectedWeiConstElemType = weiConstElemType;
@@ -223,17 +191,21 @@ class MatMulDecompressConvertTest : public testing::WithParamInterface<MatMulDec
223
191
}
224
192
225
193
void check_execution_graph () {
194
+ CheckNodePrecisionsWithType (compiledModel, " FullyConnected" , {netType, expectedWeiConstElemType}, {outType});
226
195
CheckPluginRelatedResults (compiledModel, " FullyConnected" );
227
196
CheckNumberOfNodesWithType (compiledModel, " FullyConnected" , fullyConnectedCount);
228
197
CheckNumberOfNodesWithType (compiledModel, " Transpose" , transposeCount);
229
198
CheckNumberOfNodesWithType (compiledModel, " Convert" , 0 );
230
- CheckNumberOfNodesWithType (compiledModel, " Reorder" , 0 );
231
- check_fc_weights_precision (expectedWeiConstElemType);
199
+ // Note: Convert node might be converted to Subgraph
200
+ CheckNumberOfNodesWithType (compiledModel, " Subgraph" , 0 );
201
+ CheckNumberOfNodesWithType (compiledModel, " Reorder" , reorderCount);
232
202
}
233
203
234
204
size_t fullyConnectedCount = 1 ;
235
205
size_t transposeCount = 0 ;
206
+ size_t reorderCount = 0 ;
236
207
ElementType expectedWeiConstElemType = ElementType::f32 ;
208
+ ElementType netType = ElementType::f32 ;
237
209
};
238
210
239
211
TEST_P (MatMulDecompressConvertTest, CompareWithRefs) {
@@ -265,11 +237,9 @@ const std::vector<std::vector<InputShape>> inputShapes3D = {
265
237
{{{-1 , -1 , -1 }, {{1 , 2 , 3 }, {1 , 5 , 3 }}}, {{1 , 3 , 4 }, {{1 , 3 , 4 }, {1 , 3 , 4 }}}},
266
238
};
267
239
268
- ov::AnyMap emptyConfig = {/* empty config */ };
269
-
270
240
std::vector<ov::AnyMap> filter_additional_config_bf16 () {
271
241
std::vector<ov::AnyMap> additionalConfig;
272
- if (ov::with_cpu_x86_avx512_core ()) {
242
+ if (ov::with_cpu_x86_bfloat16 ()) {
273
243
additionalConfig.push_back ({{ov::hint::inference_precision (ov::element::bf16 )}});
274
244
}
275
245
return additionalConfig;
@@ -306,7 +276,7 @@ std::vector<CPUSpecificParams> filter_specific_params_bf16() {
306
276
const auto testParams2D_FP32_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes2D),
307
277
::testing::ValuesIn (transposeParams),
308
278
::testing::Values(ElementType::f32 ),
309
- ::testing::Values(emptyConfig ),
279
+ ::testing::Values(CPUTestUtils::empty_plugin_config ),
310
280
::testing::ValuesIn(filter_specific_params(true )));
311
281
312
282
INSTANTIATE_TEST_SUITE_P (smoke_FC_2D_FP32,
@@ -317,7 +287,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_FP32,
317
287
const auto testParams2D_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes2D),
318
288
::testing::ValuesIn (transposeParams),
319
289
::testing::Values(ElementType::f16 , ElementType::bf16 ),
320
- ::testing::Values(emptyConfig ),
290
+ ::testing::Values(CPUTestUtils::empty_plugin_config ),
321
291
::testing::ValuesIn(filter_specific_params(false )));
322
292
323
293
INSTANTIATE_TEST_SUITE_P (smoke_FC_2D,
@@ -339,7 +309,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_FC_2D_BF16,
339
309
const auto testParams3D_FP32_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes3D),
340
310
::testing::ValuesIn (transposeParams),
341
311
::testing::Values(ElementType::f32 ),
342
- ::testing::Values(emptyConfig ),
312
+ ::testing::Values(CPUTestUtils::empty_plugin_config ),
343
313
::testing::ValuesIn(filter_specific_params(true )));
344
314
345
315
INSTANTIATE_TEST_SUITE_P (smoke_FC_3D_FP32,
@@ -350,7 +320,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_FC_3D_FP32,
350
320
const auto testParams3D_smoke = ::testing::Combine(::testing::ValuesIn(inputShapes3D),
351
321
::testing::ValuesIn (transposeParams),
352
322
::testing::Values(ElementType::f16 , ElementType::bf16 ),
353
- ::testing::Values(emptyConfig ),
323
+ ::testing::Values(CPUTestUtils::empty_plugin_config ),
354
324
::testing::ValuesIn(filter_specific_params(false )));
355
325
356
326
INSTANTIATE_TEST_SUITE_P (smoke_FC_3D,
@@ -464,26 +434,26 @@ class MatMulDecompressConvertTest2 : public MatMulDecompressConvertTest {
464
434
465
435
configuration.insert (additionalConfig.begin (), additionalConfig.end ());
466
436
467
- ElementType netType = ElementType::f32 ;
468
- ElementType convertOutType = ElementType::f32 ;
437
+ inType = outType = netType = ElementType::f32 ;
469
438
auto it = additionalConfig.find (ov::hint::inference_precision.name ());
470
439
if (it != additionalConfig.end () && it->second .as <ov::element::Type>() == ov::element::bf16 ) {
471
- convertOutType = inType = outType = netType = ElementType::bf16 ;
440
+ netType = ElementType::bf16 ;
472
441
weiConstElemType = (weiConstElemType != ElementType::f32 ) ? weiConstElemType : ElementType::bf16 ;
473
- } else {
474
- inType = outType = netType;
442
+ // Reorder between parameter and FullyConnected
443
+ // Note: reorder between FC and Result is not needed since FC primitive supports f32 output natively
444
+ reorderCount++;
475
445
}
476
446
477
447
std::string cpuNodeType = " FullyConnected" ;
478
- selectedType = makeSelectedTypeStr (selectedType, outType );
448
+ selectedType = makeSelectedTypeStr (selectedType, netType );
479
449
480
450
ov::ParameterVector params;
481
451
for (auto && shape : {inShapeFC0, inShapeFC1}) {
482
452
params.push_back (std::make_shared<ov::op::v0::Parameter>(inType, shape));
483
453
}
484
454
std::shared_ptr<ov::Node> inputWeights = ov::test::utils::make_constant (weiConstElemType, inShapeWeights.get_shape ());
485
- if (weiConstElemType == ElementType:: f16 ) {
486
- inputWeights = std::make_shared<ov::op::v0::Convert>(inputWeights, convertOutType );
455
+ if (weiConstElemType != inType ) {
456
+ inputWeights = std::make_shared<ov::op::v0::Convert>(inputWeights, inType );
487
457
mark_as_decompression (inputWeights);
488
458
}
489
459
expectedWeiConstElemType = weiConstElemType;
@@ -509,7 +479,7 @@ const auto testParams2D_FP16_2_smoke =
509
479
::testing::Combine (::testing::Values(static_shapes_to_test_representation({{2 , 3 }, {2 , 3 }, {3 , 4 }})),
510
480
::testing::Values(std::pair<bool , bool >{false , true }),
511
481
::testing::Values(ElementType::f16 ),
512
- ::testing::Values(emptyConfig ),
482
+ ::testing::Values(CPUTestUtils::empty_plugin_config ),
513
483
::testing::ValuesIn(filter_specific_params(false )));
514
484
515
485
INSTANTIATE_TEST_SUITE_P (smoke_FC_2D_FP16_2,
0 commit comments