tensorflow / swift

Swift for TensorFlow
https://tensorflow.org/swift
Apache License 2.0
6.13k stars 608 forks source link

Feature Request: Apple Silicon Support #565

Open ifsheldon opened 4 years ago

ifsheldon commented 4 years ago

As Apple begins to ship new Macbooks with Apple Silicon and Tensforflow was claimed to support Apple Silicon, I wonder whether Swift for Tensorflow will work on Apple Silicon-based Macs. Or, does it work with Rosseta2?

RahulBhalley commented 3 years ago

I hope Apple Silicon will help in focusing S4TF towards macOS and Xcode. It will be really awesome if we could simply add S4TF package in Xcode (without installing custom S4TF toolchain, of course after differentiation been baked into stable Swift toolchains) and use it with M chip series accelerated Macs. I think this is important because it helps in keeping the training algorithm private as opposed to cloud computing.

Maybe this is a dumb thought, but I was wondering how could Swift's differentiation (in compiler) could possibly take advantage of ML Compute (written in Metal). 🤔

ifsheldon commented 3 years ago

@rahulbhalley You may want to take a look at the TF release by Apple, but Apple did not release the source code, which is not so friendly

RahulBhalley commented 3 years ago

@ifsheldon yea, I've seen that.

compnerd commented 3 years ago

There are a few different things being discussed here.

@rahulbhalley I think that supporting ASi is a completely different task from using stock toolchains. The work required for both is completely disjoint.

Use of acceleration in X10 is yet a separate item.

I'd rather not this issue become a tracker for wishlist items, but stay focused on the specifics to support ASi.

As to supporting ASi, I think that it should be possible to do that. I did take a stab at getting Swift building (a while ago) and found that there was a bunch of work to be done. After fixing things like libdispatch and the runtime, I got to the point where the swift compiler test suite was passing. However, the next stage requires building swift-apis. That in turn requires x10 where the problem lies. x10 has a dependency on tensorflow, which requires bazel, which requires the JVM which is not (or at least was not?) available. It should be possible to cross-compile now I believe, which was not possible when I had looked at it. Thanks to the use of CMake, I'd say that if we can get x10 built, the rest should be possible to get through.

The one thing to remember is that although ASi is similar to AArch64, it is merely derived from it, and is not identical. So, although it is possible to use items on ARM64 Linux, that does not immediately translate into ASi support.