[PyTorch Mobile] Do not create a static variable in Dispatcher::singleton() (#52447)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52447
Currently, `Dispatcher::singleton()` is always inlined. Additionally, `Dispatcher::singleton()` contains a static variable, which means that the generated code calls `__cxa_guard_acquire` and `__cxa_guard_release` which help implement exactly once semantics for the initialization of the `static Dispatcher& s` variable. For `C10_MOBILE`, we should not create the additional static ref within the inlined function to save binary size since it results in a lot of additional code being generated by the compiler. The `Dispatcher::singleton()` method is called from the generated method stubs for all aten opertors that are code-generated and potentially also from other operators that hand off execution to the kernel function for the right backend via the PyTorch Dispatcher.
This is a classic space/time (efficiency) tradeoff, so feedback would be welcome. kimishpatel, I'll need your expertise in figuring out how to perf-test this change, specifically for mobile.
Here's the godbolt link in case you wish to check out the generated code for a `static` variable within a function: https://godbolt.org/z/cdsG3v
{F375631117}
ghstack-source-id: 121989311
Test Plan:
Build + BSB
### lightspeed-messenger
*Divide the number below by 2*
```
D26507049-V1 (https://www.internalfb.com/intern/diff/D26507049/?dest_number=121944956)
messenger-experimental-optimized-device: Succeeded
Change in Download Size for arm64 + 3x assets variation: -21.7 KiB
Change in Uncompressed Size for arm64 + 3x assets variation: -65.4 KiB
Mbex Comparison: https://our.intern.facebook.com/intern/mbex/bsb:243392763936025@base/bsb:243392763936025@diff/
```
### igios
```
D26507049-V1 (https://www.internalfb.com/intern/diff/D26507049/?dest_number=121944956)
igios: Succeeded
Change in Download Size for arm64 + 3x assets variation: -15.6 KiB
Change in Uncompressed Size for arm64 + 3x assets variation: -34.3 KiB
Mbex Comparison: https://our.intern.facebook.com/intern/mbex/bsb:882756935844095@base/bsb:882756935844095@diff/
```
### fbios-pika
```
D26507049-V1 (https://www.internalfb.com/intern/diff/D26507049/?dest_number=121944956)
fbios-pika: Succeeded
Change in Download Size for arm64 + 3x assets variation: -8.6 KiB
Change in Uncompressed Size for arm64 + 3x assets variation: -29.1 KiB
Mbex Comparison: https://our.intern.facebook.com/intern/mbex/bsb:832297083999539@base/bsb:832297083999539@diff/
```
Reviewed By: swolchok
Differential Revision: D26507049
fbshipit-source-id: 0d2f55ea2d42a0782fb69aabfa517f2ec60c8036