Skip to content

Commit 704447f

Browse files
committed
remove prints
1 parent 71738d2 commit 704447f

File tree

2 files changed

+5
-51
lines changed

2 files changed

+5
-51
lines changed

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

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.nio.charset.StandardCharsets;
3030
import java.security.ProtectionDomain;
3131
import java.util.ArrayList;
32-
import java.util.Arrays;
3332
import java.util.HashMap;
3433
import java.util.LinkedHashMap;
3534
import java.util.LinkedList;
@@ -58,13 +57,11 @@
5857
import io.bioimage.modelrunner.tensor.Tensor;
5958
import io.bioimage.modelrunner.tensor.shm.SharedMemoryArray;
6059
import io.bioimage.modelrunner.utils.CommonUtils;
61-
import net.imglib2.Cursor;
6260
import net.imglib2.RandomAccessibleInterval;
6361
import net.imglib2.type.NativeType;
6462
import net.imglib2.type.numeric.RealType;
6563
import net.imglib2.util.Cast;
6664
import net.imglib2.util.Util;
67-
import net.imglib2.view.Views;
6865

6966
/**
7067
* This class implements an interface that allows the main plugin to interact in
@@ -190,11 +187,11 @@ private void launchModelLoadOnProcess() throws IOException, InterruptedException
190187
if (task.status == TaskStatus.CANCELED)
191188
throw new RuntimeException();
192189
else if (task.status == TaskStatus.FAILED)
193-
throw new RuntimeException();
190+
throw new RuntimeException(task.error);
194191
else if (task.status == TaskStatus.CRASHED) {
195192
this.runner.close();
196193
runner = null;
197-
throw new RuntimeException();
194+
throw new RuntimeException(task.error);
198195
}
199196
}
200197

@@ -245,7 +242,6 @@ protected void runFromShmas(List<String> inputs, List<String> outputs) throws IO
245242
IValueVector inputsVector = new IValueVector();
246243
for (String ee : inputs) {
247244
Map<String, Object> decoded = Types.decode(ee);
248-
System.out.println("MM: -> " + ee);
249245
SharedMemoryArray shma = SharedMemoryArray.read((String) decoded.get(MEM_NAME_KEY));
250246
org.bytedeco.pytorch.Tensor inT = TensorBuilder.build(shma);
251247
inputsVector.put(new IValue(inT));
@@ -310,7 +306,7 @@ else if (task.status == TaskStatus.FAILED)
310306
else if (task.status == TaskStatus.CRASHED) {
311307
this.runner.close();
312308
runner = null;
313-
throw new RuntimeException();
309+
throw new RuntimeException(task.error);
314310
}
315311
for (int i = 0; i < outputTensors.size(); i ++) {
316312
String name = (String) Types.decode(encOuts.get(i)).get(MEM_NAME_KEY);
@@ -321,30 +317,7 @@ else if (task.status == TaskStatus.CRASHED) {
321317
shmaOutputList.add(shm);
322318
}
323319
RandomAccessibleInterval<T> rai = shm.getSharedRAI();
324-
System.out.println("Output size: " + Arrays.toString(rai.dimensionsAsLongArray()));
325-
// TODO remove
326-
double max0 = 0;
327-
Cursor<T> iter0 = Views.iterable(rai).cursor();
328-
while (iter0.hasNext()) {
329-
iter0.next();
330-
double doub = iter0.get().getRealDouble();
331-
if (doub > max0)
332-
max0 = doub;
333-
}
334-
System.out.println("Output SHM " + i + " max value: " + max0);
335-
// TODO remove
336320
outputTensors.get(i).setData(Tensor.createCopyOfRaiInWantedDataType(Cast.unchecked(rai), Util.getTypeFromInterval(Cast.unchecked(rai))));
337-
// TODO remove
338-
double max = 0;
339-
Cursor<R> iter = Views.iterable(outputTensors.get(i).getData()).cursor();
340-
while (iter.hasNext()) {
341-
iter.next();
342-
double doub = iter.get().getRealDouble();
343-
if (doub > max)
344-
max = doub;
345-
}
346-
System.out.println("Copied ouput " + i + " max value: " + max);
347-
// TODO remove
348321
}
349322
} catch (Exception e) {
350323
closeShmas();
@@ -385,11 +358,11 @@ public void closeModel() {
385358
if (task.status == TaskStatus.CANCELED)
386359
throw new RuntimeException();
387360
else if (task.status == TaskStatus.FAILED)
388-
throw new RuntimeException();
361+
throw new RuntimeException(task.error);
389362
else if (task.status == TaskStatus.CRASHED) {
390363
this.runner.close();
391364
runner = null;
392-
throw new RuntimeException();
365+
throw new RuntimeException(task.error);
393366
}
394367
this.runner.close();
395368
this.runner = null;
@@ -432,16 +405,6 @@ private <T extends RealType<T> & NativeType<T>> List<String> encodeInputs(List<T
432405
List<String> encodedInputTensors = new ArrayList<String>();
433406
Gson gson = new Gson();
434407
for (Tensor<T> tt : inputTensors) {
435-
System.out.println("Input size: " + Arrays.toString(tt.getData().dimensionsAsLongArray()));
436-
double max0 = 0;
437-
Cursor<T> iter0 = Views.iterable(tt.getData()).cursor();
438-
while (iter0.hasNext()) {
439-
iter0.next();
440-
double doub = iter0.get().getRealDouble();
441-
if (doub > max0)
442-
max0 = doub;
443-
}
444-
System.out.println("Input max: " + max0);
445408
SharedMemoryArray shma = SharedMemoryArray.createSHMAFromRAI(tt.getData(), false, true);
446409
shmaInputList.add(shma);
447410
HashMap<String, Object> map = new HashMap<String, Object>();

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +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
Tensor ndarray = Tensor.create(flat, ogShape);
142-
143-
// TODO remove
144-
double max0 = 0;
145-
for (float ff : flat) {
146-
if (ff > max0)
147-
max0 = ff;
148-
}
149-
System.out.println("Input max: " + max0);
150-
// TODO remove
151142
return ndarray;
152143
}
153144

0 commit comments

Comments
 (0)