2
2
import os
3
3
import random
4
4
import re
5
+ import sys
5
6
from functools import partial
6
7
7
8
import numpy as np
@@ -614,7 +615,7 @@ def _get_1_channel_tensor_various_types():
614
615
615
616
img_data_short = torch .ShortTensor (1 , 4 , 4 ).random_ ()
616
617
expected_output = img_data_short .numpy ()
617
- yield img_data_short , expected_output , "I;16"
618
+ yield img_data_short , expected_output , "I;16" if sys . byteorder == "little" else "I;16B"
618
619
619
620
img_data_int = torch .IntTensor (1 , 4 , 4 ).random_ ()
620
621
expected_output = img_data_int .numpy ()
@@ -631,7 +632,7 @@ def _get_2d_tensor_various_types():
631
632
632
633
img_data_short = torch .ShortTensor (4 , 4 ).random_ ()
633
634
expected_output = img_data_short .numpy ()
634
- yield img_data_short , expected_output , "I;16"
635
+ yield img_data_short , expected_output , "I;16" if sys . byteorder == "little" else "I;16B"
635
636
636
637
img_data_int = torch .IntTensor (4 , 4 ).random_ ()
637
638
expected_output = img_data_int .numpy ()
@@ -662,7 +663,7 @@ def test_1_channel_float_tensor_to_pil_image(self):
662
663
[
663
664
(torch .Tensor (4 , 4 , 1 ).uniform_ ().numpy (), "L" ),
664
665
(torch .ByteTensor (4 , 4 , 1 ).random_ (0 , 255 ).numpy (), "L" ),
665
- (torch .ShortTensor (4 , 4 , 1 ).random_ ().numpy (), "I;16" ),
666
+ (torch .ShortTensor (4 , 4 , 1 ).random_ ().numpy (), "I;16" if sys . byteorder == "little" else "I;16B" ),
666
667
(torch .IntTensor (4 , 4 , 1 ).random_ ().numpy (), "I" ),
667
668
],
668
669
)
@@ -744,7 +745,7 @@ def test_2d_tensor_to_pil_image(self, with_mode, img_data, expected_output, expe
744
745
[
745
746
(torch .Tensor (4 , 4 ).uniform_ ().numpy (), "L" ),
746
747
(torch .ByteTensor (4 , 4 ).random_ (0 , 255 ).numpy (), "L" ),
747
- (torch .ShortTensor (4 , 4 ).random_ ().numpy (), "I;16" ),
748
+ (torch .ShortTensor (4 , 4 ).random_ ().numpy (), "I;16" if sys . byteorder == "little" else "I;16B" ),
748
749
(torch .IntTensor (4 , 4 ).random_ ().numpy (), "I" ),
749
750
],
750
751
)
0 commit comments