Swift: Google's bet on differentiable programming
differentiable-programmingswifttensorflowgoogledeep-learning
Abstraction: Google's Swift for TensorFlow project integrating native differentiable programming
Key points:
- Swift for TensorFlow (S4TF) adds first-class, language-level
gradient(of:)function — no library imports required, applicable to arbitrary Swift code - Swift chosen over Julia, Go, Rust, C++, and a new language because it balances Python-like ergonomics with near-C performance (25× faster than Python; achievable C speed with pointers)
@derivativeattribute allows specifying derivatives for external C library functions, enabling seamless backprop through non-Swift codevalueWithGradientcomputes both function output and gradient in one call;callAsFunctionenables PyTorch/Keras-style model invocation- Python interoperability via
PythonObjecttype lets Swift call matplotlib, NumPy, etc. directly - Project remained experimental as of 2020: TF Eager backend caused slowness; key contributors (Chris Lattner, others) departed; Apple and Google aligning on broader Swift ecosystem goals
Connections: Google · Tensorflow · Andrej Karpathy · Fast AI · Differentiable Programming · Automatic Differentiation
Source: https://tryolabs.com/blog/2020/04/02/swift-googles-bet-on-differentiable-programming/