[NNVM] Bugfix operator fusion for residual block with layout transform #1760
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for the issue found by @kevinthesun.
In #1608, I added a logic to prevent fusing injective ops with convolution or other non-broadcast ops. To do that, we detect a node which has both injective ops and non-broadcast ops as parents, and assigning group and master node ids appropriately.
But I failed to address a case where the detected node has children nodes in the same group. In that case, we need to reassign master node id to children nodes as well, since otherwise they might still be pointing to a master node in a different group.
This issue could arise in a residual block with layout transform. There, layout transform, elemwise add, and relu ops can be fused, but not conv2d because layout transform is an injective op. Before this PR, the correct fusion was happening, but relu op's master id was pointing to a conv2d op, which caused the issue @kevinthesun reported. This is hard to describe in words, but the test case added may clarify a bit.
@kevinthesun @tqchen please review.