Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Nov 23, 2024
1 parent 292c187 commit 6486ea4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ private static void buildFromTensorFloat(Tensor tensor, String memoryName) throw
+ " is too big. Max number of elements per float output tensor supported: " + Integer.MAX_VALUE / 4);
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new UnsignedByteType(), false, true);
shma.getDataBufferNoHeader().put(tensor.asByteBuffer());
shma.getDataBufferNoHeader().rewind();
tensor.asByteBuffer().rewind();
float sum = 0;
while (tensor.asByteBuffer().hasRemaining())
sum += tensor.asByteBuffer().getFloat();
float sum2 = 0;
while (shma.getDataBufferNoHeader().hasRemaining())
sum2 += shma.getDataBufferNoHeader().getFloat();
System.out.println("KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK SRC " + sum);
System.out.println("KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK TAR " + sum2);
shma.getDataBufferNoHeader().rewind();
tensor.asByteBuffer().rewind();
if (PlatformDetection.isWindows()) shma.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ private static org.bytedeco.pytorch.Tensor buildFloat(SharedMemoryArray shmArray
float[] flat = new float[buff.capacity() / 4];
buff.asFloatBuffer().get(flat);
buff.rewind();
float sum = 0;
for (float ff : flat)
sum += ff;
System.out.println("KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK " + sum);
Tensor ndarray = Tensor.create(flat, ogShape);
return ndarray;
}
Expand Down

0 comments on commit 6486ea4

Please sign in to comment.