-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pattern match on default attributes? #2012
Comments
Thanks. So a node with default and without default is store differently in graph. They are semantically the same but syntactically different. We need to decide what the behavior of the matcher should be. |
Well, it can be outside of matcher, if one could force defaults for But as I found, it may be not formalized at all!
I wonder, how it handled in |
I would rather put defaults handler outside of matcher, with function like |
I had the same problem. For now I solved it through a def target_pattern(op, x, w):
return op.Conv(x, w, _outputs=["y"])
def replacement_pattern(op, x, w, **__):
# Naïve pattern
return op.Identity(op.Conv(x, w))
def condition_fn(*_, y, **__):
ir_node = y.producer()
return (dilatation := ir_node.attributes.get("dilatation", None)) and dilatation.value == [1,1]
rule = RewriteRule(target_pattern, replacement_pattern, condition_fn) I tried the following def target_pattern(op, x, w, dilatation=[1,1]):
return op.Conv(x, w, dilatation=dilatation) But unfortunately the condition was never triggered. Let me know if there is a simpler solution. |
@Johansmm hey, yes, it is better then my force/strip_defaults! |
Problem: rewrite
Conv
nodes, but only withdilations
==[1,1]. Issue - default value. To check dilation, I need include it in pattern, but this cause pattern match to fail on nodes with default dilations.Probably related: #1627
Possible fix: substitute defaults on deserialization, I suspect, such a function already exists.
rewr_c.py.txt
The text was updated successfully, but these errors were encountered: