Optimize mobile model on cloned module instead of in-place transformation (#36621)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/36621
Instead of doing in-place transformation inside optimizeForMobile method,
we would like to maintain the original structure for passed scriptedModule,
so before optmization starts, we use the cloned module to do subsequent optimization
process and return the optimized cloned module.
Test Plan:
unit test
python test/test_mobile_optimizer.py
Imported from OSS
Differential Revision: D21028406
fbshipit-source-id: 756172ef99b1c1df6bb7d00e5deca85a4c239a87