xref: /aosp_15_r20/external/pytorch/cmake/public/ComputeLibrary.cmake (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1# Build with Compute Library backend for the Arm architecture
2# Note: Compute Library is available from: https://github.com/ARM-software/ComputeLibrary
3#   and must be built separately. The location of the Compute Library build
4#   must be set with the env var ACL_ROOT_DIR. This path will be checked later
5#   as part of FindACL.cmake in oneDNN.
6
7if(NOT USE_MKLDNN_ACL)
8    RETURN()
9endif()
10
11set(DNNL_AARCH64_USE_ACL ON CACHE BOOL "" FORCE)
12
13# Check the Compute Library version number.
14# Note: oneDNN / MKL-DNN v2.2 onwards will check the Compute Library version
15#   the version check here can be removed once PyTorch transitions to v2.2.
16set(ACL_MINIMUM_VERSION "21.02")
17
18file(GLOB_RECURSE ACL_VERSION_FILE $ENV{ACL_ROOT_DIR}/*/arm_compute_version.embed)
19
20if("${ACL_VERSION_FILE}" STREQUAL "")
21  message(WARNING "Build may fail: Could not determine ACL version (minimum required is ${ACL_MINIMUM_VERSION})")
22else()
23  file(READ ${ACL_VERSION_FILE} ACL_VERSION_STRING)
24  string(REGEX MATCH "v([0-9]+\\.[0-9]+)" ACL_VERSION ${ACL_VERSION_STRING})
25  set(ACL_VERSION "${CMAKE_MATCH_1}")
26
27  if(${ACL_VERSION} VERSION_EQUAL "0.0")
28    # Unreleased ACL versions come with version string "v0.0-unreleased", and may not be compatible with oneDNN.
29    # It is recommended to use the latest release of ACL.
30    message(WARNING "Build may fail: Using unreleased ACL version (minimum required is ${ACL_MINIMUM_VERSION})")
31  elseif(${ACL_VERSION} VERSION_LESS ${ACL_MINIMUM_VERSION})
32    message(FATAL_ERROR "Detected ACL version ${ACL_VERSION}, but minimum required is ${ACL_MINIMUM_VERSION}")
33  endif()
34endif()
35