From fb03bc60fe90d332e357aafa8359a44369ff8caf Mon Sep 17 00:00:00 2001 From: RJ Skerry-Ryan Date: Fri, 26 Jun 2020 16:39:44 -0700 Subject: [PATCH] Python 3 fixes for ConvertLiteralToNumpyArray. In Python 3, range does not return a list. PiperOrigin-RevId: 318566171 Change-Id: I76b66d3fac05660f3735a6fcfa3bd9c1eefb610b --- tensorflow/compiler/xla/python_api/xla_literal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/compiler/xla/python_api/xla_literal.py b/tensorflow/compiler/xla/python_api/xla_literal.py index 19bd685ab22..5b542b733a5 100644 --- a/tensorflow/compiler/xla/python_api/xla_literal.py +++ b/tensorflow/compiler/xla/python_api/xla_literal.py @@ -48,9 +48,9 @@ def ConvertLiteralToNumpyArray(literal): # on the LiteralProto's layout. layout_order = literal.shape.layout.minor_to_major numpy_shape = tuple(literal.shape.dimensions) - if layout_order == range(len(literal.shape.dimensions)): + if layout_order == list(range(len(literal.shape.dimensions))): numpy_reshaper = lambda arr: arr.reshape(numpy_shape, order='F') - elif layout_order == range(len(literal.shape.dimensions) - 1, -1, -1): + elif layout_order == list(range(len(literal.shape.dimensions) - 1, -1, -1)): numpy_reshaper = lambda arr: arr.reshape(numpy_shape, order='C') else: raise NotImplementedError('Unsupported layout: {0}'.format(layout_order))