[Relay][Pass]Do we want to allow LetNode in FoldScaleAxis pass?

I’m compiling a tensorflow model and FoldScaleAxis fails because it doesn’t allow LetNode: https://github.com/apache/incubator-tvm/blob/master/src/relay/transforms/fold_scale_axis.cc#L249

If I comment out that visit function, FoldScaleAxis pass succeeds. Do we really need this check?

@tqchen @zhiics

1 Like

That simply means the pass was not designed with Let node in mind, we probably need a careful revisit, and enforce everything to basic block normal form as in Basic Block Normal Form then we can formally support the IR with let

Thanks. Do you think it make sense to change FATAL to WARN for now?

I think we will at least need to investigate into the impl before doing such a switch since it might affect the correctness. Disabling would be safer

I also hit this error after I started using prelude in the torch frontend. If I do infer type with prelude, there is always warning about the presence of free variables, which I think is related to the introduction of LetNode. I wondered if this is a bug in the Torch frontend.

Hit the same error when compiling ssd-mobilenet. Any formal solution now? BTW: I am using TVM 0.7.0.

You can skip this pass when compiling. You can refer to test_forward_ssd in tensorflow tests.

Great! Thanks, @kevinthesun Is there any regular test to track this unit test status?

I delete the other test and keep test_forward_ssd() only. Then I run the unit test in this way

python test_forward.py

It fails with the error message in the frontend:

TypeError: batch_norm() got an unexpected keyword argument 'exponential_avg_factor'

I think the above issue can be fixed by optimize the BN into BiasAdd for inference. But I still got the another error as:

tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (8) /home/tvm/tvm/build/libtvm.so(tvm::relay::StorageAllocaInit::VisitExpr_(tvm::relay::CallNode const*)+0x94) [0x7f0557b778a4]
  [bt] (7) /home/tvm/tvm/build/libtvm.so(tvm::relay::ExprVisitor::VisitExpr(tvm::RelayExpr const&)+0x7b) [0x7f0557bfaa3b]
  [bt] (6) /home/tvm/tvm/build/libtvm.so(tvm::relay::ExprFunctor<void (tvm::RelayExpr const&)>::VisitExpr(tvm::RelayExpr const&)+0x5b) [0x7f0557bbc65b]
  [bt] (5) /home/tvm/tvm/build/libtvm.so(tvm::relay::StorageAllocaInit::VisitExpr_(tvm::relay::CallNode const*)+0x94) [0x7f0557b778a4]
  [bt] (4) /home/tvm/tvm/build/libtvm.so(tvm::relay::ExprVisitor::VisitExpr(tvm::RelayExpr const&)+0x7b) [0x7f0557bfaa3b]
  [bt] (3) /home/tvm/tvm/build/libtvm.so(tvm::relay::ExprFunctor<void (tvm::RelayExpr const&)>::VisitExpr(tvm::RelayExpr const&)+0x5b) [0x7f0557bbc65b]
  [bt] (2) /home/tvm/tvm/build/libtvm.so(tvm::relay::StorageAllocaInit::VisitExpr_(tvm::relay::CallNode const*)+0x1e) [0x7f0557b7782e]
  [bt] (1) /home/tvm/tvm/build/libtvm.so(tvm::relay::StorageAllocaInit::CreateToken(tvm::RelayExprNode const*, bool)+0x61e) [0x7f0557b7716e]
  [bt] (0) /home/tvm/tvm/build/libtvm.so(+0x268a567) [0x7f0557b75567]
  File "/home/tvm/tvm/src/relay/backend/graph_plan_memory.cc", line 160

How can I know which visited op throws this error?