Skip to content

Commit

Permalink
correct bug that was not copying data to shm
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Nov 25, 2024
1 parent 6d2f6bb commit cb2a417
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.types.TFloat32;
Expand Down Expand Up @@ -102,9 +103,9 @@ private static void buildFromTensorUByte(TUint8 tensor, String memoryName) throw
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.asRawTensor().data().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}

Expand All @@ -118,9 +119,9 @@ private static void buildFromTensorInt(TInt32 tensor, String memoryName) throws
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.asRawTensor().data().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}

Expand All @@ -134,9 +135,9 @@ private static void buildFromTensorFloat(TFloat32 tensor, String memoryName) thr
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.asRawTensor().data().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}

Expand All @@ -150,9 +151,9 @@ private static void buildFromTensorDouble(TFloat64 tensor, String memoryName) th
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.asRawTensor().data().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}

Expand All @@ -167,9 +168,9 @@ private static void buildFromTensorLong(TInt64 tensor, String memoryName) throws
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.asRawTensor().data().read(flat, 0, buff.capacity());
buff = buff2;
buff.put(buff2);
if (PlatformDetection.isWindows()) shma.close();
}
}

0 comments on commit cb2a417

Please sign in to comment.