Problems with Hybridize


#1

After reading the Hybridize tutorial, there are two doubts. Please someone help me solve it.
Q1. If I have a custom network that inherits from nn.Block instead of nn.HybridBlock, will I eventually call the hybridize() method on this model to accelerate effectively? I tested it and it seems like can run. But I don’t understand it. Must inherit nn.HybridBlock, or both?
Q1. A custom network model inherits nn.HybridBlock, but if there are some layers that do not inherit from HybridBlock but Block, such as RNN. What happens when I finally call hybridize() on the model?

Please help me.


#2

See @safrooze’s excellent answer here. My understanding is that when you mix Block with HybridBlock and call hybridize, only the part of the network that can be translated to a static graph get’s compiled this way. Care must be taken in order to include everything in one final HybridBlock so graphs are combined.