Skip to main content
Enigma defines a fixed set of scalar types that map directly to Metal Shading Language types. Use them as kernel parameter type annotations and as arguments to casting functions.

Scalar types

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 to u32:
Float literals become 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:
Pass the scalar value as a 1-element numpy array at dispatch time:

Vector types

Enigma supports vector construction for geometric operations. Vector types are created from scalars:
Access components via .x, .y, .z, .w, or by lane index:
See Operations for geometric and vector math functions.