Reputation: 7867
There are a number of functions for creating XlaOp
s from native C++ values. I'm trying to figure out how to use each to construct a graph. I've gone through xla_builder.h and picked out some candidates, omitting overloads and convenience wrappers. The two most likely candidates seem to be
// Enqueues a "retrieve parameter value" instruction for a parameter that was
// passed to the computation.
XlaOp Parameter(XlaBuilder* builder, int64 parameter_number, const Shape& shape,
const string& name);
// Enqueues a constant with the value of the given literal onto the
// computation.
XlaOp ConstantLiteral(XlaBuilder* builder, const LiteralSlice& literal);
Am I right in thinking Parameter
is for "symbols", while ConstantLiteral
is for constant values? For example, in f(x) = x + 1
, we'd encode 1
as a ConstantLiteral
, and then for x
we could either
f(x)
as a C++ function, and at application site use another ConstantLiteral
for our value of x
, orx
using Parameter
and build an XlaComputation
from the corresponding XlaBuilder
. That said, I'm not clear on how to actually call the XlaComputation
with a Literal
, other than with LocalClient
which doesn't work with to multiple XlaComputation
s afaict.What's the difference between these two approaches? Is one better than the other? I notice the former doesn't appear possible for higher-order functions: those which accept XlaComputation
s.
Next there's
Infeed
, which I'd guess is a streaming version of Parameter
.Recv
which looks like a way to pass data between computations, but doesn't actually create a completely new XlaOp
itself.ReplicaId
, Iota
, and XlaOp CreateToken(XlaBuilder* builder);
appear largely irrelevant for this discussion.Have I got this right? Are there any other important functions I've missed?
Upvotes: 1
Views: 147