Skip to content

Commit

Permalink
REMOVE THIS COMMITS JUST FOR TESTING
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Dec 5, 2024
1 parent 3a5e528 commit 761ab24
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@
import io.bioimage.modelrunner.tensor.Tensor;
import io.bioimage.modelrunner.tensor.shm.SharedMemoryArray;
import io.bioimage.modelrunner.utils.CommonUtils;
import net.imglib2.Cursor;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.loops.LoopBuilder;
import net.imglib2.type.NativeType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.util.Cast;
import net.imglib2.util.Util;
import net.imglib2.view.Views;

/**
* This class implements an interface that allows the main plugin to interact in
Expand Down Expand Up @@ -316,8 +319,30 @@ else if (task.status == TaskStatus.CRASHED) {
shm = SharedMemoryArray.read(name);
shmaOutputList.add(shm);
}
RandomAccessibleInterval<?> rai = shm.getSharedRAI();
RandomAccessibleInterval<T> rai = shm.getSharedRAI();
// TODO remove
double max0 = 0;
Cursor<T> iter0 = Views.iterable(rai).cursor();
while (iter0.hasNext()) {
iter0.next();
double doub = iter0.get().getRealDouble();
if (doub > max0)
max0 = doub;
}
System.out.println("Output SHM " + i + " max value: " + max0);
// TODO remove
outputTensors.get(i).setData(Tensor.createCopyOfRaiInWantedDataType(Cast.unchecked(rai), Util.getTypeFromInterval(Cast.unchecked(rai))));
// TODO remove
double max = 0;
Cursor<R> iter = Views.iterable(outputTensors.get(i).getData()).cursor();
while (iter.hasNext()) {
iter.next();
double doub = iter.get().getRealDouble();
if (doub > max)
max = doub;
}
System.out.println("Copied ouput " + i + " max value: " + max);
// TODO remove
}
} catch (Exception e) {
closeShmas();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

import io.bioimage.modelrunner.tensor.shm.SharedMemoryArray;
import io.bioimage.modelrunner.utils.CommonUtils;
import net.imglib2.Cursor;
import net.imglib2.util.Cast;
import net.imglib2.view.Views;

import java.nio.ByteBuffer;
import java.util.Arrays;
Expand Down Expand Up @@ -139,6 +141,15 @@ private static org.bytedeco.pytorch.Tensor buildFloat(SharedMemoryArray shmArray
float[] flat = new float[buff.capacity() / 4];
buff.asFloatBuffer().get(flat);
Tensor ndarray = Tensor.create(flat, ogShape);

// TODO remove
double max0 = 0;
for (float ff : flat) {
if (ff > max0)
max0 = ff;
}
System.out.println("Input max: " + max0);
// TODO remove
return ndarray;
}

Expand Down

0 comments on commit 761ab24

Please sign in to comment.