有许多函数可以XlaOp
从原生 C++ 值创建 s。我试图弄清楚如何使用每个来构建图表。我浏览了 xla_builder.h 并挑选了一些候选者,省略了重载和便利包装器。两个最有可能的候选人似乎是
// 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);
我是否正确地认为Parameter
是“符号”,而ConstantLiteral
对于常数值?例如,在 中f(x) = x + 1
,我们将编码1
为 a ConstantLiteral
,然后x
我们可以
- 编写
f(x)
为 C++ 函数,并在应用程序站点使用另一个ConstantLiteral
作为我们的值x
,或 - 使用相应的.
x
_ 也就是说,我不清楚如何实际调用with a ,除了 with which 不适用于多个s afaict。Parameter
XlaComputation
XlaBuilder
XlaComputation
Literal
LocalClient
XlaComputation
这两种方法有什么区别?这个比那个好吗?我注意到前者对于高阶函数似乎是不可能的:那些接受XlaComputation
s 的函数。
接下来有
Infeed
,我猜这是Parameter
.Recv
这看起来像是在计算之间传递数据的一种方式,但实际上并没有创建一个全新的XlaOp
本身。ReplicaId
,Iota
, 并且XlaOp CreateToken(XlaBuilder* builder);
似乎与本次讨论无关。
我做对了吗?我还错过了其他重要的功能吗?