SWu edited a comment on issue #4534: [Relay] Dead code elimination pass blows 
up call stack
URL: https://github.com/apache/incubator-tvm/issues/4534#issuecomment-596512916
 
 
   I think the conversation here has diverged from the original problem.
   
   @ANSHUMAN87 I don't think the original problem I was running into has been 
solved. To be clear, this isn't a *bug* in the implementation (it's not 
infinite recursion, just very deep recursion, because if I remove the stack 
limit on my system the code works), but it is a problematic implementation. The 
nature of the dead code elimination implementation requires extensive recursive 
calls to visit every node of the graph. Since this is implemented as naive 
recursion, for a large enough graph (like the kind you get when using auto-diff 
to generate gradient functions Relay) it is easy to exhaust the default stack 
limit. It is not indicated anywhere obvious in the documentation that users 
should increase their stack limit, and the resulting segfault when this happens 
can be really confusing to understand if you don't consider stack overflow.
   
   As I mentioned in the original issue, there are two things that should be 
done:
   
   1. make it obvious in the documentation that users should increase their 
stack size if they encounter segfaults of this nature, or better yet, implement 
something like a recursion counter inside that graph traversal that warns users 
when they're reaching high levels of recursion in their graphs that could 
trigger stackoverflow
   2. fix the stack overflow, by either figuring out how to optimize the 
recursion implementation so that the compiler can perform tail call 
optimization, or convert the recursive code to iteration/reimplement with an 
explicit stack

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to