Skip to content

Commit ba814f4

Browse files
Shashi456rxwei
authored andcommitted
Update doc comments on non-mutating API to use proper wording. (tensorflow#183)
Fixes a part of tensorflow#160.
1 parent 781232b commit ba814f4

File tree

4 files changed

+31
-35
lines changed

4 files changed

+31
-35
lines changed

Sources/TensorFlow/Operators/Basic.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public extension Tensor {
315315
return transposed(withPermutations: Tensor<Int32>(defaultPermutations))
316316
}
317317

318-
/// Concatenates tensors along the specified axis.
318+
/// Returns a concatenated tensor along the specified axis.
319319
/// - Precondition: The tensors must have the same dimensions, except for the
320320
/// specified axis.
321321
/// - Precondition: The axis must be in the range `-rank..<rank`.
@@ -336,7 +336,7 @@ public extension Tensor {
336336
return lhs.concatenated(with: rhs)
337337
}
338338

339-
/// Gathers slices of this tensor at `indices` along the `axis` dimension.
339+
/// Returns a tensor by gathering slices of the input at `indices` along the `axis` dimension
340340
///
341341
/// For 0-D (scalar) `indices`:
342342
/// ```
@@ -387,7 +387,7 @@ public extension Tensor {
387387
return Raw.gatherV2(params: self, indices: indices, axis: Tensor<Int32>(Int32(axis)))
388388
}
389389

390-
/// Gathers values from this tensor according to the provided boolean mask.
390+
/// Returns a tensor by gathering the values after applying the provided boolean mask to the input.
391391
///
392392
/// For example:
393393
/// ```

Sources/TensorFlow/Operators/Comparison.swift

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,80 +20,80 @@ infix operator .==: ComparisonPrecedence
2020
infix operator .!=: ComparisonPrecedence
2121

2222
public extension Tensor where Scalar: Numeric & Comparable {
23-
/// Computes `lhs < rhs` element-wise and returns a `Tensor` of Boolean /// scalars.
23+
/// Returns a tensor of Boolean scalars by computing `lhs < rhs` element-wise.
2424
@inlinable
2525
static func .< (lhs: Tensor, rhs: Tensor) -> Tensor<Bool> {
2626
return Raw.less(lhs, rhs)
2727
}
2828

29-
/// Computes `lhs <= rhs` element-wise and returns a `Tensor` of Boolean scalars.
29+
/// Returns a tensor of Boolean scalars by computing `lhs <= rhs` element-wise.
3030
@inlinable
3131
static func .<= (lhs: Tensor, rhs: Tensor) -> Tensor<Bool> {
3232
return Raw.lessEqual(lhs, rhs)
3333
}
3434

35-
/// Computes `lhs > rhs` element-wise and returns a `Tensor` of Boolean scalars.
35+
/// Returns a tensor of Boolean scalars by computing `lhs > rhs` element-wise.
3636
@inlinable
3737
static func .> (lhs: Tensor, rhs: Tensor) -> Tensor<Bool> {
3838
return Raw.greater(lhs, rhs)
3939
}
4040

41-
/// Computes `lhs >= rhs` element-wise and returns a `Tensor` of Boolean scalars.
41+
/// Returns a tensor of Boolean scalars by computing `lhs >= rhs` element-wise.
4242
@inlinable
4343
static func .>= (lhs: Tensor, rhs: Tensor) -> Tensor<Bool> {
4444
return Raw.greaterEqual(lhs, rhs)
4545
}
4646

47-
/// Computes `lhs < rhs` element-wise and returns a `Tensor` of Boolean scalars.
47+
/// Returns a tensor of Boolean scalars by computing `lhs < rhs` element-wise.
4848
/// - Note: `.<` supports broadcasting.
4949
@inlinable
5050
static func .< (lhs: Scalar, rhs: Tensor) -> Tensor<Bool> {
5151
return Raw.less(Tensor(lhs), rhs)
5252
}
5353

54-
/// Computes `lhs <= rhs` element-wise and returns a `Tensor` of Boolean scalars.
54+
/// Returns a tensor of Boolean scalars by computing `lhs <= rhs` element-wise.
5555
/// - Note: `.<=` supports broadcasting.
5656
@inlinable
5757
static func .<= (lhs: Scalar, rhs: Tensor) -> Tensor<Bool> {
5858
return Raw.lessEqual(Tensor(lhs), rhs)
5959
}
6060

61-
/// Computes `lhs > rhs` element-wise and returns a `Tensor` of Boolean scalars.
61+
/// Returns a tensor of Boolean scalars by computing `lhs > rhs` element-wise.
6262
/// - Note: `.>` supports broadcasting.
6363
@inlinable
6464
static func .> (lhs: Scalar, rhs: Tensor) -> Tensor<Bool> {
6565
return Raw.greater(Tensor(lhs), rhs)
6666
}
6767

68-
/// Computes `lhs >= rhs` element-wise and returns a `Tensor` of Boolean scalars.
68+
/// Returns a tensor of Boolean scalars by computing `lhs >= rhs` element-wise.
6969
/// - Note: `.>=` supports broadcasting.
7070
@inlinable
7171
static func .>= (lhs: Scalar, rhs: Tensor) -> Tensor<Bool> {
7272
return Raw.greaterEqual(Tensor(lhs), rhs)
7373
}
7474

75-
/// Computes `lhs < rhs` element-wise and returns a `Tensor` of Boolean scalars.
75+
/// Returns a tensor of Boolean scalars by computing `lhs < rhs` element-wise.
7676
/// - Note: `.<` supports broadcasting.
7777
@inlinable
7878
static func .< (lhs: Tensor, rhs: Scalar) -> Tensor<Bool> {
7979
return Raw.less(lhs, Tensor(rhs))
8080
}
8181

82-
/// Computes `lhs <= rhs` element-wise and returns a `Tensor` of Boolean scalars.
82+
/// Returns a tensor of Boolean scalars by computing `lhs <= rhs` element-wise.
8383
/// - Note: `.<=` supports broadcasting.
8484
@inlinable
8585
static func .<= (lhs: Tensor, rhs: Scalar) -> Tensor<Bool> {
8686
return Raw.lessEqual(lhs, Tensor(rhs))
8787
}
8888

89-
/// Computes `lhs > rhs` element-wise and returns a `Tensor` of Boolean scalars.
89+
/// Returns a tensor of Boolean scalars by computing `lhs > rhs` element-wise.
9090
/// - Note: `.>` supports broadcasting.
9191
@inlinable
9292
static func .> (lhs: Tensor, rhs: Scalar) -> Tensor<Bool> {
9393
return Raw.greater(lhs, Tensor(rhs))
9494
}
9595

96-
/// Computes `lhs >= rhs` element-wise and returns a `Tensor` of Boolean scalars.
96+
/// Returns a tensor of Boolean scalars by computing `lhs >= rhs` element-wise.
9797
/// - Note: `.>=` supports broadcasting.
9898
@inlinable
9999
static func .>= (lhs: Tensor, rhs: Scalar) -> Tensor<Bool> {
@@ -162,43 +162,42 @@ public extension Tensor where Scalar: Numeric & Comparable {
162162
}
163163

164164
public extension Tensor where Scalar: Equatable {
165-
/// Computes `lhs != rhs` element-wise and returns a `Tensor` of Boolean scalars.
165+
/// Returns a tensor of Boolean scalars by computing `lhs == rhs` element-wise.
166166
/// - Note: `.==` supports broadcasting.
167167
@inlinable
168168
static func .== (lhs: Tensor, rhs: Tensor) -> Tensor<Bool> {
169169
return Raw.equal(lhs, rhs)
170170
}
171171

172-
/// Computes `lhs != rhs` element-wise and returns a `Tensor` of Boolean scalars.
172+
/// Returns a tensor of Boolean scalars by computing `lhs != rhs` element-wise.
173173
/// - Note: `.!=` supports broadcasting.
174174
@inlinable
175175
static func .!= (lhs: Tensor, rhs: Tensor) -> Tensor<Bool> {
176176
return Raw.notEqual(lhs, rhs)
177177
}
178178

179-
/// Computes `lhs == rhs` element-wise and returns a `Tensor` of Boolean scalars.
179+
/// Returns a tensor of Boolean scalars by computing `lhs == rhs` element-wise.
180180
/// - Note: `.==` supports broadcasting.
181181
@inlinable
182182
static func .== (lhs: Scalar, rhs: Tensor) -> Tensor<Bool> {
183183
return Tensor(lhs) .== rhs
184184
}
185185

186-
/// Computes `lhs != rhs` element-wise and returns a `Tensor` of Boolean scalars.
186+
/// Returns a tensor of Boolean scalars by computing `lhs != rhs` element-wise.
187187
/// - Note: `.!=` supports broadcasting.
188188
@inlinable
189189
static func .!= (lhs: Scalar, rhs: Tensor) -> Tensor<Bool> {
190190
return Tensor(lhs) .!= rhs
191191
}
192192

193-
/// Computes `lhs == rhs` element-wise and returns a `Tensor` of Boolean
194-
/// scalars.
193+
/// Returns a tensor of Boolean scalars by computing `lhs == rhs` element-wise.
195194
/// - Note: `.==` supports broadcasting.
196195
@inlinable
197196
static func .== (lhs: Tensor, rhs: Scalar) -> Tensor<Bool> {
198197
return lhs .== Tensor(rhs)
199198
}
200199

201-
/// Computes `lhs != rhs` element-wise and returns a `Tensor` of Boolean scalars.
200+
/// Returns a tensor of Boolean scalars by computing `lhs != rhs` element-wise.
202201
/// - Note: `.!=` supports broadcasting.
203202
@inlinable
204203
static func .!= (lhs: Tensor, rhs: Scalar) -> Tensor<Bool> {
@@ -209,7 +208,7 @@ public extension Tensor where Scalar: Equatable {
209208
// TODO: infix operator ≈: ComparisonPrecedence
210209

211210
public extension Tensor where Scalar: FloatingPoint & Equatable {
212-
/// Returns a `Tensor` of Boolean values indicating whether the elements of `self` are
211+
/// Returns a tensor of Boolean values indicating whether the elements of `self` are
213212
/// approximately equal to those of `other`.
214213
@inlinable
215214
func elementsApproximatelyEqual(

Sources/TensorFlow/Operators/Math.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,44 +68,41 @@ public extension Tensor where Scalar: Numeric {
6868
return lhs - Tensor(rhs)
6969
}
7070

71-
/// Adds two tensors and stores the result in the left-hand-side variable.
71+
/// Returns the tensor produced by adding the two tensors.
7272
/// - Note: `+=` supports broadcasting.
7373
@inlinable
7474
static func += (lhs: inout Tensor, rhs: Tensor) {
7575
lhs = lhs + rhs
7676
}
7777

78-
/// Adds the scalar to every scalar of the tensor and stores the result in the left-hand-side
79-
/// variable.
78+
/// Returns the scalar by adding it to every scalar of the tensor.
8079
@inlinable
8180
static func += (lhs: inout Tensor, rhs: Scalar) {
8281
lhs = lhs + rhs
8382
}
8483

85-
/// Subtracts the second tensor from the first and stores the result in the left-hand-side
86-
/// variable.
84+
/// Returns the tensor by subracting the second tensor from the first.
8785
/// - Note: `-=` supports broadcasting.
8886
@inlinable
8987
static func -= (lhs: inout Tensor, rhs: Tensor) {
9088
lhs = lhs - rhs
9189
}
9290

93-
/// Subtracts the scalar from every scalar of the tensor and stores the result in the
94-
/// left-hand-side variable.
91+
/// Returns the scalar by subtracting every scalar of the tensor from it.
9592
@inlinable
9693
static func -= (lhs: inout Tensor, rhs: Scalar) {
9794
lhs = lhs - rhs
9895
}
9996

100-
/// Multiplies two tensors and produces their product.
97+
/// Returns the tensor produced by multiplying the two tensors.
10198
/// - Note: `*` supports broadcasting.
10299
@inlinable
103100
@differentiable(vjp: _vjpMultiply(lhs:rhs:) where Scalar: TensorFlowFloatingPoint)
104101
static func * (lhs: Tensor, rhs: Tensor) -> Tensor {
105102
return Raw.mul(lhs, rhs)
106103
}
107104

108-
/// Multiplies the scalar with every scalar of the tensor and produces the product.
105+
/// Returns the scalar by multiplying it with every scalar of the tensor.
109106
@inlinable
110107
@differentiable(vjp: _vjpMultiply(lhs:rhs:) where Scalar: TensorFlowFloatingPoint)
111108
static func * (lhs: Scalar, rhs: Tensor) -> Tensor {
@@ -119,14 +116,14 @@ public extension Tensor where Scalar: Numeric {
119116
return lhs * Tensor(rhs)
120117
}
121118

122-
/// Multiplies two tensors and stores the result in the left-hand-side variable.
119+
/// Returns the tensor produced by multiplying the two tensors.
123120
/// - Note: `*=` supports broadcasting.
124121
@inlinable
125122
static func *= (lhs: inout Tensor, rhs: Tensor) {
126123
lhs = lhs * rhs
127124
}
128125

129-
/// Multiplies the tensor with the scalar, broadcasting the scalar, and stores the result in the
126+
/// Returns the tensor by multiplying it with the scalar, broadcasting the scalar.
130127
/// left-hand-side variable.
131128
@inlinable
132129
static func *= (lhs: inout Tensor, rhs: Scalar) {

Sources/TensorFlow/Operators/NN.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//===------------------------------------------------------------------------------------------===//
1818

1919
public extension Tensor where Scalar: TensorFlowFloatingPoint {
20-
/// Computes the batch normalized tensor along the specified axis.
20+
/// Returns a tensor computed from batch-normalizing the input along the specified axis.
2121
///
2222
/// Specifically, returns `(self - mu) / (var + epsilon) * gamma + beta` where `mu` and `var`
2323
/// are respectively the mean and variance of `self` along `axis`.

0 commit comments

Comments
 (0)