From ce1bcd2a765ff86cc603507b3bd7d9006e4d25c8 Mon Sep 17 00:00:00 2001 From: Bo Liu Date: Sat, 28 Sep 2024 06:11:29 +0800 Subject: [PATCH] [CPU] change Eltwise layout selection logic for x86 non-CNN ModelType (#26419) ### Details: - *change Eltwise layout selection logic for x86 non-CNN ModelType, several llm models gain performance benefits from this change since additional reorder operators have been avoided, e.g. phi3 and bloomz* - *details can be found in the [ticket discussion](https://jira.devtools.intel.com/browse/CVS-148780).)* ### Tickets: - *148780* --- src/plugins/intel_cpu/src/nodes/eltwise.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/eltwise.cpp b/src/plugins/intel_cpu/src/nodes/eltwise.cpp index 1a8986557692a2..f2f6ce503bd5e4 100644 --- a/src/plugins/intel_cpu/src/nodes/eltwise.cpp +++ b/src/plugins/intel_cpu/src/nodes/eltwise.cpp @@ -2591,11 +2591,19 @@ void Eltwise::initSupportedPrimitiveDescriptors() { return; #endif - if (isChannelsFirstApplicable) - supportedPrimitiveDescriptors.emplace_back(initDesc(ChannelsFirst)); - if (isBlockedApplicable) - supportedPrimitiveDescriptors.emplace_back(initDesc(Blocked)); - supportedPrimitiveDescriptors.emplace_back(initDesc(Planar)); + if (context->getConfig().modelType == Config::ModelType::CNN) { + if (isChannelsFirstApplicable) + supportedPrimitiveDescriptors.emplace_back(initDesc(ChannelsFirst)); + if (isBlockedApplicable) + supportedPrimitiveDescriptors.emplace_back(initDesc(Blocked)); + supportedPrimitiveDescriptors.emplace_back(initDesc(Planar)); + } else { + supportedPrimitiveDescriptors.emplace_back(initDesc(Planar)); + if (isChannelsFirstApplicable) + supportedPrimitiveDescriptors.emplace_back(initDesc(ChannelsFirst)); + if (isBlockedApplicable) + supportedPrimitiveDescriptors.emplace_back(initDesc(Blocked)); + } } void Eltwise::createPrimitive() {