[XLA] First step in adding Literal slice classes, to improve interface safety
authorKay Zhu <kayzhu@google.com>
Wed, 9 May 2018 20:07:35 +0000 (13:07 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Wed, 9 May 2018 20:47:51 +0000 (13:47 -0700)
commite1347ba769b98e260d36e895be2963af35c88d18
tree3f8c5d4edaa71035459f08d9520a4a0fdbcaadf5
parenta4afe20fb4663c0f3b7f1b0086fe1c97557fea7b
[XLA] First step in adding Literal slice classes, to improve interface safety
and prepare for enabling more efficient interfacing from Tensor to Literal to
reduce host to device latency.

More specically:
* Introducing a new LiteralBase abstract base class that contains all immutable
methods of from the old Literal class.

* Introducing a subclass LiteralSlice to replace original LiteralView class.
LiteralSlice class is read-only and does not own Shape nor any buffer through
the Pieces. Change a number of callers to use LiteralSlice directly.

* Change Literal class to explicitly own the underlying Shape as well as owning
the underlying buffer via Piece.

* Conversion from Literal to LiteralSlice is now done via an implicit
conversion constructor instead of inheritance.

* Decouple ShapeTree from Literal classes.

* Use copy-and-swap for assignment constructors.

* Other minor cleanups.

PiperOrigin-RevId: 196016576
28 files changed:
tensorflow/compiler/tf2xla/literal_util.cc
tensorflow/compiler/tf2xla/literal_util.h
tensorflow/compiler/xla/client/computation_builder.cc
tensorflow/compiler/xla/client/computation_builder.h
tensorflow/compiler/xla/client/xla_client/xla_builder.cc
tensorflow/compiler/xla/client/xla_client/xla_builder.h
tensorflow/compiler/xla/literal_util.cc
tensorflow/compiler/xla/literal_util.h
tensorflow/compiler/xla/literal_util_test.cc
tensorflow/compiler/xla/python/numpy_bridge.cc
tensorflow/compiler/xla/python/numpy_bridge.h
tensorflow/compiler/xla/service/algebraic_simplifier.cc
tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.cc
tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.h
tensorflow/compiler/xla/service/cpu/external_constant_pool.cc
tensorflow/compiler/xla/service/cpu/external_constant_pool.h
tensorflow/compiler/xla/service/generic_transfer_manager.cc
tensorflow/compiler/xla/service/generic_transfer_manager.h
tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.cc
tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.h
tensorflow/compiler/xla/service/hlo_evaluator.cc
tensorflow/compiler/xla/service/transfer_manager.h
tensorflow/compiler/xla/tests/broadcast_test.cc
tensorflow/compiler/xla/tests/client_test.cc
tensorflow/compiler/xla/tests/constants_test.cc
tensorflow/compiler/xla/tests/literal_test_util.cc
tensorflow/compiler/xla/tests/literal_test_util.h
tensorflow/compiler/xla/tests/local_client_execute_test.cc