Skip to content

Commit 06be74b

Browse files
committed
Fix a TensorFlow module error.
Fix a "expression too complex" error in Gradients.swift.
1 parent 878cdf9 commit 06be74b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

stdlib/public/TensorFlow/Gradients.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,9 @@ func _vjpPow<T : TensorFlowFloatingPoint>(
344344
) -> (Tensor<T>, (Tensor<T>) -> (Tensor<T>, Tensor<T>)) {
345345
let value = pow(x, y)
346346
return (value, { v in
347-
((v * y * pow(x, y-1)).unbroadcast(like: x),
348-
(v * log(x) * value).unbroadcast(like: y))
347+
let dfdx = v * y * pow(x, y-1)
348+
let dfdy = v * log(x) * value
349+
return (dfdx.unbroadcast(like: x), dfdy.unbroadcast(like: y))
349350
})
350351
}
351352

stdlib/public/TensorFlow/Ops.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ internal extension Tensor.IndexPath {
19231923
@inlinable
19241924
init(_ ranges: [TensorRange]) {
19251925
precondition(!ranges.isEmpty, "The tensor range collection cannot be empty.")
1926-
precondition(ranges.count { $0 == TensorRange.ellipsis } < 2,
1926+
precondition(ranges.count(where: { $0 == TensorRange.ellipsis }) < 2,
19271927
"Only one ellipsis is allowed per tensor range collection.")
19281928

19291929
var begin = [Int32](repeating: 0, count: ranges.count)

0 commit comments

Comments
 (0)