catalyst.passes.Pass

class Pass(name: str, *options: list[str], **valued_options: dict[str, str])[source]

Bases: object

Class intended to hold options for passes.

Pass will be used when generating ApplyRegisteredPassOp`s. The attribute `pass_name corresponds to the field name. The attribute options is generated by the get_options method.

People working on MLIR plugins may use this or PassPlugin to schedule their compilation pass. E.g.,

def an_optimization(qnode):
    @functools.wraps(qnode)
    def wrapper(*args, **kwargs):
        pass_pipeline = kwargs.pop("pass_pipeline", [])
        pass_pipeline.append(Pass("my_library.my_optimization", *args, **kwargs))
        kwargs["pass_pipeline"] = pass_pipeline
        return qnode(*args, **kwargs)
return wrapper

get_options()

Build a dictionary mapping option names to MLIR attributes.

get_options()[source]

Build a dictionary mapping option names to MLIR attributes. ApplyRegisteredPassOp expects options to be a dictionary from strings to attributes. See https://github.com/llvm/llvm-project/pull/143159