Skip to content

Commit 761ab24

Browse files
committed
REMOVE THIS COMMITS JUST FOR TESTING
1 parent 3a5e528 commit 761ab24

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/main/java/io/bioimage/modelrunner/pytorch/javacpp/PytorchJavaCPPInterface.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@
5757
import io.bioimage.modelrunner.tensor.Tensor;
5858
import io.bioimage.modelrunner.tensor.shm.SharedMemoryArray;
5959
import io.bioimage.modelrunner.utils.CommonUtils;
60+
import net.imglib2.Cursor;
6061
import net.imglib2.RandomAccessibleInterval;
62+
import net.imglib2.loops.LoopBuilder;
6163
import net.imglib2.type.NativeType;
6264
import net.imglib2.type.numeric.RealType;
6365
import net.imglib2.util.Cast;
6466
import net.imglib2.util.Util;
67+
import net.imglib2.view.Views;
6568

6669
/**
6770
* This class implements an interface that allows the main plugin to interact in
@@ -316,8 +319,30 @@ else if (task.status == TaskStatus.CRASHED) {
316319
shm = SharedMemoryArray.read(name);
317320
shmaOutputList.add(shm);
318321
}
319-
RandomAccessibleInterval<?> rai = shm.getSharedRAI();
322+
RandomAccessibleInterval<T> rai = shm.getSharedRAI();
323+
// TODO remove
324+
double max0 = 0;
325+
Cursor<T> iter0 = Views.iterable(rai).cursor();
326+
while (iter0.hasNext()) {
327+
iter0.next();
328+
double doub = iter0.get().getRealDouble();
329+
if (doub > max0)
330+
max0 = doub;
331+
}
332+
System.out.println("Output SHM " + i + " max value: " + max0);
333+
// TODO remove
320334
outputTensors.get(i).setData(Tensor.createCopyOfRaiInWantedDataType(Cast.unchecked(rai), Util.getTypeFromInterval(Cast.unchecked(rai))));
335+
// TODO remove
336+
double max = 0;
337+
Cursor<R> iter = Views.iterable(outputTensors.get(i).getData()).cursor();
338+
while (iter.hasNext()) {
339+
iter.next();
340+
double doub = iter.get().getRealDouble();
341+
if (doub > max)
342+
max = doub;
343+
}
344+
System.out.println("Copied ouput " + i + " max value: " + max);
345+
// TODO remove
321346
}
322347
} catch (Exception e) {
323348
closeShmas();

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424
import io.bioimage.modelrunner.tensor.shm.SharedMemoryArray;
2525
import io.bioimage.modelrunner.utils.CommonUtils;
26+
import net.imglib2.Cursor;
2627
import net.imglib2.util.Cast;
28+
import net.imglib2.view.Views;
2729

2830
import java.nio.ByteBuffer;
2931
import java.util.Arrays;
@@ -139,6 +141,15 @@ private static org.bytedeco.pytorch.Tensor buildFloat(SharedMemoryArray shmArray
139141
float[] flat = new float[buff.capacity() / 4];
140142
buff.asFloatBuffer().get(flat);
141143
Tensor ndarray = Tensor.create(flat, ogShape);
144+
145+
// TODO remove
146+
double max0 = 0;
147+
for (float ff : flat) {
148+
if (ff > max0)
149+
max0 = ff;
150+
}
151+
System.out.println("Input max: " + max0);
152+
// TODO remove
142153
return ndarray;
143154
}
144155

0 commit comments

Comments
 (0)