diff --git a/onnxscript/rewriter/_basics.py b/onnxscript/rewriter/_basics.py index a875626d3f..6529bea627 100644 --- a/onnxscript/rewriter/_basics.py +++ b/onnxscript/rewriter/_basics.py @@ -38,6 +38,14 @@ def __init__(self) -> None: # We use a stack of partial matches to handle OR patterns that require backtracking. self._partial_matches: list[PartialMatchResult] = [PartialMatchResult()] + def __repr__(self) -> str: + """Returns a string representation of the match result.""" + if not self._partial_matches: + return "MatchResult()" + return ( + f"MatchResult(success={bool(self)}, reason={self.reason!r}, nodes={self.nodes!r})" + ) + @property def _current_match(self) -> PartialMatchResult: """Returns the current match result."""