Swift for TensorFlow Now Open Source on GitHub

Google's integration of its TensorFlow machine learning framework with Apple's Swift programming language, known as Swift for TensorFlow, is now an open source project on GitHub.

Google's TensorFlow is a popular open source computational framework for developing machine learning (ML) models built around the concept of computational graphs that describe how data flows among mathematical operations. It provides APIs for Python, C++, Haskell, Java, Go, and Rust, and there's a third-party package for R. Swift is Apple's a general-purpose, compiled language for iOS, macOS, watchOS, tvOS and Linux.

The two were combined as an early stage open source project earlier this year, called "TensorFlow integrated with Swift" (TFiwS). That project aimed to provide "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," the company said in a blog post.

"Eager execution" refers to TensorFlow's imperative programming environment, which is designed to evaluate operations immediately, without an extra graph-building step.

The renamed Swift for TensorFlow was introduced by Chris Lattner, director of engineering at TensorFlow, during his keynote at the TensorFlow Developer Summit in March. This is more than just a TensorFlow API wrapper written in Swift, he said. It includes a compiler and language enhancements to Swift that provide "a first-class user experience for machine learning developers."

One of the questions that has come up on community discussion boards about this development is, Why Swift? Lattner explained his company's reasoning. Swift has a lightweight syntax, he said, making it easy to use and learn. It has a modern design that draws on best practices from many sources, including generics and functional programming. It has an interpreter and scripting capabilities. It's great in notebook environments. And it's open source, which means it's portable to lots of platforms and it has a large community.

"But the number one thing that's most important thing to us [about Swift] is that it has a fully open design environment called Swift Evolution," Lattner said, "which allows us to propose first-class machine learning language and compiler features directly for integration into Swift."

The addition of Swift support is certain to make the TensorFlow framework even more popular among AI developers, said Jay Swartz, chief science officer at Blackbox AI. "Swift adds a powerful mobile component to TensorFlow," Swartz said, "which is the most broadly used AI development technology. This will improve developer's ability to push AI to the edge and into people's hands."

Google has published a "Swift for TensorFlow Design Overview" document on GitHub to help users get started.

About the Author

John K. Waters is the editor in chief of a number of sites, with a focus on high-end development, AI and future tech. He's been writing about cutting-edge technologies and culture of Silicon Valley for more than two decades, and he's written more than a dozen books. He also co-scripted the documentary film Silicon Valley: A 100 Year Renaissance, which aired on PBS.  He can be reached at [email protected].