Enceladus v0.1.0 · alpha
Data types and tilesReference pages
Language builtinsHost APIData types and tilesEnvironment variables

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.

KindTypeBitsShort names
Booleantl.int11i1, bool
Signed integertl.int88i8
Signed integertl.int1616i16
Signed integertl.int3232i32
Signed integertl.int6464i64
Unsigned integertl.uint88u8
Unsigned integertl.uint1616u16
Unsigned integertl.uint3232u32
Unsigned integertl.uint6464u64
Floating pointtl.float1616fp16
Floating pointtl.bfloat1616bf16
Floating pointtl.float3232fp32

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 both x_ptr.dtype and x_ptr.dtype.element_ty give the element type.
  • x.numel: the number of elements.
  • x.T: the transpose, the same as tl.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).