Enable Direct Use of Arm Compute Library (ACL) in ATen (#148584)

ACL is already built with PyTorch as a shared library when USE_MKLDNN_ACL is set.
Currently, it is only used indirectly in ATen via oneDNN for AArch64 targets. However there are cases where it makes sense to utilize ACL directly without  oneDNN as an intermediary - e.g. quantization. See #145942, #147337, #146620.
This patch enables such use cases by exposing ACL to ATen

Pull Request resolved: https://github.com/pytorch/pytorch/pull/148584
Approved by: https://github.com/malfet
This commit is contained in:
Fadi Arafeh 2025-03-06 23:37:18 +00:00 committed by PyTorch MergeBot
parent 00cabd4235
commit d1f21d8ec3
3 changed files with 72 additions and 0 deletions

View File

@ -472,6 +472,11 @@ if(MKLDNN_FOUND)
list(APPEND ATen_CPU_DEPENDENCY_LIBS ${MKLDNN_LIBRARIES}) list(APPEND ATen_CPU_DEPENDENCY_LIBS ${MKLDNN_LIBRARIES})
endif(MKLDNN_FOUND) endif(MKLDNN_FOUND)
if(USE_MKLDNN_ACL)
list(APPEND ATen_CPU_INCLUDE ${ACL_INCLUDE_DIRS})
list(APPEND ATen_CPU_DEPENDENCY_LIBS ${ACL_LIBRARIES})
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x|ppc64le)$") if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x|ppc64le)$")
list(APPEND ATen_CPU_DEPENDENCY_LIBS cpuinfo) list(APPEND ATen_CPU_DEPENDENCY_LIBS cpuinfo)
endif() endif()

View File

@ -1229,6 +1229,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/../aten/src/ATen/native/quantized/qlinear_unpack.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/../aten/src/ATen/native/quantized/qlinear_unpack.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
endif() endif()
if(USE_MKLDNN_ACL)
find_package(ACL REQUIRED)
target_include_directories(torch_cpu PRIVATE ${ACL_INCLUDE_DIRS})
endif()
target_include_directories(torch_cpu PRIVATE ${ATen_CPU_INCLUDE}) target_include_directories(torch_cpu PRIVATE ${ATen_CPU_INCLUDE})
target_include_directories(torch_cpu PRIVATE target_include_directories(torch_cpu PRIVATE

View File

@ -0,0 +1,62 @@
# Copied from: https://github.com/oneapi-src/oneDNN/blob/main/cmake/FindACL.cmake
# ----------
# FindACL
# ----------
#
# Finds the Arm Compute Library
# https://arm-software.github.io/ComputeLibrary/latest/
#
# This module defines the following variables:
#
# ACL_FOUND - True if ACL was found
# ACL_INCLUDE_DIRS - include directories for ACL
# ACL_LIBRARIES - link against this library to use ACL
#
# The module will also define two cache variables:
#
# ACL_INCLUDE_DIR - the ACL include directory
# ACL_LIBRARY - the path to the ACL library
#
# Use ACL_ROOT_DIR environment variable to find the library and headers
find_path(ACL_INCLUDE_DIR
NAMES arm_compute/graph.h
PATHS ENV ACL_ROOT_DIR
)
find_library(ACL_LIBRARY
NAMES arm_compute
PATHS ENV ACL_ROOT_DIR
PATH_SUFFIXES lib build
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ACL DEFAULT_MSG
ACL_INCLUDE_DIR
ACL_LIBRARY
)
mark_as_advanced(
ACL_LIBRARY
ACL_INCLUDE_DIR
)
# Find the extra libraries and include dirs
if(ACL_FOUND)
find_path(ACL_EXTRA_INCLUDE_DIR
NAMES half/half.hpp
PATHS ENV ACL_ROOT_DIR
PATH_SUFFIXES include
)
find_library(ACL_GRAPH_LIBRARY
NAMES arm_compute_graph
PATHS ENV ACL_ROOT_DIR
PATH_SUFFIXES lib build
)
list(APPEND ACL_INCLUDE_DIRS
${ACL_INCLUDE_DIR} ${ACL_EXTRA_INCLUDE_DIR})
list(APPEND ACL_LIBRARIES
${ACL_LIBRARY} ${ACL_GRAPH_LIBRARY})
endif()