Data types and tilesReference pages
Reference
Data types and tiles
The element types that tiles, pointers, and tensors hold, and the attributes, operators, and methods of a tile.
Element types
The following element types are available as tl attributes. In a kernel, write tl.float16. In the host allocators, pass the string "float16" or a short name. Enceladus has no 64-bit floating-point type.
| Kind | Type | Bits | Short names |
|---|---|---|---|
| Boolean | tl.int1 | 1 | i1, bool |
| Signed integer | tl.int8 | 8 | i8 |
| Signed integer | tl.int16 | 16 | i16 |
| Signed integer | tl.int32 | 32 | i32 |
| Signed integer | tl.int64 | 64 | i64 |
| Unsigned integer | tl.uint8 | 8 | u8 |
| Unsigned integer | tl.uint16 | 16 | u16 |
| Unsigned integer | tl.uint32 | 32 | u32 |
| Unsigned integer | tl.uint64 | 64 | u64 |
| Floating point | tl.float16 | 16 | fp16 |
| Floating point | tl.bfloat16 | 16 | bf16 |
| Floating point | tl.float32 | 32 | fp32 |
Math functions such as tl.exp take float inputs only. For 16-bit floats, they compute in float32 and round the result back.
Tile attributes
A tile x has the following attributes:
x.shape: the shape, as a tuple of ints.x.dtype: the element type. For a pointer, it's the pointee type, so bothx_ptr.dtypeandx_ptr.dtype.element_tygive the element type.x.numel: the number of elements.x.T: the transpose, the same astl.trans(x).
Operators
Tiles support the operators +, -, *, /, //, %, &, |, ^, ~, <<, >>, and the comparisons. Operands broadcast to one shape.
** and @ aren't supported on runtime values. For matrix products, use tl.dot.
Indexing with None and : inserts dimensions. For example, x[:, None] turns a tile of shape (N,) into one of shape (N, 1).
Tile methods
You can call the following builtins as methods of a tile. Each one takes the same arguments as the tl function of the same name, without the first argument. For example, x.sum(axis=0) is tl.sum(x, axis=0).
x.abs(), x.argmax(), x.argmin(), x.associative_scan(), x.broadcast_to(), x.cast(), x.ceil(), x.cos(), x.cumsum(), x.erf(), x.exp(), x.exp2(), x.expand_dims(), x.floor(), x.log(), x.log2(), x.max(), x.min(), x.permute(), x.reduce(), x.reshape(), x.rsqrt(), x.sigmoid(), x.sin(), x.sqrt(), x.sum(), x.tanh(), x.trans()
x.to(dtype) is the same as x.cast(dtype).