You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository covers the compiler and standard libraries. Please visit the [documentation repository](https://github.com/tensorflow/swift) for more information about the project, including a project overview, technical details, and guidelines for contributing. To use Swift for TensorFlow out of the box, follow the [installation instructions](https://github.com/tensorflow/swift/blob/master/Installation.md). To build from source, follow the instructions below.
24
24
25
-
Swift is a high-performance system programming language. It has a clean
26
-
and modern syntax, offers seamless access to existing C and Objective-C code
27
-
and frameworks, and is memory safe by default.
25
+
**Note:** Swift for TensorFlow is an early stage research project. It has been released to enable open source development and is not yet ready for general use by machine learning developers.
28
26
29
-
Although inspired by Objective-C and many other languages, Swift is not itself a
30
-
C-derived language. As a complete and independent language, Swift packages core
31
-
features like flow control, data structures, and functions, with high-level
32
-
constructs like objects, protocols, closures, and generics. Swift embraces
33
-
modules, eliminating the need for headers and the code duplication they entail.
27
+
## Building Swift for TensorFlow
34
28
35
-
To learn more about the programming language, visit [swift.org](https://swift.org/documentation/).
29
+
These instructions give the most direct path to a working development environment for Swift for TensorFlow.
36
30
37
-
## Contributing to Swift
38
-
39
-
Contributions to Swift are welcomed and encouraged! Please see the
40
-
[Contributing to Swift guide](https://swift.org/contributing/).
41
-
42
-
To be a truly great community, [Swift.org](https://swift.org/) needs to welcome
43
-
developers from all walks of life, with different backgrounds, and with a wide
44
-
range of experience. A diverse and friendly community will have more great
45
-
ideas, more unique perspectives, and produce more great code. We will work
46
-
diligently to make the Swift community welcoming to everyone.
47
-
48
-
To give clarity of what is expected of our members, Swift has adopted the
49
-
code of conduct defined by the Contributor Covenant. This document is used
50
-
across many open source communities, and we think it articulates our values
51
-
well. For more, see the [Code of Conduct](https://swift.org/community/#code-of-conduct).
52
-
53
-
## Getting Started
54
-
55
-
These instructions give the most direct path to a working Swift development
56
-
environment. To build from source you will need about 2 GB of disk space for the
57
-
source code and up to 70 GB of disk space for the build artifacts with full
58
-
debugging. Depending on your machine, a clean build can take a few minutes to
59
-
several hours. Naturally, incremental builds are much faster.
31
+
**Note:** Building from source is necessary only if you want to modify the source code or build with a custom version of TensorFlow.
60
32
33
+
To build from source you will need 2 GB of disk space for the source code and over 20 GB of disk space for the build artifacts. A clean build can take multiple hours, but incremental builds will finish much faster.
61
34
62
35
### System Requirements
63
36
64
-
macOS, Ubuntu Linux LTS, and the latest Ubuntu Linux release are the current
37
+
macOS, Ubuntu Linux LTS 14.04, and Ubuntu Linux LTS 16.04 are the current
65
38
supported host development operating systems.
66
39
67
40
#### macOS
68
41
69
42
To build for macOS, you need [Xcode 10 beta](https://developer.apple.com/xcode/downloads/).
70
43
The required version of Xcode changes frequently, and is often a beta release.
71
-
Check this document or the host information on <https://ci.swift.org> for the
72
-
current required version.
44
+
Check this document for the current required version.
73
45
74
-
You will also need [CMake](https://cmake.org) and [Ninja](https://ninja-build.org),
75
-
which can be installed via a package manager:
46
+
You will also need [CMake](https://cmake.org), [Ninja](https://ninja-build.org), and [Bazel](https://www.bazel.build), which can be installed via a package manager.
76
47
77
48
**[Homebrew](https://brew.sh/)**
78
49
79
50
brew install cmake ninja
51
+
brew cask install caskroom/versions/java8 (required for Bazel)
52
+
brew install bazel (required for TensorFlow support)
80
53
81
-
**[MacPorts](https://macports.org)**
82
-
83
-
sudo port install cmake ninja
84
-
85
-
Instructions for installing CMake and Ninja directly can be found [below](#build-dependencies).
54
+
Instructions for installing CMake, Ninja, and Bazel directly can be found [below](#build-dependencies).
86
55
87
56
#### Linux
88
57
89
58
For Ubuntu, you'll need the following development dependencies:
Additionally, [Bazel](https://www.bazel.build) is required to build with TensorFlow support. Ubuntu installation instructions are [here](https://docs.bazel.build/versions/master/install-ubuntu.html).
63
+
93
64
**Note:** LLDB currently requires at least `swig-1.3.40` but will successfully build
94
65
with version 2 shipped with Ubuntu.
95
66
96
-
Build instructions for Ubuntu 14.04 LTS can be found [here](docs/Ubuntu14.md).
67
+
Additional build instructions for Ubuntu 14.04 LTS can be found [here](docs/Ubuntu14.md). These are necessary for building Swift for TensorFlow correctly.
97
68
98
69
### Getting Sources for Swift and Related Projects
99
70
100
-
First create a directory for all of the Swift sources:
71
+
First, create a directory for all of the Swift sources:
101
72
102
73
mkdir swift-source
103
74
cd swift-source
@@ -107,17 +78,19 @@ repositories next to the Swift source directory. This means that if one clones
107
78
Swift and has other unrelated repositories, update-checkout may not clone those
108
79
repositories and will update them instead.
109
80
81
+
**TensorFlow Support:** To build with TensorFlow support, the `update-checkout-config-tensorflow.json` configuration file must be specified when cloning sources. The configuration file pins specific versions of every Swift companion directory and is updated with every upstream merge from the Apple Swift repositories.
82
+
110
83
**Via HTTPS** For those checking out sources as read-only, HTTPS works best:
When developing Swift, it helps to build what you're working on in a debug
137
110
configuration while building the rest of the project with optimizations. Below
138
111
are some examples of using debug variants:
139
112
140
-
utils/build-script --release-debuginfo --debug-swift # Swift frontend built in debug
141
-
utils/build-script --release-debuginfo --debug-swift-stdlib # Standard library built in debug
142
-
utils/build-script --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
113
+
utils/build-script --enable-tensorflow --release-debuginfo --debug-swift # Swift frontend built in debug
114
+
utils/build-script --enable-tensorflow --release-debuginfo --debug-swift-stdlib # Standard library built in debug
115
+
utils/build-script --enable-tensorflow --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
143
116
144
117
Limiting the amount of debug code in the compiler has a very large impact on
145
118
Swift compile times, and in turn the test execution time. If you want to build
146
119
the entire project in debug, you can run:
147
120
148
-
utils/build-script --debug
121
+
utils/build-script --enable-tensorflow --debug
149
122
150
123
For documentation of all available arguments, as well as additional usage
151
124
information, see the inline help:
152
125
153
126
utils/build-script -h
154
127
128
+
### TensorFlow Support
129
+
130
+
To enable TensorFlow support, specify the `--enable-tensorflow` flag:
131
+
132
+
utils/build-script --enable-tensorflow
133
+
134
+
By default, TensorFlow will be automatically cloned from GitHub and built from source using Bazel. If you want to build with custom TensorFlow headers and shared libraries, please specify the `tensorflow-host-include-dir` and `tensorflow-host-lib-dir` arguments:
*`enable-tensorflow`: If true, enables TensorFlow support for Swift.
141
+
* Default value: `False`.
142
+
*`build-tensorflow`: If true, automatically clone and build TensorFlow from source.
143
+
* Default value: If `enable-tensorflow` is `True` and `tensorflow-host-lib-dir` and `tensorflow-host-include-dir` are not specified, then `True`. Otherwise, `False`.
144
+
*`host-bazel`: The absolute path to Bazel, used to build TensorFlow.
145
+
* By default, the path is auto detected.
146
+
*`tensorflow-bazel-options`: Comma separated options passed to Bazel when building TensorFlow, e.g. `--copt=-mavx,--copt=-msse4.2`.
147
+
* Default: None.
148
+
*`tensorflow-host-include-dir`: A directory containing custom TensorFlow headers.
149
+
* Default value: None.
150
+
*`tensorflow-host-lib-dir`: A directory containing custom TensorFlow shared libraries (`libtensorflow.so` and `libtensorflow_framework.so`).
151
+
* Default value: None.
152
+
155
153
#### Xcode
156
154
157
155
To build using Xcode, specify the `--xcode` argument on any of the above commands.
@@ -216,39 +214,6 @@ recompiling the entire project by passing the `--reconfigure` option.
216
214
Make sure all repositories are up to date with the `update-checkout` command
217
215
described above.
218
216
219
-
## Testing Swift
220
-
221
-
See [docs/Testing.md](docs/Testing.md), in particular the section on [lit.py](docs/Testing.md#using-litpy).
222
-
223
-
## Learning More
224
-
225
-
Be sure to look through the [docs](https://github.com/apple/swift/tree/master/docs)
226
-
directory for more information about the compiler. In particular, the documents
227
-
titled [Debugging the Swift Compiler](docs/DebuggingTheCompiler.rst) and
228
-
[Continuous Integration for Swift](docs/ContinuousIntegration.md) are very
229
-
helpful to understand before submitting your first PR.
230
-
231
-
### Building Documentation
232
-
233
-
To read the compiler documentation, start by installing the
234
-
[Sphinx](http://sphinx-doc.org) documentation generator tool by running the
235
-
command:
236
-
237
-
easy_install -U Sphinx
238
-
239
-
Once complete, you can build the Swift documentation by changing directory into
240
-
[docs](https://github.com/apple/swift/tree/master/docs) and typing `make`. This
241
-
compiles the `.rst` files in the [docs](https://github.com/apple/swift/tree/master/docs)
242
-
directory into HTML in the `docs/_build/html` directory.
243
-
244
-
Many of the docs are out of date, but you can see some historical design
245
-
documents in the `docs` directory.
246
-
247
-
Another source of documentation is the standard library itself, located in
248
-
`stdlib`. Much of the language is actually implemented in the library
249
-
(including `Int`), and the standard library gives some examples of what can be
250
-
expressed today.
251
-
252
217
## Build Dependencies
253
218
254
219
### CMake
@@ -286,3 +251,8 @@ next to the other projects and it will be bootstrapped automatically:
[Bazel](https://bazel.build) is the build tool used to build TensorFlow. Installing Bazel is necessary for building Swift with TensorFlow support.
257
+
258
+
The Bazel website has detailed installation instructions for [macOS](https://docs.bazel.build/versions/master/install-os-x.html) and [Ubuntu](https://docs.bazel.build/versions/master/install-ubuntu.html).
0 commit comments