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

Commit ae03b88

Browse files
authoredApr 30, 2020
correct whitespace in Epochs implementation (#916)
While trying to enable `swift-format` based linting, these files were noted to have whitespace errors. Correct the errors to allow enabling the linter.
1 parent 0b169ac commit ae03b88

File tree

7 files changed

+44
-44
lines changed

7 files changed

+44
-44
lines changed
 

‎Sources/TensorFlow/Epochs/Algorithms.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,21 @@ public struct Concatenation<Base1: Sequence, Base2: Sequence>: Sequence
292292
self._base1 = _base1
293293
self._base2 = base2
294294
}
295-
295+
296296
public struct Iterator: IteratorProtocol {
297297
var _iterator1: Base1.Iterator
298298
var _iterator2: Base2.Iterator
299-
299+
300300
init(_ concatenation: Concatenation) {
301301
_iterator1 = concatenation._base1.makeIterator()
302302
_iterator2 = concatenation._base2.makeIterator()
303303
}
304-
304+
305305
public mutating func next() -> Base1.Element? {
306306
return _iterator1.next() ?? _iterator2.next()
307307
}
308308
}
309-
309+
310310
public func makeIterator() -> Iterator {
311311
Iterator(self)
312312
}
@@ -614,7 +614,7 @@ extension Collection {
614614
/// predicate, as if `self.partition(by: predicate)` had already
615615
/// been called.
616616
///
617-
/// - Efficiency: At most log(N) invocations of `predicate`, where
617+
/// - Efficiency: At most log(N) invocations of `predicate`, where
618618
/// N is the length of `self`. At most log(N) index offsetting
619619
/// operations if `self` conforms to `RandomAccessCollection`;
620620
/// at most N such operations otherwise.
@@ -636,4 +636,4 @@ extension Collection {
636636
}
637637
return l
638638
}
639-
}
639+
}

