InferenceType obviously succeeded, but relay.build throws inferenceType failed

Description

It can be seen that every time we add a function to the mod, the inferenceType is done, and then the output of the mod can also see the result of the type inference.

From the running result figure shown below, we can see that each function and operator has its type annotation. But It threw “The type inference pass was unable to infer a type for this expression” when building using relay.build statement.

Runnable Script

import tvm
from tvm import relay

mod = tvm.IRModule()
var_0 = relay.var("var_0", dtype = "float32", shape = (7, 7))
# output = relay.Tuple([var_0,])
output = var_0
func_7 = relay.Function([var_0,], output)
mod['func_7'] = func_7
mod = relay.transform.InferType()(mod)
func_7_call = mod.get_global_var('func_7')
var_22 = relay.var("var_22", dtype = "float32", shape = (7, 7))
tmp = func_7_call(var_22, )

# output = relay.Tuple([tmp,])
output = tmp
F = relay.Function([var_22], output)

mod['main'] = F
mod = relay.transform.InferType()(mod)
print(mod.astext(show_meta_data=False))
graph, lib, params = relay.build(mod, target='llvm')

Running Result

I just encountered one similar problem. TVM throws the same crash message when I relay.build a IRModule in test_vm.py.

import tvm
from tvm import relay
from tvm.relay.prelude import Prelude

mod = tvm.IRModule()
p = Prelude(mod)

l, cons, nil = mod.get_type("List")
tl = mod.get_global_var("tl")

f = relay.Function([], tl(nil()))
mod['main'] = f
mod = relay.transform.InferType()(mod)
print(mod)
graph, lib, params = relay.build(mod, target='llvm')