Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for macos_arm64 #604

Closed
simonmaurer opened this issue Feb 10, 2021 · 6 comments
Closed

Support for macos_arm64 #604

simonmaurer opened this issue Feb 10, 2021 · 6 comments

Comments

@simonmaurer
Copy link
Contributor

simonmaurer commented Feb 10, 2021

tried to run lce_benchmark_model on an Apple Mac mini with M1.
turns out that this is not possible directly although the platform aarch64 is generally the same.

next step was trying to build it manually but it did not work since more adaptations for the bazel build system are needed (I assume it would need a different toolchain).

could you give me a hint on how to implement this properly such that we could do:

bazel build --config=macos_arm64 //larq_compute_engine/tflite/benchmark:lce_benchmark_model

or for the whole pip package of larq_compute_engine

bazel build --config=macos_arm64 :build_pip_pkg

since commit bab0d14036efd0adcd4e48303d045cee3c342cb0 it is possible
to build TF2.4 for Apple silicon as explained here.
I checked the subrepo of TF within larq_compute_engine, which currently is at commit 85c8b2a817f95a3e979ecd1ed95bff1dc1335cff so this is not yet included

@lgeiger lgeiger self-assigned this Feb 10, 2021
@lgeiger
Copy link
Member

lgeiger commented Feb 10, 2021

Unfortunately we are not able to give you concrete guidance here as we don't have access to Apple Silicon at the moment.

From the PR you linked it should be possible to update the TensorFlow dependency to a newer commit here, although I am not sure if this would require additional changes to our code.
Then, you will need to manually apply the changes of the PR to our .bazelrc and add the missing platform config_setting here.

I would start with lce_benchmark_model as it has a lot fewer dependencies that could lead to problems and once that compiles correctly look into building the entire pip package.

@lgeiger lgeiger removed their assignment Feb 10, 2021
@simonmaurer
Copy link
Contributor Author

so for a start I changed the .bazelrc and CONFIG according to these PR changes.
since you mentioned updating the SHA hash here: is larq compiled using TF by downloading that .tar.gz package ?
cause I also thought I had to update the tensorflow subrepo to that newer commit.

@AdamHillier
Copy link
Contributor

Hey Simon, when building with Bazel the tar.gz file that's in the WORKSPACE file you linked to gets used, and the TF submodule is used for Makefile builds. We tend to use Bazel for almost everything so the WORKSPACE file is what matters, but when we update TF versions we always bump the submodule as well to keep them in sync.

@simonmaurer
Copy link
Contributor Author

simonmaurer commented Feb 26, 2021

so workin on this front also revealed some updates.

  1. bazel: with the aforementioned changes in WORKSPACE using a more recent TF (mid January) tar.gz and BUILD I was able to build the lce_minimal example. however lce_benchmark_model/pip_package do not work yet (also tried compiling the lce_benchmark_model from offical TF repo) which resulted in errors with respect to XNNPACK. (the bazel compilation automatically builds with xnnpack whereas LCE make script does not). this is due to XNNPACK not being able to build using bazel, check this issue
  2. make: with the aforementioned changes I was able to compile the lce_benchmark_model (actually the binary will be called lce_benchmark) for macos_arm64using

larq_compute_engine/tflite/build_make/build_lce.sh --native

this works and I evaluated the QuickNet models. the performance is quite stunning. LARQ doc would also be a nice place to show these numbers

  1. I made a pull request on the official TF repo to allow a host compilation using cmake for TensorFlow Lite library and the benchmark_model on macos_arm64.

the LCE make script uses TF's makefile but without '-D' options as described here. how could XNNPACK be activated using lce_benchmark --use_xnnpack=true ? this question only refers to the make build, whereas when using bazel (which currently not possible on macos_arm64) the lce_benchmark_modelbinary does have the --use_xnnpack flag

@simonmaurer
Copy link
Contributor Author

@lgeiger @Tombana @AdamHillier as stated above bazel builds are not yet possible (due to TensorFlow Lite dependencies on XNNPACK but I issued a PR there.

once this gets accepted, I can issue a PR in the official TensorFlow repo. this should allow bazel builds of the TensorFlow Lite libraryand the benchmark_model for the macos_arm64platform.

@simonmaurer
Copy link
Contributor Author

Closing this issue as #664 fixes this and has been merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants