tilus.Class¶
- class tilus.Class[source]¶
A helper class for organizing kernel logic into reusable components.
tilus.Classworks liketilus.Scriptbut for helper objects that are not kernels themselves. It can allocate mbarriers, shared tensors, tensor memory, and use all tilus instructions.Subclass
tilus.Classand define an__init__method to create reusable abstractions. The__init__is transpiled alongside the kernel that uses it.Example:
class Pipeline(tilus.Class): def __init__(self, num_stages: int): self.barriers = self.mbarrier.alloc(counts=[1] * num_stages) self.stage: int32 = 0 def advance(self): self.stage = (self.stage + 1) % self.num_stages
Use it inside a
tilus.Script:class MyKernel(tilus.Script): def __call__(self, ...): pipe = Pipeline(num_stages=4) pipe.advance()