pytorch/cmake/public/ComputeLibrary.cmake
Nathan John Sircombe bf00d26deb Enables builds with Compute Library backend for oneDNN (#55913)
Summary:
Since v1.7, oneDNN (MKL-DNN) has supported the use of Compute Library
for the Arm architeture to provide optimised convolution primitives
on AArch64.

This change enables the use of Compute Library in the PyTorch build.
Following the approach used to enable the use of CBLAS in MKLDNN,
It is enabled by setting the env vars USE_MKLDNN and USE_MKLDNN_ACL.
The location of the Compute Library build must be set useing `ACL_ROOT_DIR`.

This is an extension of the work in https://github.com/pytorch/pytorch/pull/50400
which added support for the oneDNN/MKL-DNN backend on AArch64.

_Note: this assumes that Compute Library has been built and installed at
ACL_ROOT_DIR. Compute library can be downloaded here:
`https://github.com/ARM-software/ComputeLibrary`_

Fixes #{issue number}

Pull Request resolved: https://github.com/pytorch/pytorch/pull/55913

Reviewed By: ailzhang

Differential Revision: D28559516

Pulled By: malfet

fbshipit-source-id: 29d24996097d0a54efc9ab754fb3f0bded290005
2021-05-20 07:43:56 -07:00

35 lines
1.6 KiB
CMake

# Build with Compute Library backend for the Arm architecture
# Note: Compute Library is available from: https://github.com/ARM-software/ComputeLibrary
# and must be built separately. The location of the Compute Library build
# must be set with the env var ACL_ROOT_DIR. This path will be checked later
# as part of FindACL.cmake in oneDNN.
if(NOT USE_MKLDNN_ACL)
RETURN()
endif()
set(DNNL_AARCH64_USE_ACL ON CACHE BOOL "" FORCE)
# Check the Compute Library version number.
# Note: oneDNN / MKL-DNN v2.2 onwards will check the Compute Library version
# the version check here can be removed once PyTorch transitions to v2.2.
set(ACL_MINIMUM_VERSION "21.02")
file(GLOB_RECURSE ACL_VERSION_FILE $ENV{ACL_ROOT_DIR}/*/arm_compute_version.embed)
if("${ACL_VERSION_FILE}" STREQUAL "")
message(WARNING "Build may fail: Could not determine ACL version (minimum required is ${ACL_MINIMUM_VERSION})")
else()
file(READ ${ACL_VERSION_FILE} ACL_VERSION_STRING)
string(REGEX MATCH "v([0-9]+\\.[0-9]+)" ACL_VERSION ${ACL_VERSION_STRING})
set(ACL_VERSION "${CMAKE_MATCH_1}")
if(${ACL_VERSION} VERSION_EQUAL "0.0")
# Unreleased ACL versions come with version string "v0.0-unreleased", and may not be compatible with oneDNN.
# It is recommended to use the latest release of ACL.
message(WARNING "Build may fail: Using unreleased ACL version (minimum required is ${ACL_MINIMUM_VERSION})")
elseif(${ACL_VERSION} VERSION_LESS ${ACL_MINIMUM_VERSION})
message(FATAL_ERROR "Detected ACL version ${ACL_VERSION}, but minimum required is ${ACL_MINIMUM_VERSION}")
endif()
endif()