Module Tolk.Op
Operations.
An operation names what a node of the intermediate representation does. One vocabulary serves every stage: tensor graphs, kernels, programs and command sequences.
Operations are totally ordered by their declaration order in t. The order is part of the contract: graph orderings and canonical operand orders are derived from it.
The arithmetic operations name their sources x, y and z, in order.
Operations
type t = - #
| Special(*A hardware index, such as a workgroup or thread id. Its source bounds it and its argument names it.
*) - #
| Buffer(*Storage bound to a runtime buffer, or storage private to a program: registers and workgroup memory.
*) - #
| Alloc(*Storage declared without a runtime buffer. The call that owns it binds one.
*) - #
| Noop(*Computes nothing.
*) - #
| Param(*A parameter of a function: a buffer or a scalar variable. Its first source is its size. A view of storage has the state of storage it names as a second source (
*)Ops.view_state). - #
| Refparam(*A buffer parameter passed by its address: its first source is its size, as a
*)Param's, its second the address, aDtype.t.Uint64. - #
| Call(*An invocation of the body in its first source on the remaining sources. A call that produces a value writes it into
*)Allocarguments. - #
| Program - #
| Linear(*Operations in execution order.
*) - #
| Source(*The rendered source text of a program.
*) - #
| Binary(*A constant string of bytes: the machine code of a program, or bytes placed in a command packet or a buffer.
*) - #
| Sink(*A root gathering what a graph must compute.
*) - #
| After(*Its first source, ordered after the remaining sources: every consumer runs after them.
*) - #
| Stack(*A vector of its sources.
*) - #
| Getaddr(*The device address of a buffer or of a command sequence, for command queues.
*) - #
| Index(*A pointer into its first source, offset by the others.
*) - #
| Shrink(*Restricts each axis of its first source to the range between its second and third sources. In a program, a window of a buffer.
*) - #
| Load(*Reads through a pointer.
*) - #
| Store(*Writes its second source through its first.
*) - #
| Wmma(*A matrix multiply-accumulate on matrix units.
*) - #
| Cast - #
| Bitcast(*Reinterprets the bits as another type of the same width.
*) - #
| Exp2(*
*)2x. - #
| Log2(*The base-2 logarithm.
*) - #
| Sin(*The sine.
*) - #
| Sqrt(*The square root.
*) - #
| Recip(*
*)1 / x. - #
| Neg(*
*)-x. - #
| Trunc(*Rounds toward zero.
*) - #
| Add(*
*)x + y. - #
| Mul(*
*)x * y. - #
| Shl(*Shifts
*)xleft byybits. - #
| Shr(*Shifts
*)xright byybits. - #
| Truncdiv(*Integer division rounding toward zero; a quotient by
*)0is0. - #
| Max(*The greater of
*)xandy, computed asywherex < yand asxelsewhere. Where neither is less than the other, a NaN against any value or-0.against0., it is either of the two: rewrites treatMaxas commutative (Set.commutative) and may swap them. It is neither IEEE 754's maximum, which gives NaN, nor its maximumNumber, which gives the number; a caller that needs one tests for NaN. - #
| Truncmod - #
| Cmplt(*
*)x < y. - #
| Cmpne(*
*)x <> y. - #
| Cmpeq(*
*)x = y. - #
| Xor(*Bitwise exclusive or.
*) - #
| Or(*Bitwise or.
*) - #
| And(*Bitwise and.
*) - #
| Threefry(*The Threefry-2x32 bijection of the counter
*)xunder the keyy. - #
| Sub(*
*)x - y. - #
| Fdiv(*Floating-point division.
*) - #
| Pow(*
*)xy. - #
| Div(*Integer division rounding toward negative infinity; a quotient by
*)0is0. - #
| Mod - #
| Where(*
*)ywherexholds,zotherwise. - #
| Mulacc(*
*)x * y + z. - #
| Barrier(*Synchronises the threads of a workgroup.
*) - #
| Range(*A loop variable counting from 0 to its source, exclusive, or an unbounded loop when its type is void. A range of at most one trip is a conditional: a node runs inside it only when it depends on it (
*)Ops.ranges) or reads through anAfterof it. - #
| If(*Runs the operations it guards only when its condition holds.
*) - #
| End(*Closes the loops of its range sources around an effect.
*) - #
| Endif - #
| Backedge - #
| Const(*A constant. An integer literal an operation reads holds the value that operation's integer type gives it (
*)Ops.v). - #
| Ins(*An instruction named by its argument: a machine instruction, or a command of a device queue such as a wait, a barrier or a timestamp.
*) - #
| Contiguous_backward(*Its source, whose gradient is made contiguous.
*) - #
| Detach(*Its source, through which no gradient flows.
*) - #
| Stage(*Realizes its source into a new buffer.
*) - #
| Copy(*Copies its source to another device.
*) - #
| Custom_function(*A function named by its argument and implemented outside the graph, such as a device submission or an external callee.
*) - #
| Reshape(*Gives its source a new shape with the same element count.
*) - #
| Permute(*Permutes the axes of its source.
*) - #
| Expand(*Broadcasts axes of size one of its source.
*) - #
| Pad(*Pads each axis of its source.
*) - #
| Reduce
name o is the name of o in upper case, words separated by underscores: "ADD", "CONTIGUOUS_BACKWARD".
of_string s is the operation whose name is s, case included: of_string "ADD" is Ok Add, and of_string "add" and of_string "Ops.ADD" are errors. The error names s.
pp formats an operation as "Ops." followed by its name: Ops.ADD.