Module Tolk_uop.Ops

UOp operation tags.

Constructor declaration order is part of the semantics: compare, toposort stability, and commutative-operand canonicalisation use the constructor ordinal. Do not add, remove, or reorder constructors without updating the parity tests.

Types

type t =
  1. | Bind
    (*

    Pairs a symbolic Param with a concrete value.

    *)
  2. | Special
    (*

    Hardware index, such as group, local, or global ids.

    *)
  3. | Buffer
    (*

    Buffer allocation or buffer identity.

    *)
  4. | Noop
    (*

    Pass-through scheduling marker.

    *)
  5. | Rewrite_error
    (*

    Rewrite failure marker.

    *)
  6. | Param
    (*

    Function, symbolic, or buffer parameter.

    *)
  7. | Function
    (*

    Gradient-able function body.

    *)
  8. | Call
    (*

    Opaque kernel invocation.

    *)
  9. | Program
    (*

    Program root.

    *)
  10. | Linear
    (*

    Linearized uop sequence.

    *)
  11. | Source
    (*

    Human-readable rendered source.

    *)
  12. | Binary
    (*

    Compiled machine-code bytes.

    *)
  13. | Sink
    (*

    Graph or kernel root gathering children.

    *)
  14. | After
    (*

    Passes src.(0) through after src.(1..).

    *)
  15. | Group
    (*

    Merges dependencies without producing a value.

    *)
  16. | Stack
    (*

    Constructs value vectors and shape tuples.

    *)
  17. | Tuple
    (*

    Multi-result function body.

    *)
  18. | Gettuple
    (*

    Projects one element from a Tuple or Function.

    *)
  19. | Getaddr
    (*

    HCQ address extraction op.

    *)
  20. | Index
    (*

    Pointer arithmetic over a base pointer and offsets.

    *)
  21. | Shrink
    (*

    Trims edges per axis; declared in tinygrad's load/store block.

    *)
  22. | Load
    (*

    Loads from an indexed pointer.

    *)
  23. | Store
    (*

    Stores through an indexed pointer.

    *)
  24. | Wmma
    (*

    Tensor-core matrix multiply-accumulate.

    *)
  25. | Shaped_wmma
    (*

    Shape-aware Wmma.

    *)
  26. | Cast
    (*

    Value-preserving type conversion.

    *)
  27. | Bitcast
    (*

    Bit-preserving reinterpretation.

    *)
  28. | Exp2
    (*

    Base-2 exponential.

    *)
  29. | Log2
    (*

    Base-2 logarithm.

    *)
  30. | Sin
    (*

    Sine.

    *)
  31. | Sqrt
    (*

    Square root.

    *)
  32. | Reciprocal
    (*

    Reciprocal, 1 / x.

    *)
  33. | Neg
    (*

    Arithmetic negation.

    *)
  34. | Trunc
    (*

    Truncation toward zero.

    *)
  35. | Add
    (*

    Addition.

    *)
  36. | Mul
    (*

    Multiplication.

    *)
  37. | Shl
    (*

    Bitwise left shift.

    *)
  38. | Shr
    (*

    Bitwise right shift.

    *)
  39. | Cdiv
    (*

    C-style truncating integer division.

    *)
  40. | Max
    (*

    Pointwise maximum.

    *)
  41. | Cmod
    (*

    C-style integer remainder.

    *)
  42. | Cmplt
    (*

    Less-than comparison.

    *)
  43. | Cmpne
    (*

    Inequality comparison.

    *)
  44. | Cmpeq
    (*

    Equality comparison.

    *)
  45. | Xor
    (*

    Bitwise XOR.

    *)
  46. | Or
    (*

    Bitwise OR.

    *)
  47. | And
    (*

    Bitwise AND.

    *)
  48. | Threefry
    (*

    Threefry counter-based RNG round.

    *)
  49. | Sub
    (*

    Subtraction.

    *)
  50. | Fdiv
    (*

    Floating-point division.

    *)
  51. | Pow
    (*

    Exponentiation.

    *)
  52. | Floordiv
    (*

    Floor integer division.

    *)
  53. | Floormod
    (*

    Floor integer modulo.

    *)
  54. | Where
    (*

    Ternary select.

    *)
  55. | Mulacc
    (*

    Fused multiply-accumulate.

    *)
  56. | Barrier
    (*

    Workgroup barrier.

    *)
  57. | Range
    (*

    Loop variable.

    *)
  58. | If
    (*

    Predicated control-flow gate.

    *)
  59. | End
    (*

    Closes one or more loops around a value.

    *)
  60. | Endif
    (*

    Closes an If region.

    *)
  61. | Wait
    (*

    Wait/synchronisation point.

    *)
  62. | Const
    (*

    Compile-time constant.

    *)
  63. | Custom
    (*

    Backend-specific statement.

    *)
  64. | Customi
    (*

    Backend-specific inline expression.

    *)
  65. | Ins
    (*

    Backend machine instruction.

    *)
  66. | Contiguous
    (*

    Forces contiguous layout.

    *)
  67. | Contiguous_backward
    (*

    Backward-pass contiguous marker.

    *)
  68. | Detach
    (*

    Detaches from gradient tracking.

    *)
  69. | Stage
    (*

    Staged buffer before final buffer materialisation.

    *)
  70. | Copy
    (*

    Cross-device copy.

    *)
  71. | Slice
    (*

    Slice of a buffer identity.

    *)
  72. | Mselect
    (*

    Selects one shard of a sharded value.

    *)
  73. | Mstack
    (*

    Stacks per-device shards.

    *)
  74. | Custom_function
    (*

    User-defined tensor-stage function.

    *)
  75. | Reshape
    (*

    Rearranges elements into a new shape.

    *)
  76. | Permute
    (*

    Permutes axes.

    *)
  77. | Expand
    (*

    Broadcasts to a target shape.

    *)
  78. | Pad
    (*

    Pads per axis.

    *)
  79. | Flip
    (*

    Reverses selected axes.

    *)
  80. | Multi
    (*

    Distributes a value across devices.

    *)
  81. | Reduce
    (*

    Reduction by Add, Mul, or Max.

    *)
  82. | Allreduce
    (*

    Cross-device reduction.

    *)

One flat tag per tinygrad uop kind.

val equal : t -> t -> bool

equal a b is true iff a and b are the same constructor.

val compare : t -> t -> int

compare a b orders by tinygrad declaration order.

val name : t -> string

name op is the uppercase tinygrad operator name.

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

pp ppf op prints op using name.

Groups

Group exposes operation families used by validation and rewrites. Lists use stable declaration-oriented order; predicates and lists agree.

module Group : sig ... end