tilelang.jit.adapter.base¶
The profiler and convert to torch utils
Attributes¶
Classes¶
Helper class that provides a standard way to create an ABC using |
Functions¶
|
Return the caller-supplied launch stream when outputs must be allocated on it. |
Module Contents¶
- class tilelang.jit.adapter.base.CachedTextSource¶
- text: str | None = None¶
- path: str | None = None¶
- tilelang.jit.adapter.base.CachedTextSourceLike¶
- tilelang.jit.adapter.base.output_allocation_stream(stream, device)¶
Return the caller-supplied launch stream when outputs must be allocated on it.
torch’s caching allocator orders reuse of a block only after earlier work on the stream the block was allocated on, so tensors written by a kernel launched on
streamare allocated onstream.Nonemeans the launch stream is the current stream, where a plaintorch.emptyis already correct.- Parameters:
stream (int)
device (torch.device)
- Return type:
torch.cuda.Stream | None
- class tilelang.jit.adapter.base.BaseKernelAdapter(mod, params, result_idx)¶
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- Parameters:
params (list[tilelang.engine.param.KernelParam])
result_idx (int | list[int] | None)
- func: collections.abc.Callable | None = None¶
- mod¶
- params¶
- result_idx¶
- static get_current_stream_functor(device=None)¶
Return a callable that reads Torch’s current device stream pointer.
The returned lambda yields the raw stream handle of the current PyTorch stream on the active device. It’s a thunk (evaluated at call time) so that any upstream stream guards are respected. If no supported device runtime is available, it returns a lambda that yields 0. An explicit Torch device takes precedence over runtime auto-detection.
- Parameters:
device (torch.device | None)
- Return type:
collections.abc.Callable[[], int]
- static get_current_device_functor()¶
Return a callable that yields Torch’s current device.
Similar to the stream functor, we capture a callable that, when called, fetches the current device according to PyTorch, independently of the compilation target. If neither NPU nor CUDA is available, returns
torch.device('cpu').- Return type:
collections.abc.Callable[[], torch.device]
- __call__(*args, **kwds)¶
- Parameters:
args (Any)
kwds (Any)
- Return type:
Any