Bases: ModulePass
Transform dialect interpreter
Source code in xdsl/transforms/transform_interpreter.py
| @dataclass(frozen=True)
class TransformInterpreterPass(ModulePass):
"""Transform dialect interpreter"""
name = "transform-interpreter"
entry_point: str = "__transform_main"
@staticmethod
def find_transform_entry_point(
root: builtin.ModuleOp, entry_point: str
) -> transform.NamedSequenceOp:
for op in root.walk():
if (
isinstance(op, transform.NamedSequenceOp)
and op.sym_name.data == entry_point
):
return op
raise PassFailedException(
f"{root} could not find a nested named sequence with name: {entry_point}"
)
def apply(self, ctx: Context, op: builtin.ModuleOp) -> None:
schedule = TransformInterpreterPass.find_transform_entry_point(
op, self.entry_point
)
interpreter = Interpreter(op)
interpreter.register_implementations(TransformFunctions(ctx, get_all_passes()))
interpreter.register_implementations(PrintfFunctions())
interpreter.call_op(schedule, (OperationHandle(op),))
|
entry_point: str = '__transform_main'
class-attribute
instance-attribute
find_transform_entry_point(root: builtin.ModuleOp, entry_point: str) -> transform.NamedSequenceOp
staticmethod
Source code in xdsl/transforms/transform_interpreter.py
| @staticmethod
def find_transform_entry_point(
root: builtin.ModuleOp, entry_point: str
) -> transform.NamedSequenceOp:
for op in root.walk():
if (
isinstance(op, transform.NamedSequenceOp)
and op.sym_name.data == entry_point
):
return op
raise PassFailedException(
f"{root} could not find a nested named sequence with name: {entry_point}"
)
|
Source code in xdsl/transforms/transform_interpreter.py
| def apply(self, ctx: Context, op: builtin.ModuleOp) -> None:
schedule = TransformInterpreterPass.find_transform_entry_point(
op, self.entry_point
)
interpreter = Interpreter(op)
interpreter.register_implementations(TransformFunctions(ctx, get_all_passes()))
interpreter.register_implementations(PrintfFunctions())
interpreter.call_op(schedule, (OperationHandle(op),))
|