tilelang.autoddΒΆ

AttributesΒΆ

ClassesΒΆ

ASTRewrite

Helper class that provides a standard way to create an ABC using

GeneralRemove

Helper class that provides a standard way to create an ABC using

CallFwdArg1

Helper class that provides a standard way to create an ABC using

AttachFullFuncArgs

Helper class that provides a standard way to create an ABC using

IntConstApply

Helper class that provides a standard way to create an ABC using

BinOpFwdArg

Helper class that provides a standard way to create an ABC using

ASTPat

ASTPatRewrite

Helper class that provides a standard way to create an ABC using

ASTMutator

LabeledRewrite

RewriteAttacher

RewriteApplier

Task

PDD

TaskManager

Helper class that provides a standard way to create an ABC using

ASTPDD

Helper class that provides a standard way to create an ABC using

LinePDD

Helper class that provides a standard way to create an ABC using

Ruff

Helper class that provides a standard way to create an ABC using

AsyncPythonRunner

SubProcRunner

ParTaskManager

Args

FunctionsΒΆ

ast_replace(node, **changes)

parse_stmts(s)

parse_expr(s)

expr_to_zeros(target)

attach_rewrites(tree, rewrites)

apply_rewrites(tree, target_labels)

test_rewrite(rewrite, code)

ruff_fix_code(code_string[, fix_lint, format_code])

clean_empty_pass(code)

main(args)

cli_main([argv])

Module ContentsΒΆ

tilelang.autodd.ast_replace(node, **changes)ΒΆ
Parameters:

node (ast.AST)

Return type:

ast.AST

tilelang.autodd.parse_stmts(s)ΒΆ
Parameters:

s (str)

Return type:

list[ast.stmt]

tilelang.autodd.parse_expr(s)ΒΆ
Parameters:

s (str)

Return type:

ast.expr

class tilelang.autodd.ASTRewriteΒΆ

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract get_name()ΒΆ
Return type:

str

