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: us...@infra.apache.org With regards, Apache Git Services