extractFromResources(String library) {
/**
* Maps the library name into a platform dependent library filename. Converts macOS's "jnilib" to
- * "dylib" but otherwise is the same as {@link System#mapLibraryName(String)}.
+ * "dylib" but otherwise is the same as {\@link System#mapLibraryName(String)}.
*
* @param library The library name
* @return The library filename.
diff --git a/src/java/src/main/java/ai/onnxruntime/genai/GenAIException.java b/src/java/src/main/java/ai/onnxruntime/genai/GenAIException.java
index 30c1d58c1..613d18908 100644
--- a/src/java/src/main/java/ai/onnxruntime/genai/GenAIException.java
+++ b/src/java/src/main/java/ai/onnxruntime/genai/GenAIException.java
@@ -5,11 +5,11 @@
/** An exception which contains the error message and code produced by the native layer. */
public final class GenAIException extends Exception {
- public GenAIException(String message) {
+ private GenAIException(String message) {
super(message);
}
- public GenAIException(String message, Exception innerException) {
+ private GenAIException(String message, Exception innerException) {
super(message, innerException);
}
}
diff --git a/src/java/src/main/java/ai/onnxruntime/genai/GeneratorParams.java b/src/java/src/main/java/ai/onnxruntime/genai/GeneratorParams.java
index cb1f77b41..9ac507a3d 100644
--- a/src/java/src/main/java/ai/onnxruntime/genai/GeneratorParams.java
+++ b/src/java/src/main/java/ai/onnxruntime/genai/GeneratorParams.java
@@ -8,7 +8,7 @@
import java.nio.ByteOrder;
/**
- * The `GeneratorParams` class represents the parameters used for generating sequences with a model.
+ * Represents the parameters used for generating sequences with a model.
* Set the prompt using setInput, and any other search options using setSearchOption.
*/
public final class GeneratorParams implements AutoCloseable {
@@ -23,6 +23,12 @@ public final class GeneratorParams implements AutoCloseable {
nativeHandle = createGeneratorParams(model.nativeHandle());
}
+ /**
+ * Set seach option with double value.
+ * @param optionName The option name.
+ * @param value The option value.
+ * @throws GenAIException
+ */
public void setSearchOption(String optionName, double value) throws GenAIException {
if (nativeHandle == 0) {
throw new IllegalStateException("Instance has been freed and is invalid");
@@ -31,6 +37,12 @@ public void setSearchOption(String optionName, double value) throws GenAIExcepti
setSearchOptionNumber(nativeHandle, optionName, value);
}
+ /**
+ * Set search option with boolean value.
+ * @param optionName The option name.
+ * @param value The option value.
+ * @throws GenAIException
+ */
public void setSearchOption(String optionName, boolean value) throws GenAIException {
if (nativeHandle == 0) {
throw new IllegalStateException("Instance has been freed and is invalid");
@@ -159,7 +171,7 @@ private native void setInputSequences(long nativeHandle, long sequencesHandle)
private native void setModelInput(long nativeHandle, String inputName, long tensorHandle)
throws GenAIException;
-
+
private native void setInputs(long nativeHandle, long namedTensorsHandle)
throws GenAIException;
diff --git a/src/java/src/main/java/ai/onnxruntime/genai/Images.java b/src/java/src/main/java/ai/onnxruntime/genai/Images.java
index 51eaa61ac..b93547c18 100644
--- a/src/java/src/main/java/ai/onnxruntime/genai/Images.java
+++ b/src/java/src/main/java/ai/onnxruntime/genai/Images.java
@@ -3,6 +3,9 @@
*/
package ai.onnxruntime.genai;
+/**
+ * This class can load images from the given path and prepare them for processing.
+ */
public class Images implements AutoCloseable{
private long nativeHandle;
diff --git a/src/java/src/main/java/ai/onnxruntime/genai/Model.java b/src/java/src/main/java/ai/onnxruntime/genai/Model.java
index 0cc67b14a..080143c05 100644
--- a/src/java/src/main/java/ai/onnxruntime/genai/Model.java
+++ b/src/java/src/main/java/ai/onnxruntime/genai/Model.java
@@ -3,6 +3,9 @@
*/
package ai.onnxruntime.genai;
+/**
+ * An ORT GenAI model.
+ */
public final class Model implements AutoCloseable {
private long nativeHandle;
diff --git a/src/java/src/main/java/ai/onnxruntime/genai/NamedTensors.java b/src/java/src/main/java/ai/onnxruntime/genai/NamedTensors.java
index 5811e554f..298d91d36 100644
--- a/src/java/src/main/java/ai/onnxruntime/genai/NamedTensors.java
+++ b/src/java/src/main/java/ai/onnxruntime/genai/NamedTensors.java
@@ -3,6 +3,10 @@
*/
package ai.onnxruntime.genai;
+/**
+ * This class is an intermediate storage class that bridges the output of preprocessing and
+ * the input of the ONNX model.
+ */
public class NamedTensors implements AutoCloseable{
private long nativeHandle;
diff --git a/src/java/src/main/java/ai/onnxruntime/genai/Tensor.java b/src/java/src/main/java/ai/onnxruntime/genai/Tensor.java
index d5946c23e..57d99def8 100644
--- a/src/java/src/main/java/ai/onnxruntime/genai/Tensor.java
+++ b/src/java/src/main/java/ai/onnxruntime/genai/Tensor.java
@@ -7,6 +7,9 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+/**
+ * Wraps ORT native Tensor.
+ */
public final class Tensor implements AutoCloseable {
private long nativeHandle = 0;
private final ElementType elementType;
@@ -17,6 +20,9 @@ public final class Tensor implements AutoCloseable {
// The values in this enum must match ONNX values
// https://github.com/onnx/onnx/blob/159fa47b7c4d40e6d9740fcf14c36fff1d11ccd8/onnx/onnx.proto#L499-L544
+ /**
+ * ORT native element types.
+ */
public enum ElementType {
undefined,
float32,
diff --git a/src/java/src/main/java/ai/onnxruntime/genai/package-info.java b/src/java/src/main/java/ai/onnxruntime/genai/package-info.java
index 9a43f976a..2f53547d3 100644
--- a/src/java/src/main/java/ai/onnxruntime/genai/package-info.java
+++ b/src/java/src/main/java/ai/onnxruntime/genai/package-info.java
@@ -8,26 +8,26 @@
*
* There are two shared libraries required: onnxruntime-genai
and
* onnxruntime-genai-jni
- *
. The loader is in {@link ai.onnxruntime.genai.GenAI} and the logic is in this order:
+ * . The loader is in {\@link ai.onnxruntime.genai.GenAI} and the logic is in this order:
*
*
* - The user may signal to skip loading of a shared library using a property in the form
* onnxruntime-genai.native.LIB_NAME.skip
with a value of true
. This means
* the user has decided to load the library by some other means.
* - The user may specify an explicit location of all native library files using a property in
- * the form
onnxruntime-genai.native.path
. This uses {@link
+ * the form onnxruntime-genai.native.path
. This uses {\@link
* java.lang.System#load}.
* - The user may specify an explicit location of the shared library file using a property in
- * the form
onnxruntime-genai.native.LIB_NAME.path
. This uses {@link
+ * the form onnxruntime-genai.native.LIB_NAME.path
. This uses {\@link
* java.lang.System#load}.
* - The shared library is autodiscovered:
*
- * - If the shared library is present in the classpath resources, load using {@link
+ *
- If the shared library is present in the classpath resources, load using {\@link
* java.lang.System#load} via a temporary file. Ideally, this should be the default use
* case when adding JAR's/dependencies containing the shared libraries to your
* classpath.
*
- If the shared library is not present in the classpath resources, then load using
- * {@link java.lang.System#loadLibrary}, which usually looks elsewhere on the filesystem
+ * {\@link java.lang.System#loadLibrary}, which usually looks elsewhere on the filesystem
* for the library. The semantics and behavior of that method are system/JVM dependent.
* Typically, the
java.library.path
property is used to specify the
* location of native libraries.
From edd56cb7148bb2585d52ea7b70be50850fb81e75 Mon Sep 17 00:00:00 2001
From: Chester Liu <4710575+skyline75489@users.noreply.github.com>
Date: Thu, 14 Nov 2024 08:54:17 +0000
Subject: [PATCH 02/24] pass doxygen
---
src/csharp/Adapters.cs | 9 +++
src/csharp/Config.cs | 12 ++++
src/csharp/Generator.cs | 49 +++++++++++++--
src/csharp/GeneratorParams.cs | 62 +++++++++++++++++++
src/csharp/Images.cs | 2 +-
src/csharp/Model.cs | 21 +++++++
src/csharp/MultiModalProcessor.cs | 38 ++++++++++++
src/csharp/Sequences.cs | 6 ++
src/csharp/Tensor.cs | 33 +++++++++-
src/csharp/Tokenizer.cs | 57 +++++++++++++++++
src/csharp/TokenizerStream.cs | 10 +++
src/csharp/Utils.cs | 2 +-
.../ai/onnxruntime/genai/GeneratorParams.java | 2 +
.../java/ai/onnxruntime/genai/Images.java | 6 ++
.../main/java/ai/onnxruntime/genai/Model.java | 12 ++++
.../genai/MultiModalProcessor.java | 6 ++
.../ai/onnxruntime/genai/NamedTensors.java | 5 ++
.../ai/onnxruntime/genai/SimpleGenAI.java | 6 ++
.../ai/onnxruntime/genai/TokenizerStream.java | 12 ++++
.../ai/onnxruntime/genai/package-info.java | 12 ++--
20 files changed, 347 insertions(+), 15 deletions(-)
diff --git a/src/csharp/Adapters.cs b/src/csharp/Adapters.cs
index bb3b63f3a..34966bc04 100644
--- a/src/csharp/Adapters.cs
+++ b/src/csharp/Adapters.cs
@@ -17,6 +17,9 @@ public class Adapters : SafeHandle
/// Throws on error.
///