Skip to content

Commit 6486ea4

Browse files
committed
add more tests
1 parent 292c187 commit 6486ea4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/main/java/io/bioimage/modelrunner/pytorch/javacpp/shm/ShmBuilder.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ private static void buildFromTensorFloat(Tensor tensor, String memoryName) throw
103103
+ " is too big. Max number of elements per float output tensor supported: " + Integer.MAX_VALUE / 4);
104104
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new UnsignedByteType(), false, true);
105105
shma.getDataBufferNoHeader().put(tensor.asByteBuffer());
106+
shma.getDataBufferNoHeader().rewind();
107+
tensor.asByteBuffer().rewind();
108+
float sum = 0;
109+
while (tensor.asByteBuffer().hasRemaining())
110+
sum += tensor.asByteBuffer().getFloat();
111+
float sum2 = 0;
112+
while (shma.getDataBufferNoHeader().hasRemaining())
113+
sum2 += shma.getDataBufferNoHeader().getFloat();
114+
System.out.println("KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK SRC " + sum);
115+
System.out.println("KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK TAR " + sum2);
116+
shma.getDataBufferNoHeader().rewind();
117+
tensor.asByteBuffer().rewind();
106118
if (PlatformDetection.isWindows()) shma.close();
107119
}
108120

src/main/java/io/bioimage/modelrunner/pytorch/javacpp/shm/TensorBuilder.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ private static org.bytedeco.pytorch.Tensor buildFloat(SharedMemoryArray shmArray
139139
float[] flat = new float[buff.capacity() / 4];
140140
buff.asFloatBuffer().get(flat);
141141
buff.rewind();
142-
float sum = 0;
143-
for (float ff : flat)
144-
sum += ff;
145-
System.out.println("KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK " + sum);
146142
Tensor ndarray = Tensor.create(flat, ogShape);
147143
return ndarray;
148144
}

0 commit comments

Comments
 (0)