Skip to main content
For arithmetic, math, and comparison ops, see Operations. This page covers the API surface for the remaining intrinsics: vector construction, geometry, packing/unpacking between float vectors and packed integers, and type casting.

Type casting

enigma.metal_cast(value, dtype) -> IRValue

Numeric conversion. Lowers to MSL static_cast<T>(x).

enigma.as_type(value, dtype) -> IRValue

Bitwise reinterpret. Target type must have the same bit width. Lowers to MSL as_type<T>(x).

Vector construction

Short vectors are IRValues with dtype "vec<N,elem>" and map to Metal floatN / halfN / intN / uintN types.

enigma.make_vec(*components) -> IRValue

Construct a vector from 2, 3, or 4 scalar components. All components must share the same dtype.

Convenience constructors

Lane access


Geometry

All take vector IRValues. Returns are scalar or vector as noted.

Scalar-returning

Vector-returning


Pack / unpack (color and texture formats)

Convert between float vectors and packed integer representations. These mirror MSL’s pack_float_to_* / unpack_*_to_float functions used for color and texture encoding. For integer-only packing (uint8, int4) used in quantized GEMM, see Quantization Helpers.

Pack: vector → uint

All take a vector IRValue and return a uint IRValue.

Unpack: uint → vector

All take a uint IRValue and return a vector IRValue.

Example: round-trip