TVMError: found cast; operators should be removed by future passes; try fusing and lowering

When calling relay.build with a tflite model

    TARGET = 'c -device=micro_dev'
    disable_vectorize = tvm.target.build_config(disable_vectorize=True)
    disable_fusion = relay.build_config(disabled_pass={'FuseOps'})

    with disable_vectorize, disable_fusion:
        graph, c_mod, params = relay.build(mod, target=TARGET, params=params)

it’ll fail with

  [bt] (0) /home/tgall/tvm/tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x79) [0x7fe4a53be8e9]
  File "/home/tgall/tvm/tvm/src/relay/backend/interpreter.cc", line 592
TVMError: found cast; operators should be removed by future passes; try fusing and lowering

However if I use that same model and the target to “llvm”, no crash.

target = "llvm"
disable_vectorize = tvm.target.build_config(disable_vectorize=True)
disable_fusion = relay.build_config(disabled_pass={'FuseOps'})
with disable_vectorize, disable_fusion, relay.build_config(opt_level=3):
    graph, lib, params = relay.build(mod, target, params=params)

Thoughts?

Hi, @tgall_foo . I also encountered the same error. When i use the quantized tflite model, the program will have the following errors

1: _ZZN3tvm5relay11ExprFunctorIFNS_7runtime9ObjectRefERKNS_9RelayExprEEE
  0: tvm::relay::Interpreter::VisitExpr_(tvm::relay::CallNode const*)
  File "/home/vagrant/tvm/src/relay/backend/interpreter.cc", line 560
TVMError: found cast; operators should be removed by future passes; try fusing and lowering

Have you solved this problem ,can you share the solution :grin: