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))