Easier way to do Relay level mutation?

Hello everyone,

I am wondering if there is an easier way to do Relay level mutations than what I have currently seen.

The example I will use is the GraphPack from VTA.

In simple forms, at the point in the code there is something like: A->B were A are the weights and B is the convolution op.

This kind of mutations I guess are easy since we “stop” at B and want to transform A into C (were C is basically A->padding). After transformation we would get C->B and it’s easy because we are at B and have all the information of it to recreate the type of node B is and just give it the new argument C.

But what about given some relay expression which looks like A->B->C->D->E, and given that we are in E (i.e. E is some specific op we know) we want to create A->C->D->E. In other words, we want to eliminate B if and only if C->D is followed by E and A would be now the input to C.

You can imagine that C->D could be a larger Relay operation chain, so we would have to “feed” A to the first operation C (while also giving it the same attributes it had before) and then recreating the rest of the chain.

I am not aware of a simple “copy constructor” for a relay chain nor a way to “just” change the argument of an op without having to create a new op.

Thanks