@@ -183,14 +183,14 @@ def _match_value(
183
183
self , pattern_value : _pattern_ir .ValuePattern , value : ir .Value | None
184
184
) -> bool :
185
185
"""Match an IR value against a ValuePattern instance."""
186
- if value is not None and value .graph is not self ._graph_or_function :
186
+ if value is not None and value .graph is not self ._graph :
187
187
if not isinstance (
188
188
pattern_value , (_pattern_ir .Var , _pattern_ir .Constant , _pattern_ir .AnyValue )
189
189
):
190
190
# If the pattern value is a Var, Constant, or AnyValue, we allow it to match
191
191
# values from other graphs. Otherwise, we fail the match.
192
192
return self .fail (
193
- f"Value { value .name } is not in the graph { self ._graph_or_function .name } . "
193
+ f"Value { value .name } is not in the graph { self ._graph .name } . "
194
194
f"Pattern matches crossing graph boundaries are not supported."
195
195
)
196
196
if isinstance (pattern_value , _pattern_ir .AnyValue ):
@@ -362,7 +362,10 @@ def match(
362
362
complications which require careful consideration.
363
363
"""
364
364
self ._tracer = tracer
365
- self ._graph_or_function = graph_or_function [0 ].graph
365
+ if isinstance (graph_or_function , ir .Graph ):
366
+ self ._graph : ir .Graph = graph_or_function
367
+ else :
368
+ self ._graph = graph_or_function .graph
366
369
if self .pattern .has_single_output_node :
367
370
self ._init_match (verbose )
368
371
return self ._match_single_output_node (
0 commit comments