[PyTorch Mobile] 15KiB size reduction by reducing MaxTypeIndex from 256 to 32 (#51881)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51881
`MaxTypeIndex` controls the size of the array
```
detail::TypeMetaData* TypeMeta::typeMetaDatas() {
static detail::TypeMetaData instances[MaxTypeIndex + 1]
```
in `typeid.cpp`.
In practice, I have seen that this array doesn't hold more than 18 elements once the PyTorch library has been initialized (in mobile unit tests). I couldn't find situations where elements may be added to this array post library initialization.
There is a runtime check to prevent array overflow, so reducing the size of the storage shouldn't come at any additional risk from the perspective of loss in visibility of errors.
The fact that this array is staically allocated ends up using a bunch of space in the binary (potentially to initialize the trailing elements?). I'm somewhat surprised but this. However, this change registered a 15KiB size win on both fbios as well as igios.
Found this when I was looking at a bloaty run that I shared with smessmer on friday: https://www.internalfb.com/intern/everpaste/?handle=GLXImQisHOfT74EBAKw47V3ktuAzbsIXAAAB
I initially thought that the methods being passed in to the constructor of `detail::TypeMetaData` were causing the size increase, but only later relaized the issue after reading the folloing helpful comment:
```
// The remainder of the array is padded with TypeMetaData blanks.
// The first of these is the entry for ScalarType::Undefined.
// The rest are consumed by CAFFE_KNOWN_TYPE entries.
```
ghstack-source-id: 121875657
Test Plan:
Sandcastle runs + the following BSB runs.
### igios
```
D26299594-V1 (https://www.internalfb.com/intern/diff/D26299594/?dest_number=121221891)
igios: Succeeded
Change in Download Size for arm64 + 3x assets variation: +596 B
Change in Uncompressed Size for arm64 + 3x assets variation: -15.8 KiB
Mbex Comparison: https://our.intern.facebook.com/intern/mbex/bsb:443632243487886@base/bsb:443632243487886@diff/
```
### fbios
```
D26299594-V1 (https://www.internalfb.com/intern/diff/D26299594/?dest_number=121221891)
fbios: Succeeded
Change in Download Size for arm64 + 3x assets variation: +104 B
Change in Uncompressed Size for arm64 + 3x assets variation: -15.7 KiB
Mbex Comparison: https://our.intern.facebook.com/intern/mbex/bsb:169233698063125@base/bsb:169233698063125@diff/
```
Reviewed By: raziel, iseeyuan
Differential Revision: D26299594
fbshipit-source-id: 9a78c03da621fbc25a1d8087376628bccc8dbfda