top | item 16934050

Swift for TensorFlow Design Overview

198 points| asparagui | 7 years ago |github.com

45 comments

order
[+] __erik|7 years ago|reply
At first I was fairly disappointed that Swift was chosen over Julia, and I still wish there was strong Julia support because Julia is a great language, but I've slowly been changing my mind and think Swift could be a really good choice long term.

I also just really like Chris' work and trust him to make the right calls until proven otherwise.

[+] dnautics|7 years ago|reply
I love julia, but it already has a TF library that does a lot of very nice things (like not having to specify a computational graph separately from the execution) and there are other really interesting machine learning libraries (like knet).

Swift is a good choice because there are some reasonably good mobile targets, which Julia does not have. If you're deploying a ML model, you should use swift. If you're developing one, you should use julia.

[+] yodon|7 years ago|reply
As a longtime fan of C#, this article and use case just pushed me from “why would anyone think they needed to invent Swift” to “wow that’s an extremely cool set of language design constraints!”
[+] gok|7 years ago|reply
> Automatic differentiation in Swift is a compiler IR transformation implemented with static analysis.

Super cool to see this implemented at the language level like this.

[+] AlexeyBrin|7 years ago|reply
Given the fact that the vast majority of people is still on Windows, using Swift (with zero official support for Windows) will artificially limit the use of the project outside the circle of the original developers.

That being said, you can use Swift through WSL, but not directly on Windows.

[+] oscargrouch|7 years ago|reply
> That being said, you can use Swift through WSL, but not directly on Windows.

I thought so too, but i've checked the instructions to build on windows, and now there's a way to build it natively using Visual Studio cl(or clang-cl).

Following the instructions here, it worked for me.

https://github.com/apple/swift/blob/master/docs/WindowsBuild...

[+] waleedka|7 years ago|reply
Does Swift have a large community beyond iOS apps? Last I used it was years ago, right after it was introduced by Apple. I'm curious if it has found growth in other areas.
[+] stiGGG|7 years ago|reply
Not really atm. There is a small community around server-side-swift which did some impressive work so far, most interesting project is IMO the Vapor Framework [1], but at least outside the Apple Dev community they didn’t get much attention so far. For general system programming, which would be also possible with swift, Rust seems currently a lot more popular.

[1]: https://vapor.codes

[+] johnymontana|7 years ago|reply
I've seen a few server-side Swift frameworks (for building web apps or API apps) such as Perfect[1] and Kitura[2] (which is backed by IBM). It's not clear to me how much uptake they have so far.

[1] https://perfect.org/

[2] https://www.kitura.io/

[+] woolvalley|7 years ago|reply
I wouldn't want to use it for anything that would evolve beyond 100k lines of swift code until the language improves it's build and IDE performance.

And if your making a backend, why not use kotlin which is fairly similar, but you get the entire java ecosystem?

[+] bitL|7 years ago|reply
Still a bit more verbose than Python. What would you gain by doing the same in Swift actually? If you have to type more code to do some experiments, and still have to import Python libraries for extra functions as they do in that example, what's the selling point? (beside it being cool)
[+] favorited|7 years ago|reply
Here's some context: https://github.com/tensorflow/swift/blob/master/docs/WhySwif...

Some benefits vs Python are static types (catching more errors at compile-time vs hours into a training run), no GIL, don't have to drop to C++ for higher performance.

Some benefits vs some other (non-Python) languages are a shallow learning curve, small boilerplate, safety-by-default, and a growing community.

Obviously there are places where Python and others have advantages over Swift too, and several of those are called out in the paper.

[+] glass_of_water|7 years ago|reply
I think the primary advantage of using this is that you get both the usability of writing imperative code (like PyTorch or TF Eager) and the benefits of having a computation graph (easier distributed training, using TPUs and stuff).
[+] netheril96|7 years ago|reply
Static typing is nice.

But no GIL is the most important part. Multithreaded preprocessing data input to the network is almost a must these days, but that is hard to achieve in Python. Multiprocessing or that PyTorch magic alleviates the problem, but they are not as high performant as multithreading.

[+] Froyoh|7 years ago|reply
Swift for Tensorflow or Tensorflow for Swift?
[+] ScottBurson|7 years ago|reply
Yes, it's right up there with "Windows Subsystem for Linux".