From ce109b3f79d47618c37d11fa7066d05e9158f803 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Thu, 16 Oct 2025 13:14:17 -0700 Subject: [PATCH] Add `torch.backends.mkldnn.is_acl_available()` method (#165678) That tells whether or not PyTorch was compiled with Arm Compute Library Pull Request resolved: https://github.com/pytorch/pytorch/pull/165678 Approved by: https://github.com/Skylion007, https://github.com/atalman, https://github.com/albanD ghstack dependencies: #165583, #165584, #165676 --- torch/_C/__init__.pyi.in | 1 + torch/backends/mkldnn/__init__.py | 5 +++++ torch/csrc/Module.cpp | 2 ++ 3 files changed, 8 insertions(+) diff --git a/torch/_C/__init__.pyi.in b/torch/_C/__init__.pyi.in index c7e2c608ab53..244200216ec9 100644 --- a/torch/_C/__init__.pyi.in +++ b/torch/_C/__init__.pyi.in @@ -1442,6 +1442,7 @@ _has_cuda: _bool _has_magma: _bool _has_xpu: _bool _has_mkldnn: _bool +_has_mkldnn_acl: _bool _has_cudnn: _bool _has_cusparselt: _bool has_spectral: _bool diff --git a/torch/backends/mkldnn/__init__.py b/torch/backends/mkldnn/__init__.py index ae76a9f20c46..a98c2cb64dfc 100644 --- a/torch/backends/mkldnn/__init__.py +++ b/torch/backends/mkldnn/__init__.py @@ -19,6 +19,11 @@ def is_available(): return torch._C._has_mkldnn +def is_acl_available(): + r"""Return whether PyTorch is built with MKL-DNN + ACL support.""" + return torch._C._has_mkldnn_acl + + VERBOSE_OFF = 0 VERBOSE_ON = 1 VERBOSE_ON_CREATION = 2 diff --git a/torch/csrc/Module.cpp b/torch/csrc/Module.cpp index 4f99fa40bc6c..4a864daa8c12 100644 --- a/torch/csrc/Module.cpp +++ b/torch/csrc/Module.cpp @@ -2701,6 +2701,8 @@ Call this whenever a new thread is created in order to propagate values from ASSERT_TRUE(set_module_attr("_has_xpu", has_xpu)); ASSERT_TRUE( set_module_attr("_has_mkldnn", at::hasMKLDNN() ? Py_True : Py_False)); + ASSERT_TRUE(set_module_attr( + "_has_mkldnn_acl", AT_MKLDNN_ACL_ENABLED() ? Py_True : Py_False)); ASSERT_TRUE(set_module_attr("_GLIBCXX_USE_CXX11_ABI", Py_True));