From 907bde43cce72c585912686774fd0ce0b08caf85 Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Tue, 22 Dec 2020 19:53:56 -0800 Subject: [PATCH] [TF2XLA] [NFC] Test case for uninitialized tensor array due to dynamic size PiperOrigin-RevId: 348732190 Change-Id: I419f2211a70e95e96bd9d44bd66ee271321b006a --- .../python/eager/def_function_xla_jit_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tensorflow/python/eager/def_function_xla_jit_test.py b/tensorflow/python/eager/def_function_xla_jit_test.py index ead508c3043..dfed13a2669 100644 --- a/tensorflow/python/eager/def_function_xla_jit_test.py +++ b/tensorflow/python/eager/def_function_xla_jit_test.py @@ -871,6 +871,24 @@ class DefFunctionTest(xla_test.XLATestCase): f(constant_op.constant(1)) + @test_util.disable_mlir_bridge('TODO(b/155782411): MLIR bridge does not' + 'support stack traces') + def testTensorArrayErrorMessage(self): + with ops.device('device:{}:0'.format(self.device)): + + @def_function.function(jit_compile=True) + def f(): + ta = tensor_array_ops.TensorArray( + dtype=dtypes.float32, + size=2, + dynamic_size=True, + element_shape=(None,)) + return ta.concat() # EXPECTED_MESSAGE + + with self.assertRaisesRegex(errors.InvalidArgumentError, + 'EXPECTED_MESSAGE'): + f() + if __name__ == '__main__': ops.enable_eager_execution()