github ↗
docs menu

Module Op.Set

Sets of operations.

The named sets are the families that rewrites and checks match on, such as Set.alu or Set.movement; the set operations combine them into new sets.

#type op := t
#type t

The type for sets of operations.

#val of_list : op list -> t

of_list ops is the set of the operations in ops.

#val mem : op -> t -> bool

mem o s is true iff o is in s.

#val union : t -> t -> t

union s0 s1 is the set of the operations in s0 or in s1.

#val diff : t -> t -> t

diff s0 s1 is the set of the operations in s0 and not in s1.

#val to_list : t -> op list

to_list s is the operations of s in declaration order.

#val equal : t -> t -> bool

equal s0 s1 is true iff s0 and s1 have the same operations.

#val pp : Stdlib.Format.formatter -> t -> unit

pp formats a set as its operations in declaration order, between braces and separated by commas: {Ops.ADD, Ops.MUL}. The empty set is {}.

Named sets

#val unary : t

unary is the operations of one operand: Exp2, Log2, Sin, Sqrt, Recip, Neg and Trunc.

#val binary : t

binary is the operations of two operands: Add, Mul, Truncdiv, Max, Truncmod, Cmplt, Cmpne, Cmpeq, Xor, Shl, Shr, Or, And, Threefry, Sub, Fdiv, Pow, Div and Mod.

#val ternary : t

ternary is the operations of three operands: Where and Mulacc.

#val alu : t

alu is the arithmetic and logic operations: unary, binary and ternary.

#val broadcastable : t

broadcastable is binary and ternary: the operations whose operands are brought to a common shape and type.

#val elementwise : t

elementwise is alu, Cast and Bitcast: the operations applied element by element.

#val defines : t

defines is the operations that declare storage or variables, and constant bytes: Param, Refparam, Buffer, Alloc and Binary.

#val irreducible : t

irreducible is the operations that index arithmetic treats as atoms: Const, Special, Range, Param and Getaddr.

#val movement : t

movement is the operations that move elements without computing: Reshape, Expand, Permute, Pad and Shrink.

#val effectful : t

effectful is the operations that may act beyond their value each time they run: Store, Call and Barrier. A rewrite that changes how often one runs, or whether it runs, changes what the kernel does.

#val commutative : t

commutative is the binary operations f with f x y = f y x, whose operands rewrites may swap: Add, Mul, Max, Cmpne, Cmpeq, Xor, And and Or. For Max it holds up to which of two values neither less than the other it gives.

#val associative : t

associative is the binary operations that rewrites may regroup, each satisfying f (f x y) z = f x (f y z): Add, Mul, And, Or, Max and Xor.

#val idempotent : t

idempotent is the binary operations f with f x x = x: Or, And and Max.

#val reduce : t

reduce is the operations a Reduce can reduce with: Add, Mul and Max.

#val comparison : t

comparison is the operations whose result is a boolean whatever the type of their operands: Cmplt, Cmpne and Cmpeq.

#val all : t

all is every operation.