I’m working on saving and loading model files in a byte order-consistent way due to zip file serialization endianness detection is broken · Issue #65300 · pytorch/pytorch · GitHub .
I have created a PR:
The PR’s objective is to ensure we always correctly treat saved model files as little endian files. Currently I have successfully corrected the byte order when loading on a big endian platform by swapping bytes once after loading them to memory. (I believe) I have also located the spot in which byteswap should happen for saving on a big endian platform: pytorch/serialization.py at e70b5d64f40feaed5d7fb98ce150f6ca3362150a · pytorch/pytorch · GitHub
However, I’m not really sure how to retrieve the size of each element before the line mentioned. It would be impossible to do byteswapping if the size of each element is unknown. Could someone help, please? Thanks in advance.