Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 2.82 KB

FAQ.md

File metadata and controls

48 lines (34 loc) · 2.82 KB

Frequently Asked Questions

This is a list of questions we frequently get and problems that are often encountered. Because this project is still in development, we have missing pieces that are commonly encountered and prefer not to get new issues filed in our bug tracker.

Why Swift?

The short answer is that our decision was driven by the needs of the core Graph Program Extraction compiler transformation that started the whole project. We have a long document that explains all of this rationale in depth named "Why Swift for TensorFlow?".

Separate from that, Swift really is a great fit for our purposes, and a very nice language.

If you ran into this error, you likely wrote some code using Tensor without running Swift with optimizations (-O).

The -O flag enables optimizations and is currently required for the graph program extraction algorithm to work correctly. We're working on making -O not required, but in the meantime you need to specify it.

Here's how to enable optimizations in different environments:

  • REPL: No need to add extra flags. Optimizations are on by default.
  • Interpreter: swift -O main.swift
  • Compiler: swiftc -O main.swift
  • swift build: swift build -Xswiftc -O
  • Xcode: Go to Build Settings > Swift Compiler > Code Generation > Optimization Level and select Optimize for Speed [-O].
    • You may also need to add libtensorflow.so and libtensorflow_framework.so to Linked Frameworks and Libraries and change Runtime Search Paths. See this comment for specific instructions with screenshots.

How can I use Python 3 with the Python module?

Currently, Swift is hard-coded to use Python 2.7. Adding proper Python 3 support is non-trivial but in discussion. See this issue for more information.

[Mac] I wrote some code in an Xcode Playground. Why is it frozen/hanging?

Xcode Playgrounds are known to be somewhat unstable, unfortunately. If your Playground appears to hang, please try restarting Xcode or creating a new Playground.