Skip to contents

Add a primitive call to 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

(AnvlPrimitive | JitPrimitive)
The primitive the call is for. A JitPrimitive is accepted and unwrapped to its underlying AnvlPrimitive metadata.

args

(list of GraphNode)
The arguments to the primitive.

params

(list)
The parameters to the primitive.

infer_fn

(function)
The inference function to use. Must output a list of AbstractArrays.

desc

(GraphDescriptor | NULL)
The graph descriptor to add the primitive call to. Uses the current descriptor if NULL.

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 to desc, 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 this NULL.

Value

(list of GraphBox)