Unique ids for relay.Module computation nodes?

Hello, I’m currently trying to optimize my compiler by not regenerating computation nodes that have already been created, but I’m looking for an efficient way to do this with the module outputted from the from_keras function in the frontend. Does the computation graph have any ids or tags that let me know if two different computation nodes in the abstract syntax tree generated from the module are the same?

There is pointer equality (which is just a == b in C++). there is also alpha equality which you can call. You might want to look into hash consing and build a hash cons. Relay does not do it rn but I think it will be a neat addition to relay.

1 Like

Hi all,

Has there been a desire to revisit this request and introduce a unique ID on each relay-node that survives a pass ? AFAIU in relay we assign a unique ID for the VarNode but not on the rest of the nodes. Why is that ? AFAIU relay is SSA-like .

From my side I am trying to compare the relay graph across 2 or more passes and understand the effect of the different passes. Having a unique ID per node would make that comparison easier and simpler to identify which nodes are added/removed or replaced.

How do we usually go about doing such debugging ?