Skip to content

Commit e74afb2

Browse files
committed
correct javadoc
1 parent d123975 commit e74afb2

File tree

2 files changed

+22
-119
lines changed

2 files changed

+22
-119
lines changed

Diff for: src/main/java/io/bioimage/modelrunner/tensorflow/v2/api020/shm/ShmBuilder.java

+12-55
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,17 @@
3636
import org.tensorflow.types.TUint8;
3737
import org.tensorflow.types.family.TType;
3838

39-
import net.imglib2.RandomAccessibleInterval;
4039
import net.imglib2.type.numeric.integer.IntType;
4140
import net.imglib2.type.numeric.integer.LongType;
4241
import net.imglib2.type.numeric.integer.UnsignedByteType;
4342
import net.imglib2.type.numeric.real.DoubleType;
4443
import net.imglib2.type.numeric.real.FloatType;
4544

4645
/**
47-
* A {@link RandomAccessibleInterval} builder for TensorFlow {@link Tensor} objects.
48-
* Build ImgLib2 objects (backend of {@link io.bioimage.modelrunner.tensor.Tensor})
49-
* from Tensorflow 2 {@link Tensor}
46+
* A utility class that converts {@link Tensor}s into {@link SharedMemoryArray}s for
47+
* interprocessing communication
5048
*
51-
* @author Carlos Garcia Lopez de Haro and Daniel Felipe Gonzalez Obando
49+
* @author Carlos Garcia Lopez de Haro
5250
*/
5351
public final class ShmBuilder
5452
{
@@ -59,16 +57,15 @@ private ShmBuilder()
5957
{
6058
}
6159

62-
/**
63-
* Creates a {@link RandomAccessibleInterval} from a given {@link TType} tensor
64-
*
65-
* @param <T>
66-
* the possible ImgLib2 datatypes of the image
67-
* @param tensor
68-
* The {@link TType} tensor data is read from.
69-
* @throws IllegalArgumentException If the {@link TType} tensor type is not supported.
70-
* @throws IOException
71-
*/
60+
/**
61+
* Create a {@link SharedMemoryArray} from a {@link Tensor}
62+
* @param tensor
63+
* the tensor to be passed into the other process through the shared memory
64+
* @param memoryName
65+
* the name of the memory region where the tensor is going to be copied
66+
* @throws IllegalArgumentException if the data type of the tensor is not supported
67+
* @throws IOException if there is any error creating the shared memory array
68+
*/
7269
@SuppressWarnings("unchecked")
7370
public static void build(Tensor<? extends TType> tensor, String memoryName) throws IllegalArgumentException, IOException
7471
{
@@ -89,14 +86,6 @@ public static void build(Tensor<? extends TType> tensor, String memoryName) thr
8986
}
9087
}
9188

