Skip to content

Commit 9340dcf

Browse files
committed
Fix pattern matcher
Signed-off-by: Justin Chu <[email protected]>
1 parent 5729447 commit 9340dcf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

onnxscript/rewriter/_pattern_ir.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,16 @@ class AttrConstantPattern(AttrPattern):
123123

124124
def __init__(self, value: SupportedAttrTypes):
125125
super().__init__(None)
126-
if isinstance(value, Sequence):
127-
value = tuple(value)
128126
self._value = value
129127

130128
def matches(self, attr: ir.Attr) -> bool:
131-
if attr.type in {ir.AttributeType.INTS, ir.AttributeType.FLOATS, ir.AttributeType.STRINGS}:
129+
if attr.type in {
130+
ir.AttributeType.INTS,
131+
ir.AttributeType.FLOATS,
132+
ir.AttributeType.STRINGS,
133+
}:
132134
# Since the type of attr.value is Sequence, we need to convert to the same type for comparison.
133-
return tuple(attr.value) == self._value
135+
return tuple(attr.value) == tuple(self._value)
134136
return attr.value == self._value
135137

136138
def __str__(self) -> str:

0 commit comments

Comments
 (0)