‎Sources/TensorFlow/Epochs/NonuniformTrainingEpochs.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ where Entropy == SystemRandomNumberGenerator {
160160

161161
/// A collection of batches suitable for inference, drawing samples from
162162
/// `samples` into batches of `batchSize`.
163-
public typealias NonuniformInferenceBatches<Samples: Collection>
163+
public typealias NonuniformInferenceBatches<Samples: Collection>
164164
= Slices<Sampling<Samples, [Samples.Index]>>
165165

166166
/// An implementation detail used to work around the fact that Swift can't
@@ -174,9 +174,9 @@ public protocol SamplingProtocol : Collection {
174174
}
175175
extension Sampling : SamplingProtocol {}
176176

177-
extension Slices
177+
extension Slices
178178
// This constraint matches when Self == NonuniformInferenceBatches<T>.
179-
where Base: SamplingProtocol, Base.Selection == [Base.Samples.Index]
179+
where Base: SamplingProtocol, Base.Selection == [Base.Samples.Index]
180180
{
181181
/// Creates an instance containing batches of `n` elements of `samples` where
182182
/// the size of the largest sample in successive batches is strictly
@@ -189,8 +189,8 @@ extension Slices
189189
areInAscendingSizeOrder:
190190
@escaping (Base.Samples.Element, Base.Samples.Element) -> Bool
191191
) {
192-
self.init(samples: samples, batchSize: n) {
193-
areInAscendingSizeOrder(samples[$0], samples[$1])
192+
self.init(samples: samples, batchSize: n) {
193+
areInAscendingSizeOrder(samples[$0], samples[$1])
194194
}
195195
}
196196

‎Sources/TensorFlow/Epochs/Sampling.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ where Selection: BidirectionalCollection {
5858
public func index(_ i: Index, offsetBy n: Int) -> Index {
5959
selection.index(before: i)
6060
}
61-
61+
6262
// Needed because of https://bugs.swift.org/browse/SR-12692
63-
/// Returns `i` offset by `distance` unless that requires passing `limit`, in
63+
/// Returns `i` offset by `distance` unless that requires passing `limit`, in
6464
/// which case `nil` is returned.
6565
@inlinable
6666
public func index(

‎Sources/TensorFlow/Epochs/Slices.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public struct Slices<Base: Collection> {
2525

2626
/// The maximum length of the slices.
2727
private let batchSize: Int
28-
29-
/// Creates an instance that divides `base` into batches
28+
29+
/// Creates an instance that divides `base` into batches
3030
/// of size `n`.
3131
///
3232
/// If `base.count % n != 0` the `count` of the last batch

‎Sources/TensorFlow/Operators/Math.swift

+27-27
Original file line numberDiff line numberDiff line change
@@ -393,36 +393,36 @@ extension Tensor: VectorProtocol where Scalar: TensorFlowFloatingPoint {
393393
// Consider publicly exposing these operators when tensorflow/swift-apis is no
394394
// longer built as part of the Swift standard library,
395395
/*
396-
public extension VectorProtocol {
397-
static func + (lhs: VectorSpaceScalar, rhs: Self) -> Self {
398-
rhs.adding(lhs)
399-
}
396+
public extension VectorProtocol {
397+
static func + (lhs: VectorSpaceScalar, rhs: Self) -> Self {
398+
rhs.adding(lhs)
399+
}
400400

401-
static func + (lhs: Self, rhs: VectorSpaceScalar) -> Self {
402-
lhs.adding(rhs)
403-
}
401+
static func + (lhs: Self, rhs: VectorSpaceScalar) -> Self {
402+
lhs.adding(rhs)
403+
}
404404

405-
static func - (lhs: Self, rhs: VectorSpaceScalar) -> Self {
406-
lhs.subtracting(rhs)
407-
}
405+
static func - (lhs: Self, rhs: VectorSpaceScalar) -> Self {
406+
lhs.subtracting(rhs)
407+
}
408408

409-
static func * (lhs: VectorSpaceScalar, rhs: Self) -> Self {
410-
rhs.scaled(by: lhs)
411-
}
409+
static func * (lhs: VectorSpaceScalar, rhs: Self) -> Self {
410+
rhs.scaled(by: lhs)
411+
}
412412

413-
static func * (lhs: Self, rhs: VectorSpaceScalar) -> Self {
414-
lhs.scaled(by: rhs)
415-
}
416-
}
413+
static func * (lhs: Self, rhs: VectorSpaceScalar) -> Self {
414+
lhs.scaled(by: rhs)
415+
}
416+
}
417417

418-
public extension VectorProtocol where VectorSpaceScalar: SignedNumeric {
419-
static prefix func - (x: Self) -> Self {
420-
.zero - x
421-
}
418+
public extension VectorProtocol where VectorSpaceScalar: SignedNumeric {
419+
static prefix func - (x: Self) -> Self {
420+
.zero - x
421+
}
422422

423-
static func - (lhs: VectorSpaceScalar, rhs: Self) -> Self {
424-
(-rhs).adding(lhs)
425-
}
423+
static func - (lhs: VectorSpaceScalar, rhs: Self) -> Self {
424+
(-rhs).adding(lhs)
425+
}
426426
}
427427
*/
428428

@@ -1472,9 +1472,9 @@ public func swish<T: TensorFlowFloatingPoint>(_ x: Tensor<T>) -> Tensor<T> {
14721472
x * sigmoid(x)
14731473
}
14741474

1475-
// Note: A custom vjp function for swish is required to avoid excessive
1476-
// tensor memory consumption due to storing both `x` and `sigmoid(x)` for
1477-
// backprop. This vjp recomputes `sigmoid(x)` during backprop, so that
1475+
// Note: A custom vjp function for swish is required to avoid excessive
1476+
// tensor memory consumption due to storing both `x` and `sigmoid(x)` for
1477+
// backprop. This vjp recomputes `sigmoid(x)` during backprop, so that
14781478
// the `sigmoid(x)` expression can be freed during the forward pass.
14791479
@inlinable
14801480
@derivative(of: swish)

‎Sources/TensorFlow/StdlibExtensions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,4 @@ where Element: Differentiable & PointwiseMultiplicative {
281281
extension Collection {
282282
/// Returns the `n`th position in `self`.
283283
func index(atOffset n: Int) -> Index { index(startIndex, offsetBy: n) }
284-
}
284+
}

‎Tests/TensorFlowTests/LayerTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,7 @@ final class LayerTests: XCTestCase {
19701970
let transformerResult = transformerLayerNorm(transformerTensor)
19711971
XCTAssertEqual(transformerTensor.shape, transformerResult.shape)
19721972
}
1973-
1973+
19741974
func testGaussianNoise() {
19751975
Context.local.learningPhase = .inference
19761976
let gaussianNoise = GaussianNoise<Float>(standardDeviation: 1.0)

0 commit comments

Comments
 (0)
This repository has been archived.