Hi All, I am trying to experiment with IRModule update function.
My goal is to update the IRModule with another relay function as follows, and it is throwing an error.
Any comments/suggestions? Thanks in advance.
def module_update():
x0 = relay.var('x0', shape = (5,1))
y0 = relay.var('x0', shape = (5,1))
sub0 = relay.op.subtract(x0, y0)
f0 = relay.Function([], sub0)
mod = tvm.IRModule({'func1', f0})
x1 = relay.var('x1', shape = (5,1))
y1 = relay.var('x1', shape = (5,1))
add1 = relay.op.add(x1, y1)
f1 = relay.Function([], add1 )
a = tvm.ir.GlobalVar('func2')
mod.uodate(a, f1) # ==> This line gives error.
```
Here is the error:
```
tvm._ffi.base.TVMError: Traceback (most recent call last):
File "C:\tvm\src\ir\module.cc", line 192
TVMError: Check failed: fv.size() == 0 (2 vs. 0) : There are free variables: [Var(x1, ty=TensorType([5, 1], float32)), Var(y1, ty=TensorType([5, 1], float32))] in function: #[version = "0.0.5"]
fn () {
free_var %x1: Tensor[(5, 1), float32];
free_var %y1: Tensor[(5, 1), float32];
add(%x1, %y1)
}
tvm._ffi.base.TVMError: Traceback (most recent call last):
File "C:\tvm\src\ir\module.cc", line 192
TVMError: Check failed: fv.size() == 0 (2 vs. 0) : There are free variables: [Var(x1, ty=TensorType([5, 1], float32)), Var(y1, ty=TensorType([5, 1], float32))] in function: #[version = "0.0.5"]
fn () {
free_var %x1: Tensor[(5, 1), float32];
free_var %y1: Tensor[(5, 1), float32];
add(%x1, %y1)
}
```