-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[TF frontend][bugfix]Avoid making a new node when already has span info #7789
Conversation
cc @zhiics can you please help manage this PR Thank you |
@@ -3851,11 +3851,11 @@ def _convert_operator( | |||
@staticmethod | |||
def _set_span(sym, node_name): | |||
span = tvm.relay.Span(tvm.relay.SourceName(node_name), 0, 0, 0, 0) | |||
if isinstance(sym, _expr.Call): | |||
if isinstance(sym, _expr.Call) and sym.span is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a test case for these two lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to, but I don't know how to create unitest for pb parsering flow, any suggestion? thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require pb parsing or directly creating a tf program would be sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require pb parsing or directly creating a tf program would be sufficient?
You are right,where can I find an exmple? I know the basic idea is creatig a tf graph, using from_tensorflow to handle it, then check the output graph ir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can refer to the existing unit/integration tests for tf frontend. Most of them just create a tf graph.
It is ok to me. I guess this is caused by different nodes in PB are being parsed to the same Relay node, so they have different names. I think EliminateCommonSubexpr() should be able to eliminate the redundancy, but it requires opt_level 3, so it is disabled by default. tvm/include/tvm/ir/transform.h Line 88 in 8131364
|
Yes,EliminateCommonSubexpr() can remove redundant operations, however better to fix at the very beginning. |
@zhiics @kevinthesun Added a unites, please review. BTW it's easy to add nn.moments as unitest because we met it, however I don't know which tf graph/layer can tigger tuple branch, appreciate if you have suggestions. |
@xqdan thanks for adding the test. But I think we probably don't need to create a new test file though. Instead, we can put it under test_forward as the operator tests are sitting there. |
Thanks @xqdan @kevinthesun |
…fo (apache#7789) * Avoid making a new node when already has span info * add test * add test * add test * fix * fix * move test to test_forward.py * fix * fix Co-authored-by: xiaoqiang.dan <xiaoqiang.dan@streamcoputing.com>
…fo (apache#7789) * Avoid making a new node when already has span info * add test * add test * add test * fix * fix * move test to test_forward.py * fix * fix Co-authored-by: xiaoqiang.dan <xiaoqiang.dan@streamcoputing.com>
…fo (apache#7789) * Avoid making a new node when already has span info * add test * add test * add test * fix * fix * move test to test_forward.py * fix * fix Co-authored-by: xiaoqiang.dan <xiaoqiang.dan@streamcoputing.com>
…fo (apache#7789) * Avoid making a new node when already has span info * add test * add test * add test * fix * fix * move test to test_forward.py * fix * fix Co-authored-by: xiaoqiang.dan <xiaoqiang.dan@streamcoputing.com>
…fo (apache#7789) * Avoid making a new node when already has span info * add test * add test * add test * fix * fix * move test to test_forward.py * fix * fix Co-authored-by: xiaoqiang.dan <xiaoqiang.dan@streamcoputing.com>
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.
@lixiaoquan @zhiics @srkreddy1238
This bug will lead redundent operations in graph ir when parsering bert:
The last mean is redundent op created by _set_span.
Since this is pb parsering flow, does anyone know how to make a unitest?