Skip to content

Commit

Permalink
correct bug
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Nov 25, 2024
1 parent d52ec73 commit d366c11
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

import org.tensorflow.Tensor;
Expand Down Expand Up @@ -100,9 +101,9 @@ private static void buildFromTensorUByte(Tensor<TUint8> tensor, String memoryNam
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new UnsignedByteType(), false, true);
ByteBuffer buff = shma.getDataBufferNoHeader();
byte[] flat = new byte[buff.capacity()];
ByteBuffer buff2 = ByteBuffer.wrap(flat);
ByteBuffer buff2 = ByteBuffer.wrap(flat).order(ByteOrder.LITTLE_ENDIAN);
tensor.rawData().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}

Expand All @@ -116,9 +117,9 @@ private static void buildFromTensorInt(Tensor<TInt32> tensor, String memoryName)
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new IntType(), false, true);
ByteBuffer buff = shma.getDataBufferNoHeader();
byte[] flat = new byte[buff.capacity()];
ByteBuffer buff2 = ByteBuffer.wrap(flat);
ByteBuffer buff2 = ByteBuffer.wrap(flat).order(ByteOrder.LITTLE_ENDIAN);
tensor.rawData().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}

Expand All @@ -132,9 +133,9 @@ private static void buildFromTensorFloat(Tensor<TFloat32> tensor, String memoryN
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new FloatType(), false, true);
ByteBuffer buff = shma.getDataBufferNoHeader();
byte[] flat = new byte[buff.capacity()];
ByteBuffer buff2 = ByteBuffer.wrap(flat);
ByteBuffer buff2 = ByteBuffer.wrap(flat).order(ByteOrder.LITTLE_ENDIAN);
tensor.rawData().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}

Expand All @@ -148,9 +149,9 @@ private static void buildFromTensorDouble(Tensor<TFloat64> tensor, String memory
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new DoubleType(), false, true);
ByteBuffer buff = shma.getDataBufferNoHeader();
byte[] flat = new byte[buff.capacity()];
ByteBuffer buff2 = ByteBuffer.wrap(flat);
ByteBuffer buff2 = ByteBuffer.wrap(flat).order(ByteOrder.LITTLE_ENDIAN);
tensor.rawData().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}

Expand All @@ -165,9 +166,9 @@ private static void buildFromTensorLong(Tensor<TInt64> tensor, String memoryName
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new LongType(), false, true);
ByteBuffer buff = shma.getDataBufferNoHeader();
byte[] flat = new byte[buff.capacity()];
ByteBuffer buff2 = ByteBuffer.wrap(flat);
ByteBuffer buff2 = ByteBuffer.wrap(flat).order(ByteOrder.LITTLE_ENDIAN);
tensor.rawData().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}
}

0 comments on commit d366c11

Please sign in to comment.