Record a call of a primitive as a GraphStatement in a graph descriptor. Inside a primitive body created
with new_primitive(), pass the lexically-bound self as the primitive
argument.
Usage
graph_desc_add(
primitive,
args,
params = list(),
infer_fn,
desc = NULL,
device = NULL
)Arguments
- primitive
(
AnvlPrimitiveDef|AnvlPrimitive)
The primitive the statement applies. AnAnvlPrimitiveis accepted and unwrapped to its underlyingAnvlPrimitiveDef.- args
(
listofarrayish)
The arguments to the primitive:GraphBoxes,AnvlArrays (registered as constants of the graph) or R values (materialized at their default data type).- params
(
list)
The parameters to the primitive.- infer_fn
(
function)
The inference function to use. Must output a list ofAbstractArrays.- desc
(
GraphDescriptor|NULL)
The graph descriptor to add the statement to. Uses the current descriptor ifNULL.- device
(
NULL|character(1)| device object)
The device the call places its result on, for a primitive that constructs an array out of nothing (e.g.prim_fill(),prim_iota()) and so has no operand to carry one. It is declared todesc, where it counts like the device of an array input to the same trace: it decides what that program is compiled for, and disagreeing with another device in it is an error. Every other primitive takes its device from its operands and leaves thisNULL.
Value
(list of GraphBox)