Skip to content

Commit 2aeb693

Browse files
Copilotgramalingam
andcommitted
Move callable check to last position in _to_value_pattern function
Co-authored-by: gramalingam <10075881+gramalingam@users.noreply.github.com>
1 parent ccf8d4a commit 2aeb693

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

onnxscript/rewriter/_pattern_ir.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,19 @@ def _to_value_pattern(
284284
explicitly write this as:
285285
::
286286
z = op.Add(x, op.Constant(0))
287-
287+
288288
If a callable is provided, it will be converted to a ValuePattern with the callable as the check attribute.
289289
"""
290290
if x is None or isinstance(x, ValuePattern):
291291
return x
292-
if callable(x):
293-
return ValuePattern(None, check=x)
294292
if isinstance(x, (int, float)):
295293
return Constant(x)
296294
if isinstance(x, Sequence):
297295
if all(isinstance(i, (int, float)) for i in x):
298296
return Constant(x)
299297
raise ValueError("Only lists of int/float can be used as a ValuePattern")
298+
if callable(x):
299+
return ValuePattern(None, check=x)
300300

301301
raise TypeError(f"Cannot convert {type(x)} to ValuePattern")
302302

0 commit comments

Comments
 (0)