From b63e20724a707d6035f70088306c44033f489456 Mon Sep 17 00:00:00 2001 From: "Li, Tingqian" Date: Thu, 9 Mar 2023 00:18:46 -0800 Subject: [PATCH 1/5] Fix crash issue: RuntimeError: Primitive descriptor was not found for node while/MatMul. --- src/plugins/intel_cpu/src/nodes/matmul.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/matmul.cpp b/src/plugins/intel_cpu/src/nodes/matmul.cpp index 98c1886aeb65d2..0df8e29d201371 100644 --- a/src/plugins/intel_cpu/src/nodes/matmul.cpp +++ b/src/plugins/intel_cpu/src/nodes/matmul.cpp @@ -624,6 +624,7 @@ void MatMul::prepareParams() { primitive_desc_iterator itpd = desc.createPrimitiveDescriptorIterator(engine, key.attr); matmul::primitive_desc prim_desc; + auto itpdFirst = itpd; while (static_cast(itpd)) { impl_desc_type impl_type = parse_impl_name(itpd.impl_info_str()); @@ -631,8 +632,10 @@ void MatMul::prepareParams() { prim_desc = itpd.get(); break; } - if (!itpd.next_impl()) - return matmul(); + if (!itpd.next_impl()) { + prim_desc = itpdFirst.get(); + break; + } } return matmul(prim_desc); }; From 151399fc3fc30c11db72cb2c0d021ca7e0e14b76 Mon Sep 17 00:00:00 2001 From: xipingya Date: Fri, 10 Mar 2023 00:31:17 -0500 Subject: [PATCH 2/5] Update variable name style to prim_desc, add some comments --- src/plugins/intel_cpu/src/nodes/matmul.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/matmul.cpp b/src/plugins/intel_cpu/src/nodes/matmul.cpp index 0df8e29d201371..faa9f7c5e41531 100644 --- a/src/plugins/intel_cpu/src/nodes/matmul.cpp +++ b/src/plugins/intel_cpu/src/nodes/matmul.cpp @@ -624,7 +624,7 @@ void MatMul::prepareParams() { primitive_desc_iterator itpd = desc.createPrimitiveDescriptorIterator(engine, key.attr); matmul::primitive_desc prim_desc; - auto itpdFirst = itpd; + auto itpd_first = itpd; while (static_cast(itpd)) { impl_desc_type impl_type = parse_impl_name(itpd.impl_info_str()); @@ -633,7 +633,10 @@ void MatMul::prepareParams() { break; } if (!itpd.next_impl()) { - prim_desc = itpdFirst.get(); + // implType(AMX) will be not in list when input dynamic shape for AMX. + // Bcause AMX will be available when it assumes batch 16 for dynamic shape in compile model. + // However if we only pass batch 1 in runtime, AMX will be not avaiable(Performance is low). + prim_desc = itpd_first.get(); break; } } From 14269ee6cd29a145ba6e83f5b9d4d9ec21cc4375 Mon Sep 17 00:00:00 2001 From: "Yan, Xiping" Date: Mon, 13 Mar 2023 15:53:21 +0800 Subject: [PATCH 3/5] Add test case to cover MatMul descriptor was not found bug. Signed-off-by: Yan, Xiping --- .../tests/functional/single_layer_tests/matmul.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul.cpp index 276f4abbd10fa8..ba14e14d2c8a2e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul.cpp @@ -1277,6 +1277,13 @@ INSTANTIATE_TEST_SUITE_P(nightly_MM_Brgemm_Amx_Static, MatMulLayerCPUTest, testB const std::vector IS_Brgemm_Dynamic = { + { + { + {{-1, 256}, {{1, 256}}}, + {{256, 384}, {{256, 384}}} + }, + {false, false} + }, { { {{-1, -1}, {{55, 12}, {33, 7}}}, From 0e2b8290c0473d73f0b28a05bc026319c4731863 Mon Sep 17 00:00:00 2001 From: "Yan, Xiping" Date: Mon, 13 Mar 2023 15:57:39 +0800 Subject: [PATCH 4/5] Fix comment word error. Signed-off-by: Yan, Xiping --- src/plugins/intel_cpu/src/nodes/matmul.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/src/nodes/matmul.cpp b/src/plugins/intel_cpu/src/nodes/matmul.cpp index faa9f7c5e41531..2b97c6c72e35bf 100644 --- a/src/plugins/intel_cpu/src/nodes/matmul.cpp +++ b/src/plugins/intel_cpu/src/nodes/matmul.cpp @@ -635,7 +635,7 @@ void MatMul::prepareParams() { if (!itpd.next_impl()) { // implType(AMX) will be not in list when input dynamic shape for AMX. // Bcause AMX will be available when it assumes batch 16 for dynamic shape in compile model. - // However if we only pass batch 1 in runtime, AMX will be not avaiable(Performance is low). + // However if we only pass batch 1 in runtime, AMX will be not available(Performance is low). prim_desc = itpd_first.get(); break; } From 690b2110d4ca515ecb9eca53752b472dac30bb7a Mon Sep 17 00:00:00 2001 From: "Yan, Xiping" Date: Tue, 14 Mar 2023 08:33:25 +0800 Subject: [PATCH 5/5] Update comments, gave more clear explanation. Signed-off-by: Yan, Xiping --- src/plugins/intel_cpu/src/nodes/matmul.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/matmul.cpp b/src/plugins/intel_cpu/src/nodes/matmul.cpp index 2b97c6c72e35bf..64722dea88e064 100644 --- a/src/plugins/intel_cpu/src/nodes/matmul.cpp +++ b/src/plugins/intel_cpu/src/nodes/matmul.cpp @@ -633,9 +633,10 @@ void MatMul::prepareParams() { break; } if (!itpd.next_impl()) { - // implType(AMX) will be not in list when input dynamic shape for AMX. - // Bcause AMX will be available when it assumes batch 16 for dynamic shape in compile model. - // However if we only pass batch 1 in runtime, AMX will be not available(Performance is low). + // In case of dynamic shapes an implementation type chosen as optimal for a primitive_desc with + // undefined input shapes, is not necessarily available for the primitive_desc with defined shape. + // Example: brgemm_avx512_amx (Intel Sapphire Rapids Platform) is available for a primitive with + // undefined input shapes but not available for primitive_desc with input batch 1. prim_desc = itpd_first.get(); break; }