Make XlaOpKernelContext::ConstantInputReshaped private, and change its users to use other methods, since its use cases can be handled other ways.
Move code to copy a tensor to a literal into common literal_util module and simplify it.
PiperOrigin-RevId: 220502409
Currently Literal classes sits in literal_util.{h,cc} instead of literal.{h,cc}.
It also contains helper functions that are better fit to be their own separate
class/namespace. This change starts this process by moving most static factory
methods to LiteralUtil namespace.
PiperOrigin-RevId: 203217065
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
This renames the existing Literal message to LiteralProto and introduces a new
C++ class named Literal to replace it.
The LiteralProto is only used at RPC boundaries, or when protobuf-specific
functionality is required. The Literal class offers a 'ToProto' function to
generate a new LiteralProto message when necessary.
Currently, all the static functions in class LiteralUtil, just forward to their
counterparts in class Literal. This will change in a future CL.
Class Literal implements all the buffers as std::vectors. The only exception
is preds(), which given the std::vector<bool> representation, makes it unusable
for the semantics we require (it's not possible to get the address of the
underlying vector, for instance).
The CL adds a BoolVector class to work around that issue.
In future CLs, the std::vector representation may be changed to something more
efficient, if needed.
PiperOrigin-RevId: 157739125
XLA is a compiler-based linear algebra execution engine that targets CPUs, GPUs and custom accelerators.
XLA is still experimental; we are releasing it early to get the community involved.
Change: 143990941