You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/01/13 19:25:14 UTC

[GitHub] [incubator-tvm] abergeron opened a new issue #4697: VM prunes global functions with no direct calls.

abergeron opened a new issue #4697: VM prunes global functions with no direct calls.
URL: https://github.com/apache/incubator-tvm/issues/4697
 
 
   It seems there is a problem in the VM compiler for indirect calls to global functions that aren't used elsewhere.
   
   I have a simple code block that reproduces it:
   
   ```python
   import tvm
   from tvm import relay
   
   ctx = tvm.ndarray.context('cpu', 0)
   
   mod = relay.Module({})
   
   fn1 = relay.Function([], relay.const(1))
   fn2 = relay.Function([], relay.const(2))
   
   g1 = relay.GlobalVar('g1')
   g2 = relay.GlobalVar('g2')
   mod[g1] = fn1
   mod[g2] = fn2
   
   p = relay.var('p', 'bool')
   mod['main'] = relay.Function([p], relay.Call(relay.If(p, g1, g2), []))
   
   print(str(mod))
   
   vm = relay.create_executor(mod=mod, ctx=ctx, target='llvm', kind="vm")
   
   relay_out = vm.evaluate()(True)
   
   print("Relay result:\n", relay_out)
   ```
   
   This errors at the `relay.create_executor` line saying there is no definition for g1.
   
   - If you change the calls in the main functions to use the `fn1` and `fn2` instead of the global variables, it works.
   - If you move the `Call` inside the `If` it works.
   
   So it seems that because g1 and g2 don't get directly called they get removed at some point.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on issue #4697: [Relay] VM prunes global functions with no direct calls.

Posted by GitBox <gi...@apache.org>.
zhiics commented on issue #4697: [Relay] VM prunes global functions with no direct calls.
URL: https://github.com/apache/incubator-tvm/issues/4697#issuecomment-573835864
 
 
   @abergeron Thanks for reporting this. There is pass in VM that removes the "unused" global functions. It probably removed these functions.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics commented on issue #4697: [Relay] VM prunes global functions with no direct calls.

Posted by GitBox <gi...@apache.org>.
zhiics commented on issue #4697: [Relay] VM prunes global functions with no direct calls.
URL: https://github.com/apache/incubator-tvm/issues/4697#issuecomment-573909502
 
 
   @abergeron #4700 fixes this.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-tvm] zhiics closed issue #4697: [Relay] VM prunes global functions with no direct calls.

Posted by GitBox <gi...@apache.org>.
zhiics closed issue #4697: [Relay] VM prunes global functions with no direct calls.
URL: https://github.com/apache/incubator-tvm/issues/4697
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services