tilelang.autodd

Attributes

類別

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

函式

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)
參數:

node (ast.AST)

回傳型別:

ast.AST

tilelang.autodd.parse_stmts(s)
參數:

s (str)

回傳型別:

list[ast.stmt]

tilelang.autodd.parse_expr(s)
參數:

s (str)

回傳型別:

ast.expr

class tilelang.autodd.ASTRewrite

Bases: abc.ABC

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

abstractmethod get_name()
回傳型別:

str

abstractmethod match(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

bool

abstractmethod rewrite(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

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()
回傳型別:

str

match(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

bool

rewrite(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

None

tilelang.autodd.expr_to_zeros(target)
參數:

target (ast.expr)

回傳型別:

ast.expr

class tilelang.autodd.CallFwdArg1

Bases: ASTRewrite

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

get_name()
回傳型別:

str

match(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

bool

rewrite(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

ast.AST

class tilelang.autodd.AttachFullFuncArgs

Bases: ASTRewrite

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

get_name()
回傳型別:

str

match(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

bool

rewrite(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

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()
回傳型別:

str

match(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

bool

rewrite(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

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()
回傳型別:

str

match(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

bool

rewrite(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

ast.AST

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

  • code (str)

  • placeholders (set[str])

回傳型別:

ASTPat

match_placeholders(node)
參數:

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

回傳型別:

dict[str, ast.AST] | bool

match(node)
參數:

node (ast.AST)

回傳型別:

bool

replace(repl)
參數:

repl (dict[str, ast.AST])

回傳型別:

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)
參數:
  • 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)

回傳型別:

ASTPatRewrite

get_name()
回傳型別:

str

match_placeholders(node)
參數:

node (ast.AST)

match(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

bool

rewrite(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST)

  • field (str)

  • inside_list (bool)

回傳型別:

ast.AST

class tilelang.autodd.ASTMutator
generic_visit(node)
visit(node, parent, field, inside_list)
參數:
  • 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

參數:

rewrites (list[ASTRewrite])

rewrites
uid_counter = 0
rewrite_counter = 0
rewrite_names
visit(node, parent, field, inside_list)
參數:
  • node (ast.AST)

  • parent (ast.AST | None)

  • field (str | None)

  • inside_list (bool)

tilelang.autodd.attach_rewrites(tree, rewrites)
參數:
回傳型別:

tuple[ast.AST, int, int]

class tilelang.autodd.RewriteApplier(target_labels)

Bases: ASTMutator

參數:

target_labels (set[int])

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

  • parent (ast.AST | None)

  • field (str | None)

  • inside_list (bool)

tilelang.autodd.apply_rewrites(tree, target_labels)
參數:
  • tree (ast.AST)

  • target_labels (set[int])

回傳型別:

tuple[ast.AST, set[int]]

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

source (str)

回傳型別:

Task

class tilelang.autodd.PDD(all_labels, init_proba=0.93)
參數:
  • all_labels (list[int])

  • init_proba (float)

all_labels
probas
apply(target_labels)
參數:

target_labels (set[int])

回傳型別:

set[int]

generator()
回傳型別:

collections.abc.Iterable[Task]

update(task, is_interesting)
參數:
class tilelang.autodd.TaskManager

Bases: abc.ABC

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

abstractmethod task_generator()
回傳型別:

collections.abc.Iterable[Task]

abstractmethod task_update(task, is_interesting)
參數:
classmethod from_source(source, *args, **kwargs)
Abstractmethod:

參數:

source (str)

回傳型別:

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.

參數:
  • tree (ast.AST)

  • rewrites (list[ASTRewrite])

  • init_proba (float)

classmethod from_source(source, *args, **kwargs)
apply(target_labels)
參數:

target_labels (set[int])

回傳型別:

set[int]

task_generator()
回傳型別:

collections.abc.Iterable[Task]

task_update(task, is_interesting)
參數:
tilelang.autodd.ruff_fix_code(code_string, fix_lint=True, format_code=True)
參數:
  • code_string (str)

  • fix_lint (bool)

  • format_code (bool)

回傳型別:

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.

參數:
  • source (str)

  • init_proba (float)

lines
classmethod from_source(source, *args, **kwargs)
task_generator()
回傳型別:

collections.abc.Iterable[Task]

task_update(task, is_interesting)
參數:
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.

參數:
  • source (str)

  • fix_lint (bool)

  • format_code (bool)

source
fix_lint = True
format_code = True
finished = False
classmethod from_source(source, *args, **kwargs)
參數:

source (str)

回傳型別:

Ruff

task_generator()
task_update(task, is_interesting)
參數:
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)
參數:
  • code (str)

  • timeout (float)

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

  • timeout (float)

tilelang.autodd.clean_empty_pass(code)
參數:

code (str)

回傳型別:

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)
參數:

task_manager (TaskManager)

async get_next_task()
回傳型別:

Task | None

async submit_result(task, is_interested)
參數:
post_proc(text)
async worker(wid)
參數:

wid (int)

async start_workers()
async stop_workers()
async run_async(task_manager)
參數:

task_manager (TaskManager)

async run_with(cls, *args, **kwargs)
參數:

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)
參數:

args (Args)

tilelang.autodd.cli_main(argv=None)
參數:

argv (Sequence[str] | None)

回傳型別:

None