26
26
27
27
import java .io .IOException ;
28
28
import java .nio .ByteBuffer ;
29
+ import java .nio .ByteOrder ;
29
30
import java .util .Arrays ;
30
31
31
32
import org .tensorflow .Tensor ;
@@ -100,9 +101,9 @@ private static void buildFromTensorUByte(Tensor<TUint8> tensor, String memoryNam
100
101
SharedMemoryArray shma = SharedMemoryArray .readOrCreate (memoryName , arrayShape , new UnsignedByteType (), false , true );
101
102
ByteBuffer buff = shma .getDataBufferNoHeader ();
102
103
byte [] flat = new byte [buff .capacity ()];
103
- ByteBuffer buff2 = ByteBuffer .wrap (flat );
104
+ ByteBuffer buff2 = ByteBuffer .wrap (flat ). order ( ByteOrder . LITTLE_ENDIAN ) ;
104
105
tensor .rawData ().read (flat , 0 , buff .capacity ());
105
- buff = buff2 ;
106
+ buff . put ( buff2 ) ;
106
107
if (PlatformDetection .isWindows ()) shma .close ();
107
108
}
108
109
@@ -116,9 +117,9 @@ private static void buildFromTensorInt(Tensor<TInt32> tensor, String memoryName)
116
117
SharedMemoryArray shma = SharedMemoryArray .readOrCreate (memoryName , arrayShape , new IntType (), false , true );
117
118
ByteBuffer buff = shma .getDataBufferNoHeader ();
118
119
byte [] flat = new byte [buff .capacity ()];
119
- ByteBuffer buff2 = ByteBuffer .wrap (flat );
120
+ ByteBuffer buff2 = ByteBuffer .wrap (flat ). order ( ByteOrder . LITTLE_ENDIAN ) ;
120
121
tensor .rawData ().read (flat , 0 , buff .capacity ());
121
- buff = buff2 ;
122
+ buff . put ( buff2 ) ;
122
123
if (PlatformDetection .isWindows ()) shma .close ();
123
124
}
124
125
@@ -132,9 +133,9 @@ private static void buildFromTensorFloat(Tensor<TFloat32> tensor, String memoryN
132
133
SharedMemoryArray shma = SharedMemoryArray .readOrCreate (memoryName , arrayShape , new FloatType (), false , true );
133
134
ByteBuffer buff = shma .getDataBufferNoHeader ();
134
135
byte [] flat = new byte [buff .capacity ()];
135
- ByteBuffer buff2 = ByteBuffer .wrap (flat );
136
+ ByteBuffer buff2 = ByteBuffer .wrap (flat ). order ( ByteOrder . LITTLE_ENDIAN ) ;
136
137
tensor .rawData ().read (flat , 0 , buff .capacity ());
137
- buff = buff2 ;
138
+ buff . put ( buff2 ) ;
138
139
if (PlatformDetection .isWindows ()) shma .close ();
139
140
}
140
141
@@ -148,9 +149,9 @@ private static void buildFromTensorDouble(Tensor<TFloat64> tensor, String memory
148
149
SharedMemoryArray shma = SharedMemoryArray .readOrCreate (memoryName , arrayShape , new DoubleType (), false , true );
149
150
ByteBuffer buff = shma .getDataBufferNoHeader ();
150
151
byte [] flat = new byte [buff .capacity ()];
151
- ByteBuffer buff2 = ByteBuffer .wrap (flat );
152
+ ByteBuffer buff2 = ByteBuffer .wrap (flat ). order ( ByteOrder . LITTLE_ENDIAN ) ;
152
153
tensor .rawData ().read (flat , 0 , buff .capacity ());
153
- buff = buff2 ;
154
+ buff . put ( buff2 ) ;
154
155
if (PlatformDetection .isWindows ()) shma .close ();
155
156
}
156
157
@@ -165,9 +166,9 @@ private static void buildFromTensorLong(Tensor<TInt64> tensor, String memoryName
165
166
SharedMemoryArray shma = SharedMemoryArray .readOrCreate (memoryName , arrayShape , new LongType (), false , true );
166
167
ByteBuffer buff = shma .getDataBufferNoHeader ();
167
168
byte [] flat = new byte [buff .capacity ()];
168
- ByteBuffer buff2 = ByteBuffer .wrap (flat );
169
+ ByteBuffer buff2 = ByteBuffer .wrap (flat ). order ( ByteOrder . LITTLE_ENDIAN ) ;
169
170
tensor .rawData ().read (flat , 0 , buff .capacity ());
170
- buff = buff2 ;
171
+ buff . put ( buff2 ) ;
171
172
if (PlatformDetection .isWindows ()) shma .close ();
172
173
}
173
174
}
0 commit comments