[TF frontend][bugfix]Avoid making a new node when already has span info#7789
[TF frontend][bugfix]Avoid making a new node when already has span info#7789zhiics merged 9 commits intoapache:mainfrom xqdan:spanfix
Conversation
|
cc @zhiics can you please help manage this PR Thank you |
| 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.
could you add a test case for these two lines?
There was a problem hiding this comment.
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.
Does this require pb parsing or directly creating a tf program would be sufficient?
There was a problem hiding this comment.
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.
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?