[Relay] TVMError: if is not supported

Dear community, I wanted to deploy an in-house network using TVM. However I’m getting an error while building the Relay IR (graph, lib, params = relay.build(irmodule, target=hw.target, params=params) as follows:

Traceback (most recent call last):
  File "/usr/lib/python3.6/pdb.py", line 1667, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib/python3.6/pdb.py", line 1548, in _runscript
    self.run(statement)
  File "/usr/lib/python3.6/bdb.py", line 434, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/home/buecs/tf_tvm_e2e/tvm_import_e2e_tf.py", line 241, in <module>
    graph, lib, params = relay.build(irmodule, target=hw.target, params=params)
  File "/home/buecs/tvm/python/tvm/relay/build_module.py", line 251, in build
    graph_json, mod, params = bld_mod.build(mod, target, target_host, params)
  File "/home/buecs/tvm/python/tvm/relay/build_module.py", line 120, in build
    self._build(mod, target, target_host)
  File "/home/buecs/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 225, in __call__
    raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (8) /home/buecs/tvm/build/libtvm.so(tvm::relay::StorageAllocaBaseVisitor::GetToken(tvm::RelayExpr const&)+0x28) [0x7eff52d19f78]
  [bt] (7) /home/buecs/tvm/build/libtvm.so(tvm::relay::ExprVisitor::VisitExpr(tvm::RelayExpr const&)+0x7b) [0x7eff52d9409b]
  [bt] (6) /home/buecs/tvm/build/libtvm.so(tvm::relay::ExprFunctor<void (tvm::RelayExpr const&)>::VisitExpr(tvm::RelayExpr const&)+0x92) [0x7eff52b7dcc2]
  [bt] (5) /home/buecs/tvm/build/libtvm.so(tvm::relay::StorageAllocaInit::VisitExpr_(tvm::relay::CallNode const*)+0xa4) [0x7eff52d22b64]
  [bt] (4) /home/buecs/tvm/build/libtvm.so(tvm::relay::StorageAllocaBaseVisitor::GetToken(tvm::RelayExpr const&)+0x28) [0x7eff52d19f78]
  [bt] (3) /home/buecs/tvm/build/libtvm.so(tvm::relay::ExprVisitor::VisitExpr(tvm::RelayExpr const&)+0x7b) [0x7eff52d9409b]
  [bt] (2) /home/buecs/tvm/build/libtvm.so(tvm::relay::ExprFunctor<void (tvm::RelayExpr const&)>::VisitExpr(tvm::RelayExpr const&)+0x92) [0x7eff52b7dcc2]
  [bt] (1) /home/buecs/tvm/build/libtvm.so(tvm::relay::StorageAllocaBaseVisitor::VisitExpr_(tvm::relay::IfNode const*)+0x4f) [0x7eff52d19f0f]
  [bt] (0) /home/buecs/tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x43) [0x7eff524edd53]
  File "/home/buecs/tvm/src/relay/backend/graph_plan_memory.cc", line 100
TVMError: if is not supported.

There are some wacky switch blocks in the Tensorflow model, I’m not sure whether or not these causes the trouble… I’m not familiar with Relay at all…

I would highly appreciate it if someone could give me a pointer on what is going wrong here. However I’m not sure who to tag… @jroesch maybe? Can this error be mitigated somehow?

Thank you & Best regards, Robert

1 Like

If there are switches in your model, you need to build with VM instead of graph runtime.

1 Like

https://github.com/apache/incubator-tvm/pull/5699 After this PR, tf models with control flow will be generally supported. You can follow this test to build model with VM: https://github.com/apache/incubator-tvm/pull/5699/files#diff-b99ebebad3c7b2900ecc6539e107177bR2265

1 Like

Oh wow! Thank you very much for you support @kevinthesun!!! I do very much appreciate it! Best regards, Robert