Skip to content

Commit 168ad4e

Browse files
[XLA] Add inequality operator to Comparison.
PiperOrigin-RevId: 507842166
1 parent 038681c commit 168ad4e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tensorflow/compiler/xla/comparison_util.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ class Comparison {
8888
// targets may support total order floating point type comparisons.
8989
explicit Comparison(Direction dir, PrimitiveType type, Order order);
9090

91-
// Two comparisons are equivalent iff they have the same direction, precision,
92-
// and ordering.
93-
bool operator==(const Comparison& other) const {
94-
return GetDirection() == other.GetDirection() &&
95-
GetPrimitiveType() == other.GetPrimitiveType() &&
96-
GetOrder() == other.GetOrder();
97-
}
98-
9991
// Returns a comparison with a primitive type matching the Comparison::Type
10092
// and using a default bit width of 32. For example,
10193
// Comparison(Direction::kLt, Type::kFloat).PrimitiveType() /* F32 */
@@ -257,6 +249,18 @@ auto LessThanByKey(KeyFn&& key_fn) {
257249
return [=](const auto& a, const auto& b) { return key_fn(a) < key_fn(b); };
258250
}
259251

252+
// Two comparisons are equivalent iff they have the same direction, precision,
253+
// and ordering.
254+
inline bool operator==(const Comparison& a, const Comparison& b) {
255+
return a.GetDirection() == b.GetDirection() &&
256+
a.GetPrimitiveType() == b.GetPrimitiveType() &&
257+
a.GetOrder() == b.GetOrder();
258+
}
259+
260+
inline bool operator!=(const Comparison& a, const Comparison& b) {
261+
return !(a == b);
262+
}
263+
260264
} // namespace xla
261265

262266
#endif // TENSORFLOW_COMPILER_XLA_COMPARISON_UTIL_H_

0 commit comments

Comments
 (0)