aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Peter Hawkins <phawkins@google.com>2018-06-22 08:21:25 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-06-22 08:24:11 -0700
commitfcb519a4a3d3bce0fc14dc2e46761a22b2d665a3 (patch)
tree9eb09f53e50b3f4d39a4fc97f337c06495417d6c
parent18921a5d96610b703338431c0563f14754363a0a (diff)
[TF:XLA] Implement BitwiseXor.
PiperOrigin-RevId: 201687789
-rw-r--r--tensorflow/compiler/tests/binary_ops_test.py5
-rw-r--r--tensorflow/compiler/tf2xla/kernels/binary_ops.cc1
2 files changed, 6 insertions, 0 deletions
diff --git a/tensorflow/compiler/tests/binary_ops_test.py b/tensorflow/compiler/tests/binary_ops_test.py
index 69a99dd1cd..afef36d9d2 100644
--- a/tensorflow/compiler/tests/binary_ops_test.py
+++ b/tensorflow/compiler/tests/binary_ops_test.py
@@ -226,6 +226,11 @@ class BinaryOpsTest(XLATestCase):
np.array([0b1, 0b101, 0b1000], dtype=dtype),
np.array([0b0, 0b101, 0b1001], dtype=dtype),
expected=np.array([0b1, 0b101, 0b1001], dtype=dtype))
+ self._testSymmetricBinary(
+ bitwise_ops.bitwise_xor,
+ np.array([0b1, 0b111, 0b1100], dtype=dtype),
+ np.array([0b0, 0b101, 0b1001], dtype=dtype),
+ expected=np.array([0b1, 0b010, 0b0101], dtype=dtype))
lhs = np.array([0, 5, 3, 14], dtype=dtype)
rhs = np.array([5, 0, 7, 11], dtype=dtype)
diff --git a/tensorflow/compiler/tf2xla/kernels/binary_ops.cc b/tensorflow/compiler/tf2xla/kernels/binary_ops.cc
index f04cde878e..fee939bdea 100644
--- a/tensorflow/compiler/tf2xla/kernels/binary_ops.cc
+++ b/tensorflow/compiler/tf2xla/kernels/binary_ops.cc
@@ -96,6 +96,7 @@ XLA_MAKE_BINARY(FloorMod,
XLA_MAKE_BINARY(BitwiseAnd, b->And(lhs, rhs, extend_dimensions));
XLA_MAKE_BINARY(BitwiseOr, b->Or(lhs, rhs, extend_dimensions));
+XLA_MAKE_BINARY(BitwiseXor, b->Xor(lhs, rhs, extend_dimensions));
XLA_MAKE_BINARY(LeftShift, b->ShiftLeft(lhs, rhs, extend_dimensions));
XLA_MAKE_BINARY(RightShift,