This PR adds a CopyWithNewVars function to replace CopyWithNewParams. CopyWithNewVars will copy all variables defined in a function, rather than just copy function parameters like what CopyWithNewParams does.
When the copy of a function needs to be added to the same IRModule of original function, it's important that the copy doesn't use the same variable as the original function does. Otherwise it's not possible to assert structural equal between the result and an IRModule created through TVMScript, which is a common pattern used in tests.
This PR adds a
CopyWithNewVars
function to replaceCopyWithNewParams
.CopyWithNewVars
will copy all variables defined in a function, rather than just copy function parameters like whatCopyWithNewParams
does.When the copy of a function needs to be added to the same IRModule of original function, it's important that the copy doesn't use the same variable as the original function does. Otherwise it's not possible to assert structural equal between the result and an IRModule created through TVMScript, which is a common pattern used in tests.