[JIT] Optimize hot path in ProfilingGraphExecutorImpl::getPlanFor. (#47465)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47465
This results in a ~10% improvement on a DeepAndWide model:
10 runs of a benchmark before the change:
```
1.480785621330142
1.430812582373619
1.3845220785588026
1.4510653037577868
1.4827174227684736
1.3679781593382359
1.4239587392657995
1.5069784726947546
1.3988622818142176
1.4533461946994066
```
10 runs of the same benchmark after the change:
```
1.3221493270248175
1.3624659553170204
1.3415213637053967
1.3560577500611544
1.3064174111932516
1.2934542261064053
1.379274770617485
1.3850531745702028
1.26725466363132
1.3738237638026476
```
Link to benchmark: https://gist.github.com/ZolotukhinM/2308732eabb47685c6f7786e5a13b3d1
Test Plan: Imported from OSS
Reviewed By: eellison
Differential Revision: D24767247
Pulled By: ZolotukhinM
fbshipit-source-id: a77e89fdfb54286e6463533c86b3a4ba606ca1c7
Author
Mikhail Zolotukhin