raise ValueError("Type of input parameter mod must be tvm.IRModule")
if isinstance(mod, _expr.Function):
+ if params:
+ mod = bind_params_by_name(mod, params)
mod = IRModule.from_expr(mod)
warnings.warn(
"Please use input parameter mod (tvm.IRModule) "
raise ValueError("Type of input parameter mod must be tvm.IRModule")
if isinstance(mod, _expr.Function):
+ if params:
+ mod = bind_params_by_name(mod, params)
mod = IRModule.from_expr(mod)
warnings.warn(
"Please use input parameter mod (tvm.IRModule) "
# Analyze free variables and generate Relay function
output = layers[-1]
-func = relay.Function(relay.analysis.free_vars(output), output)
######################################################################
# Compile and run with TVM
# Set the TVM build target
target = 'llvm' # Currently only support `llvm` as target
+func = relay.Function(relay.analysis.free_vars(output), output)
+func = relay.build_module.bind_params_by_name(func, params)
+mod = tvm.IRModule()
+mod["main"] = func
# Build with Relay
with relay.build_config(opt_level=0): # Currently only support opt_level=0
- graph, lib, params = relay.build(func, target, params=params)
+ graph, lib, params = relay.build(mod, target, params=params)
# Generate graph runtime
ctx = tvm.context(target, 0)