Better hashing for constant pool (#27733)
Summary:
Some models many contain thousands constants (like list of ints) and Constant Pooling and CSE pass will move the constant around and update the constant pooling.
However our existing hash function only consider the node type + input type + output node (https://bddppq.github.io/codebrowser/pytorch/pytorch/torch/csrc/jit/node_hashing.cpp.html#_ZNK5torch3jit8HashNodeclEPKNS0_4NodeE), which will have a lot of conflicts... I have profiled, one insert may take as long as about 0.2 second... And loading the model will take 200 second, which is insane.
So we should fix this performance issue by considering the constant value as well to avoid the conflict.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27733
Reviewed By: bddppq
Differential Revision: D17873733
Pulled By: houseroad
fbshipit-source-id: 2338d7bf67174a8e56caa19a30401199f68b592a