Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 59989bd

Browse files
committed
Merge branch 'master' into complex-numbers2
2 parents 33b178f + 2114912 commit 59989bd

File tree

81 files changed

+10667
-3237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+10667
-3237
lines changed

.swift-format

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": 1,
3+
"lineLength": 100,
4+
"indentation": {
5+
"spaces": 4
6+
},
7+
"maximumBlankLines": 1,
8+
"respectsExistingLineBreaks": true,
9+
"blankLineBetweenMembers": {
10+
"ignoreSingleLineProperties": true
11+
},
12+
"lineBreakBeforeControlFlowKeywords": false,
13+
"lineBreakBeforeEachArgument": false
14+
}

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,34 @@ use GitHub pull requests for this purpose. Consult [GitHub
3131
Help](https://help.github.com/articles/about-pull-requests/) for more
3232
information on using pull requests.
3333

34+
### Contribution guidelines and standards
35+
36+
Before sending your pull request for
37+
[review](https://github.com/tensorflow/swift-apis/pulls),
38+
make sure your changes are consistent with the guidelines.
39+
40+
#### Testing
41+
42+
* Include unit tests when you contribute new features, as they help to a)
43+
prove that your code works correctly, and b) guard against future breaking
44+
changes to lower the maintenance cost.
45+
* Bug fixes also generally require unit tests, because the presence of bugs
46+
usually indicates insufficient test coverage.
47+
48+
#### License
49+
50+
Include a license at the top of new files.
51+
* [License example](https://github.com/tensorflow/swift-apis/blob/master/Sources/TensorFlow/Random.swift)
52+
53+
#### Swift coding style
54+
55+
Changes should conform to:
56+
57+
* [Google Swift Style Guide](https://google.github.io/swift/)
58+
* [Swift API Design Guidelines](https://swift.org/documentation/api-design-guidelines/)
59+
60+
With the exception that 4-space indendation be used.
61+
3462
## Community
3563

3664
It's a good idea to discuss any non-trivial submissions with the project

Dockerfile

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
44

55
# Allows the caller to specify the toolchain to use.
6-
ARG swift_tf_url=https://storage.googleapis.com/s4tf-kokoro-artifact-testing/latest/swift-tensorflow-DEVELOPMENT-cuda10.0-cudnn7-test-ubuntu18.04.tar.gz
6+
ARG swift_tf_url=https://storage.googleapis.com/swift-tensorflow-artifacts/nightlies/latest/swift-tensorflow-DEVELOPMENT-cuda10.0-cudnn7-ubuntu18.04.tar.gz
77

88
# Install Swift deps.
99
ENV DEBIAN_FRONTEND=noninteractive
@@ -36,5 +36,28 @@ COPY . .
3636
RUN echo "/usr/local/cuda-10.0/targets/x86_64-linux/lib/stubs" > /etc/ld.so.conf.d/cuda-10.0-stubs.conf && \
3737
ldconfig
3838

39+
# Print out swift version for better debugging for toolchain problems
40+
RUN /swift-tensorflow-toolchain/usr/bin/swift --version
41+
42+
# Clean out existing artifacts.
43+
# TODO: move into bash scripts...
44+
RUN rm /swift-tensorflow-toolchain/usr/lib/swift/linux/x86_64/TensorFlow.swiftinterface
45+
RUN rm /swift-tensorflow-toolchain/usr/lib/swift/linux/x86_64/TensorFlow.swiftdoc
46+
RUN rm /swift-tensorflow-toolchain/usr/lib/swift/linux/x86_64/TensorFlow.swiftmodule
47+
RUN rm /swift-tensorflow-toolchain/usr/lib/swift/linux/libswiftTensorFlow.so
48+
3949
# Run SwiftPM tests
4050
RUN /swift-tensorflow-toolchain/usr/bin/swift test
51+
52+
# Install into toolchain
53+
# TODO: Unify this with testing. (currently there is a demangling bug).
54+
RUN /swift-tensorflow-toolchain/usr/bin/swift build -Xswiftc -module-link-name -Xswiftc TensorFlow
55+
RUN cp /swift-apis/.build/debug/TensorFlow.swiftmodule /swift-tensorflow-toolchain/usr/lib/swift/linux/x86_64/
56+
RUN cp /swift-apis/.build/debug/libTensorFlow.so /swift-tensorflow-toolchain/usr/lib/swift/linux/
57+
58+
WORKDIR /
59+
RUN git clone https://github.com/tensorflow/swift-models.git
60+
61+
WORKDIR /swift-models
62+
63+
RUN /swift-tensorflow-toolchain/usr/bin/swift build

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// swift-tools-version:4.2
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33
//
4-
// Copyright 2018 The TensorFlow Authors. All Rights Reserved.
4+
// Copyright 2019 The TensorFlow Authors. All Rights Reserved.
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ let package = Package(
2222
products: [
2323
.library(
2424
name: "TensorFlow",
25+
type: .dynamic,
2526
targets: ["TensorFlow"]),
2627
],
2728
dependencies: [],

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct Model: Layer {
2929
var layer3 = Dense<Float>(inputSize: hiddenSize, outputSize: 3, activation: identity)
3030

3131
@differentiable
32-
func call(_ input: Tensor<Float>) -> Tensor<Float> {
32+
func callAsFunction(_ input: Tensor<Float>) -> Tensor<Float> {
3333
return input.sequenced(through: layer1, layer2, layer3)
3434
}
3535
}
@@ -38,11 +38,11 @@ struct Model: Layer {
3838
#### Initialize a model and an optimizer
3939

4040
```swift
41-
let optimizer = SGD(for: model, learningRate: 0.02)
4241
var classifier = Model()
42+
let optimizer = SGD(for: classifier, learningRate: 0.02)
4343
Context.local.learningPhase = .training
4444
let x: Tensor<Float> = ...
45-
let y: Tensor<Float> = ...
45+
let y: Tensor<Int32> = ...
4646
```
4747

4848
#### Run a training loop

0 commit comments

Comments
 (0)