bshillingford / python-torchfile

Deserialize Lua torch-serialized objects from Python
BSD 3-Clause "New" or "Revised" License
216 stars 25 forks source link

Add handling of 8 bytes long #1

Closed jrao1 closed 8 years ago

jrao1 commented 8 years ago

The previous version uses 4 bytes long to read tensor, this won't work with files under https://github.com/facebook/fb.resnet.torch/tree/master/pretrained, since they're using 8 bytes long.

bshillingford commented 8 years ago

Are you on a 32-bit machine, or on a machine that for another reason has 4-byte longs? That's the expected behaviour: the 'l' type specifier for python's struct will use the machine-dependent size of a long, meaning the loader is guaranteed to be compatible with torch7 files from your own machine, but not from others' machines. (More precisely, your C compiler, not your machine.)

Could you please change use_8bytes_long to force_8bytes_long and default it to False since this behaviour is not always desirable as I mentioned above. Then I'll merge it, thanks for contributing!

jrao1 commented 8 years ago

Ok, done. I'm on 64bit machine, but I'm using Windows, I guess that may be the reason for 4-byte longs.