Introducing Swift For TensorFlow
april 26, 2018
Posted by the Swift for TensorFlow team at Google

Swift logo and TensorFlow logo

At the TensorFlow Developer Summit in March, we announced and demo’d the Swift for TensorFlow project. Now, we’re excited to launch Swift for TensorFlow as an open-source project on GitHub!



Swift for TensorFlow provides a new programming model that combines the performance of graphs with the flexibility and expressivity of Eager execution, with a strong focus on improved usability at every level of the stack. This is not just a TensorFlow API wrapper written in Swift — we added compiler and language enhancements to Swift to provide a first-class user experience for machine learning developers.

Our approach is a new and different way to use TensorFlow, opening new design opportunities and new avenues for solving existing problems. Though the project is in early development, we’ve decided to open-source it and move our design discussions to a public mailing list so anyone interested in the project can get involved.

Design documentation

We’ve written some detailed documents to outline our approach and explain how things work, all accessible from our project README. A good place to start is the Swift for TensorFlow Design Overview, which explains the major components of the project and how they fit together.

After that, we have a few documents which dive deeper into important areas of the project. A cornerstone of our design is an algorithm we call Graph Program Extraction, which allows you to write in an eager execution-style programming model while retaining all of the benefits of graphs. Our design also includes support for advanced automatic differentiation built directly into Swift. We also have a deep dive on Python integration with Swift, which allows you to use arbitrary Python APIs directly from Swift code.

Finally, our Graph Program Extraction approach imposed several technical constraints on our implementation, which led us to choosing Swift as a host language. The Why *Swift* for TensorFlow? deep dive explains the tradeoffs in more detail, along with the decision process that led to this choice.

Get involved!

It is a bit too early to rewrite your deep learning models using Swift for TensorFlow, but if you’re interested in ML, languages and compilers, there are many ways you can get involved and contribute. We have pre-built packages for macOS and Linux that you can try now, along with a sample MNIST model. We also have instructions for building from source. At this phase of the project, there are many known issues — if you run into trouble, please reach out to us on our mailing list.

We are excited about building a beautiful new interface to TensorFlow that users will love, and we would really like to hear what you think about the project!

The Swift for TensorFlow Team
Next post
Introducing Swift For TensorFlow

Posted by the Swift for TensorFlow team at Google


At the TensorFlow Developer Summit in March, we announced and demo’d the Swift for TensorFlow project. Now, we’re excited to launch Swift for TensorFlow as an open-source project on GitHub!



Swift for TensorFlow provides a new programming model that combines the performance of graphs with the flexibility and expressivity of Eager execution, with a s…