Skip to content

Commit

Permalink
Add fp32 executor
Browse files Browse the repository at this point in the history
  • Loading branch information
mory91 committed Nov 14, 2024
1 parent 4b52286 commit a745ed1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/plugins/intel_cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ if(RISCV64_XUANTIE)
else()
set(ENABLE_SHL_FOR_CPU_DEFAULT OFF)
endif()
set(ENABLE_KLEIDIAI_FOR_CPU ON)
ov_dependent_option(ENABLE_SHL_FOR_CPU "Enable SHL for OpenVINO CPU Plugin" ${ENABLE_SHL_FOR_CPU_DEFAULT} "RISCV64" OFF)

add_subdirectory(thirdparty)
Expand Down Expand Up @@ -175,6 +176,11 @@ if(DNNL_USE_ACL)
set(OV_CPU_WITH_ACL ON)
endif()

if(ENABLE_KLEIDIAI_FOR_CPU)
add_definitions(-DOV_CPU_WITH_KLEIDIAI)
set(OV_CPU_WITH_KLEIDIAI ON)
endif()

if(OV_CPU_WITH_ACL)
set(CMAKE_CXX_STANDARD 14)
endif()
Expand Down Expand Up @@ -273,6 +279,7 @@ if(ENABLE_SHL_FOR_CPU)
endif()
if(ENABLE_KLEIDIAI_FOR_CPU)
target_link_libraries(${TARGET_NAME} PRIVATE kleidiai)
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $<TARGET_PROPERTY:kleidiai,INCLUDE_DIRECTORIES>)
endif()
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE $<TARGET_PROPERTY:dnnl,INCLUDE_DIRECTORIES>)

Expand Down
9 changes: 8 additions & 1 deletion src/plugins/intel_cpu/src/nodes/executors/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ namespace intel_cpu {
# define OV_CPU_INSTANCE_DNNL(...)
#endif

#if defined(OV_CPU_WITH_KLEIDIAI)
# define OV_CPU_INSTANCE_KLEIDIAI(...) {__VA_ARGS__},
#else
# define OV_CPU_INSTANCE_KLEIDIAI(...)
#endif

#if defined(OPENVINO_ARCH_X86_64)
# define OV_CPU_INSTANCE_X64(...) {__VA_ARGS__},
#else
Expand Down Expand Up @@ -86,7 +92,8 @@ enum class ExecutorType {
Acl,
Mlas,
jit_aarch64,
Shl
Shl,
Kleidiai
};

enum class OperationType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ov_optional.hpp"
#include "utils/cpp/maybe_unused.hpp"
#include "utils/debug_capabilities.h"
#include "nodes/executors/kleidiai/kleidiai_mm.hpp"

#if defined(OV_CPU_WITH_ACL)
#include "nodes/executors/acl/acl_fullyconnected.hpp"
Expand Down Expand Up @@ -208,6 +209,27 @@ OV_CPU_MAYBE_UNUSED_FUNCTION static inline bool noPostOps(const FCConfig& config
template <>
const std::vector<ExecutorImplementation<FCAttrs>>& getImplementations() {
static const std::vector<ExecutorImplementation<FCAttrs>> fullyconnectedImplementations {
OV_CPU_INSTANCE_KLEIDIAI(
"fullyconnected_kleidiai",
ExecutorType::Kleidiai,
OperationType::MatMul,
ShapeTolerance::Agnostic,
// supports
[](const FCConfig& config) -> bool {
return MatMulKleidiAIExecutor::supports(config);
},
// requiresFallback
[](const FCConfig& config) -> ov::optional<executor::Config<FCAttrs>> {
return {};
},
// acceptsShapes
[](const MemoryArgs& memory) -> bool {
return true;
},
// create
[](const FCAttrs& attrs, const PostOps& postOps, const MemoryArgs& memory, ExecutorContext::CPtr context) {
return std::make_shared<MatMulKleidiAIExecutor>(attrs, postOps, memory, context);
})
OV_CPU_INSTANCE_MLAS_X64(
"fullyconnected_mlas",
ExecutorType::Mlas,
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/intel_cpu/thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ endif()

if(ENABLE_KLEIDIAI_FOR_CPU)
set(KLEIDIAI_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
add_subdirectory(kleidiai)
ov_install_static_lib(kleidiai ${OV_CPACK_COMP_CORE})
# ov_install_static_lib(kleidiai ${OV_CPACK_COMP_CORE})
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
endif()

ov_add_onednn()

0 comments on commit a745ed1

Please sign in to comment.