Scalar types
| Enigma type | Metal type | Bits | Python/NumPy |
|---|---|---|---|
enigma.f32 | float | 32 | np.float32 |
enigma.f16 | half | 16 | np.float16 |
enigma.bf16 | bfloat | 16 | ml_dtypes.bfloat16 |
enigma.i32 | int | 32 | np.int32 |
enigma.u32 | uint | 32 | np.uint32 |
enigma.i64 | long | 64 | np.int64 |
enigma.u64 | ulong | 64 | np.uint64 |
enigma.i16 | short | 16 | np.int16 |
enigma.u16 | ushort | 16 | np.uint16 |
enigma.i8 | char | 8 | np.int8 |
enigma.u8 | uchar | 8 | np.uint8 |
enigma.b1 | bool | 1 | — |
Using types as kernel parameters
Type annotations on kernel parameters declare the buffer element type:Type casting
enigma.metal_cast(value, target_type)
Standard type conversion, equivalent to C-style casting in Metal:
enigma.as_type(value, target_type)
Bitwise reinterpret (no value conversion, same bit pattern):
Integer literals
Integer literals in kernel bodies are automatically promoted tou32:
f32:
Scalar parameters
enigma.Scalar(dtype) declares a per-dispatch constant. It is lowered as a 1-element device buffer and auto-loaded at kernel entry:
Vector types
Enigma supports vector construction for geometric operations. Vector types are created from scalars:.x, .y, .z, .w, or by lane index:
