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

Commit 719d7fa

Browse files
dominikgrewerxwei
authored andcommitted
Remove check for equal shapes in isAlmostEqual (#367)
1 parent d0c95c9 commit 719d7fa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/TensorFlow/Operators/Comparison.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ public extension Tensor where Scalar: Equatable {
210210
public extension Tensor where Scalar: TensorFlowFloatingPoint & Equatable {
211211
/// Returns a tensor of Boolean values indicating whether the elements of `self` are
212212
/// approximately equal to those of `other`.
213+
/// - Precondition: `self` and `other` must be of the same shape.
213214
@inlinable
214215
func elementsAlmostEqual(
215216
_ other: Tensor,
@@ -229,14 +230,13 @@ public extension StringTensor {
229230
}
230231

231232
public extension Tensor where Scalar: TensorFlowFloatingPoint {
232-
/// Returns `true` if tensors are of equal shape and all pairs of scalars are approximately
233-
/// equal.
233+
/// Returns `true` if all elements of `self` are approximately equal to those of `other`.
234+
/// - Precondition: `self` and `other` must be of the same shape.
234235
@inlinable
235236
func isAlmostEqual(
236237
to other: Tensor,
237238
tolerance: Scalar = Scalar.ulpOfOne.squareRoot()
238239
) -> Bool {
239-
return self.shape == other.shape &&
240-
self.elementsAlmostEqual(other, tolerance: tolerance).all()
240+
elementsAlmostEqual(other, tolerance: tolerance).all()
241241
}
242242
}

0 commit comments

Comments
 (0)