Tvm.relay.build modifying its argument

Hi,

I noticed that tvm.relay.build is modifying the module I pass to it. Is that expected? This surprised me as the discussion of TVM passes appears (to me) to emphasize that the passes are functional rather than in-place.

Best regards

Thomas

cc @jroesch

The IRModule itself is indeed mutable, but right now the relay pass infra tries to create a new module when possible(via copy on write), if you have a particular example and dig a bit into where the mutaiton happen, we can try to work on fixing it.

OK, thanks! I just wanted to know whether it’s intentional but then I can track this down.

1 Like

Turns out that binding the variables looks suspicious:

@tqchen What do you think, bug or feature?

sorry to miss the thread during the weekend, it is certainly a bug we should fix, @t-vi can you send a patch?

Yes. Thank you for your input!

Best regards

Thomas