Based on the raised error message I think the endianness of the loaded numpy array isn’t matching the default value (little-endian if I’m not mistaken).
Trigger a copy on the numpy array to use the default endian byte order and it should work:
def npy_loader(path):
    arr = np.load(path)
    arr = arr.astype(np.float32)
    sample = torch.from_numpy(arr)
    return sample