92-
/**
93-
* Builds a {@link RandomAccessibleInterval} from a unsigned byte-typed {@link TUint8} tensor.
94-
*
95-
* @param tensor
96-
* The {@link TUint8} tensor data is read from.
97-
* @return The {@link RandomAccessibleInterval} built from the tensor, of type {@link UnsignedByteType}.
98-
* @throws IOException
99-
*/
10089
private static void buildFromTensorUByte(Tensor<TUint8> tensor, String memoryName) throws IOException
10190
{
10291
long[] arrayShape = tensor.shape().asArray();
@@ -114,14 +103,6 @@ private static void buildFromTensorUByte(Tensor<TUint8> tensor, String memoryNam
114103
if (PlatformDetection.isWindows()) shma.close();
115104
}
116105

117-
/**
118-
* Builds a {@link RandomAccessibleInterval} from a unsigned int32-typed {@link TInt32} tensor.
119-
*
120-
* @param tensor
121-
* The {@link TInt32} tensor data is read from.
122-
* @return The {@link RandomAccessibleInterval} built from the tensor, of type {@link IntType}.
123-
* @throws IOException
124-
*/
125106
private static void buildFromTensorInt(Tensor<TInt32> tensor, String memoryName) throws IOException
126107
{
127108
long[] arrayShape = tensor.shape().asArray();
@@ -140,14 +121,6 @@ private static void buildFromTensorInt(Tensor<TInt32> tensor, String memoryName)
140121
if (PlatformDetection.isWindows()) shma.close();
141122
}
142123

143-
/**
144-
* Builds a {@link RandomAccessibleInterval} from a unsigned float32-typed {@link TFloat32} tensor.
145-
*
146-
* @param tensor
147-
* The {@link TFloat32} tensor data is read from.
148-
* @return The {@link RandomAccessibleInterval} built from the tensor, of type {@link FloatType}.
149-
* @throws IOException
150-
*/
151124
private static void buildFromTensorFloat(Tensor<TFloat32> tensor, String memoryName) throws IOException
152125
{
153126
long[] arrayShape = tensor.shape().asArray();
@@ -166,14 +139,6 @@ private static void buildFromTensorFloat(Tensor<TFloat32> tensor, String memoryN
166139
if (PlatformDetection.isWindows()) shma.close();
167140
}
168141

169-
/**
170-
* Builds a {@link RandomAccessibleInterval} from a unsigned float64-typed {@link TFloat64} tensor.
171-
*
172-
* @param tensor
173-
* The {@link TFloat64} tensor data is read from.
174-
* @return The {@link RandomAccessibleInterval} built from the tensor, of type {@link DoubleType}.
175-
* @throws IOException
176-
*/
177142
private static void buildFromTensorDouble(Tensor<TFloat64> tensor, String memoryName) throws IOException
178143
{
179144
long[] arrayShape = tensor.shape().asArray();
@@ -192,14 +157,6 @@ private static void buildFromTensorDouble(Tensor<TFloat64> tensor, String memory
192157
if (PlatformDetection.isWindows()) shma.close();
193158
}
194159

195-
/**
196-
* Builds a {@link RandomAccessibleInterval} from a unsigned int64-typed {@link TInt64} tensor.
197-
*
198-
* @param tensor
199-
* The {@link TInt64} tensor data is read from.
200-
* @return The {@link RandomAccessibleInterval} built from the tensor, of type {@link LongType}.
201-
* @throws IOException
202-
*/
203160
private static void buildFromTensorLong(Tensor<TInt64> tensor, String memoryName) throws IOException
204161
{
205162
long[] arrayShape = tensor.shape().asArray();

Diff for: src/main/java/io/bioimage/modelrunner/tensorflow/v2/api020/shm/TensorBuilder.java

+10-64
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@
5555
import org.tensorflow.types.family.TType;
5656

5757
/**
58-
* A TensorFlow 2 {@link Tensor} builder from {@link Img} and
59-
* {@link io.bioimage.modelrunner.tensor.Tensor} objects.
58+
* Utility class to build Tensorflow tensors from shm segments using {@link SharedMemoryArray}
6059
*
61-
* @author Carlos Garcia Lopez de Haro and Daniel Felipe Gonzalez Obando
60+
* @author Carlos Garcia Lopez de Haro
6261
*/
6362
public final class TensorBuilder {
6463

@@ -68,16 +67,13 @@ public final class TensorBuilder {
6867
private TensorBuilder() {}
6968

7069
/**
71-
* Creates {@link TType} instance with the same size and information as the
72-
* given {@link RandomAccessibleInterval}.
70+
* Creates {@link Tensor} instance from a {@link SharedMemoryArray}
7371
*
74-
* @param <T>
75-
* the ImgLib2 data types the {@link RandomAccessibleInterval} can be
7672
* @param array
77-
* the {@link RandomAccessibleInterval} that is going to be converted into
78-
* a {@link TType} tensor
79-
* @return a {@link TType} tensor
80-
* @throws IllegalArgumentException if the type of the {@link RandomAccessibleInterval}
73+
* the {@link SharedMemoryArray} that is going to be converted into
74+
* a {@link Tensor} tensor
75+
* @return the Tensorflow {@link Tensor} as the one stored in the shared memory segment
76+
* @throws IllegalArgumentException if the type of the {@link SharedMemoryArray}
8177
* is not supported
8278
*/
8379
public static Tensor<? extends TType> build(SharedMemoryArray array) throws IllegalArgumentException
@@ -103,17 +99,7 @@ else if (array.getOriginalDataType().equals("int64")) {
10399
}
104100
}
105101

106-
/**
107-
* Creates a {@link TType} tensor of type {@link TUint8} from an
108-
* {@link RandomAccessibleInterval} of type {@link UnsignedByteType}
109-
*
110-
* @param tensor
111-
* The {@link RandomAccessibleInterval} to fill the tensor with.
112-
* @return The {@link TType} tensor filled with the {@link RandomAccessibleInterval} data.
113-
* @throws IllegalArgumentException if the input {@link RandomAccessibleInterval} type is
114-
* not compatible
115-
*/
116-
public static Tensor<TUint8> buildUByte(SharedMemoryArray tensor)
102+
private static Tensor<TUint8> buildUByte(SharedMemoryArray tensor)
117103
throws IllegalArgumentException
118104
{
119105
long[] ogShape = tensor.getOriginalShape();
@@ -128,17 +114,7 @@ public static Tensor<TUint8> buildUByte(SharedMemoryArray tensor)
128114
return ndarray;
129115
}
130116

131-
/**
132-
* Creates a {@link TInt32} tensor of type {@link TInt32} from an
133-
* {@link RandomAccessibleInterval} of type {@link IntType}
134-
*
135-
* @param tensor
136-
* The {@link RandomAccessibleInterval} to fill the tensor with.
137-
* @return The {@link TInt32} tensor filled with the {@link RandomAccessibleInterval} data.
138-
* @throws IllegalArgumentException if the input {@link RandomAccessibleInterval} type is
139-
* not compatible
140-
*/
141-
public static Tensor<TInt32> buildInt(SharedMemoryArray tensor)
117+
private static Tensor<TInt32> buildInt(SharedMemoryArray tensor)
142118
throws IllegalArgumentException
143119
{
144120
long[] ogShape = tensor.getOriginalShape();
@@ -156,16 +132,6 @@ public static Tensor<TInt32> buildInt(SharedMemoryArray tensor)
156132
return ndarray;
157133
}
158134

159-
/**
160-
* Creates a {@link TInt64} tensor of type {@link TInt64} from an
161-
* {@link RandomAccessibleInterval} of type {@link LongType}
162-
*
163-
* @param tensor
164-
* The {@link RandomAccessibleInterval} to fill the tensor with.
165-
* @return The {@link TInt64} tensor filled with the {@link RandomAccessibleInterval} data.
166-
* @throws IllegalArgumentException if the input {@link RandomAccessibleInterval} type is
167-
* not compatible
168-
*/
169135
private static Tensor<TInt64> buildLong(SharedMemoryArray tensor)
170136
throws IllegalArgumentException
171137
{
@@ -184,17 +150,7 @@ private static Tensor<TInt64> buildLong(SharedMemoryArray tensor)
184150
return ndarray;
185151
}
186152

187-
/**
188-
* Creates a {@link TFloat32} tensor of type {@link TFloat32} from an
189-
* {@link RandomAccessibleInterval} of type {@link FloatType}
190-
*
191-
* @param tensor
192-
* The {@link RandomAccessibleInterval} to fill the tensor with.
193-
* @return The {@link TFloat32} tensor filled with the {@link RandomAccessibleInterval} data.
194-
* @throws IllegalArgumentException if the input {@link RandomAccessibleInterval} type is
195-
* not compatible
196-
*/
197-
public static Tensor<TFloat32> buildFloat(SharedMemoryArray tensor)
153+
private static Tensor<TFloat32> buildFloat(SharedMemoryArray tensor)
198154
throws IllegalArgumentException
199155
{
200156
long[] ogShape = tensor.getOriginalShape();
@@ -212,16 +168,6 @@ public static Tensor<TFloat32> buildFloat(SharedMemoryArray tensor)
212168
return ndarray;
213169
}
214170

215-
/**
216-
* Creates a {@link TFloat64} tensor of type {@link TFloat64} from an
217-
* {@link RandomAccessibleInterval} of type {@link DoubleType}
218-
*
219-
* @param tensor
220-
* The {@link RandomAccessibleInterval} to fill the tensor with.
221-
* @return The {@link TFloat64} tensor filled with the {@link RandomAccessibleInterval} data.
222-
* @throws IllegalArgumentException if the input {@link RandomAccessibleInterval} type is
223-
* not compatible
224-
*/
225171
private static Tensor<TFloat64> buildDouble(SharedMemoryArray tensor)
226172
throws IllegalArgumentException
227173
{

0 commit comments

Comments
 (0)