Skip to content

Commit b107798

Browse files
jdduketensorflower-gardener
authored andcommitted
Fully qualify TFLite Javadoc references
Types that aren't explicitly imported should be fully qualifed. Also mark private several native JNI methods that shouldn't be public. Note that this doesn't fix the generated links for external API types, but it does avoid generated errors in the Javadoc generation. PiperOrigin-RevId: 348060889 Change-Id: Iec886bf0cf25731e1a0a393de78ad19c7ef69ff0
1 parent d081040 commit b107798

File tree

2 files changed

+55
-51
lines changed

2 files changed

+55
-51
lines changed

tensorflow/lite/java/src/main/java/org/tensorflow/lite/Interpreter.java

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@
6565
* model with Toco, as are the default shapes of the inputs.
6666
*
6767
* <p>When inputs are provided as (multi-dimensional) arrays, the corresponding input tensor(s) will
68-
* be implicitly resized according to that array's shape. When inputs are provided as {@link Buffer}
69-
* types, no implicit resizing is done; the caller must ensure that the {@link Buffer} byte size
70-
* either matches that of the corresponding tensor, or that they first resize the tensor via {@link
71-
* #resizeInput()}. Tensor shape and type information can be obtained via the {@link Tensor} class,
72-
* available via {@link #getInputTensor(int)} and {@link #getOutputTensor(int)}.
68+
* be implicitly resized according to that array's shape. When inputs are provided as {@link
69+
* java.nio.Buffer} types, no implicit resizing is done; the caller must ensure that the {@link
70+
* java.nio.Buffer} byte size either matches that of the corresponding tensor, or that they first
71+
* resize the tensor via {@link #resizeInput(int, int[])}. Tensor shape and type information can be
72+
* obtained via the {@link Tensor} class, available via {@link #getInputTensor(int)} and {@link
73+
* #getOutputTensor(int)}.
7374
*
7475
* <p><b>WARNING:</b>Instances of a {@code Interpreter} is <b>not</b> thread-safe. A {@code
7576
* Interpreter} owns resources that <b>must</b> be explicitly freed by invoking {@link #close()}
@@ -269,7 +270,7 @@ public Interpreter(@NonNull MappedByteBuffer mappedByteBuffer) {
269270

270271
/**
271272
* Initializes a {@code Interpreter} with a {@code ByteBuffer} of a model file and a set of custom
272-
* {@link #Options}.
273+
* {@link Interpreter.Options}.
273274
*
274275
* <p>The ByteBuffer should not be modified after the construction of a {@code Interpreter}. The
275276
* {@code ByteBuffer} can be either a {@link MappedByteBuffer} that memory-maps a model file, or a
@@ -285,33 +286,35 @@ public Interpreter(@NonNull ByteBuffer byteBuffer, Options options) {
285286
/**
286287
* Runs model inference if the model takes only one input, and provides only one output.
287288
*
288-
* <p>Warning: The API is more efficient if a {@link Buffer} (preferably direct, but not required)
289-
* is used as the input/output data type. Please consider using {@link Buffer} to feed and fetch
290-
* primitive data for better performance. The following concrete {@link Buffer} types are
291-
* supported:
289+
* <p>Warning: The API is more efficient if a {@link java.nio.Buffer} (preferably direct, but not
290+
* required) is used as the input/output data type. Please consider using {@link java.nio.Buffer}
291+
* to feed and fetch primitive data for better performance. The following concrete {@link
292+
* java.nio.Buffer} types are supported:
292293
*
293294
* <ul>
294295
* <li>{@link ByteBuffer} - compatible with any underlying primitive Tensor type.
295-
* <li>{@link FloatBuffer} - compatible with float Tensors.
296-
* <li>{@link IntBuffer} - compatible with int32 Tensors.
297-
* <li>{@link LongBuffer} - compatible with int64 Tensors.
296+
* <li>{@link java.nio.FloatBuffer} - compatible with float Tensors.
297+
* <li>{@link java.nio.IntBuffer} - compatible with int32 Tensors.
298+
* <li>{@link java.nio.LongBuffer} - compatible with int64 Tensors.
298299
* </ul>
299300
*
300-
* Note that boolean types are only supported as arrays, not {@link Buffer}s, or as scalar inputs.
301-
*
302-
* @param input an array or multidimensional array, or a {@link Buffer} of primitive types
303-
* including int, float, long, and byte. {@link Buffer} is the preferred way to pass large
304-
* input data for primitive types, whereas string types require using the (multi-dimensional)
305-
* array input path. When a {@link Buffer} is used, its content should remain unchanged until
306-
* model inference is done, and the caller must ensure that the {@link Buffer} is at the
307-
* appropriate read position. A {@code null} value is allowed only if the caller is using a
308-
* {@link Delegate} that allows buffer handle interop, and such a buffer has been bound to the
309-
* input {@link Tensor}.
310-
* @param output a multidimensional array of output data, or a {@link Buffer} of primitive types
311-
* including int, float, long, and byte. When a {@link Buffer} is used, the caller must ensure
312-
* that it is set the appropriate write position. A null value is allowed only if the caller
313-
* is using a {@link Delegate} that allows buffer handle interop, and such a buffer has been
314-
* bound to the output {@link Tensor}. See {@link Options#setAllowBufferHandleOutput()}.
301+
* Note that boolean types are only supported as arrays, not {@link java.nio.Buffer}s, or as
302+
* scalar inputs.
303+
*
304+
* @param input an array or multidimensional array, or a {@link java.nio.Buffer} of primitive
305+
* types including int, float, long, and byte. {@link java.nio.Buffer} is the preferred way to
306+
* pass large input data for primitive types, whereas string types require using the
307+
* (multi-dimensional) array input path. When a {@link java.nio.Buffer} is used, its content
308+
* should remain unchanged until model inference is done, and the caller must ensure that the
309+
* {@link java.nio.Buffer} is at the appropriate read position. A {@code null} value is
310+
* allowed only if the caller is using a {@link Delegate} that allows buffer handle interop,
311+
* and such a buffer has been bound to the input {@link Tensor}.
312+
* @param output a multidimensional array of output data, or a {@link java.nio.Buffer} of
313+
* primitive types including int, float, long, and byte. When a {@link java.nio.Buffer} is
314+
* used, the caller must ensure that it is set the appropriate write position. A null value is
315+
* allowed only if the caller is using a {@link Delegate} that allows buffer handle interop,
316+
* and such a buffer has been bound to the output {@link Tensor}. See {@link
317+
* Interpreter.Options#setAllowBufferHandleOutput(boolean)}.
315318
* @throws IllegalArgumentException if {@code input} or {@code output} is null or empty, or if
316319
* error occurs when running the inference.
317320
* @throws IllegalArgumentException (EXPERIMENTAL, subject to change) if the inference is
@@ -327,35 +330,36 @@ public void run(Object input, Object output) {
327330
/**
328331
* Runs model inference if the model takes multiple inputs, or returns multiple outputs.
329332
*
330-
* <p>Warning: The API is more efficient if {@link Buffer}s (preferably direct, but not required)
331-
* are used as the input/output data types. Please consider using {@link Buffer} to feed and fetch
332-
* primitive data for better performance. The following concrete {@link Buffer} types are
333-
* supported:
333+
* <p>Warning: The API is more efficient if {@link java.nio.Buffer}s (preferably direct, but not
334+
* required) are used as the input/output data types. Please consider using {@link
335+
* java.nio.Buffer} to feed and fetch primitive data for better performance. The following
336+
* concrete {@link java.nio.Buffer} types are supported:
334337
*
335338
* <ul>
336339
* <li>{@link ByteBuffer} - compatible with any underlying primitive Tensor type.
337-
* <li>{@link FloatBuffer} - compatible with float Tensors.
338-
* <li>{@link IntBuffer} - compatible with int32 Tensors.
339-
* <li>{@link LongBuffer} - compatible with int64 Tensors.
340+
* <li>{@link java.nio.FloatBuffer} - compatible with float Tensors.
341+
* <li>{@link java.nio.IntBuffer} - compatible with int32 Tensors.
342+
* <li>{@link java.nio.LongBuffer} - compatible with int64 Tensors.
340343
* </ul>
341344
*
342-
* Note that boolean types are only supported as arrays, not {@link Buffer}s, or as scalar inputs.
345+
* Note that boolean types are only supported as arrays, not {@link java.nio.Buffer}s, or as
346+
* scalar inputs.
343347
*
344348
* <p>Note: {@code null} values for invididual elements of {@code inputs} and {@code outputs} is
345349
* allowed only if the caller is using a {@link Delegate} that allows buffer handle interop, and
346350
* such a buffer has been bound to the corresponding input or output {@link Tensor}(s).
347351
*
348352
* @param inputs an array of input data. The inputs should be in the same order as inputs of the
349-
* model. Each input can be an array or multidimensional array, or a {@link Buffer} of
350-
* primitive types including int, float, long, and byte. {@link Buffer} is the preferred way
351-
* to pass large input data, whereas string types require using the (multi-dimensional) array
352-
* input path. When {@link Buffer} is used, its content should remain unchanged until model
353-
* inference is done, and the caller must ensure that the {@link Buffer} is at the appropriate
354-
* read position.
353+
* model. Each input can be an array or multidimensional array, or a {@link java.nio.Buffer}
354+
* of primitive types including int, float, long, and byte. {@link java.nio.Buffer} is the
355+
* preferred way to pass large input data, whereas string types require using the
356+
* (multi-dimensional) array input path. When {@link java.nio.Buffer} is used, its content
357+
* should remain unchanged until model inference is done, and the caller must ensure that the
358+
* {@link java.nio.Buffer} is at the appropriate read position.
355359
* @param outputs a map mapping output indices to multidimensional arrays of output data or {@link
356-
* Buffer}s of primitive types including int, float, long, and byte. It only needs to keep
357-
* entries for the outputs to be used. When a {@link Buffer} is used, the caller must ensure
358-
* that it is set the appropriate write position.
360+
* java.nio.Buffer}s of primitive types including int, float, long, and byte. It only needs to
361+
* keep entries for the outputs to be used. When a {@link java.nio.Buffer} is used, the caller
362+
* must ensure that it is set the appropriate write position.
359363
* @throws IllegalArgumentException if {@code inputs} or {@code outputs} is null or empty, or if
360364
* error occurs when running the inference.
361365
*/
@@ -494,8 +498,8 @@ public Long getLastNativeInferenceDurationNanoseconds() {
494498
/**
495499
* Sets the number of threads to be used for ops that support multi-threading.
496500
*
497-
* @deprecated Prefer using {@link Options#setNumThreads(int)} directly for controlling thread
498-
* multi-threading. This method will be removed in a future release.
501+
* @deprecated Prefer using {@link Interpreter.Options#setNumThreads(int)} directly for
502+
* controlling thread multi-threading. This method will be removed in a future release.
499503
*/
500504
@Deprecated
501505
public void setNumThreads(int numThreads) {
@@ -507,8 +511,8 @@ public void setNumThreads(int numThreads) {
507511
* Advanced: Modifies the graph with the provided {@link Delegate}.
508512
*
509513
* @throws IllegalArgumentException if error occurs when modifying graph with {@code delegate}.
510-
* @deprecated Prefer using {@link Options#addDelegate} to provide delegates at creation time.
511-
* This method will be removed in a future release.
514+
* @deprecated Prefer using {@link Interpreter.Options#addDelegate} to provide delegates at
515+
* creation time. This method will be removed in a future release.
512516
*/
513517
@Deprecated
514518
public void modifyGraphWithDelegate(Delegate delegate) {

tensorflow/lite/java/src/main/java/org/tensorflow/lite/TensorFlowLite.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static void init() {
8585
}
8686
}
8787

88-
public static native String nativeRuntimeVersion();
88+
private static native String nativeRuntimeVersion();
8989

90-
public static native String nativeSchemaVersion();
90+
private static native String nativeSchemaVersion();
9191
}

0 commit comments

Comments
 (0)