Swift for TensorFlow Shuts Down

Swift for TensorFlow was once an experiment in the next-generation platform for machine discovering out, incorporating the latest research all the map by machine discovering out, compilers, differentiable programming, techniques function, and past. It was once archived in February 2021. Some essential achievements from this project consist of:

  • Added language-integrated differentiable programming into the Swift language. This work continues in the legit Swift compiler.
  • Developed a mutable-value-semantics-oriented deep discovering out API
  • Fostered the come of a model garden with more than 30 fashions from a form of deep discovering out disciplines.
  • Enabled unusual research that combines deep discovering out with probabilistic graphical fashions for 3D motion tracking and past.
  • Powered a(n almost) pure-Swift prototype of a GPU+CPU runtime supporting pmap.
  • Spun off plenty of beginning offer facet efforts which proceed to be below stuffed with life pattern:
    • PythonKit: Python interoperability with Swift.
    • swift-jupyter: Permits converse of Swift within Jupyter notebooks.
    • swift-benchmark: Affords a sturdy benchmarking suite for Swift code.
  • Spun off several varied beginning offer efforts:
    • penguin: Parallel programming, records structures, graph algorithms, and more.
    • Tensors Fitting Perfectly: Static prognosis of tensor shape mismatches.
  • Swift-evolution proposals proposed and utilized:
    • SE-0195: Person-defined “Dynamic Member Search for” Kinds
    • SE-0216: Introduce consumer-defined dynamically “callable” kinds
    • SE-0233: Build Numeric Refine a fresh AdditiveArithmetic Protocol
    • SE-0253: Callable values of consumer-defined nominal kinds

This scheme will no longer get additional updates. The API documentation and binary downloads will proceed to be accessible in addition as the Open Beget Overview meeting recordings.

Getting started

The utilization of Swift for TensorFlow

  • Google Colaboratory: The quickest manner to gain started is to have a examine out Swift
    for TensorFlow real to your browser. Correct beginning up an tutorial,
    or beginning from a smooth notebook!
    Read more in our utilization records.

  • Install in the neighborhood: It’s most likely you’ll maybe well have the opportunity to get a pre-built Swift for TensorFlow
    . After installation, you might maybe maybe well educate these
    step-by-step instructions to develop and stop a Swift script on
    your laptop.

  • Drag on GCP: It’s most likely you’ll maybe well have the opportunity to wander up a GCE instance using a Swift for TensorFlow
    Deep Learning VM image, with all drivers and the toolchain
    pre-build in. Directions might maybe maybe presumably also also be recount in the
    Set up E-book.

  • Bring together from offer: In case you would delight in to customize Swift for TensorFlow or
    make a contribution wait on, educate our instructions
    on building Swift for TensorFlow from offer.



  • Units and Examples
  • TensorFlow Swift API Reference
  • Unlock Notes
  • Identified Complications
  • Veritably Asked Questions
  • TensorFlow Blog Posts


The discussions occurred on the
swift@tensorflow.org mailing record.

Why Swift for TensorFlow?

Swift for TensorFlow is a fresh manner to fabricate machine discovering out fashions. It
presents you the energy of
TensorFlow straight integrated into the
Swift programming language. We are waiting for about that
machine discovering out paradigms are so crucial that they deserve
top quality language and compiler improve.

A fundamental vulnerable in machine discovering out is gradient-essentially based mostly optimization:
computing characteristic derivatives to optimize parameters. With Swift for
TensorFlow, you might maybe maybe well simply differentiate functions using differential
operators delight in gradient(of:), or differentiate with respect to an total
model by calling map gradient(in:). These differentiation APIs
are no longer lawful accessible for Tensor-linked ideas—they are
generalized for all kinds that conform to the Differentiable
protocol, alongside side Float, Double, SIMD vectors, and your possess records

// Customized differentiable model.
struct Mannequin: Differentiable {
    var w:  Float
    var b:  Float
    func utilized(to input: Float) -> Float {
        return w * input + b

// Differentiate using `gradient(at:_:in:)`.
let model = Mannequin(w: 4, b: 3)
let input:  Float = 2
let (𝛁model, 𝛁input) = gradient(at: model, input) { model, input in
    model.utilized(to: input)

print(𝛁model) // Mannequin.TangentVector(w: 2.0, b: 1.0)
print(𝛁input) // 4.0

Past derivatives, the Swift for TensorFlow project comes with a flowery toolchain
to fabricate users more productive. It’s most likely you’ll maybe well have the opportunity to bustle Swift interactively in a Jupyter
notebook, and gain pleasurable autocomplete solutions to assist you explore the
wide API surface of a recent deep discovering out library. It’s most likely you’ll maybe well have the opportunity to gain started
real to your browser in

Migrating to Swift for TensorFlow is basically easy in consequence of Swift’s highly fantastic
Python integration. It’s most likely you’ll maybe well have the opportunity to incrementally migrate your Python code over (or
proceed to make converse of your licensed Python libraries), since you might maybe maybe well simply call
your licensed Python library with a acquainted syntax:

import TensorFlow
import Python

let np = Python.import("numpy")

let array = np.arange(100).reshape(10, 10)  // Form a 10x10 numpy array.
let tensor = TensorFloat>(numpy: array)  // Seamless integration!


Beware: the project is shifting very rapid, and thus these accomplish of documents
are moderately of outdated-long-established as when put next to the current notify of the art.


Skills deep dive

The Swift for TensorFlow project builds on top of highly fantastic theoretical
foundations. For insight accurate into a pair of of the underlying technologies, compare
out the next documentation.

Source code

Compiler and customary library pattern happens on the main division of the
apple/swift repository.

Extra code repositories that fabricate up the core of the project consist of:

  • Deep discovering out library: high-level
    API acquainted to Keras users.

Swift for TensorFlow is no longer a fork of the legit Swift language;
pattern was once beforehand done on the tensorflow division of the
apple/swift repository.
Language additions had been designed to compare with the direction of Swift and are
going by the Swift Evolution

Jupyter Notebook improve

Jupyter Notebook improve for Swift is below pattern at

Mannequin garden

tensorflow/swift-fashions is a
repository of machine discovering out fashions built with Swift for TensorFlow. It
supposed to offer examples of how to make converse of Swift for TensorFlow, to permit for
stop-to-stop tests of machine discovering out APIs, and to host model benchmarking


fastai/swiftai is a high-level API for
Swift for TensorFlow, modeled after the
fastai Python library.


Swift for TensorFlow discussions occur on the
swift@tensorflow.org mailing record.

Bugs reports and feature requests

Earlier than reporting a mission, please compare the Veritably Asked Questions
to survey in case your build a query to has already been addressed.

For questions on customary converse or feature requests, please send an email to
the mailing record or probe for relevant points
in the JIRA mission tracker.

For the most phase, the core team’s pattern is also tracked in


We welcome contributions from all individuals. Read the contributing
for records on how to gain started.

Code of behavior

Within the curiosity of fostering an beginning and welcoming atmosphere, we as
contributors and maintainers pledge to creating participation in our project and
our team a harassment-free ride for everyone, in spite of age, physique
measurement, disability, ethnicity, gender identity and expression, level of
ride, schooling, socio-financial set up, nationality, private appearance,
rush, religion, or sexual identity and orientation.

The Swift for TensorFlow team is guided by our Code of
, which we attend all individuals to read sooner than

Read More

Recent Content