Introducing Swift for Tensorflow

I just was wondering, everything is cool. ;)

This is up now, docs and more info is here: GitHub - tensorflow/swift: Swift for TensorFlow

27 Likes

I just watched the presentation from Mar 6, 2019, and am hoping this means our iOS project can use Swift for Tensorflow instead of the C++ Tensorflow we're currently using. I went to see what it takes to install it (e.g. is it available as a Framework for Xcode), and see that it requires special build tools.

Will (are) those new swiftc features be integrated into Xcode 11 or 12?

I ask because it seems the selected toolchain applies to the whole IDE, rather than, say a target within a project. We don't want to have to manually switch between toolchains to build our project.

1 Like

i don't think this will heppen any time soon, even current state of swift is too too apple centric, there is no proper support for other platforms (other then darwin), swift is really good langauge but i think rust is properly executed (ie)
what we need here is swift foundation away from apple, clean implementation with all platforms supports and proper standard library

1 Like

If the differentiable programming features are upstreamed then yes, eventually those will be available in Xcode. TensorFlow the library probably will never be directly available in Xcode, and I can't speak as to whether it'll be made to work directly on iOS or not. My understanding is the current implementation still relies heavily on Python interop.

No, no, I wouldn't expect the library to be in Xcode. I just don't want to have to switch between toolchains; that seems fraught with danger.

1 Like

The implementation of the TensorFlow library does not rely on Python interop, except for a very very tiny part which provides convenience APIs for converting numpy arrays. It is guarded by #if camImport(Python).

1 Like

The TensorFlow library is a SwiftPM package. It depends almost exclusively on the differentiable programming feature, which we plan to push through Swift Evolution this year.

Assuming the differentiable programming feature had landed in master, the only other thing you need to compile TensorFlow package is to set up a CTensorFlow module map, which you can do with SwiftPM.

So in short, a fork of the compiler toolchain is not where we are headed in the long term. Instead, we try to push technologies to become included in the official Swift.

13 Likes

This is what I'm hoping for. If Xcode let me choose the toolchain per-target, it might not matter so much, but it gets really cumbersome to need a different toolchain if I want to use TensorFlow inside my iOS app.

That's great to hear :) Though we haven't prioritized making all that possible today, it is absolutely important to us that iOS and Android apps can be developed using Swift for TensorFlow like a normal Swift library. The support for it is non-trivial because we'll need technologies such as MLIR to make sure mobile inference/training is efficient. Stay tuned :)

3 Likes