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()

Stringify options according to what mlir-opt expects.

get_options()[source]

Stringify options according to what mlir-opt expects.

ApplyRegisteredPassOp expects options to be a single StringAttr which follows the same format as the one used with mlir-opt.

https://mlir.llvm.org/docs/Dialects/Transform/#transformapply_registered_pass-transformapplyregisteredpassop

Options passed to a pass are specified via the syntax {option1=value1 option2=value2 …}, i.e., use space-separated key=value pairs for each option.

https://mlir.llvm.org/docs/Tutorials/MlirOpt/#running-a-pass-with-options

Experimentally we found that single-options also work without values.