Swift for TensorFlow is now open source

0
1684
3 min read

TensorFlow has continued its success in 2017 well into 2018. It’s quickly expanding its capabilities, and we’re beginning to see it used by engineers that aren’t data specialists.  We’ve seen that in the launch of TensorFlow.js, which allows you to bring machine learning to the browser. But Swift for TensorFlow is a slightly different proposition. In fact, it does two things. On the one hand it offers a new way of approaching TensorFlow, but it also helps to redefine Swift.

Let’s be honest – Swift has come a long way since it was first launched by Apple back at WWDC 2014. Back then it was a new language created to reinvigorate iOS development. It was meant to make Apple mobile developers happier and more productive. That is, of course, a noble aim – and by and large it seems to have worked. If it hadn’t we probably wouldn’t still be talking about it. But Swift for TensorFlow marks Swift as a powerful modern programming language that can be applied to some of the most complex engineering problems.

What is Swift for TensorFlow?

Swift for TensorFlow was first unveiled at the TensorFlow Dev Summit in March 2018. Now it’s open source, it’s going to be interesting to see how it shapes the way engineers use TensorFlow – and, of course, how the toolchain might shift.

But what is it exactly? Watch the video below, recorded at TensorFlow Dev Summit, to find out more.


Here’s what the TensorFlow team had to say about Swift for TensorFlow in a detailed post on Medium.

“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.”

Why did TensorFlow choose Swift?

This is perhaps the key question: why did the TensorFlow team decide to use Swift for this project? The team themselves note that they are often asked this question themselves. Considering many of the features of Swift for TensorFlow can easily be implemented in other programming languages, it’s a reasonable question to ask.

To properly understand why TensorFlow chose Swift you need to go back to the aims of the project. And they’re actually quite simple – the team want to make TensorFlow more usable. They explain:

“We quickly realized that our core static analysis-based Graph Program Extraction algorithm would not work well for Python given its highly dynamic nature. This led us down the path of having to pick another language to work with, and we wanted to approach this methodically.”

The post on GitHub is well worth reading. It provides a detailed insight into how to best go about evaluating the advantages and disadvantages of one programming language over another.

Incidentally, The TensorFlow team say the final shortlist of languages was Swift, Rust, Julia, and C++. Swift ended up winning out – there were ‘usability concerns’ around C++ and Rust, and compared to Julia not only was there a larger and more active community, it is also much more similar to Python in terms of syntax.

LEAVE A REPLY

Please enter your comment!
Please enter your name here