XNNPACK icon indicating copy to clipboard operation
XNNPACK copied to clipboard

macOS_arm64 build

Open simonmaurer opened this issue 5 years ago • 5 comments

hi y'all

with the aim of compiling the benchmark_model in TF (as this depends on XNNPACK) on commit c2db3a8fae0f6558e9dbdee79e67e74c1e95981c I was trying to build the end2end_bench using bazel 4.0.0 (ARM64)

the docs state a macOS support for arm64, I assume this only holds true when using cmake. so I added configs macos_arm64by updating .bazelrc, build_defs.bzl, cpuinfo.BUILD, BUILD.bazel and then run:

bazel build --config=macos_arm64 :end2end_bench

compiling with ios_arm64 as build config works fine. however not with macos_arm64 even though the macOS should be using the iOS kernels

could you give me a hint on how to build for platform macos_arm64 with bazel ? @Maratyszcza

simonmaurer avatar Feb 16 '21 01:02 simonmaurer

any feedback with respect to this?

simonmaurer avatar Feb 24 '21 17:02 simonmaurer

Bazel build for ARM64 Mac is currently not supported. CMake build should work.

Maratyszcza avatar Feb 24 '21 19:02 Maratyszcza

@Maratyszcza okay thanks for the feedback. issued a pull request in the official TensorFlow repo to allow building on platform macos_arm64 using cmake.

could you give me a hint on where to make changes to allow bazel builds ? already modified the following files: bazel.rc, BUILD.bazel, build_defs.bzl, third_party/cpuinfo.BUILD, see the changes (inspired by this commit in the official TF repo)

simonmaurer avatar Feb 27 '21 12:02 simonmaurer

These changes should be sufficient

Maratyszcza avatar Feb 27 '21 16:02 Maratyszcza

PR to resolve this. allows compilation for macos_arm64on M1 host using:

bazel build -c opt --config=macos_arm64 :end2end_bench

cross compilation on other platforms (e.g. Linux or macOS_x86-64) does not work yet due to missing toolchains. at least I get the following errors when building on a macOS_x86-64 platform for macos_arm64:

ERROR: /private/var/tmp/**/**/external/local_config_cc/BUILD:48:19: in cc_toolchain_suite rule @local_config_cc//:toolchain: cc_toolchain_suite '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'darwin_arm64' INFO: Repository cpuinfo instantiated at: /**/**/**/**/xnnpack_simonmaurer/WORKSPACE:66:13: in <toplevel> Repository rule http_archive defined at: /private/var/tmp/**/**/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel> ERROR: Analysis of target '//:end2end_bench' failed; build aborted: Analysis of target '@local_config_cc//:toolchain' failed

simonmaurer avatar Mar 05 '21 17:03 simonmaurer