Skip to content
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

[BUG] Pattern Reeriter Seg Fault #5605

Closed
comaniac opened this issue May 16, 2020 · 2 comments
Closed

[BUG] Pattern Reeriter Seg Fault #5605

comaniac opened this issue May 16, 2020 · 2 comments

Comments

@comaniac
Copy link
Contributor

comaniac commented May 16, 2020

I was trying the new merged pattern language. Specifically, my goal is to create a function for the matched pattern and rewrite the pattern with a function call, which is very similar to fusion.

However, the following example encounters segmentation fault. I breifly located the position and found that it was in dominator analysis. Specifically in LeastCommonAncestor. It crashes when visiting an input node with null parent.

Here is the code snippet to reproduce the problem. I am not sure if I wrote the pattern in the right way, but it works fine with pattern.match.

cc @mbrookhart

import tvm
from tvm import relay
from tvm.relay.dataflow_pattern import *

class PatternCallback(DFPatternCallback):
    def __init__(self, pattern):
        self.pattern = pattern

    def callback(self, pre, post, node_map):
        return post

def gen():
    x = relay.var('x')
    y = relay.var('y')
    y_add = relay.add(y, y)
    n0 = relay.add(x, y_add)
    n1 = relay.add(x, n0)
    return relay.add(n1, n0)

def pattern():
    a = wildcard()
    b = wildcard()
    n0 = is_op('add')(a, b)
    n1 = is_op('add')(n0, a)
    return is_op('add')(n0, n1)

out = gen()
pat = pattern()
print(pat.match(out))
new_out = rewrite(PatternCallback(pat), out)
print(new_out)

Output:

1
Segmentation Fault (core dumped)
@mbrookhart
Copy link
Contributor

Thanks, @comaniac! Just saw this, I'll reproduce and produce a fix first thing tomorrow.

@comaniac
Copy link
Contributor Author

The PR fixed this issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants