aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/tests
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-08-28 02:45:57 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-28 02:49:08 -0700
commit5045a71675fd198b5ae322593ec47ea4327ad348 (patch)
tree784e756061d24db896c5e8c75670f1dafb75f0ee /tensorflow/compiler/tests
parenta6ebb9294a8eb848bcba46905d5f71ccf0da1a18 (diff)
[TF:XLA] Add support for mirror_pad in symmetric mode.
PiperOrigin-RevId: 210512603
Diffstat (limited to 'tensorflow/compiler/tests')
-rw-r--r--tensorflow/compiler/tests/binary_ops_test.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/tensorflow/compiler/tests/binary_ops_test.py b/tensorflow/compiler/tests/binary_ops_test.py
index ed4940f204..17280e445b 100644
--- a/tensorflow/compiler/tests/binary_ops_test.py
+++ b/tensorflow/compiler/tests/binary_ops_test.py
@@ -1010,7 +1010,38 @@ class BinaryOpsTest(xla_test.XLATestCase):
[7, 7, 7, 7, 7, 7]],
dtype=dtype))
- def testMirrorPad(self):
+ def testSymmetricMirrorPad(self):
+ mirror_pad = lambda t, paddings: array_ops.pad(t, paddings, "SYMMETRIC")
+ for dtype in self.numeric_types:
+ self._testBinary(
+ mirror_pad,
+ np.array(
+ [
+ [1, 2, 3], #
+ [4, 5, 6], #
+ ],
+ dtype=dtype),
+ np.array([[
+ 2,
+ 2,
+ ], [3, 3]], dtype=np.int32),
+ expected=np.array(
+ [
+ [6, 5, 4, 4, 5, 6, 6, 5, 4], #
+ [3, 2, 1, 1, 2, 3, 3, 2, 1], #
+ [3, 2, 1, 1, 2, 3, 3, 2, 1], #
+ [6, 5, 4, 4, 5, 6, 6, 5, 4], #
+ [6, 5, 4, 4, 5, 6, 6, 5, 4], #
+ [3, 2, 1, 1, 2, 3, 3, 2, 1], #
+ ],
+ dtype=dtype))
+ self._testBinary(
+ mirror_pad,
+ np.array([[1, 2, 3], [4, 5, 6]], dtype=dtype),
+ np.array([[0, 0], [0, 0]], dtype=np.int32),
+ expected=np.array([[1, 2, 3], [4, 5, 6]], dtype=dtype))
+
+ def testReflectMirrorPad(self):
mirror_pad = lambda t, paddings: array_ops.pad(t, paddings, "REFLECT")
for dtype in self.numeric_types:
self._testBinary(