abstract match(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

bool

abstract rewrite(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

ast.AST | list[ast.AST] | None

class tilelang.autodd.GeneralRemoveΒΆ

Bases: ASTRewrite

Helper class that provides a standard way to create an ABC using inheritance.

name: strΒΆ
target_type: type[ast.AST]ΒΆ
inside_list: bool = TrueΒΆ
replace_with: ast.AST | list[ast.AST] | None = NoneΒΆ
get_name()ΒΆ
Return type:

str

match(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

bool

rewrite(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

None

tilelang.autodd.expr_to_zeros(target)ΒΆ
Parameters:

target (ast.expr)

Return type:

ast.expr

class tilelang.autodd.CallFwdArg1ΒΆ

Bases: ASTRewrite

Helper class that provides a standard way to create an ABC using inheritance.

get_name()ΒΆ
Return type:

str

match(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

bool

rewrite(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

ast.AST

class tilelang.autodd.AttachFullFuncArgsΒΆ

Bases: ASTRewrite

Helper class that provides a standard way to create an ABC using inheritance.

get_name()ΒΆ
Return type:

str

match(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

bool

rewrite(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

ast.AST

class tilelang.autodd.IntConstApplyΒΆ

Bases: ASTRewrite

Helper class that provides a standard way to create an ABC using inheritance.

matcher: Callable[[int], bool]ΒΆ
apply: Callable[[int], ast.AST]ΒΆ
name: strΒΆ
get_name()ΒΆ
Return type:

str

match(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

bool

rewrite(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

ast.AST

class tilelang.autodd.BinOpFwdArgΒΆ

Bases: ASTRewrite

Helper class that provides a standard way to create an ABC using inheritance.

forward: Literal['left', 'right'] = 'left'ΒΆ
get_name()ΒΆ
Return type:

str

match(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

bool

rewrite(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

ast.AST

tilelang.autodd.ASTPatKindΒΆ
class tilelang.autodd.ASTPatΒΆ
tree: ast.expr | list[ast.stmt]ΒΆ
placeholders: set[str]ΒΆ
classmethod from_code(kind, code, placeholders)ΒΆ
Parameters:
  • kind (ASTPatKind)

  • code (str)

  • placeholders (set[str])

Return type:

ASTPat

match_placeholders(node)ΒΆ
Parameters:

node (ast.AST | list[ast.AST])

Return type:

dict[str, ast.AST] | bool

match(node)ΒΆ
Parameters:

node (ast.AST)

Return type:

bool

replace(repl)ΒΆ
Parameters:

repl (dict[str, ast.AST])

Return type:

ast.AST

class tilelang.autodd.ASTPatRewriteΒΆ

Bases: ASTRewrite

Helper class that provides a standard way to create an ABC using inheritance.

name: strΒΆ
match_pat: ASTPatΒΆ
rewrite_pat: ASTPatΒΆ
checker: Callable[[dict[str, ast.AST]], bool] | dict[str, Callable[[ast.AST], bool]] | None = NoneΒΆ
derived: dict[str, Callable[[dict[str, ast.AST]], ast.AST]] | None = NoneΒΆ
classmethod from_code(name, kind, match, rewrite, placeholders, checker=None, derived=None)ΒΆ
Parameters:
  • name (str)

  • kind (ASTPatKind)

  • match (str)

  • rewrite (str)

  • placeholders (set[str])

  • checker (Callable[[dict[str, ast.AST]], bool] | dict[str, Callable[[ast.AST], bool]] | None)

  • derived (dict[str, Callable[[dict[str, ast.AST]], ast.AST]] | None)

Return type:

ASTPatRewrite

get_name()ΒΆ
Return type:

str

match_placeholders(node)ΒΆ
Parameters:

node (ast.AST)

match(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

bool

rewrite(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

Return type:

ast.AST

class tilelang.autodd.ASTMutatorΒΆ
generic_visit(node)ΒΆ
visit(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST | None)

  • field (str | None)

  • inside_list (bool)

class tilelang.autodd.LabeledRewriteΒΆ
label: intΒΆ
rewrite: ASTRewriteΒΆ
class tilelang.autodd.RewriteAttacher(rewrites)ΒΆ

Bases: ASTMutator

Parameters:

rewrites (list[ASTRewrite])

rewritesΒΆ
uid_counter = 0ΒΆ
rewrite_counter = 0ΒΆ
rewrite_namesΒΆ
visit(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST | None)

  • field (str | None)

  • inside_list (bool)

tilelang.autodd.attach_rewrites(tree, rewrites)ΒΆ
Parameters:
Return type:

tuple[ast.AST, int, int]

class tilelang.autodd.RewriteApplier(target_labels)ΒΆ

Bases: ASTMutator

Parameters:

target_labels (set[int])

target_labelsΒΆ
applied_rewrites: set[int]ΒΆ
visited: set[int]ΒΆ
visit(node, parent, field, inside_list)ΒΆ
Parameters:
  • node (ast.AST)

  • parent (ast.AST | None)

  • field (str | None)

  • inside_list (bool)

tilelang.autodd.apply_rewrites(tree, target_labels)ΒΆ
Parameters:
  • tree (ast.AST)

  • target_labels (set[int])

Return type:

tuple[ast.AST, set[int]]

tilelang.autodd.test_rewrite(rewrite, code)ΒΆ
Parameters:
class tilelang.autodd.TaskΒΆ
source: strΒΆ
applied: list[int]ΒΆ
masked: list[int]ΒΆ
with_source(source)ΒΆ
Parameters:

source (str)

Return type:

Task

class tilelang.autodd.PDD(all_labels, init_proba=0.93)ΒΆ
Parameters:
  • all_labels (list[int])

  • init_proba (float)

all_labelsΒΆ
probasΒΆ
apply(target_labels)ΒΆ
Parameters:

target_labels (set[int])

Return type:

set[int]

generator()ΒΆ
Return type:

collections.abc.Iterable[Task]

update(task, is_interesting)ΒΆ
Parameters:
class tilelang.autodd.TaskManagerΒΆ

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract task_generator()ΒΆ
Return type:

collections.abc.Iterable[Task]

abstract task_update(task, is_interesting)ΒΆ
Parameters:
classmethod from_source(source, *args, **kwargs)ΒΆ
Abstractmethod:

Parameters:

source (str)

Return type:

TaskManager

class tilelang.autodd.ASTPDD(tree, rewrites, init_proba=0.93)ΒΆ

Bases: TaskManager, PDD

Helper class that provides a standard way to create an ABC using inheritance.

Parameters:
  • tree (ast.AST)

  • rewrites (list[ASTRewrite])

  • init_proba (float)

classmethod from_source(source, *args, **kwargs)ΒΆ
apply(target_labels)ΒΆ
Parameters:

target_labels (set[int])

Return type:

set[int]

task_generator()ΒΆ
Return type:

collections.abc.Iterable[Task]

task_update(task, is_interesting)ΒΆ
Parameters:
tilelang.autodd.ruff_fix_code(code_string, fix_lint=True, format_code=True)ΒΆ
Parameters:
  • code_string (str)

  • fix_lint (bool)

  • format_code (bool)

Return type:

str

class tilelang.autodd.LinePDD(source, init_proba=0.93)ΒΆ

Bases: TaskManager, PDD

Helper class that provides a standard way to create an ABC using inheritance.

Parameters:
  • source (str)

  • init_proba (float)

linesΒΆ
classmethod from_source(source, *args, **kwargs)ΒΆ
task_generator()ΒΆ
Return type:

collections.abc.Iterable[Task]

task_update(task, is_interesting)ΒΆ
Parameters:
class tilelang.autodd.Ruff(source, fix_lint=True, format_code=True)ΒΆ

Bases: TaskManager

Helper class that provides a standard way to create an ABC using inheritance.

Parameters:
  • source (str)

  • fix_lint (bool)

  • format_code (bool)

sourceΒΆ
fix_lint = TrueΒΆ
format_code = TrueΒΆ
finished = FalseΒΆ
classmethod from_source(source, *args, **kwargs)ΒΆ
Parameters:

source (str)

Return type:

Ruff

task_generator()ΒΆ
task_update(task, is_interesting)ΒΆ
Parameters:
class tilelang.autodd.AsyncPythonRunnerΒΆ
process = NoneΒΆ
input_queue = NoneΒΆ
output_queue = NoneΒΆ
lockΒΆ
start_proc()ΒΆ
stop_proc()ΒΆ
__enter__()ΒΆ
__exit__(exc_type, exc_value, traceback)ΒΆ
async run(code, timeout=5.0)ΒΆ
Parameters:
  • code (str)

  • timeout (float)

class tilelang.autodd.SubProcRunnerΒΆ
__enter__()ΒΆ
__exit__(exc_type, exc_value, traceback)ΒΆ
async run(code, timeout=5.0)ΒΆ
Parameters:
  • code (str)

  • timeout (float)

tilelang.autodd.clean_empty_pass(code)ΒΆ
Parameters:

code (str)

Return type:

str

tilelang.autodd.JobBackendΒΆ
class tilelang.autodd.ParTaskManagerΒΆ
err_msg: strΒΆ
text: strΒΆ
output_file: pathlib.PathΒΆ
timeout: int = 60ΒΆ
num_workers: int = 1ΒΆ
backend: JobBackend = 'runner'ΒΆ
allow_larger: bool = FalseΒΆ
__post_init__()ΒΆ
property text_lenΒΆ
reset(task_manager)ΒΆ
Parameters:

task_manager (TaskManager)

async get_next_task()ΒΆ
Return type:

Task | None

async submit_result(task, is_interested)ΒΆ
Parameters:
post_proc(text)ΒΆ
async worker(wid)ΒΆ
Parameters:

wid (int)

async start_workers()ΒΆ
async stop_workers()ΒΆ
async run_async(task_manager)ΒΆ
Parameters:

task_manager (TaskManager)

async run_with(cls, *args, **kwargs)ΒΆ
Parameters:

cls (type[TaskManager])

class tilelang.autodd.ArgsΒΆ

Bases: NamedTuple

source: pathlib.PathΒΆ
err_msg: strΒΆ
output: pathlib.PathΒΆ
backend: JobBackendΒΆ
timeout: intΒΆ
jobs: intΒΆ
async tilelang.autodd.main(args)ΒΆ
Parameters:

args (Args)

tilelang.autodd.cli_main(argv=None)ΒΆ
Parameters:

argv (Sequence[str] | None)

Return type:

None