tilelang.tools.compile_onlyΒΆ

Compile-only tool: emit inspectable lower() kernel source without a GPU.

Usage:

python3 -I -m tilelang.tools.compile_only --output_file out.s example.py

The default target is c (CPU C). CUDA is optional:

python3 -I -m tilelang.tools.compile_only --target cuda --output_file out.s example.py

Programmatic API:

from tilelang.tools.compile_only import compile_kernel_source

source = compile_kernel_source(func)  # default target c

AttributesΒΆ

FunctionsΒΆ

cuda_codegen_available()

Return whether this wheel can lower CUDA (AnnotateDeviceBoundTmaCopies).

resolve_target(target)

Map a CLI/library target string to an explicit lower() target.

load_example(path)

Load example.py as a module (D2). Do not treat it as a launch script.

discover_prim_func(module)

Return the first @tilelang.jit / PrimFunc in module order (D2, 叀法: one piece).

compile_kernel_source(func[, target])

Lower func with enable_device_compile=False and return kernel_source (D1).

cli_main([argv])

CE-shaped CLI (D2): --output_file + example.py. Default target c (D3).

Module ContentsΒΆ

tilelang.tools.compile_only.DEFAULT_TARGET = 'c'ΒΆ
tilelang.tools.compile_only.cuda_codegen_available()ΒΆ

Return whether this wheel can lower CUDA (AnnotateDeviceBoundTmaCopies).

Return type:

bool

tilelang.tools.compile_only.resolve_target(target)ΒΆ

Map a CLI/library target string to an explicit lower() target.

Parameters:

target (str) – User-facing target. auto is rejected. cuda is pinned to sm_80. Option-bearing CUDA strings (cuda -arch=sm_90 or JSON) keep their arch.

Returns:

A TVM target string, or a CUDA target dict.

Return type:

str or dict

tilelang.tools.compile_only.load_example(path)ΒΆ

Load example.py as a module (D2). Do not treat it as a launch script.

Parameters:

path (str)

Return type:

types.ModuleType

tilelang.tools.compile_only.discover_prim_func(module)ΒΆ

Return the first @tilelang.jit / PrimFunc in module order (D2, 叀法: one piece).

Parameters:

module (types.ModuleType)

tilelang.tools.compile_only.compile_kernel_source(func, target=DEFAULT_TARGET)ΒΆ

Lower func with enable_device_compile=False and return kernel_source (D1).

Parameters:
  • func (PrimFunc or IRModule) – Kernel from JITImpl.get_tir() or a PrimFunc. No tensor args.

  • target (str or dict, optional) – Explicit target. Strings go through resolve_target(). Default c.

Returns:

Non-empty CompiledArtifact.kernel_source from existing lower().

Return type:

str

tilelang.tools.compile_only.cli_main(argv=None)ΒΆ

CE-shaped CLI (D2): --output_file + example.py. Default target c (D3).

Parameters:

argv (list[str] | None)

Return type:

int