-
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
[RELAY] Fixes to MergeCompilerRegions #5195
Conversation
Thanks @mbaret ! This fixes the segfault issues with resnet and other networks. However now it is impossible to execute a model that is not fully offloaded to an external codegen. Since |
For "default", I commented in the other PR: #5028 |
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.
Please also address the problem @trevor-m encountered. The graph partitioning pass should set the attributes correctly for the regions that will be handled by TVM codegens.
@@ -52,6 +55,13 @@ class AnnotateTargetWrapper : public ExprMutator { | |||
return fannotate[op](call->attrs, call->args); | |||
} | |||
} | |||
if (expr->IsInstance<TupleGetItemNode>()) { |
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 have a concern about this. It seems like you have to list all possible nodes here and it's easy to miss something. For now I would suggest adding an exception at least to indicate that we need to add more here.
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 don't think that many nodes will need to be supported here. TupleGetItemNode is needed for batchnorm. I have a PR ready to add support for TupleNode which is needed for concatenate. I haven't encountered any other nodes yet that would need to be added here.
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'm not sure yet what we plan on doing with Let nodes (or Ref* nodes). I think just saying they're not supported is sufficient for now though without also throwing an error.
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.
please fix the default target issue and add unit tests that use both merge regions and partitioning graph.
HI @mbaret, I prepared this small enhancement to include TupleNode in annotation when surrounded by supported nodes, in a similar way to what you have done for TupleGetItemNode. Here is the code, you are welcome to include it in this PR if you would like. |
This PR addresses a few outstanding issues with the implementation of MergeCompilerRegions. In particular, it now handles TupleGetItem nodes properly and other minor bugs related to region merging have been fixed. Change-Id: I07783afc56183a6f798a510209f23b0a5f252255
Change-Id: I0a844ac59bda1089ae0c67cef52f0b0c7ab2cbd7
Change-Id: Ib6f2eede6f38bbb270073eb8d4c4dc19f60832c6
Change-Id: I9b7696a51c95871491cbea33c40f92ec327e417f
9ae789f
to
b35023b
Compare
Change-Id: I0098bd1bf6788dd6366810dcefa84f1ebbffaab0
b35023b
to
f8e378e
Compare
Change-Id: I944365cd3080a97a9261f643a8f1efa5a63cf82b
Change-Id: Ie43113492bda8f1ce63eaf9615cb645bb9e2ee86
Change-Id: I46f9e349b1a813a9140f7e4f8a2241687e2df73b
Can you add a unit test for end-to-end test? It should include anntation-mege-partitioning and we can invoke it using runtime. I just want to make sure everything is correct. |
Change-Id: I309afdd1951d7e796e41d13788aa487707e0ac4c
Yup, I'm looking at adding this right now :) My question is what codegen can I use? |
You can have a mock example that uses gcc. I think we have examples for it already. |
Do you mean ccompiler? If so, I don't think that supports codegen on a region of multiple ops. |
hmm, you are right. Let's have examples with annotation-merge-partitioning with structural equal check first. |
Hi @mbaret, thanks again for fixing these issues! I noticed the call to MergeCompilerRegions hangs indefinitely for Densenet121 when all nodes are annotated. Here is a script to reproduce the issue. You will also need this commit trevor-m@2b7c3b1 to make sure that Tuple + concatenate is annotated properly also. There might a some infinite loop in the pass code or the runtime is scaling very poorly with respect to number of nodes.
|
Thanks again Trevor for testing :) That test completes for me (in less than a second). If I had to take a guess, I'd say you might be hitting a recursion limit? |
Actually, are you using your patch for Tuples? I'm testing it without that patch. |
Yes, I am using that patch. Without the patch it works. Maybe we don't have to fix it right here if it is introduced by my patch changes. |
* [RELAY] Fixed issues with MergeCompilerRegions This PR addresses a few outstanding issues with the implementation of MergeCompilerRegions. In particular, it now handles TupleGetItem nodes properly and other minor bugs related to region merging have been fixed. Change-Id: I07783afc56183a6f798a510209f23b0a5f252255 * Fixed issue using pre-merged regions Change-Id: I0a844ac59bda1089ae0c67cef52f0b0c7ab2cbd7 * Removed some debugging logic Change-Id: Ib6f2eede6f38bbb270073eb8d4c4dc19f60832c6 * Remove default annotations Change-Id: I9b7696a51c95871491cbea33c40f92ec327e417f * Annotate default 'if's Change-Id: I0098bd1bf6788dd6366810dcefa84f1ebbffaab0 * Clang format Change-Id: I944365cd3080a97a9261f643a8f1efa5a63cf82b * Use src/dest in merge Change-Id: Ie43113492bda8f1ce63eaf9615cb645bb9e2ee86 * Fixed partition test Change-Id: I46f9e349b1a813a9140f7e4f8a2241687e2df73b * Removed comments Change-Id: I309afdd1951d7e796e41d13788aa487707e0ac4c
* [RELAY] Fixed issues with MergeCompilerRegions This PR addresses a few outstanding issues with the implementation of MergeCompilerRegions. In particular, it now handles TupleGetItem nodes properly and other minor bugs related to region merging have been fixed. Change-Id: I07783afc56183a6f798a510209f23b0a5f252255 * Fixed issue using pre-merged regions Change-Id: I0a844ac59bda1089ae0c67cef52f0b0c7ab2cbd7 * Removed some debugging logic Change-Id: Ib6f2eede6f38bbb270073eb8d4c4dc19f60832c6 * Remove default annotations Change-Id: I9b7696a51c95871491cbea33c40f92ec327e417f * Annotate default 'if's Change-Id: I0098bd1bf6788dd6366810dcefa84f1ebbffaab0 * Clang format Change-Id: I944365cd3080a97a9261f643a8f1efa5a63cf82b * Use src/dest in merge Change-Id: Ie43113492bda8f1ce63eaf9615cb645bb9e2ee86 * Fixed partition test Change-Id: I46f9e349b1a813a9140f7e4f8a2241687e2df73b * Removed comments Change-Id: I309afdd1951d7e796e41d13788aa487707e0ac4c
There were a few outstanding issues with the previous PR to implement the MergeCompilerRegions pass. This PR addresses those issues and fixes the AnnotateTarget test.