diff --git a/.gitignore b/.gitignore index 12f2ecf2d5fa9..a5f5320dace3f 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ onnxprofile_profile_test_*.json /csharp/packages /csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.targets /csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.props +# Java specific ignores +java/src/main/native/ai_onnxruntime_*.h +java/.gradle diff --git a/README.md b/README.md index a336da6afdcac..7ec951823a2b2 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Additional dockerfiles can be found [here](./dockerfiles). * [C](docs/C_API.md) * [C#](docs/CSharp_API.md) * [C++](./include/onnxruntime/core/session/onnxruntime_cxx_api.h) +* [Java](docs/Java_API.md) * [Ruby](https://github.com/ankane/onnxruntime) (external project) ### Official Builds @@ -107,6 +108,7 @@ system. * Version: **CUDA 10.0** and **cuDNN 7.6** * Older ONNX Runtime releases: used **CUDA 9.1** and **cuDNN 7.1** - please refer to [prior release notes](https://github.com/microsoft/onnxruntime/releases) for more details. * Python binaries are compatible with **Python 3.5-3.7**. See [Python Dev Notes](./docs/Python_Dev_Notes.md). If using `pip` to be download the Python binaries, run `pip install --upgrade pip` prior to downloading. +* The Java API is compatible with **Java 8-13**. * Certain operators makes use of system locales. Installation of the **English language package** and configuring `en_US.UTF-8 locale` is required. * For Ubuntu install [language-pack-en package](https://packages.ubuntu.com/search?keywords=language-pack-en) * Run the following commands: diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 78353bc7b440e..ef2cd84e54444 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -726,6 +726,11 @@ if (onnxruntime_BUILD_SERVER) include(onnxruntime_server.cmake) endif() +if (onnxruntime_BUILD_JAVA) + message(STATUS "Java Build is enabled") + include(onnxruntime_java.cmake) +endif() + # some of the tests rely on the shared libs to be # built; hence the ordering if (onnxruntime_BUILD_UNIT_TESTS) @@ -756,3 +761,4 @@ if (onnxruntime_BUILD_CSHARP) # set_property(GLOBAL PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "netstandard2.0") include(onnxruntime_csharp.cmake) endif() + diff --git a/cmake/onnxruntime_java.cmake b/cmake/onnxruntime_java.cmake new file mode 100644 index 0000000000000..1dc8ea16a055c --- /dev/null +++ b/cmake/onnxruntime_java.cmake @@ -0,0 +1,110 @@ +# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. +# Licensed under the MIT License. + +#set(CMAKE_VERBOSE_MAKEFILE on) + +# Setup Java compilation +include(FindJava) +find_package(Java REQUIRED) +find_package(JNI REQUIRED) +include(UseJava) +include_directories(${JNI_INCLUDE_DIRS}) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") + +set(JAVA_ROOT ${REPO_ROOT}/java) +set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.8" "-target" "1.8" "-encoding" "UTF-8") +if (onnxruntime_RUN_ONNX_TESTS) + set(JAVA_DEPENDS onnxruntime ${test_data_target}) +else() + set(JAVA_DEPENDS onnxruntime) +endif() + +# Specify the Java source files +set(onnxruntime4j_src + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/MapInfo.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/NodeInfo.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OnnxRuntime.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OnnxJavaType.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OnnxMap.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OnnxSequence.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OnnxTensor.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OnnxValue.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OrtAllocator.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OrtEnvironment.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OrtException.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OrtSession.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/OrtUtil.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/package-info.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/SequenceInfo.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/TensorInfo.java + ${REPO_ROOT}/java/src/main/java/ai/onnxruntime/ValueInfo.java + ) + +# Build the jar and generate the native headers +add_jar(onnxruntime4j SOURCES ${onnxruntime4j_src} VERSION ${ORT_VERSION} GENERATE_NATIVE_HEADERS onnxruntime4j_generated DESTINATION ${REPO_ROOT}/java/src/main/native/) + +# Specify the native sources (without the generated headers) +file(GLOB onnxruntime4j_native_src + "${REPO_ROOT}/java/src/main/native/*.c" + "${REPO_ROOT}/java/src/main/native/OrtJniUtil.h" + "${REPO_ROOT}/include/onnxruntime/core/session/*.h" + ) + +# Build the JNI library +add_library(onnxruntime4j_jni SHARED ${onnxruntime4j_native_src} ${onnxruntime4j_generated}) +onnxruntime_add_include_to_target(onnxruntime4j_jni onnxruntime_session) +target_include_directories(onnxruntime4j_jni PRIVATE ${REPO_ROOT}/include ${REPO_ROOT}/java/src/main/native) +target_link_libraries(onnxruntime4j_jni PUBLIC ${JNI_LIBRARIES} onnxruntime onnxruntime4j_generated) + +# Now the jar, jni binary and shared lib binary have been built, now to build the jar with the binaries added. + +# This blob creates the new jar name +get_property(onnxruntime_jar_name TARGET onnxruntime4j PROPERTY JAR_FILE) +get_filename_component(onnxruntime_jar_abs ${onnxruntime_jar_name} ABSOLUTE) +get_filename_component(jar_path ${onnxruntime_jar_abs} DIRECTORY) +set(onnxruntime_jar_binaries_name "${jar_path}/onnxruntime4j-${ORT_VERSION}-with-binaries.jar") +set(onnxruntime_jar_binaries_platform "$") + +# Copy the current jar +add_custom_command(TARGET onnxruntime4j_jni PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${onnxruntime_jar_name} + ${onnxruntime_jar_binaries_platform}) + +# Make a temp directory to store the binaries +add_custom_command(TARGET onnxruntime4j_jni POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/java-libs/lib") + +# Copy the binaries +add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}/java-libs/lib/) + +if (WIN32) +add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}/java-libs/lib/) +# Update the with-binaries jar so it includes the binaries +add_custom_command( + TARGET onnxruntime4j_jni POST_BUILD + COMMAND ${Java_JAR_EXECUTABLE} -uf ${onnxruntime_jar_binaries_platform} -C ${CMAKE_CURRENT_BINARY_DIR}/java-libs lib/$ -C ${CMAKE_CURRENT_BINARY_DIR}/java-libs lib/$ + DEPENDS onnxruntime4j + COMMENT "Rebuilding Java archive ${_JAVA_TARGET_OUTPUT_NAME}" + VERBATIM + ) +else () +add_custom_command(TARGET onnxruntime4j_jni POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}/java-libs/lib/) +# Update the with-binaries jar so it includes the binaries +add_custom_command( + TARGET onnxruntime4j_jni POST_BUILD + COMMAND ${Java_JAR_EXECUTABLE} -uf ${onnxruntime_jar_binaries_platform} -C ${CMAKE_CURRENT_BINARY_DIR}/java-libs lib/$ -C ${CMAKE_CURRENT_BINARY_DIR}/java-libs lib/$ + DEPENDS onnxruntime4j + COMMENT "Rebuilding Java archive ${_JAVA_TARGET_OUTPUT_NAME}" + VERBATIM + ) +endif() + +create_javadoc(onnxruntime4j_javadoc + FILES ${onnxruntime4j_src} + DOCTITLE "Onnx Runtime Java API" + WINDOWTITLE "OnnxRuntime-Java-API" + AUTHOR FALSE + USE TRUE + VERSION FALSE + ) diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake index 47c5642d7453b..115776cffdff4 100644 --- a/cmake/onnxruntime_unittests.cmake +++ b/cmake/onnxruntime_unittests.cmake @@ -800,7 +800,6 @@ list(APPEND onnxruntime_mlas_test_libs Threads::Threads) target_link_libraries(onnxruntime_mlas_test PRIVATE ${onnxruntime_mlas_test_libs}) set_target_properties(onnxruntime_mlas_test PROPERTIES FOLDER "ONNXRuntimeTest") - add_library(custom_op_library SHARED ${REPO_ROOT}/onnxruntime/test/testdata/custom_op_library/custom_op_library.cc) target_include_directories(custom_op_library PRIVATE ${REPO_ROOT}/include) if(UNIX) @@ -814,3 +813,38 @@ else() # need to ignore the linker warning 4199, due to some global linker flags failing here endif() set_property(TARGET custom_op_library APPEND_STRING PROPERTY LINK_FLAGS ${ONNXRUNTIME_CUSTOM_OP_LIB_LINK_FLAG}) + +if (onnxruntime_BUILD_JAVA) + message(STATUS "Running Java tests") + # Build and run tests + set(onnxruntime4j_test_src + ${REPO_ROOT}/java/src/test/java/ai/onnxruntime/InferenceTest.java + ${REPO_ROOT}/java/src/test/java/ai/onnxruntime/TestHelpers.java + ${REPO_ROOT}/java/src/test/java/ai/onnxruntime/OnnxMl.java + ${REPO_ROOT}/java/src/test/java/ai/onnxruntime/UtilTest.java + ) + + # Create test directories + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/java-tests/") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/java-tests/results") + + # Download test dependencies + if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/java-tests/junit-platform-console-standalone-1.5.2.jar) + message("Downloading JUnit 5") + file(DOWNLOAD https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/1.5.2/junit-platform-console-standalone-1.5.2.jar ${CMAKE_CURRENT_BINARY_DIR}/java-tests/junit-platform-console-standalone-1.5.2.jar EXPECTED_HASH SHA1=8d937d2b461018a876836362b256629f4da5feb1) + endif() + + if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/java-tests/protobuf-java-3.10.0.jar) + message("Downloading protobuf-java 3.10.0") + file(DOWNLOAD https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/3.10.0/protobuf-java-3.10.0.jar ${CMAKE_CURRENT_BINARY_DIR}/java-tests/protobuf-java-3.10.0.jar EXPECTED_HASH SHA1=410b61dd0088aab4caa05739558d43df248958c9) + endif() + + # Build the test jar + add_jar(onnxruntime4j_test SOURCES ${onnxruntime4j_test_src} VERSION ${ORT_VERSION} INCLUDE_JARS ${onnxruntime_jar_name} ${CMAKE_CURRENT_BINARY_DIR}/java-tests/junit-platform-console-standalone-1.5.2.jar ${CMAKE_CURRENT_BINARY_DIR}/java-tests/protobuf-java-3.10.0.jar) + + add_dependencies(onnxruntime4j_test onnxruntime4j_jni onnxruntime4j) + get_property(onnxruntime_test_jar_name TARGET onnxruntime4j_test PROPERTY JAR_FILE) + + # Run the tests with JUnit's console launcher + add_test(NAME java-api COMMAND ${Java_JAVA_EXECUTABLE} -jar ${CMAKE_CURRENT_BINARY_DIR}/java-tests/junit-platform-console-standalone-1.5.2.jar -cp ${CMAKE_CURRENT_BINARY_DIR}/java-tests/protobuf-java-3.10.0.jar -cp ${onnxruntime_test_jar_name} -cp ${onnxruntime_jar_binaries_platform} --scan-class-path --fail-if-no-tests --reports-dir=${CMAKE_CURRENT_BINARY_DIR}/java-tests/results --disable-banner WORKING_DIRECTORY ${REPO_ROOT}) +endif() diff --git a/docs/Java_API.md b/docs/Java_API.md new file mode 100644 index 0000000000000..5d8db79ddc9a6 --- /dev/null +++ b/docs/Java_API.md @@ -0,0 +1,56 @@ +# ONNX Runtime Java API +The ONNX runtime provides a Java binding for running inference on ONNX models on a JVM, using Java 8 or newer. + +Two jar files are created during the build process, one contains the onnxruntime shared library, the JNI binding and the Java class files, and the other only contains the class files. By default the shared libraries are loaded from the classpath in a folder called `/lib`, if you wish to have them load from `java.library.path` then supply `-DORT_LOAD_FROM_LIBRARY_PATH` to the JVM at runtime. + +## Sample Code + +The unit tests contain several examples of loading models, inspecting input/output node shapes and types, as well as constructing tensors for scoring. + +* [../java/src/test/java/ai/onnxruntime/InferenceTest.java#L66](../java/src/test/java/ai/onnxruntime/InferenceTest.java#L66) + +## Getting Started +Here is simple tutorial for getting started with running inference on an existing ONNX model for a given input data. The model is typically trained using any of the well-known training frameworks and exported into the ONNX format. +Note the code presented below uses syntax available from Java 10 onwards. The Java 8 syntax is similar but more verbose. +To start a scoring session, first create the `OrtEnvironment`, then open a session using the `OrtSession` class, passing in the file path to the model as a parameter. + + var env = OrtEnvironment.getEnvironment(); + var session = env.createSession("model.onnx",new OrtSession.SessionOptions()); + +Once a session is created, you can execute queries using the `run` method of the `OrtSession` object. +At the moment we support `OnnxTensor` inputs, and models can produce `OnnxTensor`, `OnnxSequence` or `OnnxMap` outputs. The latter two are more likely when scoring models produced by frameworks like scikit-learn. +The run call expects a `Map` where the keys match input node names stored in the model. These can be viewed by calling `session.getInputNames()` or `session.getInputInfo()` on an instantiated session. +The run call produces a `Result` object, which contains a `Map` representing the output. The `Result` object is `AutoCloseable` and can be used in a try-with-resources statement to +prevent references from leaking out. Once the `Result` object is closed, all it's child `OnnxValue`s are closed too. + + OnnxTensor t1,t2; + var inputs = Map.of("name1",t1,"name2",t2); + try (var results = session.run(inputs)) { + // manipulate the results + } + +You can load your input data into OnnxTensor objects in several ways. The most efficient way is to use a `java.nio.Buffer`, but it's possible to use multidimensional arrays too. If constructed using arrays the arrays must not be ragged. + + FloatBuffer sourceData; // assume your data is loaded into a FloatBuffer + long[] dimensions; // and the dimensions of the input are stored here + var tensorFromBuffer = OnnxTensor.createTensor(env,sourceData,dimensions); + + float[][] sourceArray = new float[28][28]; // assume your data is loaded into a float array + var tensorFromArray = OnnxTensor.createTensor(env,sourceArray); + +Here is a [complete sample program](../java/sample/ScoreMNIST.java) that runs inference on a pretrained MNIST model. + +## Running on a GPU or with another provider (Optional) +To enable other execution providers like GPUs simply turn on the appropriate flag on SessionOptions when creating an OrtSession. + + int gpuDeviceId = 0; // The GPU device ID to execute on + var sessionOptions = new OrtSession.SessionOptions(); + sessionOptions.addCUDA(gpuDeviceId); + var session = environment.createSession("model.onnx", sessionOptions); + +The execution providers are preferred in the order they were enabled. + +## API Reference + +The Javadoc is available [here](https://microsoft.github.io/onnxruntime/java/index.html). + diff --git a/java/sample/ScoreMNIST.java b/java/sample/ScoreMNIST.java new file mode 100644 index 0000000000000..5158037133985 --- /dev/null +++ b/java/sample/ScoreMNIST.java @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +import ai.onnxruntime.NodeInfo; +import ai.onnxruntime.OnnxTensor; +import ai.onnxruntime.OnnxValue; +import ai.onnxruntime.OrtEnvironment; +import ai.onnxruntime.OrtException; +import ai.onnxruntime.OrtSession; +import ai.onnxruntime.OrtSession.Result; +import ai.onnxruntime.OrtSession.SessionOptions; +import ai.onnxruntime.OrtSession.SessionOptions.OptLevel; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Demo code, supporting both a pytorch CNN trained on MNIST and a scikit-learn model trained on MNIST. + */ +public class ScoreMNIST { + + private static final Logger logger = Logger.getLogger(ScoreMNIST.class.getName()); + + /** + * A named tuple for sparse classification data. + */ + private static class SparseData { + public final int[] labels; + public final List indices; + public final List values; + + public SparseData(int[] labels, List indices, List values) { + this.labels = labels; + this.indices = indices; + this.values = values; + } + } + + /** + * Deserialises the data and puts it in a named tuple. + * @param path The path to load the data from. + * @return A named tuple containing the data. + * @throws IOException If it failed to read the file. + * @throws ClassNotFoundException If a class wasn't found (only uses JDK types so this would be very odd). + */ + @SuppressWarnings("unchecked") + private static SparseData load(String path) throws IOException, ClassNotFoundException { + try (ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(path)))) { + int[] labels = (int[]) ois.readObject(); + List indices = (List) ois.readObject(); + List values = (List) ois.readObject(); + return new SparseData(labels,indices,values); + } + } + + /** + * Naively takes the softmax of the input. + * @param input The input array. + * @return The softmax of the input. + */ + public static float[] softmax(float[] input) { + double[] tmp = new double[input.length]; + double sum = 0.0; + for (int i = 0; i < input.length; i++) { + double val = Math.exp(input[i]); + sum += val; + tmp[i] = val; + } + + float[] output = new float[input.length]; + for (int i = 0; i < output.length; i++) { + output[i] = (float) (tmp[i]/sum); + } + + return output; + } + + /** + * Zeros the supplied array. + * @param data The array to zero. + */ + public static void zeroData(float[][][][] data) { + // Zero the array + for (int i = 0; i < data.length; i++) { + for (int j = 0; j < data[i].length; j++) { + for (int k = 0; k < data[i][j].length; k++) { + Arrays.fill(data[i][j][k],0.0f); + } + } + } + } + + /** + * Writes out sparse data into the last two dimensions of the supplied 4d array. + * @param data The 4d array to write to. + * @param indices The indices of the sparse data. + * @param values The values of the sparse data. + */ + public static void writeData(float[][][][] data, int[] indices, float[] values) { + zeroData(data); + + for (int m = 0; m < indices.length; m++) { + int i = (indices[m]) / 28; + int j = (indices[m]) % 28; + data[0][0][i][j] = values[m]/255; + } + + for (int i = 0; i < 28; i++) { + for (int j = 0; j < 28; j++) { + data[0][0][i][j] = (data[0][0][i][j] - 0.1307f) / 0.3081f; + } + } + } + + /** + * Zeros the array used by the scikit-learn model. + * @param data The array to zero. + */ + public static void zeroDataSKL(float[][] data) { + // Zero the array + for (int i = 0; i < data.length; i++) { + Arrays.fill(data[i],0.0f); + } + } + + /** + * Writes out sparse data to the last dimension of the supplied 2d array. + * @param data The 2d array to write to. + * @param indices The indices of the sparse data. + * @param values THe values of the sparse data. + */ + public static void writeDataSKL(float[][] data, int[] indices, float[] values) { + zeroDataSKL(data); + + for (int m = 0; m < indices.length; m++) { + data[0][indices[m]] = values[m]; + } + } + + /** + * Find the maximum probability and return it's index. + * @param probabilities The probabilites. + * @return The index of the max. + */ + public static int pred(float[] probabilities) { + float maxVal = Float.NEGATIVE_INFINITY; + int idx = 0; + for (int i = 0; i < probabilities.length; i++) { + if (probabilities[i] > maxVal) { + maxVal = probabilities[i]; + idx = i; + } + } + return idx; + } + + public static void main(String[] args) throws OrtException, IOException, ClassNotFoundException { + if (args.length < 2 || args.length > 3) { + System.out.println("Usage: ScoreMNIST "); + System.out.println("The test data input format is a Java serialized file containing an array of int labels, a list of int[] feature indices, and a list of float[] feature values"); + return; + } + + try (OrtEnvironment env = OrtEnvironment.getEnvironment(); + OrtSession.SessionOptions opts = new SessionOptions()) { + + opts.setOptimizationLevel(OptLevel.BASIC_OPT); + + logger.info("Loading model from " + args[0]); + try (OrtSession session = env.createSession(args[0], opts)) { + + logger.info("Inputs:"); + for (NodeInfo i : session.getInputInfo().values()) { + logger.info(i.toString()); + } + + logger.info("Outputs:"); + for (NodeInfo i : session.getOutputInfo().values()) { + logger.info(i.toString()); + } + + SparseData data = load(args[1]); + + float[][][][] testData = new float[1][1][28][28]; + float[][] testDataSKL = new float[1][780]; + + int correctCount = 0; + int[][] confusionMatrix = new int[10][10]; + + String inputName = session.getInputNames().iterator().next(); + + for (int i = 0; i < data.labels.length; i++) { + if (args.length==3) { + writeDataSKL(testDataSKL, data.indices.get(i), data.values.get(i)); + } else { + writeData(testData, data.indices.get(i), data.values.get(i)); + } + + try (OnnxTensor test = OnnxTensor.createTensor(env,args.length==3?testDataSKL:testData); + Result output = session.run(Collections.singletonMap(inputName,test))) { + + int predLabel; + + if (args.length==3) { + long[] labels = (long[]) output.get(0).getValue(); + predLabel = (int) labels[0]; + } else { + float[][] outputProbs = (float[][]) output.get(0).getValue(); + predLabel = pred(outputProbs[0]); + } + if (predLabel == data.labels[i]) { + correctCount++; + } + + confusionMatrix[data.labels[i]][predLabel]++; + + if (i % 500 == 0) { + logger.log(Level.INFO, "Cur accuracy = " + ((float)correctCount)/(i+1)); + logger.log(Level.INFO, "Output type = " + output.get(0).toString()); + if (args.length == 3) { + logger.log(Level.INFO, "Output type = " + output.get(1).toString()); + logger.log(Level.INFO, "Output value = " + output.get(1).getValue().toString()); + } + } + } + } + + logger.info("Final accuracy = " + ((float)correctCount)/data.labels.length); + + StringBuilder sb = new StringBuilder(); + sb.append("Label"); + for (int i = 0; i < confusionMatrix.length; i++) { + sb.append(String.format("%1$5s", ""+i)); + } + sb.append("\n"); + + for (int i = 0; i < confusionMatrix.length; i++) { + sb.append(String.format("%1$5s", ""+i)); + for (int j = 0; j < confusionMatrix[i].length; j++) { + sb.append(String.format("%1$5s", ""+confusionMatrix[i][j])); + } + sb.append("\n"); + } + + System.out.println(sb.toString()); + } + } + + logger.info("Done!"); + } +} diff --git a/java/src/main/java/ai/onnxruntime/MapInfo.java b/java/src/main/java/ai/onnxruntime/MapInfo.java new file mode 100644 index 0000000000000..41ade1711e4a7 --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/MapInfo.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +/** + * Describes an {@link OnnxMap} object or output node. + */ +public class MapInfo implements ValueInfo { + + /** + * The number of entries in this map. + */ + public final int size; + + /** + * The Java type of the keys. + */ + public final OnnxJavaType keyType; + + /** + * The Java type of the values. + */ + public final OnnxJavaType valueType; + + /** + * Construct a MapInfo with the specified key type and value type. + * The size is unknown and set to -1. + * @param keyType The Java type of the keys. + * @param valueType The Java type of the values. + */ + MapInfo(OnnxJavaType keyType, OnnxJavaType valueType) { + this.size = -1; + this.keyType = keyType; + this.valueType = valueType; + } + + /** + * Construct a MapInfo with the specified size, key type and value type. + * @param size The size. + * @param keyType The Java type of the keys. + * @param valueType The Java type of the values. + */ + MapInfo(int size, OnnxJavaType keyType, OnnxJavaType valueType) { + this.size = size; + this.keyType = keyType; + this.valueType = valueType; + } + + @Override + public String toString() { + String initial = size == -1 ? "MapInfo(size=UNKNOWN" : "MapInfo(size="+size; + return initial + ",keyType=" + keyType.toString() + ",valueType=" + valueType.toString() + ")"; + } +} diff --git a/java/src/main/java/ai/onnxruntime/NodeInfo.java b/java/src/main/java/ai/onnxruntime/NodeInfo.java new file mode 100644 index 0000000000000..6c1f18fe79cca --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/NodeInfo.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +/** + * The info for an input or output node from an ONNX model. + */ +public class NodeInfo { + + private final ValueInfo info; + + private final String name; + + /** + * Creates a node info object from the supplied name and value info. + * + * Called from native code. + * @param name The name of the node. + * @param info The ValueInfo for this node. + */ + public NodeInfo(String name, ValueInfo info) { + this.name = name; + this.info = info; + } + + /** + * The name of the node. + * @return The name. + */ + public String getName() { + return name; + } + + /** + * The type and shape information of this node. + *

+ * WARNING: {@link MapInfo} and {@link SequenceInfo} instances returned by this type will have insufficient information in + * them as it's not available from the model without an example output. + * @return The information of the value. + */ + public ValueInfo getInfo() { + return info; + } + + @Override + public String toString() { + return "NodeInfo(name="+name+",info="+info.toString()+")"; + } + +} diff --git a/java/src/main/java/ai/onnxruntime/OnnxJavaType.java b/java/src/main/java/ai/onnxruntime/OnnxJavaType.java new file mode 100644 index 0000000000000..fb9736d437240 --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OnnxJavaType.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import ai.onnxruntime.TensorInfo.OnnxTensorType; + +/** + * An enum representing onnxruntime supported Java primitive types (and String). + */ +public enum OnnxJavaType { + FLOAT(1, float.class, 4), + DOUBLE(2, double.class, 8), + INT8(3, byte.class, 1), + INT16(4, short.class, 2), + INT32(5, int.class, 4), + INT64(6, long.class, 8), + BOOL(7, boolean.class, 1), + STRING(8, String.class, 4), + UNKNOWN(0, Object.class, 0); + + private static final OnnxJavaType[] values = new OnnxJavaType[9]; + + static { + for (OnnxJavaType ot : OnnxJavaType.values()) { + values[ot.value] = ot; + } + } + + public final int value; + public final Class clazz; + public final int size; + + OnnxJavaType(int value, Class clazz, int size) { + this.value = value; + this.clazz = clazz; + this.size = size; + } + + /** + * Maps from an int in native land into an OnnxJavaType instance. + * @param value The value to lookup. + * @return The enum instance. + */ + public static OnnxJavaType mapFromInt(int value) { + if ((value > 0) && (value < values.length)) { + return values[value]; + } else { + return UNKNOWN; + } + } + + /** + * Maps from the {@link OnnxTensorType} enum to the corresponding OnnxJavaType + * enum, converting types as appropriate. + *

+ * Must match the values from OrtJniUtil.c. + * @param onnxValue The native value type. + * @return A OnnxJavaType instance representing the Java type + */ + public static OnnxJavaType mapFromOnnxTensorType(OnnxTensorType onnxValue) { + switch (onnxValue) { + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8: + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8: + return OnnxJavaType.INT8; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16: + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16: + return OnnxJavaType.INT16; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32: + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32: + return OnnxJavaType.INT32; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64: + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64: + return OnnxJavaType.INT64; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16: + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT: + return OnnxJavaType.FLOAT; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE: + return OnnxJavaType.DOUBLE; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING: + return OnnxJavaType.STRING; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL: + return OnnxJavaType.BOOL; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED: + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64: + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128: + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16: + default: + return OnnxJavaType.UNKNOWN; + } + } + + /** + * Maps from a Java class object into the enum type, returning {@link OnnxJavaType#UNKNOWN} + * for unsupported types. + * @param clazz The class to use. + * @return An OnnxJavaType instance. + */ + public static OnnxJavaType mapFromClass(Class clazz) { + if (clazz.equals(Byte.TYPE) || clazz.equals(Byte.class)) { + return OnnxJavaType.INT8; + } else if (clazz.equals(Short.TYPE) || clazz.equals(Short.class)) { + return OnnxJavaType.INT16; + } else if (clazz.equals(Integer.TYPE) || clazz.equals(Integer.class)) { + return OnnxJavaType.INT32; + } else if (clazz.equals(Long.TYPE) || clazz.equals(Long.class)) { + return OnnxJavaType.INT64; + } else if (clazz.equals(Float.TYPE) || clazz.equals(Float.class)) { + return OnnxJavaType.FLOAT; + } else if (clazz.equals(Double.TYPE) || clazz.equals(Double.class)) { + return OnnxJavaType.DOUBLE; + } else if (clazz.equals(Boolean.TYPE) || clazz.equals(Boolean.class)) { + return OnnxJavaType.BOOL; + } else if (clazz.equals(String.class)) { + return OnnxJavaType.STRING; + } else { + return OnnxJavaType.UNKNOWN; + } + } +} diff --git a/java/src/main/java/ai/onnxruntime/OnnxMap.java b/java/src/main/java/ai/onnxruntime/OnnxMap.java new file mode 100644 index 0000000000000..0e06a31a383cc --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OnnxMap.java @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * A container for a map returned by {@link OrtSession#run(Map)}. + *

+ * Supported types are those mentioned in "onnxruntime_c_api.h", + * keys: String and Long, values: String, Long, Float, Double. + */ +public class OnnxMap implements OnnxValue { + + static { + try { + OnnxRuntime.init(); + } catch (IOException e) { + throw new RuntimeException("Failed to load onnx-runtime library",e); + } + } + + /** + * An enum representing the Java type of the values stored in an {@link OnnxMap}. + */ + public enum OnnxMapValueType { + INVALID(0), STRING(1), LONG(2), FLOAT(3), DOUBLE(4); + final int value; + OnnxMapValueType(int value) { + this.value = value; + } + private static final OnnxMapValueType[] values = new OnnxMapValueType[5]; + static { + for (OnnxMapValueType ot : OnnxMapValueType.values()) { + values[ot.value] = ot; + } + } + + /** + * Gets the enum type from it's integer id. Used by native code. + * @param value The integer id. + * @return The enum instance. + */ + public static OnnxMapValueType mapFromInt(int value) { + if ((value > 0) && (value < values.length)) { + return values[value]; + } else { + return INVALID; + } + } + + /** + * Maps a {@link OnnxJavaType} into a map value type. If it's not a valid + * map type return {@link OnnxMapValueType#INVALID}. + * @param type The Java type. + * @return The equivalent Map value type. + */ + public static OnnxMapValueType mapFromOnnxJavaType(OnnxJavaType type) { + switch (type) { + case FLOAT: + return OnnxMapValueType.FLOAT; + case DOUBLE: + return OnnxMapValueType.DOUBLE; + case INT64: + return OnnxMapValueType.LONG; + case STRING: + return OnnxMapValueType.STRING; + case INT8: + case INT16: + case INT32: + case BOOL: + case UNKNOWN: + default: + return OnnxMapValueType.INVALID; + } + } + } + + final long nativeHandle; + + final long allocatorHandle; + + private final MapInfo info; + + private final boolean stringKeys; + + private final OnnxMapValueType valueType; + + /** + * Constructs an OnnxMap containing a reference to the native map + * along with the type information. + *

+ * Called from native code. + * @param nativeHandle The reference to the native map object. + * @param allocatorHandle The reference to the allocator that created the map. + * @param info The type information. + */ + OnnxMap(long nativeHandle, long allocatorHandle, MapInfo info) { + this.nativeHandle = nativeHandle; + this.allocatorHandle = allocatorHandle; + this.info = info; + this.stringKeys = info.keyType == OnnxJavaType.STRING; + this.valueType = OnnxMapValueType.mapFromOnnxJavaType(info.valueType); + } + + /** + * The number of entries in the map. + * @return The number of entries. + */ + public int size() { + return info.size; + } + + @Override + public OnnxValueType getType() { + return OnnxValueType.ONNX_TYPE_MAP; + } + + /** + * Returns a weakly typed Map containing all the elements. + * @return A map. + * @throws OrtException If the onnx runtime failed to read the entries. + */ + @Override + public Map getValue() throws OrtException { + HashMap map = new HashMap<>(); + Object[] keys = getMapKeys(); + Object[] values = getMapValues(); + for (int i = 0; i < keys.length; i++) { + map.put(keys[i],values[i]); + } + return map; + } + + /** + * Extracts the map keys, boxing the primitives as necessary. + * @return The keys from the map as an array. + * @throws OrtException If the onnxruntime failed to read the keys. + */ + private Object[] getMapKeys() throws OrtException { + if (stringKeys) { + return getStringKeys(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle); + } else { + return Arrays.stream(getLongKeys(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle)).boxed().toArray(); + } + } + + /** + * Extracts the map values, boxing primitives as necessary. + * @return The values from the map as an array. + * @throws OrtException If the onnxruntime failed to read the values. + */ + private Object[] getMapValues() throws OrtException { + switch (valueType) { + case STRING: { + return getStringValues(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle); + } + case LONG:{ + return Arrays.stream(getLongValues(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle)).boxed().toArray(); + } + case FLOAT:{ + float[] floats = getFloatValues(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle); + Float[] boxed = new Float[floats.length]; + for (int i = 0; i < floats.length; i++) { + // cast float to Float + boxed[i] = floats[i]; + } + return boxed; + } + case DOUBLE:{ + return Arrays.stream(getDoubleValues(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle)).boxed().toArray(); + } + default: + throw new RuntimeException("Invalid or unknown valueType: " + valueType); + } + } + + @Override + public MapInfo getInfo() { + return info; + } + + @Override + public String toString() { + return "ONNXMap(size="+size()+",info="+info.toString()+")"; + } + + /** + * Closes this map, releasing the native memory backing it and it's elements. + */ + @Override + public void close() { + close(OnnxRuntime.ortApiHandle,nativeHandle); + } + + private native String[] getStringKeys(long apiHandle,long nativeHandle,long allocatorHandle) throws OrtException; + private native long[] getLongKeys(long apiHandle,long nativeHandle,long allocatorHandle) throws OrtException; + + private native String[] getStringValues(long apiHandle,long nativeHandle,long allocatorHandle) throws OrtException; + private native long[] getLongValues(long apiHandle,long nativeHandle,long allocatorHandle) throws OrtException; + private native float[] getFloatValues(long apiHandle,long nativeHandle,long allocatorHandle) throws OrtException; + private native double[] getDoubleValues(long apiHandle,long nativeHandle,long allocatorHandle) throws OrtException; + + private native void close(long apiHandle,long nativeHandle); +} diff --git a/java/src/main/java/ai/onnxruntime/OnnxRuntime.java b/java/src/main/java/ai/onnxruntime/OnnxRuntime.java new file mode 100644 index 0000000000000..b1108717cea9f --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OnnxRuntime.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Static loader for the JNI binding. + */ +final class OnnxRuntime { + private static final Logger logger = Logger.getLogger(OnnxRuntime.class.getName()); + + // The initial release of the ORT API. + private static final int ORT_API_VERSION_1 = 1; + + /** + * Turns on debug logging during library loading. + */ + public static final String LIBRARY_LOAD_LOGGING = "ORT_LOAD_LOGGING"; + + /** + * Specifies that the libraries should be loaded from java.library.path rather than unzipped from the jar file. + */ + public static final String LOAD_LIBRARY_PATH = "ORT_LOAD_FROM_LIBRARY_PATH"; + + private static boolean loaded = false; + + /** + * The API handle. + */ + static long ortApiHandle; + + /** + * Library names stored in the jar. + */ + private static final List libraryNames = Arrays.asList("onnxruntime","onnxruntime4j_jni"); + + private OnnxRuntime() {} + + /** + * Loads the native C library. + * @throws IOException If it can't write to disk to copy out the library from the jar file. + */ + static synchronized void init() throws IOException { + if (!loaded) { + // Check system properties for load time configuration. + Properties props = System.getProperties(); + boolean debug = props.containsKey(LIBRARY_LOAD_LOGGING); + boolean loadLibraryPath = props.containsKey(LOAD_LIBRARY_PATH); + if (loadLibraryPath) { + if (debug) { + logger.info("Loading from java.library.path"); + } + try { + for (String libraryName : libraryNames) { + if (debug) { + logger.info("Loading " + libraryName + " from java.library.path"); + } + System.loadLibrary(libraryName); + } + } catch (UnsatisfiedLinkError e) { + logger.log(Level.SEVERE, "Failed to load onnx-runtime library from library path."); + throw e; + } + } else { + if (debug) { + logger.info("Loading from classpath resource"); + } + try { + for (String libraryName : libraryNames) { + try { + // This code path is used during testing. + String libraryFromJar = "/" + System.mapLibraryName(libraryName); + if (debug) { + logger.info("Attempting to load library from classpath using " + libraryFromJar); + } + String tempLibraryPath = createTempFileFromResource(libraryFromJar, debug); + if (debug) { + logger.info("Copied resource " + libraryFromJar + " to location " + tempLibraryPath); + } + System.load(tempLibraryPath); + } catch (Exception e) { + if (debug) { + logger.info("Failed to load from testing location, looking for /lib/"); + } + String libraryFromJar = "/lib/" + System.mapLibraryName(libraryName); + if (debug) { + logger.info("Attempting to load library from classpath using " + libraryFromJar); + } + String tempLibraryPath = createTempFileFromResource(libraryFromJar, debug); + if (debug) { + logger.info("Copied resource " + libraryFromJar + " to location " + tempLibraryPath); + } + System.load(tempLibraryPath); + } + } + } catch (IOException e) { + logger.log(Level.SEVERE, "Failed to load onnx-runtime library from jar"); + throw e; + } + } + ortApiHandle = initialiseAPIBase(ORT_API_VERSION_1); + loaded = true; + } + } + + /** + * Copies out the named file from the class path into a temporary directory so it can be loaded + * by {@link System#load}. + *

+ * The file is marked delete on exit. Throws {@link IllegalArgumentException} if the + * supplied path is not absolute. + * @param path The path to the file in the classpath. + * @param debugLogging If true turn on debug logging. + * @return The path to the extracted file on disk. + * @throws IOException If the file failed to read or write. + */ + private static String createTempFileFromResource(String path, boolean debugLogging) throws IOException { + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path has to be absolute (start with '/')."); + } else { + String[] parts = path.split("/"); + String filename = parts.length > 1 ? parts[parts.length - 1] : null; + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = parts.length > 1 ? "." + parts[parts.length - 1] : null; + } + + if (filename != null && prefix.length() >= 3) { + File temp = File.createTempFile(prefix, suffix); + if (debugLogging) { + logger.info("Writing " + path + " out to " + temp.getAbsolutePath()); + } + temp.deleteOnExit(); + if (!temp.exists()) { + throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist."); + } else { + byte[] buffer = new byte[1024]; + try (InputStream is = OnnxRuntime.class.getResourceAsStream(path)) { + if (is == null) { + throw new FileNotFoundException("File " + path + " was not found inside JAR."); + } else { + int readBytes; + try (FileOutputStream os = new FileOutputStream(temp)) { + while ((readBytes = is.read(buffer)) != -1) { + os.write(buffer, 0, readBytes); + } + } + return temp.getAbsolutePath(); + } + } + } + } else { + throw new IllegalArgumentException("The filename has to be at least 3 characters long."); + } + } + } + + /** + * Get a reference to the API struct. + * @param apiVersionNumber The API version to use. + * @return A pointer to the API struct. + */ + private static native long initialiseAPIBase(int apiVersionNumber); +} diff --git a/java/src/main/java/ai/onnxruntime/OnnxSequence.java b/java/src/main/java/ai/onnxruntime/OnnxSequence.java new file mode 100644 index 0000000000000..4bfc3afdd858e --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OnnxSequence.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +/** + * A sequence of {@link OnnxValue}s all of the same type. + * + * Supports the types mentioned in "onnxruntime_c_api.h", + * currently String, Long, Float, Double, Map>String,Float<, Map>Long,Float<. + */ +public class OnnxSequence implements OnnxValue { + + static { + try { + OnnxRuntime.init(); + } catch (IOException e) { + throw new RuntimeException("Failed to load onnx-runtime library",e); + } + } + + final long nativeHandle; + + private final long allocatorHandle; + + private final SequenceInfo info; + + /** + * Creates the wrapper object for a native sequence. + *

+ * Called from native code. + * @param nativeHandle The reference to the native sequence object. + * @param allocatorHandle The reference to the allocator. + * @param info The sequence type information. + */ + OnnxSequence(long nativeHandle, long allocatorHandle, SequenceInfo info) { + this.nativeHandle = nativeHandle; + this.allocatorHandle = allocatorHandle; + this.info = info; + } + + @Override + public OnnxValueType getType() { + return OnnxValueType.ONNX_TYPE_SEQUENCE; + } + + /** + * Extracts a Java object from the native ONNX type. + * + * Returns either a {@link List} of boxed primitives, {@link String}s, or {@link java.util.Map}s. + * @return A Java object containing the value. + * @throws OrtException If the runtime failed to read an element. + */ + @Override + public List getValue() throws OrtException { + if (info.sequenceOfMaps) { + List outputSequence = new ArrayList<>(); + for (int i = 0; i < info.length; i++) { + HashMap map = new HashMap<>(); + Object[] keys = getMapKeys(i); + Object[] values = getMapValues(i); + for (int j = 0; j < keys.length; j++) { + map.put(keys[j],values[j]); + } + outputSequence.add(map); + } + return outputSequence; + } else { + switch (info.sequenceType) { + case FLOAT: + float[] floats = getFloats(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle); + ArrayList boxed = new ArrayList<>(floats.length); + for (float aFloat : floats) { + // box float to Float + boxed.add(aFloat); + } + return boxed; + case DOUBLE: + return Arrays.stream(getDoubles(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle)).boxed().collect(Collectors.toList()); + case INT64: + return Arrays.stream(getLongs(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle)).boxed().collect(Collectors.toList()); + case STRING: + String[] strings = getStrings(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle); + ArrayList list = new ArrayList<>(strings.length); + list.addAll(Arrays.asList(strings)); + return list; + case BOOL: + case INT8: + case INT16: + case INT32: + case UNKNOWN: + default: + throw new OrtException("Unsupported type in a sequence, found " + info.sequenceType); + } + } + } + + @Override + public SequenceInfo getInfo() { + return info; + } + + @Override + public String toString() { + return "OnnxSequence(info="+info.toString()+")"; + } + + /** + * Closes this sequence, releasing the native memory backing it and it's elements. + */ + @Override + public void close() { + close(OnnxRuntime.ortApiHandle,nativeHandle); + } + + /** + * Extract the keys for the map at the specified index. + * @param index The index to extract. + * @return The map keys as an array. + * @throws OrtException If the native code failed to read the keys. + */ + private Object[] getMapKeys(int index) throws OrtException { + if (info.mapInfo.keyType == OnnxJavaType.STRING) { + return getStringKeys(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle,index); + } else { + return Arrays.stream(getLongKeys(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle,index)).boxed().toArray(); + } + } + + /** + * Extract the values for the map at the specified index. + * @param index The index to extract. + * @return The map values as an array. + * @throws OrtException If the native code failed to read the values. + */ + private Object[] getMapValues(int index) throws OrtException { + switch (info.mapInfo.valueType) { + case STRING: { + return getStringValues(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle,index); + } + case INT64:{ + return Arrays.stream(getLongValues(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle,index)).boxed().toArray(); + } + case FLOAT:{ + float[] floats = getFloatValues(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle,index); + Float[] boxed = new Float[floats.length]; + for (int i = 0; i < floats.length; i++) { + // cast float to Float + boxed[i] = floats[i]; + } + return boxed; + } + case DOUBLE:{ + return Arrays.stream(getDoubleValues(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle,index)).boxed().toArray(); + } + default: + throw new RuntimeException("Invalid or unknown valueType: " + info.mapInfo.valueType); + } + } + + + private native String[] getStringKeys(long apiHandle, long nativeHandle,long allocatorHandle, int index) throws OrtException; + private native long[] getLongKeys(long apiHandle, long nativeHandle,long allocatorHandle, int index) throws OrtException; + + private native String[] getStringValues(long apiHandle, long nativeHandle,long allocatorHandle, int index) throws OrtException; + private native long[] getLongValues(long apiHandle, long nativeHandle,long allocatorHandle, int index) throws OrtException; + private native float[] getFloatValues(long apiHandle, long nativeHandle,long allocatorHandle, int index) throws OrtException; + private native double[] getDoubleValues(long apiHandle, long nativeHandle,long allocatorHandle, int index) throws OrtException; + + private native String[] getStrings(long apiHandle, long nativeHandle,long allocatorHandle) throws OrtException; + private native long[] getLongs(long apiHandle, long nativeHandle,long allocatorHandle) throws OrtException; + private native float[] getFloats(long apiHandle, long nativeHandle,long allocatorHandle) throws OrtException; + private native double[] getDoubles(long apiHandle, long nativeHandle,long allocatorHandle) throws OrtException; + + private native void close(long apiHandle, long nativeHandle); +} diff --git a/java/src/main/java/ai/onnxruntime/OnnxTensor.java b/java/src/main/java/ai/onnxruntime/OnnxTensor.java new file mode 100644 index 0000000000000..252871a2d82df --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OnnxTensor.java @@ -0,0 +1,668 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.io.IOException; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; +import java.nio.ShortBuffer; + +/** + * A Java object wrapping an OnnxTensor. Tensors are the main input to the library, + * and can also be returned as outputs. + */ +public class OnnxTensor implements OnnxValue { + + static { + try { + OnnxRuntime.init(); + } catch (IOException e) { + throw new RuntimeException("Failed to load onnx-runtime library",e); + } + } + + private final long nativeHandle; + + private final long allocatorHandle; + + private final TensorInfo info; + + /** + * This reference is held for OnnxTensors backed by a Java nio buffer to ensure + * the buffer does not go out of scope while the OnnxTensor exists. + */ + private final Buffer buffer; + + OnnxTensor(long nativeHandle, long allocatorHandle, TensorInfo info) { + this(nativeHandle,allocatorHandle,info,null); + } + + OnnxTensor(long nativeHandle, long allocatorHandle, TensorInfo info, Buffer buffer) { + this.nativeHandle = nativeHandle; + this.allocatorHandle = allocatorHandle; + this.info = info; + this.buffer = buffer; + } + + @Override + public OnnxValueType getType() { + return OnnxValueType.ONNX_TYPE_TENSOR; + } + + long getNativeHandle() { + return nativeHandle; + } + + /** + * Either returns a boxed primitive if the Tensor is a scalar, or a multidimensional array of + * primitives if it has multiple dimensions. + *

+ * Java multidimensional arrays are quite slow for more than 2 dimensions, in that + * case it is recommended you use the java.nio.Buffer extractors below (e.g. {@link #getFloatBuffer}). + * @return A Java value. + * @throws OrtException If the value could not be extracted as the Tensor is invalid, or if the native code encountered an error. + */ + @Override + public Object getValue() throws OrtException { + if (info.isScalar()) { + switch (info.type) { + case FLOAT: + return getFloat(OnnxRuntime.ortApiHandle,nativeHandle,info.onnxType.value); + case DOUBLE: + return getDouble(OnnxRuntime.ortApiHandle,nativeHandle); + case INT8: + return getByte(OnnxRuntime.ortApiHandle,nativeHandle,info.onnxType.value); + case INT16: + return getShort(OnnxRuntime.ortApiHandle,nativeHandle,info.onnxType.value); + case INT32: + return getInt(OnnxRuntime.ortApiHandle,nativeHandle,info.onnxType.value); + case INT64: + return getLong(OnnxRuntime.ortApiHandle,nativeHandle,info.onnxType.value); + case BOOL: + return getBool(OnnxRuntime.ortApiHandle,nativeHandle); + case STRING: + return getString(OnnxRuntime.ortApiHandle,nativeHandle,allocatorHandle); + case UNKNOWN: + default: + throw new OrtException("Extracting the value of an invalid Tensor."); + } + } else { + Object carrier = info.makeCarrier(); + getArray(OnnxRuntime.ortApiHandle,nativeHandle, allocatorHandle, carrier); + return carrier; + } + } + + @Override + public TensorInfo getInfo() { + return info; + } + + @Override + public String toString() { + return "OnnxTensor(info="+info.toString()+")"; + } + + /** + * Closes the tensor, releasing it's underlying memory (if it's not backed by an NIO buffer). + * If it is backed by a buffer then the memory is released when the buffer is GC'd. + */ + @Override + public void close() { + close(OnnxRuntime.ortApiHandle,nativeHandle); + } + + /** + * Returns a copy of the underlying OnnxTensor as a ByteBuffer. + *

+ * This method returns null if the OnnxTensor contains Strings as they are stored externally to the OnnxTensor. + * @return A ByteBuffer copy of the OnnxTensor. + */ + public ByteBuffer getByteBuffer() { + if (info.type != OnnxJavaType.STRING) { + ByteBuffer buffer = getBuffer(OnnxRuntime.ortApiHandle,nativeHandle); + ByteBuffer output = ByteBuffer.allocate(buffer.capacity()); + output.put(buffer); + output.rewind(); + return output; + } else { + return null; + } + } + + /** + * Returns a copy of the underlying OnnxTensor as a FloatBuffer + * if it can be losslessly converted into a float (i.e. it's a float or fp16), otherwise it + * returns null. + * @return A FloatBuffer copy of the OnnxTensor. + */ + public FloatBuffer getFloatBuffer() { + if (info.type == OnnxJavaType.FLOAT) { + if (info.onnxType == TensorInfo.OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16) { + // if it's fp16 we need to copy it out by hand. + ShortBuffer buffer = getBuffer().asShortBuffer(); + int bufferCap = buffer.capacity(); + FloatBuffer output = FloatBuffer.allocate(bufferCap); + for (int i = 0; i < bufferCap; i++) { + output.put(fp16ToFloat(buffer.get(i))); + } + output.rewind(); + return output; + } else { + // if it's fp32 use the efficient copy. + FloatBuffer buffer = getBuffer().asFloatBuffer(); + FloatBuffer output = FloatBuffer.allocate(buffer.capacity()); + output.put(buffer); + output.rewind(); + return output; + } + } else { + return null; + } + } + + /** + * Returns a copy of the underlying OnnxTensor as a DoubleBuffer if the underlying type is + * a double, otherwise it returns null. + * @return A DoubleBuffer copy of the OnnxTensor. + */ + public DoubleBuffer getDoubleBuffer() { + if (info.type == OnnxJavaType.DOUBLE) { + DoubleBuffer buffer = getBuffer().asDoubleBuffer(); + DoubleBuffer output = DoubleBuffer.allocate(buffer.capacity()); + output.put(buffer); + output.rewind(); + return output; + } else { + return null; + } + } + + /** + * Returns a copy of the underlying OnnxTensor as a ShortBuffer if the + * underlying type is int16 or uint16, otherwise it returns null. + * @return A ShortBuffer copy of the OnnxTensor. + */ + public ShortBuffer getShortBuffer() { + if (info.type == OnnxJavaType.INT16) { + ShortBuffer buffer = getBuffer().asShortBuffer(); + ShortBuffer output = ShortBuffer.allocate(buffer.capacity()); + output.put(buffer); + output.rewind(); + return output; + } else { + return null; + } + } + + /** + * Returns a copy of the underlying OnnxTensor as an IntBuffer if + * the underlying type is int32 or uint32, otherwise it returns null. + * @return An IntBuffer copy of the OnnxTensor. + */ + public IntBuffer getIntBuffer() { + if (info.type == OnnxJavaType.INT32) { + IntBuffer buffer = getBuffer().asIntBuffer(); + IntBuffer output = IntBuffer.allocate(buffer.capacity()); + output.put(buffer); + output.rewind(); + return output; + } else { + return null; + } + } + + /** + * Returns a copy of the underlying OnnxTensor as a LongBuffer + * if the underlying type is int64 or uint64, otherwise it returns null. + * @return A LongBuffer copy of the OnnxTensor. + */ + public LongBuffer getLongBuffer() { + if (info.type == OnnxJavaType.INT64) { + LongBuffer buffer = getBuffer().asLongBuffer(); + LongBuffer output = LongBuffer.allocate(buffer.capacity()); + output.put(buffer); + output.rewind(); + return output; + } else { + return null; + } + } + + /** + * Wraps the OrtTensor pointer in a direct byte buffer of the native platform endian-ness. + * Unless you really know what you're doing, you want this one rather than the native call {@link OnnxTensor#getBuffer(long,long)}. + * @return A ByteBuffer wrapping the data. + */ + private ByteBuffer getBuffer() { + return getBuffer(OnnxRuntime.ortApiHandle,nativeHandle).order(ByteOrder.nativeOrder()); + } + + /** + * Wraps the OrtTensor pointer in a direct byte buffer. + * @param apiHandle The OrtApi pointer. + * @param nativeHandle The OrtTensor pointer. + * @return A ByteBuffer wrapping the data. + */ + private native ByteBuffer getBuffer(long apiHandle, long nativeHandle); + + private native float getFloat(long apiHandle, long nativeHandle, int onnxType) throws OrtException; + private native double getDouble(long apiHandle, long nativeHandle) throws OrtException; + private native byte getByte(long apiHandle, long nativeHandle, int onnxType) throws OrtException; + private native short getShort(long apiHandle, long nativeHandle, int onnxType) throws OrtException; + private native int getInt(long apiHandle, long nativeHandle, int onnxType) throws OrtException; + private native long getLong(long apiHandle, long nativeHandle, int onnxType) throws OrtException; + private native String getString(long apiHandle, long nativeHandle, long allocatorHandle) throws OrtException; + private native boolean getBool(long apiHandle, long nativeHandle) throws OrtException; + + private native void getArray(long apiHandle, long nativeHandle, long allocatorHandle, Object carrier) throws OrtException; + + private native void close(long apiHandle, long nativeHandle); + + /** + * Mirrors the conversion in the C code. It's not precise if there are subnormal values, + * nor does it preserve all the different kinds of NaNs (which aren't representable in Java anyway). + * @param input A uint16_t representing an IEEE half precision float. + * @return A float. + */ + private static float fp16ToFloat(short input) { + int output = ((input&0x8000)<<16) | (((input&0x7c00)+0x1C000)<<13) | ((input&0x03FF)<<13); + return Float.intBitsToFloat(output); + } + + /** + * Create a Tensor from a Java primitive or String multidimensional array. + * The shape is inferred from the array using reflection. + * The default allocator is used. + * @param env The current OrtEnvironment. + * @param data The data to store in a tensor. + * @return An OnnxTensor storing the data. + * @throws OrtException If the onnx runtime threw an error. + */ + public static OnnxTensor createTensor(OrtEnvironment env, Object data) throws OrtException { + return createTensor(env,env.defaultAllocator,data); + } + + /** + * Create a Tensor from a Java primitive or String multidimensional array. + * The shape is inferred from the array using reflection. + * @param env The current OrtEnvironment. + * @param allocator The allocator to use. + * @param data The data to store in a tensor. + * @return An OnnxTensor storing the data. + * @throws OrtException If the onnx runtime threw an error. + */ + static OnnxTensor createTensor(OrtEnvironment env, OrtAllocator allocator, Object data) throws OrtException { + if ((!env.isClosed()) && (!allocator.isClosed())) { + TensorInfo info = TensorInfo.constructFromJavaArray(data); + if (info.type == OnnxJavaType.STRING) { + if (info.shape.length == 0) { + return new OnnxTensor(createString(OnnxRuntime.ortApiHandle, allocator.handle,(String)data), allocator.handle, info); + } else { + return new OnnxTensor(createStringTensor(OnnxRuntime.ortApiHandle, allocator.handle, OrtUtil.flattenString(data), info.shape), allocator.handle, info); + } + } else { + if (info.shape.length == 0) { + data = OrtUtil.convertBoxedPrimitiveToArray(data); + } + return new OnnxTensor(createTensor(OnnxRuntime.ortApiHandle, allocator.handle, data, info.shape, info.onnxType.value), allocator.handle, info); + } + } else { + throw new IllegalStateException("Trying to create an OnnxTensor with a closed OrtAllocator."); + } + } + + /** + * Create a tensor from a flattened string array. + *

+ * Requires the array to be flattened in row-major order. Uses the default allocator. + * @param env The current OrtEnvironment. + * @param data The tensor data + * @param shape the shape of the tensor + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + public static OnnxTensor createTensor(OrtEnvironment env, String[] data, long[] shape) throws OrtException { + return createTensor(env,env.defaultAllocator,data,shape); + } + + /** + * Create a tensor from a flattened string array. + *

+ * Requires the array to be flattened in row-major order. + * @param env The current OrtEnvironment. + * @param allocator The allocator to use. + * @param data The tensor data + * @param shape the shape of the tensor + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + static OnnxTensor createTensor(OrtEnvironment env, OrtAllocator allocator, String[] data, long[] shape) throws OrtException { + if ((!env.isClosed()) && (!allocator.isClosed())) { + TensorInfo info = new TensorInfo(shape, OnnxJavaType.STRING, TensorInfo.OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING); + return new OnnxTensor(createStringTensor(OnnxRuntime.ortApiHandle, allocator.handle, data, shape), allocator.handle, info); + } else { + throw new IllegalStateException("Trying to create an OnnxTensor on a closed OrtAllocator."); + } + } + + /** + * Create an OnnxTensor backed by a direct FloatBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Uses the default allocator. + * @param env The current OrtEnvironment. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + public static OnnxTensor createTensor(OrtEnvironment env, FloatBuffer data, long[] shape) throws OrtException { + return createTensor(env,env.defaultAllocator,data,shape); + } + + /** + * Create an OnnxTensor backed by a direct FloatBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. + * @param env The current OrtEnvironment. + * @param allocator The allocator to use. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + static OnnxTensor createTensor(OrtEnvironment env, OrtAllocator allocator, FloatBuffer data, long[] shape) throws OrtException { + if ((!env.isClosed()) && (!allocator.isClosed())) { + OnnxJavaType type = OnnxJavaType.FLOAT; + int bufferSize = data.capacity()*type.size; + FloatBuffer tmp; + if (data.isDirect()) { + tmp = data; + } else { + ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize).order(ByteOrder.nativeOrder()); + tmp = buffer.asFloatBuffer(); + tmp.put(data); + } + TensorInfo info = TensorInfo.constructFromBuffer(tmp, shape, type); + return new OnnxTensor(createTensorFromBuffer(OnnxRuntime.ortApiHandle, allocator.handle, tmp, bufferSize, shape, info.onnxType.value), allocator.handle, info, tmp); + } else { + throw new IllegalStateException("Trying to create an OnnxTensor on a closed OrtAllocator."); + } + } + + /** + * Create an OnnxTensor backed by a direct DoubleBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Uses the default allocator. + * @param env The current OrtEnvironment. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + public static OnnxTensor createTensor(OrtEnvironment env, DoubleBuffer data, long[] shape) throws OrtException { + return createTensor(env,env.defaultAllocator,data,shape); + } + + /** + * Create an OnnxTensor backed by a direct DoubleBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. + * @param env The current OrtEnvironment. + * @param allocator The allocator to use. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + static OnnxTensor createTensor(OrtEnvironment env, OrtAllocator allocator, DoubleBuffer data, long[] shape) throws OrtException { + if ((!env.isClosed()) && (!allocator.isClosed())) { + OnnxJavaType type = OnnxJavaType.DOUBLE; + int bufferSize = data.capacity()*type.size; + DoubleBuffer tmp; + if (data.isDirect()) { + tmp = data; + } else { + ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize).order(ByteOrder.nativeOrder()); + tmp = buffer.asDoubleBuffer(); + tmp.put(data); + } + TensorInfo info = TensorInfo.constructFromBuffer(tmp, shape, type); + return new OnnxTensor(createTensorFromBuffer(OnnxRuntime.ortApiHandle, allocator.handle, tmp, bufferSize, shape, info.onnxType.value), allocator.handle, info, tmp); + } else { + throw new IllegalStateException("Trying to create an OnnxTensor on a closed OrtAllocator."); + } + } + + /** + * Create an OnnxTensor backed by a direct ByteBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Uses the default allocator. Tells the runtime it's {@link OnnxJavaType#INT8}. + * @param env The current OrtEnvironment. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + public static OnnxTensor createTensor(OrtEnvironment env, ByteBuffer data, long[] shape) throws OrtException { + return createTensor(env,env.defaultAllocator,data,shape); + } + + /** + * Create an OnnxTensor backed by a direct ByteBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Tells the runtime it's {@link OnnxJavaType#INT8}. + * @param env The current OrtEnvironment. + * @param allocator The allocator to use. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + static OnnxTensor createTensor(OrtEnvironment env, OrtAllocator allocator, ByteBuffer data, long[] shape) throws OrtException { + return createTensor(env,allocator,data,shape,OnnxJavaType.INT8); + } + + /** + * Create an OnnxTensor backed by a direct ByteBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Uses the default allocator. Tells the runtime it's the specified type. + * @param env The current OrtEnvironment. + * @param data The tensor data. + * @param shape The shape of tensor. + * @param type The type to use for the byte buffer elements. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + public static OnnxTensor createTensor(OrtEnvironment env, ByteBuffer data, long[] shape, OnnxJavaType type) throws OrtException { + return createTensor(env,env.defaultAllocator,data,shape,type); + } + + /** + * Create an OnnxTensor backed by a direct ByteBuffer. The buffer should be in nativeOrder. + * + * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Tells the runtime it's the specified type. + * @param env The current OrtEnvironment. + * @param allocator The allocator to use. + * @param data The tensor data. + * @param shape The shape of tensor. + * @param type The type to use for the byte buffer elements. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + static OnnxTensor createTensor(OrtEnvironment env, OrtAllocator allocator, ByteBuffer data, long[] shape, OnnxJavaType type) throws OrtException { + if ((!env.isClosed()) && (!allocator.isClosed())) { + int bufferSize = data.capacity(); + ByteBuffer tmp; + if (data.isDirect()) { + tmp = data; + } else { + tmp = ByteBuffer.allocateDirect(bufferSize).order(ByteOrder.nativeOrder()); + tmp.put(data); + } + TensorInfo info = TensorInfo.constructFromBuffer(tmp, shape, type); + return new OnnxTensor(createTensorFromBuffer(OnnxRuntime.ortApiHandle, allocator.handle, tmp, bufferSize, shape, info.onnxType.value), allocator.handle, info, tmp); + } else { + throw new IllegalStateException("Trying to create an OnnxTensor on a closed OrtAllocator."); + } + } + + /** + * Create an OnnxTensor backed by a direct ShortBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Uses the default allocator. + * @param env The current OrtEnvironment. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + public static OnnxTensor createTensor(OrtEnvironment env, ShortBuffer data, long[] shape) throws OrtException { + return createTensor(env,env.defaultAllocator,data,shape); + } + + /** + * Create an OnnxTensor backed by a direct ShortBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. + * @param env The current OrtEnvironment. + * @param allocator The allocator to use. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + static OnnxTensor createTensor(OrtEnvironment env, OrtAllocator allocator, ShortBuffer data, long[] shape) throws OrtException { + if ((!env.isClosed()) && (!allocator.isClosed())) { + OnnxJavaType type = OnnxJavaType.INT16; + int bufferSize = data.capacity()*type.size; + ShortBuffer tmp; + if (data.isDirect()) { + tmp = data; + } else { + ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize).order(ByteOrder.nativeOrder()); + tmp = buffer.asShortBuffer(); + tmp.put(data); + } + TensorInfo info = TensorInfo.constructFromBuffer(tmp, shape, type); + return new OnnxTensor(createTensorFromBuffer(OnnxRuntime.ortApiHandle, allocator.handle, tmp, bufferSize, shape, info.onnxType.value), allocator.handle, info, tmp); + } else { + throw new IllegalStateException("Trying to create an OnnxTensor on a closed OrtAllocator."); + } + } + + /** + * Create an OnnxTensor backed by a direct IntBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Uses the default allocator. + * @param env The current OrtEnvironment. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + public static OnnxTensor createTensor(OrtEnvironment env, IntBuffer data, long[] shape) throws OrtException { + return createTensor(env,env.defaultAllocator,data,shape); + } + + /** + * Create an OnnxTensor backed by a direct IntBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. + * @param env The current OrtEnvironment. + * @param allocator The allocator to use. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + static OnnxTensor createTensor(OrtEnvironment env, OrtAllocator allocator, IntBuffer data, long[] shape) throws OrtException { + if ((!env.isClosed()) && (!allocator.isClosed())) { + OnnxJavaType type = OnnxJavaType.INT32; + int bufferSize = data.capacity()*type.size; + IntBuffer tmp; + if (data.isDirect()) { + tmp = data; + } else { + ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize).order(ByteOrder.nativeOrder()); + tmp = buffer.asIntBuffer(); + tmp.put(data); + } + TensorInfo info = TensorInfo.constructFromBuffer(tmp, shape, type); + return new OnnxTensor(createTensorFromBuffer(OnnxRuntime.ortApiHandle, allocator.handle, tmp, bufferSize, shape, info.onnxType.value), allocator.handle, info, tmp); + } else { + throw new IllegalStateException("Trying to create an OnnxTensor on a closed OrtAllocator."); + } + } + + /** + * Create an OnnxTensor backed by a direct LongBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Uses the default allocator. + * @param env The current OrtEnvironment. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + public static OnnxTensor createTensor(OrtEnvironment env, LongBuffer data, long[] shape) throws OrtException { + return createTensor(env,env.defaultAllocator,data,shape); + } + + /** + * Create an OnnxTensor backed by a direct LongBuffer. The buffer should be in nativeOrder. + *

+ * If the supplied buffer is not a direct buffer, a direct copy is created tied to the lifetime + * of the tensor. Uses the supplied allocator. + * @param env The current OrtEnvironment. + * @param allocator The allocator to use. + * @param data The tensor data. + * @param shape The shape of tensor. + * @return An OnnxTensor of the required shape. + * @throws OrtException Thrown if there is an onnx error or if the data and shape don't match. + */ + static OnnxTensor createTensor(OrtEnvironment env, OrtAllocator allocator, LongBuffer data, long[] shape) throws OrtException { + if ((!env.isClosed()) && (!allocator.isClosed())) { + OnnxJavaType type = OnnxJavaType.INT64; + int bufferSize = data.capacity()*type.size; + LongBuffer tmp; + if (data.isDirect()) { + tmp = data; + } else { + ByteBuffer buffer = ByteBuffer.allocateDirect(bufferSize).order(ByteOrder.nativeOrder()); + tmp = buffer.asLongBuffer(); + tmp.put(data); + } + TensorInfo info = TensorInfo.constructFromBuffer(tmp, shape, type); + return new OnnxTensor(createTensorFromBuffer(OnnxRuntime.ortApiHandle, allocator.handle, tmp, bufferSize, shape, info.onnxType.value), allocator.handle, info, tmp); + } else { + throw new IllegalStateException("Trying to create an OnnxTensor on a closed OrtAllocator."); + } + } + + private static native long createTensor(long apiHandle, long allocatorHandle, Object data, long[] shape, int onnxType) throws OrtException; + private static native long createTensorFromBuffer(long apiHandle, long allocatorHandle, Buffer data, long bufferSize, long[] shape, int onnxType) throws OrtException; + + private static native long createString(long apiHandle, long allocatorHandle, String data) throws OrtException; + private static native long createStringTensor(long apiHandle, long allocatorHandle, Object[] data, long[] shape) throws OrtException; +} diff --git a/java/src/main/java/ai/onnxruntime/OnnxValue.java b/java/src/main/java/ai/onnxruntime/OnnxValue.java new file mode 100644 index 0000000000000..761a8d8726911 --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OnnxValue.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.util.Map; + +/** + * Top interface for input and output values from ONNX models. + * Currently implemented by {@link OnnxTensor}, {@link OnnxSequence} and {@link OnnxMap}. Will be sealed to + * these types one day. + * + * Does not support sparse tensors. + */ +public interface OnnxValue extends AutoCloseable { + + /** + * The type of the {@link OnnxValue}, mirroring the id in the C API. + */ + public enum OnnxValueType { + ONNX_TYPE_UNKNOWN(0), + ONNX_TYPE_TENSOR(1), + ONNX_TYPE_SEQUENCE(2), + ONNX_TYPE_MAP(3), + ONNX_TYPE_OPAQUE(4), + ONNX_TYPE_SPARSETENSOR(5); + + /** + * The id number of this type in the C API. + */ + public final int value; + OnnxValueType(int value) { + this.value = value; + } + } + + /** + * Gets the type of this OnnxValue. + * @return The value type. + */ + public OnnxValueType getType(); + + /** + * Returns the value as a Java object copying it out of the native heap. + * This operation can be quite slow for high dimensional tensors, where + * you should prefer {@link OnnxTensor#getByteBuffer()} etc. + *

+ * Overridden by the subclasses with a more specific type if available. + * @return The value. + * @throws OrtException If an error occurred reading the value. + */ + public Object getValue() throws OrtException; + + /** + * Gets the type info object associated with this OnnxValue. + * @return The type information. + */ + public ValueInfo getInfo(); + + /** + * Closes the OnnxValue, freeing it's native memory. + */ + @Override + public void close(); + + /** + * Calls close on each element of the iterable. + * @param itr An iterable of closeable OnnxValues. + */ + public static void close(Iterable itr) { + for (OnnxValue t : itr) { + t.close(); + } + } + + /** + * Calls close on each {@link OnnxValue} in the map. + * @param map A map of {@link OnnxValue}s. + */ + public static void close(Map map) { + for (OnnxValue t : map.values()) { + t.close(); + } + } + +} diff --git a/java/src/main/java/ai/onnxruntime/OrtAllocator.java b/java/src/main/java/ai/onnxruntime/OrtAllocator.java new file mode 100644 index 0000000000000..9729b8cebf50b --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OrtAllocator.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.io.IOException; + +/** + * An ONNX Runtime memory allocator. + */ +class OrtAllocator implements AutoCloseable { + + static { + try { + OnnxRuntime.init(); + } catch (IOException e) { + throw new RuntimeException("Failed to load onnx-runtime library",e); + } + } + + final long handle; + + private final boolean isDefault; + + private boolean closed = false; + + /** + * Constructs an OrtAllocator wrapped around a native reference. + * @param handle The reference to a native OrtAllocator. + * @param isDefault Is this the default allocator. + */ + OrtAllocator(long handle, boolean isDefault) { + this.handle = handle; + this.isDefault = isDefault; + } + + /** + * Is this allocator closed? + * @return True if the allocator is closed. + */ + public boolean isClosed() { + return closed; + } + + /** + * Is this the default allocator? + * @return True if it is the default allocator. + */ + public boolean isDefault() { + return isDefault; + } + + /** + * Closes the allocator, must be done after all it's child objects have been closed. + *

+ * The default allocator is not closeable, and this operation is a no-op on that allocator. + * @throws OrtException If it failed to close. + */ + @Override + public void close() throws OrtException { + if (!closed) { + if (!isDefault) { + // Can only close custom allocators. + closeAllocator(OnnxRuntime.ortApiHandle, handle); + closed = true; + } + } else { + throw new IllegalStateException("Trying to close an already closed OrtAllocator."); + } + } + + // The default allocator cannot be closed, this is guarded in the close method above. + private native void closeAllocator(long apiHandle, long nativeHandle) throws OrtException; +} \ No newline at end of file diff --git a/java/src/main/java/ai/onnxruntime/OrtEnvironment.java b/java/src/main/java/ai/onnxruntime/OrtEnvironment.java new file mode 100644 index 0000000000000..f8da2c29fd25f --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OrtEnvironment.java @@ -0,0 +1,299 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import ai.onnxruntime.OrtSession.SessionOptions; +import ai.onnxruntime.TensorInfo.OnnxTensorType; + +import java.io.IOException; +import java.lang.reflect.Array; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; +import java.nio.ShortBuffer; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Logger; + +/** + * The host object for the onnx-runtime system. Can create {@link OrtSession}s + * which encapsulate specific models. + */ +public class OrtEnvironment implements AutoCloseable { + + /** + * The logging level for messages from the environment and session. + */ + public enum LoggingLevel { + ORT_LOGGING_LEVEL_VERBOSE(0), + ORT_LOGGING_LEVEL_INFO(1), + ORT_LOGGING_LEVEL_WARNING(2), + ORT_LOGGING_LEVEL_ERROR(3), + ORT_LOGGING_LEVEL_FATAL(4); + private final int value; + + LoggingLevel(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + private static final Logger logger = Logger.getLogger(OrtEnvironment.class.getName()); + + public static final String DEFAULT_NAME = "ort-java"; + + static { + try { + OnnxRuntime.init(); + } catch (IOException e) { + throw new RuntimeException("Failed to load onnx-runtime library",e); + } + } + + private static volatile OrtEnvironment INSTANCE; + + private static final AtomicInteger refCount = new AtomicInteger(); + + private static volatile LoggingLevel curLogLevel; + + private static volatile String curLoggingName; + + /** + * Gets the OrtEnvironment. If there is not an environment currently created, it creates one + * using {@link OrtEnvironment#DEFAULT_NAME} and {@link LoggingLevel#ORT_LOGGING_LEVEL_WARNING}. + * @return An onnxruntime environment. + */ + public static OrtEnvironment getEnvironment() { + return getEnvironment(LoggingLevel.ORT_LOGGING_LEVEL_WARNING,DEFAULT_NAME); + } + + /** + * Gets the OrtEnvironment. If there is not an environment currently created, it creates one + * using the supplied name and {@link LoggingLevel#ORT_LOGGING_LEVEL_WARNING}. + * @param name The logging id of the environment. + * @return An onnxruntime environment. + */ + public static OrtEnvironment getEnvironment(String name) { + return getEnvironment(LoggingLevel.ORT_LOGGING_LEVEL_WARNING,name); + } + + /** + * Gets the OrtEnvironment. If there is not an environment currently created, it creates one + * using the {@link OrtEnvironment#DEFAULT_NAME} and the supplied logging level. + * @param logLevel The logging level to use. + * @return An onnxruntime environment. + */ + public static OrtEnvironment getEnvironment(LoggingLevel logLevel) { + return getEnvironment(logLevel,DEFAULT_NAME); + } + + /** + * Gets the OrtEnvironment. If there is not an environment currently created, it creates one + * using the supplied name and logging level. If an environment already exists with a different name, + * that environment is returned and a warning is logged. + * @param loggingLevel The logging level to use. + * @param name The log id. + * @return The OrtEnvironment singleton. + */ + public static synchronized OrtEnvironment getEnvironment(LoggingLevel loggingLevel, String name) { + if (INSTANCE == null) { + try { + INSTANCE = new OrtEnvironment(loggingLevel, name); + curLogLevel = loggingLevel; + curLoggingName = name; + } catch (OrtException e) { + throw new IllegalStateException("Failed to create OrtEnvironment",e); + } + } else { + if ((loggingLevel.value != curLogLevel.value) || (!name.equals(curLoggingName))) { + logger.warning("Tried to change OrtEnvironment's logging level or name while a reference exists."); + } + } + refCount.incrementAndGet(); + return INSTANCE; + } + + final long nativeHandle; + + final OrtAllocator defaultAllocator; + + private boolean closed = false; + + /** + * Create an OrtEnvironment using a default name. + * @throws OrtException If the environment couldn't be created. + */ + private OrtEnvironment() throws OrtException { + this(LoggingLevel.ORT_LOGGING_LEVEL_WARNING,"java-default"); + } + + /** + * Create an OrtEnvironment using the specified name and log level. + * @param loggingLevel The logging level to use. + * @param name The logging id of the environment. + * @throws OrtException If the environment couldn't be created. + */ + private OrtEnvironment(LoggingLevel loggingLevel, String name) throws OrtException { + nativeHandle = createHandle(OnnxRuntime.ortApiHandle,loggingLevel.getValue(),name); + defaultAllocator = new OrtAllocator(getDefaultAllocator(OnnxRuntime.ortApiHandle),true); + } + + /** + * Create a session using the default {@link SessionOptions}, model and the default memory allocator. + * @param modelPath Path on disk to load the model from. + * @return An {@link OrtSession} with the specified model. + * @throws OrtException If the model failed to load, wasn't compatible or caused an error. + */ + public OrtSession createSession(String modelPath) throws OrtException { + return createSession(modelPath,new OrtSession.SessionOptions()); + } + + /** + * Create a session using the specified {@link SessionOptions}, model and the default memory allocator. + * @param modelPath Path on disk to load the model from. + * @param options The session options. + * @return An {@link OrtSession} with the specified model. + * @throws OrtException If the model failed to load, wasn't compatible or caused an error. + */ + public OrtSession createSession(String modelPath, SessionOptions options) throws OrtException { + return createSession(modelPath,defaultAllocator,options); + } + + /** + * Create a session using the specified {@link SessionOptions} and model. + * @param modelPath Path on disk to load the model from. + * @param allocator The memory allocator to use. + * @param options The session options. + * @return An {@link OrtSession} with the specified model. + * @throws OrtException If the model failed to load, wasn't compatible or caused an error. + */ + OrtSession createSession(String modelPath, OrtAllocator allocator, SessionOptions options) throws OrtException { + if (!closed) { + return new OrtSession(this,modelPath,allocator,options); + } else { + throw new IllegalStateException("Trying to create an OrtSession on a closed OrtEnvironment."); + } + } + + /** + * Create a session using the specified {@link SessionOptions}, model and the default memory allocator. + * @param modelArray Byte array representing an ONNX model. + * @param options The session options. + * @return An {@link OrtSession} with the specified model. + * @throws OrtException If the model failed to parse, wasn't compatible or caused an error. + */ + public OrtSession createSession(byte[] modelArray, SessionOptions options) throws OrtException { + return createSession(modelArray,defaultAllocator,options); + } + + /** + * Create a session using the default {@link SessionOptions}, model and the default memory allocator. + * @param modelArray Byte array representing an ONNX model. + * @return An {@link OrtSession} with the specified model. + * @throws OrtException If the model failed to parse, wasn't compatible or caused an error. + */ + public OrtSession createSession(byte[] modelArray) throws OrtException { + return createSession(modelArray,new OrtSession.SessionOptions()); + } + + /** + * Create a session using the specified {@link SessionOptions} and model. + * @param modelArray Byte array representing an ONNX model. + * @param allocator The memory allocator to use. + * @param options The session options. + * @return An {@link OrtSession} with the specified model. + * @throws OrtException If the model failed to parse, wasn't compatible or caused an error. + */ + OrtSession createSession(byte[] modelArray, OrtAllocator allocator, SessionOptions options) throws OrtException { + if (!closed) { + return new OrtSession(this, modelArray, allocator, options); + } else { + throw new IllegalStateException("Trying to create an OrtSession on a closed OrtEnvironment."); + } + } + + /** + * Turns on or off the telemetry. + * @param sendTelemetry If true then send telemetry on onnxruntime usage. + * @throws OrtException If the call failed. + */ + public void setTelemetry(boolean sendTelemetry) throws OrtException { + setTelemetry(OnnxRuntime.ortApiHandle,nativeHandle,sendTelemetry); + } + + /** + * Is this environment closed? + * @return True if the environment is closed. + */ + public boolean isClosed() { + return closed; + } + + @Override + public String toString() { + return "OrtEnvironment(name="+ curLoggingName +",logLevel="+curLogLevel+")"; + } + + /** + * Closes the OrtEnvironment. If this is the last reference to the environment then it closes the native handle. + * @throws OrtException If the close failed. + */ + @Override + public synchronized void close() throws OrtException { + closed = true; + synchronized (refCount) { + int curCount = refCount.get(); + if (curCount != 0) { + refCount.decrementAndGet(); + } + if (curCount == 1) { + close(OnnxRuntime.ortApiHandle, nativeHandle); + INSTANCE = null; + } + } + } + + /** + * Creates the native object. + * @param apiHandle The API pointer. + * @param loggingLevel The logging level. + * @param name The name of the environment. + * @return The pointer to the native object. + * @throws OrtException If the creation failed. + */ + private static native long createHandle(long apiHandle, int loggingLevel, String name) throws OrtException; + + /** + * Gets a reference to the default allocator. + * @param apiHandle The API handle to use. + * @return A pointer to the default allocator. + * @throws OrtException If it failed to get the allocator. + */ + private static native long getDefaultAllocator(long apiHandle) throws OrtException; + + /** + * Closes the OrtEnvironment, frees the handle. + * @param apiHandle The API pointer. + * @param nativeHandle The handle to free. + * @throws OrtException If an error was caused by freeing the handle. + */ + private static native void close(long apiHandle, long nativeHandle) throws OrtException; + + /** + * Enables or disables the telemetry. + * @param apiHandle The API pointer. + * @param nativeHandle The native handle for the environment. + * @param sendTelemetry Turn on or off the telemetry. + * @throws OrtException If an error was caused when setting the telemetry status. + */ + private static native void setTelemetry(long apiHandle, long nativeHandle, boolean sendTelemetry) throws OrtException; + +} diff --git a/java/src/main/java/ai/onnxruntime/OrtException.java b/java/src/main/java/ai/onnxruntime/OrtException.java new file mode 100644 index 0000000000000..666cf79b5f72a --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OrtException.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +/** + * An exception which contains the error message and code produced by the native onnxruntime. + */ +public class OrtException extends Exception { + private static final long serialVersionUID = 1L; + + private final OrtErrorCode errorCode; + + /** + * Creates an OrtException with a default Java error code and the specified message. + * @param message The message to use. + */ + public OrtException(String message) { + super(message); + this.errorCode = OrtErrorCode.ORT_JAVA_UNKNOWN; + } + + /** + * Used to throw an exception from native code as it handles the enum lookup in Java. + * @param code The error code. + * @param message The message. + */ + public OrtException(int code, String message) { + this(OrtErrorCode.mapFromInt(code),message); + } + + /** + * Creates an OrtException using the specified error code and message. + * @param code The error code from the native runtime. + * @param message The error message. + */ + public OrtException(OrtErrorCode code, String message) { + super("Error code - " + code + " - message: " + message); + this.errorCode = code; + } + + /** + * Return the error code. + * @return The error code. + */ + public OrtErrorCode getCode() { + return errorCode; + } + + /** + * Maps the OrtErrorCode struct in "onnxruntime_c_api.h" with an additional entry for Java side errors. + */ + public enum OrtErrorCode { + ORT_JAVA_UNKNOWN(-1), + ORT_OK(0), + ORT_FAIL(1), + ORT_INVALID_ARGUMENT(2), + ORT_NO_SUCHFILE(3), + ORT_NO_MODEL(4), + ORT_ENGINE_ERROR(5), + ORT_RUNTIME_EXCEPTION(6), + ORT_INVALID_PROTOBUF(7), + ORT_MODEL_LOADED(8), + ORT_NOT_IMPLEMENTED(9), + ORT_INVALID_GRAPH(10), + ORT_EP_FAIL(11); + + private final int value; + + private static final OrtErrorCode[] values = new OrtErrorCode[12]; + + static { + for (OrtErrorCode ot : OrtErrorCode.values()) { + if (ot != ORT_JAVA_UNKNOWN) { + values[ot.value] = ot; + } + } + } + + OrtErrorCode(int value) { + this.value = value; + } + + /** + * Maps from an int in native land into an OrtErrorCode instance. + * @param value The value to lookup. + * @return The enum instance. + */ + public static OrtErrorCode mapFromInt(int value) { + if ((value >= 0) && (value < values.length)) { + return values[value]; + } else { + return ORT_JAVA_UNKNOWN; + } + } + } + +} diff --git a/java/src/main/java/ai/onnxruntime/OrtSession.java b/java/src/main/java/ai/onnxruntime/OrtSession.java new file mode 100644 index 0000000000000..ae7cce8ea7bc1 --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OrtSession.java @@ -0,0 +1,602 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.logging.Logger; + +/** + * Wraps an ONNX model and allows inference calls. + *

+ * Allows the inspection of the model's input and output nodes. + * Produced by an {@link OrtEnvironment}. + *

+ * Most instance methods throw {@link IllegalStateException} if the + * session is closed and the methods are called. + */ +public class OrtSession implements AutoCloseable { + + static { + try { + OnnxRuntime.init(); + } catch (IOException e) { + throw new RuntimeException("Failed to load onnx-runtime library",e); + } + } + + private final long nativeHandle; + + private final OrtAllocator allocator; + + private final long numInputs; + + private final Set inputNames; + + private final long numOutputs; + + private final Set outputNames; + + private boolean closed = false; + + /** + * Create a session loading the model from disk. + * @param env The environment. + * @param modelPath The path to the model. + * @param allocator The allocator to use. + * @param options Session configuration options. + * @throws OrtException If the file could not be read, or the model was corrupted etc. + */ + OrtSession(OrtEnvironment env, String modelPath, OrtAllocator allocator, SessionOptions options) throws OrtException { + nativeHandle = createSession(OnnxRuntime.ortApiHandle,env.nativeHandle,modelPath,options.nativeHandle); + this.allocator = allocator; + numInputs = getNumInputs(OnnxRuntime.ortApiHandle,nativeHandle); + inputNames = new LinkedHashSet<>(Arrays.asList(getInputNames(OnnxRuntime.ortApiHandle,nativeHandle,allocator.handle))); + numOutputs = getNumOutputs(OnnxRuntime.ortApiHandle,nativeHandle); + outputNames = new LinkedHashSet<>(Arrays.asList(getOutputNames(OnnxRuntime.ortApiHandle,nativeHandle,allocator.handle))); + } + + /** + * Creates a session reading the model from the supplied byte array. + * @param env The environment. + * @param modelArray The model protobuf as a byte array. + * @param allocator The allocator to use. + * @param options Session configuration options. + * @throws OrtException If the mode was corrupted or some other error occurred in native code. + */ + OrtSession(OrtEnvironment env, byte[] modelArray, OrtAllocator allocator, SessionOptions options) throws OrtException { + nativeHandle = createSession(OnnxRuntime.ortApiHandle,env.nativeHandle,modelArray,options.nativeHandle); + this.allocator = allocator; + numInputs = getNumInputs(OnnxRuntime.ortApiHandle,nativeHandle); + inputNames = new LinkedHashSet<>(Arrays.asList(getInputNames(OnnxRuntime.ortApiHandle,nativeHandle,allocator.handle))); + numOutputs = getNumOutputs(OnnxRuntime.ortApiHandle,nativeHandle); + outputNames = new LinkedHashSet<>(Arrays.asList(getOutputNames(OnnxRuntime.ortApiHandle,nativeHandle,allocator.handle))); + } + + /** + * Returns the number of inputs this model expects. + * @return The number of inputs. + */ + public long getNumInputs() { + if (!closed) { + return numInputs; + } else { + throw new IllegalStateException("Asking for inputs from a closed OrtSession."); + } + } + + /** + * Returns the number of outputs this model expects. + * @return The number of outputs. + */ + public long getNumOutputs() { + if (!closed) { + return numOutputs; + } else { + throw new IllegalStateException("Asking for outputs from a closed OrtSession."); + } + } + + /** + * Returns the input names. The underlying collection is sorted based on the input id number. + * @return The input names. + */ + public Set getInputNames() { + if (!closed) { + return inputNames; + } else { + throw new IllegalStateException("Asking for inputs from a closed OrtSession."); + } + } + + /** + * Returns the output names. The underlying collection is sorted based on the output id number. + * @return The output names. + */ + public Set getOutputNames() { + if (!closed) { + return outputNames; + } else { + throw new IllegalStateException("Asking for outputs from a closed OrtSession."); + } + } + + /** + * Returns the info objects for the inputs, including their names and types. + * The underlying collection is sorted based on the input id number. + * @return The input information. + * @throws OrtException If there was an error in native code. + */ + public Map getInputInfo() throws OrtException { + if (!closed) { + return wrapInMap(getInputInfo(OnnxRuntime.ortApiHandle,nativeHandle,allocator.handle)); + } else { + throw new IllegalStateException("Asking for inputs from a closed OrtSession."); + } + } + + /** + * Returns the info objects for the outputs, including their names and types. + * The underlying collection is sorted based on the output id number. + * @return The output information. + * @throws OrtException If there was an error in native code. + */ + public Map getOutputInfo() throws OrtException { + if (!closed) { + return wrapInMap(getOutputInfo(OnnxRuntime.ortApiHandle,nativeHandle,allocator.handle)); + } else { + throw new IllegalStateException("Asking for outputs from a closed OrtSession."); + } + } + + /** + * Scores an input feed dict, returning the map of all inferred outputs. + *

+ * The outputs are sorted based on their id number. + * @param inputs The inputs to score. + * @return The inferred outputs. + * @throws OrtException If there was an error in native code, the input names are invalid, or if there are zero or too many inputs. + */ + public Result run(Map inputs) throws OrtException { + return run(inputs,outputNames); + } + + /** + * Scores an input feed dict, returning the map of requested inferred outputs. + *

+ * The outputs are sorted based on the supplied set traveral order. + * @param inputs The inputs to score. + * @param requestedOutputs The requested outputs. + * @return The inferred outputs. + * @throws OrtException If there was an error in native code, the input or output names are invalid, or if there are zero or too many inputs or outputs. + */ + public Result run(Map inputs, Set requestedOutputs) throws OrtException { + if (!closed) { + if (inputs.isEmpty() || (inputs.size() > numInputs)) { + throw new OrtException("Unexpected number of inputs, expected [1," + numInputs + ") found " + inputs.size()); + } + if (requestedOutputs.isEmpty() || (requestedOutputs.size() > numOutputs)) { + throw new OrtException("Unexpected number of requestedOutputs, expected [1," + numOutputs + ") found " + requestedOutputs.size()); + } + String[] inputNamesArray = new String[inputs.size()]; + long[] inputHandles = new long[inputs.size()]; + int i = 0; + for (Map.Entry t : inputs.entrySet()) { + if (inputNames.contains(t.getKey())) { + inputNamesArray[i] = t.getKey(); + inputHandles[i] = t.getValue().getNativeHandle(); + i++; + } else { + throw new OrtException("Unknown input name " + t.getKey() + ", expected one of " + inputNames.toString()); + } + } + String[] outputNamesArray = new String[requestedOutputs.size()]; + i = 0; + for (String s : requestedOutputs) { + if (outputNames.contains(s)) { + outputNamesArray[i] = s; + i++; + } else { + throw new OrtException("Unknown output name " + s + ", expected one of " + outputNames.toString()); + } + } + OnnxValue[] outputValues = run(OnnxRuntime.ortApiHandle,nativeHandle, allocator.handle, inputNamesArray, inputHandles, numInputs, outputNamesArray, numOutputs); + return new Result(outputNamesArray,outputValues); + } else { + throw new IllegalStateException("Trying to score a closed OrtSession."); + } + } + + @Override + public String toString() { + return "OrtSession(numInputs="+numInputs+",numOutputs="+numOutputs+")"; + } + + /** + * Closes the session, releasing it's resources. + * @throws OrtException If it failed to close. + */ + @Override + public void close() throws OrtException { + if (!closed) { + closeSession(OnnxRuntime.ortApiHandle,nativeHandle); + closed = true; + } else { + throw new IllegalStateException("Trying to close an already closed OrtSession."); + } + } + + /** + * Converts a NodeInfo array into a map from node name to node info. + * @param infos The NodeInfo array to convert. + * @return A Map from String to NodeInfo. + */ + private static Map wrapInMap(NodeInfo[] infos) { + Map output = new LinkedHashMap<>(); + + for (int i = 0; i < infos.length; i++) { + output.put(infos[i].getName(),infos[i]); + } + + return output; + } + + private native long createSession(long apiHandle, long envHandle, String modelPath, long optsHandle) throws OrtException; + private native long createSession(long apiHandle, long envHandle, byte[] modelArray, long optsHandle) throws OrtException; + + private native long getNumInputs(long apiHandle, long nativeHandle) throws OrtException; + private native String[] getInputNames(long apiHandle, long nativeHandle, long allocatorHandle) throws OrtException; + private native NodeInfo[] getInputInfo(long apiHandle, long nativeHandle, long allocatorHandle) throws OrtException; + + private native long getNumOutputs(long apiHandle, long nativeHandle) throws OrtException; + private native String[] getOutputNames(long apiHandle, long nativeHandle, long allocatorHandle) throws OrtException; + private native NodeInfo[] getOutputInfo(long apiHandle, long nativeHandle, long allocatorHandle) throws OrtException; + + private native OnnxValue[] run(long apiHandle, long nativeHandle, long allocatorHandle, String[] inputNamesArray, long[] inputs, long numInputs, String[] outputNamesArray, long numOutputs) throws OrtException; + + private native void closeSession(long apiHandle, long nativeHandle) throws OrtException; + + /** + * Represents the options used to construct this session. + *

+ * Used to set the number of threads, optimisation level, computation backend and other options. + *

+ * Modifying this after the session has been constructed will have no effect. + */ + public static class SessionOptions implements AutoCloseable { + + /** + * The optimisation level to use. Needs to be kept in sync with the GraphOptimizationLevel enum in the C API. + */ + public enum OptLevel { + NO_OPT(0), BASIC_OPT(1), EXTENDED_OPT(2), ALL_OPT(99); + + private final int id; + + OptLevel(int id) { + this.id = id; + } + + /** + * Gets the int id used in native code for this optimisation level. + * @return The int id. + */ + public int getID() { + return id; + } + } + + /** + * The execution mode to use. Needs to be kept in sync with the ExecutionMode enum in the C API. + */ + public enum ExecutionMode { + SEQUENTIAL(0), PARALLEL(1); + private final int id; + + ExecutionMode(int id) { + this.id = id; + } + + /** + * Gets the int id used in native code for the execution mode. + * @return The int id. + */ + public int getID() { + return id; + } + } + + private final long nativeHandle; + + /** + * Create an empty session options. + */ + public SessionOptions() { + nativeHandle = createOptions(OnnxRuntime.ortApiHandle); + } + + /** + * Closes the session options, releasing any memory acquired. + */ + @Override + public void close() { + closeOptions(OnnxRuntime.ortApiHandle,nativeHandle); + } + + /** + * Sets the execution mode of this options object, overriding the old setting. + * @param mode The execution mode to use. + * @throws OrtException If there was an error in native code. + */ + public void setExecutionMode(ExecutionMode mode) throws OrtException { + setExecutionMode(OnnxRuntime.ortApiHandle,nativeHandle,mode.getID()); + } + + /** + * Sets the optimization level of this options object, overriding the old setting. + * @param level The optimization level to use. + * @throws OrtException If there was an error in native code. + */ + public void setOptimizationLevel(OptLevel level) throws OrtException { + setOptimizationLevel(OnnxRuntime.ortApiHandle,nativeHandle,level.getID()); + } + + /** + * Sets the size of the CPU thread pool used for executing multiple request concurrently, if executing on a CPU. + * @param numThreads The number of threads to use. + * @throws OrtException If there was an error in native code. + */ + public void setInterOpNumThreads(int numThreads) throws OrtException { + setInterOpNumThreads(OnnxRuntime.ortApiHandle,nativeHandle,numThreads); + } + + /** + * Sets the size of the CPU thread pool used for executing a single graph, if executing on a CPU. + * @param numThreads The number of threads to use. + * @throws OrtException If there was an error in native code. + */ + public void setIntraOpNumThreads(int numThreads) throws OrtException { + setIntraOpNumThreads(OnnxRuntime.ortApiHandle,nativeHandle,numThreads); + } + + /** + * Sets the output path for the optimized model. + * @param outputPath The output path to write the model to. + * @throws OrtException If there was an error in native code. + */ + public void setOptimizedModelFilePath(String outputPath) throws OrtException { + setOptimizationModelFilePath(OnnxRuntime.ortApiHandle,nativeHandle,outputPath); + } + + /** + * Add CUDA as an execution backend, using device 0. + * @throws OrtException If there was an error in native code. + */ + public void addCUDA() throws OrtException { + addCUDA(0); + } + + /** + * Add CUDA as an execution backend, using the specified CUDA device id. + * @param deviceNum The CUDA device id. + * @throws OrtException If there was an error in native code. + */ + public void addCUDA(int deviceNum) throws OrtException { + addCUDA(OnnxRuntime.ortApiHandle,nativeHandle,deviceNum); + } + + /** + * Adds the CPU as an execution backend, using the arena allocator if desired. + *

+ * By default this backend is used, but if other backends are requested, + * it should be requested last. + * @param useArena If true use the arena memory allocator. + * @throws OrtException If there was an error in native code. + */ + public void addCPU(boolean useArena) throws OrtException { + addCPU(OnnxRuntime.ortApiHandle,nativeHandle,useArena?1:0); + } + + /** + * Adds Intel's Deep Neural Network Library as an execution backend. + * @param useArena If true use the arena memory allocator. + * @throws OrtException If there was an error in native code. + */ + public void addDnnl(boolean useArena) throws OrtException { + addDnnl(OnnxRuntime.ortApiHandle,nativeHandle,useArena?1:0); + } + + /** + * Adds NGraph as an execution backend. + *

+ * See the documentation for the supported backend types. + * @param ngBackendType The NGraph backend type. + * @throws OrtException If there was an error in native code. + */ + public void addNGraph(String ngBackendType) throws OrtException { + addNGraph(OnnxRuntime.ortApiHandle,nativeHandle,ngBackendType); + } + + /** + * Adds OpenVINO as an execution backend. + * @param deviceId The id of the OpenVINO execution device. + * @throws OrtException If there was an error in native code. + */ + public void addOpenVINO(String deviceId) throws OrtException { + addOpenVINO(OnnxRuntime.ortApiHandle,nativeHandle,deviceId); + } + + /** + * Adds Nvidia's TensorRT as an execution backend. + * @param deviceNum The id of the CUDA device. + * @throws OrtException If there was an error in native code. + */ + public void addTensorrt(int deviceNum) throws OrtException { + addTensorrt(OnnxRuntime.ortApiHandle,nativeHandle,deviceNum); + } + + /** + * Adds Android's NNAPI as an execution backend. + * @throws OrtException If there was an error in native code. + */ + public void addNnapi() throws OrtException { + addNnapi(OnnxRuntime.ortApiHandle,nativeHandle); + } + + /** + * Adds Nuphar as an execution backend. + * @param allowUnalignedBuffers Allow unaligned memory buffers. + * @param settings See the documentation for valid settings strings. + * @throws OrtException If there was an error in native code. + */ + public void addNuphar(boolean allowUnalignedBuffers, String settings) throws OrtException { + addNuphar(OnnxRuntime.ortApiHandle,nativeHandle,allowUnalignedBuffers?1:0, settings); + } + + private native void setExecutionMode(long apiHandle, long nativeHandle, int mode) throws OrtException; + + private native void setOptimizationLevel(long apiHandle, long nativeHandle, int level) throws OrtException; + + private native void setInterOpNumThreads(long apiHandle, long nativeHandle, int numThreads) throws OrtException; + private native void setIntraOpNumThreads(long apiHandle, long nativeHandle, int numThreads) throws OrtException; + + private native void setOptimizationModelFilePath(long apiHandle, long nativeHandle, String modelPath) throws OrtException; + + private native long createOptions(long apiHandle); + + private native void closeOptions(long apiHandle, long nativeHandle); + + /* + * To use additional providers, you must build ORT with the extra providers enabled. Then call one of these + * functions to enable them in the session: + * OrtSessionOptionsAppendExecutionProvider_CPU + * OrtSessionOptionsAppendExecutionProvider_CUDA + * OrtSessionOptionsAppendExecutionProvider_ + * The order they care called indicates the preference order as well. In other words call this method + * on your most preferred execution provider first followed by the less preferred ones. + * If none are called Ort will use its internal CPU execution provider. + * + * If a backend is unavailable then it throws an OrtException + */ + private native void addCPU(long apiHandle, long nativeHandle, int useArena) throws OrtException; + private native void addCUDA(long apiHandle, long nativeHandle, int deviceNum) throws OrtException; + private native void addDnnl(long apiHandle, long nativeHandle, int useArena) throws OrtException; + private native void addNGraph(long apiHandle, long nativeHandle, String ngBackendType) throws OrtException; + private native void addOpenVINO(long apiHandle, long nativeHandle, String deviceId) throws OrtException; + private native void addTensorrt(long apiHandle, long nativeHandle, int deviceNum) throws OrtException; + private native void addNnapi(long apiHandle, long nativeHandle) throws OrtException; + private native void addNuphar(long apiHandle, long nativeHandle, int allowUnalignedBuffers, String settings) throws OrtException; + } + + /** + * An {@link AutoCloseable} wrapper around a {@link Map} containing {@link OnnxValue}s. + *

+ * When this is closed it closes all the {@link OnnxValue}s inside it. If you maintain a reference to a + * value after this object has been closed it will throw an {@link IllegalStateException} upon access. + */ + public static class Result implements AutoCloseable, Iterable> { + + private static final Logger logger = Logger.getLogger(Result.class.getName()); + + private final Map map; + + private final List list; + + private boolean closed; + + /** + * Creates a Result from the names and values produced by {@link OrtSession#run(Map)}. + * @param names The output names. + * @param values The output values. + */ + Result(String[] names, OnnxValue[] values) { + map = new LinkedHashMap<>(); + list = new ArrayList<>(); + + if (names.length != values.length) { + throw new IllegalArgumentException("Expected same number of names and values, found names.length = " + names.length + ", values.length = " + values.length); + } + + for (int i = 0; i < names.length; i++) { + map.put(names[i],values[i]); + list.add(values[i]); + } + this.closed = false; + } + + @Override + public void close() { + if (!closed) { + closed = true; + for (OnnxValue t : map.values()) { + t.close(); + } + } else { + logger.warning("Closing an already closed Result"); + } + } + + @Override + public Iterator> iterator() { + if (!closed) { + return map.entrySet().iterator(); + } else { + throw new IllegalStateException("Result is closed"); + } + } + + /** + * Gets the value from the container at the specified index. + * + * Throws {@link IllegalStateException} if the container has been closed, and {@link IndexOutOfBoundsException} if the index is invalid. + * + * @param index The index to lookup. + * @return The value at the index. + */ + public OnnxValue get(int index) { + if (!closed) { + return list.get(index); + } else { + throw new IllegalStateException("Result is closed"); + } + } + + /** + * Returns the number of outputs in this Result. + * @return The number of outputs. + */ + public int size() { + return map.size(); + } + + /** + * Gets the value from the container assuming it's not been closed. + * + * Throws {@link IllegalStateException} if the container has been closed. + * @param key The key to lookup. + * @return Optional.of the value if it exists. + */ + public Optional get(String key) { + if (!closed) { + OnnxValue value = map.get(key); + if (value != null) { + return Optional.of(value); + } else { + return Optional.empty(); + } + } else { + throw new IllegalStateException("Result is closed"); + } + } + } +} diff --git a/java/src/main/java/ai/onnxruntime/OrtUtil.java b/java/src/main/java/ai/onnxruntime/OrtUtil.java new file mode 100644 index 0000000000000..56db41b6fded9 --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/OrtUtil.java @@ -0,0 +1,354 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Util code for interacting with Java arrays. + */ +public final class OrtUtil { + + /** + * Private constructor for static util class. + */ + private OrtUtil() {} + + /** + * Converts an long shape into a int shape. + *

+ * Validates that the shape has more than 1 elements, + * less than 9 elements, each element is less than {@link Integer#MAX_VALUE} + * and that each entry is non-negative. + * @param shape The long shape. + * @return The int shape. + */ + public static int[] transformShape(long[] shape) { + if (shape.length == 0 || shape.length > TensorInfo.MAX_DIMENSIONS) { + throw new IllegalArgumentException("Arrays with less than 1 and greater than " + + TensorInfo.MAX_DIMENSIONS + " dimensions are not supported."); + } + int[] newShape = new int[shape.length]; + for (int i = 0; i < shape.length; i++) { + long curDim = shape[i]; + if (curDim < 1 || curDim > Integer.MAX_VALUE) { + throw new IllegalArgumentException("Invalid shape for a Java array, expected positive entries smaller than Integer.MAX_VALUE. Found " + Arrays.toString(shape)); + } else { + newShape[i] = (int) curDim; + } + } + return newShape; + } + + /** + * Converts an int shape into a long shape. + *

+ * Validates that the shape has more than 1 element, less than 9 elements and that each entry is non-negative. + * @param shape The int shape. + * @return The long shape. + */ + public static long[] transformShape(int[] shape) { + if (shape.length == 0 || shape.length > 8) { + throw new IllegalArgumentException("Arrays with less than 1 and greater than " + + TensorInfo.MAX_DIMENSIONS + " dimensions are not supported."); + } + long[] newShape = new long[shape.length]; + for (int i = 0; i < shape.length; i++) { + long curDim = shape[i]; + if (curDim < 1) { + throw new IllegalArgumentException("Invalid shape for a Java array, expected positive entries smaller than Integer.MAX_VALUE. Found " + Arrays.toString(shape)); + } else { + newShape[i] = curDim; + } + } + return newShape; + } + + /** + * Creates a new primitive boolean array of up to 8 dimensions, using the supplied shape. + *

+ * @param shape The shape of array to create. + * @return A boolean array. + */ + public static Object newBooleanArray(long[] shape) { + int[] intShape = transformShape(shape); + return Array.newInstance(boolean.class, intShape); + } + + /** + * Creates a new primitive byte array of up to 8 dimensions, using the supplied shape. + *

+ * @param shape The shape of array to create. + * @return A byte array. + */ + public static Object newByteArray(long[] shape) { + int[] intShape = transformShape(shape); + return Array.newInstance(byte.class, intShape); + } + + /** + * Creates a new primitive short array of up to 8 dimensions, using the supplied shape. + *

+ * @param shape The shape of array to create. + * @return A short array. + */ + public static Object newShortArray(long[] shape) { + int[] intShape = transformShape(shape); + return Array.newInstance(short.class, intShape); + } + + /** + * Creates a new primitive int array of up to 8 dimensions, using the supplied shape. + *

+ * @param shape The shape of array to create. + * @return A int array. + */ + public static Object newIntArray(long[] shape) { + int[] intShape = transformShape(shape); + return Array.newInstance(int.class, intShape); + } + + /** + * Creates a new primitive long array of up to 8 dimensions, using the supplied shape. + *

+ * @param shape The shape of array to create. + * @return A long array. + */ + public static Object newLongArray(long[] shape) { + int[] intShape = transformShape(shape); + return Array.newInstance(long.class, intShape); + } + + /** + * Creates a new primitive float array of up to 8 dimensions, using the supplied shape. + *

+ * @param shape The shape of array to create. + * @return A float array. + */ + public static Object newFloatArray(long[] shape) { + int[] intShape = transformShape(shape); + return Array.newInstance(float.class, intShape); + } + + /** + * Creates a new primitive double array of up to 8 dimensions, using the supplied shape. + *

+ * @param shape The shape of array to create. + * @return A double array. + */ + public static Object newDoubleArray(long[] shape) { + int[] intShape = transformShape(shape); + return Array.newInstance(double.class, intShape); + } + + /** + * Reshapes a boolean array into the desired n-dimensional array assuming the boolean array is stored in n-dimensional row-major order. + * Throws {@link IllegalArgumentException} if the number of elements doesn't match between the shape and the input or the shape is invalid. + * @param input The boolean array. + * @param shape The desired shape. + * @return An n-dimensional boolean array. + */ + public static Object reshape(boolean[] input, long[] shape) { + Object output = OrtUtil.newBooleanArray(shape); + reshape(input,output,0); + return output; + } + + /** + * Reshapes a byte array into the desired n-dimensional array assuming the byte array is stored in n-dimensional row-major order. + * Throws {@link IllegalArgumentException} if the number of elements doesn't match between the shape and the input or the shape is invalid. + * @param input The byte array. + * @param shape The desired shape. + * @return An n-dimensional byte array. + */ + public static Object reshape(byte[] input, long[] shape) { + Object output = OrtUtil.newByteArray(shape); + reshape(input,output,0); + return output; + } + + /** + * Reshapes a short array into the desired n-dimensional array assuming the short array is stored in n-dimensional row-major order. + * Throws {@link IllegalArgumentException} if the number of elements doesn't match between the shape and the input or the shape is invalid. + * @param input The short array. + * @param shape The desired shape. + * @return An n-dimensional short array. + */ + public static Object reshape(short[] input, long[] shape) { + Object output = OrtUtil.newShortArray(shape); + reshape(input,output,0); + return output; + } + + /** + * Reshapes an int array into the desired n-dimensional array, assuming the int array is stored in n-dimensional row-major order. + * Throws {@link IllegalArgumentException} if the number of elements doesn't match between the shape and the input or the shape is invalid. + * @param input The int array. + * @param shape The desired shape. + * @return An n-dimensional int array. + */ + public static Object reshape(int[] input, long[] shape) { + Object output = OrtUtil.newIntArray(shape); + reshape(input,output,0); + return output; + } + + /** + * Reshapes a long array into the desired n-dimensional array, assuming the long array is stored in n-dimensional row-major order. + * Throws {@link IllegalArgumentException} if the number of elements doesn't match between the shape and the input or the shape is invalid. + * @param input The long array. + * @param shape The desired shape. + * @return An n-dimensional long array. + */ + public static Object reshape(long[] input, long[] shape) { + Object output = OrtUtil.newLongArray(shape); + reshape(input,output,0); + return output; + } + + /** + * Reshapes a float array into the desired n-dimensional array assuming the float array is stored in n-dimensional row-major order. + * Throws {@link IllegalArgumentException} if the number of elements doesn't match between the shape and the input or the shape is invalid. + * @param input The float array. + * @param shape The desired shape. + * @return An n-dimensional float array. + */ + public static Object reshape(float[] input, long[] shape) { + Object output = OrtUtil.newFloatArray(shape); + reshape(input,output,0); + return output; + } + + /** + * Reshapes a double array into the desired n-dimensional array assuming the double array is stored in n-dimensional row-major order. + * Throws {@link IllegalArgumentException} if the number of elements doesn't match between the shape and the input or the shape is invalid. + * @param input The double array. + * @param shape The desired shape. + * @return An n-dimensional double array. + */ + public static Object reshape(double[] input, long[] shape) { + Object output = OrtUtil.newDoubleArray(shape); + reshape(input,output,0); + return output; + } + + /** + * Copies elements from the flat input array to the + * appropriate primitive array of the output. + * Recursively calls itself as it traverses the output array. + * @param input The input array. + * @param output The output multidimensional array. + * @param position The current position in the input array. + * @return The new position in the input array. + */ + private static int reshape(Object input, Object output, int position) { + if (output.getClass().isArray()) { + Object[] outputArray = (Object[]) output; + for (Object outputElement : outputArray) { + Class outputElementClass = outputElement.getClass(); + if (outputElementClass.isArray()) { + if (outputElementClass.getComponentType().isPrimitive()) { + int length = Array.getLength(outputElement); + System.arraycopy(input,position,outputElement,0,length); + position += length; + } else { + position = reshape(input,outputElement,position); + } + } else { + throw new IllegalStateException("Found element type when expecting an array. Class " + outputElementClass); + } + } + } else { + throw new IllegalStateException("Found element type when expecting an array. Class " + output.getClass()); + } + + return position; + } + + /** + * Counts the number of elements stored in a Tensor of this shape. + *

+ * Multiplies all the elements together if they are positive, throws an {@link IllegalArgumentException} otherwise. + *

+ * @param shape The shape to use. + * @return The number of elements. + */ + public static long elementCount(long[] shape) { + long count = 1; + for (int i = 0; i < shape.length; i++) { + if (shape[i] > 0) { + count *= shape[i]; + } else { + throw new IllegalArgumentException("Received non-positive value in shape " + Arrays.toString(shape) + " ."); + } + } + return count; + } + + /** + * Checks that the shape is a valid shape for a Java array (i.e. that the values are all positive and representable by an int). + * @param shape The shape to check. + * @return True if the shape is valid. + */ + public static boolean validateShape(long[] shape) { + boolean valid = true; + for (int i = 0; i < shape.length; i++) { + valid &= shape[i] > 0; + valid &= ((int)shape[i]) == shape[i]; + } + return valid && shape.length <= TensorInfo.MAX_DIMENSIONS; + } + + /** + * Flatten a multidimensional String array into a single dimensional String array, reading + * it in a multidimensional row-major order. + * @param o A multidimensional String array. + * @return A single dimensional String array. + */ + public static String[] flattenString(Object o) { + ArrayList output = new ArrayList<>(); + + flattenString((Object[]) o,output); + + return output.toArray(new String[0]); + } + + /** + * Flattens a multidimensional String array into the ArrayList. + * @param input The multidimensional String array. + * @param output The output ArrayList. + */ + private static void flattenString(Object[] input, ArrayList output) { + for (Object i : input) { + Class iClazz = i.getClass(); + if (iClazz.isArray()) { + if (iClazz.getComponentType().isArray()) { + flattenString((Object[]) i, output); + } else if (iClazz.getComponentType().equals(String.class)) { + output.addAll(Arrays.asList((String[])i)); + } else { + throw new IllegalStateException("Found a non-String, non-array element type, " + iClazz); + } + } else { + throw new IllegalStateException("Found an element type where there should have been an array. Class = " + iClazz); + } + } + } + + /** + * Stores a boxed primitive in a single element array of the boxed type. + * Otherwise returns the input. + * @param data The boxed primitive. + * @return The boxed primitive in an array. + */ + static Object convertBoxedPrimitiveToArray(Object data) { + Object array = Array.newInstance(data.getClass(), 1); + Array.set(array, 0, data); + return array; + } +} diff --git a/java/src/main/java/ai/onnxruntime/SequenceInfo.java b/java/src/main/java/ai/onnxruntime/SequenceInfo.java new file mode 100644 index 0000000000000..6e48f9bbf5abd --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/SequenceInfo.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +/** + * Describes an {@link OnnxSequence}, including it's element type if known. + */ +public class SequenceInfo implements ValueInfo { + + /** + * Is this a sequence of maps. + */ + public final boolean sequenceOfMaps; + + /** + * The type of the sequence if it does not contain a map, {@link OnnxJavaType#UNKNOWN} if it does. + */ + public final OnnxJavaType sequenceType; + + /** + * The type of the map if it contains a map, null otherwise. + */ + public final MapInfo mapInfo; + + /** + * The number of elements in this sequence. + */ + public final int length; + + /** + * Construct a sequence of known length, with the specified type. + * This sequence does not contain maps. + * @param length The length of the sequence. + * @param sequenceType The element type of the sequence. + */ + SequenceInfo(int length, OnnxJavaType sequenceType) { + this.length = length; + this.sequenceType = sequenceType; + this.sequenceOfMaps = false; + this.mapInfo = null; + } + + /** + * Construct a sequence of known length containing maps. + * @param length The length of the sequence. + * @param mapInfo The map type information. + */ + SequenceInfo(int length, MapInfo mapInfo) { + this.length = length; + this.sequenceOfMaps = true; + this.mapInfo = mapInfo; + this.sequenceType = OnnxJavaType.UNKNOWN; + } + + /** + * Constructs a sequence of known lenght containing maps. + * @param length The length of the sequence. + * @param keyType The map key type. + * @param valueType The map value type. + */ + SequenceInfo(int length, OnnxJavaType keyType, OnnxJavaType valueType) { + this.length = length; + this.sequenceType = OnnxJavaType.UNKNOWN; + this.sequenceOfMaps = true; + this.mapInfo = new MapInfo(keyType,valueType); + } + + /** + * Is this a sequence of maps? + * @return True if it's a sequence of maps. + */ + public boolean isSequenceOfMaps() { + return sequenceOfMaps; + } + + @Override + public String toString() { + String initial = "SequenceInfo(length=" + (length == -1 ? "UNKNOWN" : length); + if (sequenceOfMaps) { + return initial+",type=" + mapInfo.toString() + ")"; + } else { + return initial+",type=" + sequenceType.toString() + ")"; + } + } + +} diff --git a/java/src/main/java/ai/onnxruntime/TensorInfo.java b/java/src/main/java/ai/onnxruntime/TensorInfo.java new file mode 100644 index 0000000000000..d34fa016e3495 --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/TensorInfo.java @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.lang.reflect.Array; +import java.nio.Buffer; +import java.util.Arrays; + +/** + * Describes an {@link OnnxTensor}, including it's size, shape and element type. + */ +public class TensorInfo implements ValueInfo { + + /** + * Maximum number of dimensions supported by the Java interface methods. + */ + public static final int MAX_DIMENSIONS = 8; + + /** + * The native element types supported by the ONNX runtime. + */ + public enum OnnxTensorType { + ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED(0), + ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8(1), // maps to c type uint8_t + ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8(2), // maps to c type int8_t + ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16(3), // maps to c type uint16_t + ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16(4), // maps to c type int16_t + ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32(5), // maps to c type uint32_t + ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32(6), // maps to c type int32_t + ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64(7), // maps to c type uint64_t + ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64(8), // maps to c type int64_t + ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16(9), // stored as a uint16_t + ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT(10), // maps to c type float + ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE(11), // maps to c type double + ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING(12), // maps to c++ type std::string + ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL(13), + ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64(14), // complex with float32 real and imaginary components + ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128(15), // complex with float64 real and imaginary components + ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16(16); // Non-IEEE floating-point format based on IEEE754 single-precision + + /** + * The int id on the native side. + */ + public final int value; + + private static final OnnxTensorType[] values = new OnnxTensorType[17]; + + static { + for (OnnxTensorType ot : OnnxTensorType.values()) { + values[ot.value] = ot; + } + } + + OnnxTensorType(int value) { + this.value = value; + } + + /** + * Maps from the C API's int enum to the Java enum. + * @param value The index of the Java enum. + * @return The Java enum. + */ + public static OnnxTensorType mapFromInt(int value) { + if ((value > 0) && (value < values.length)) { + return values[value]; + } else { + return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED; + } + } + + /** + * Maps a OnnxJavaType into the appropriate native element type. + * @param type The type of the Java input/output. + * @return The native element type. + */ + public static OnnxTensorType mapFromJavaType(OnnxJavaType type) { + switch (type) { + case FLOAT: + return OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; + case DOUBLE: + return OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE; + case INT8: + return OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8; + case INT16: + return OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16; + case INT32: + return OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32; + case INT64: + return OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64; + case BOOL: + return OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL; + case STRING: + return OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING; + case UNKNOWN: + default: + return OnnxTensorType.ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED; + } + } + } + + final long[] shape; + + /** + * The Java type of this tensor. + */ + public final OnnxJavaType type; + + /** + * The native type of this tensor. + */ + public final OnnxTensorType onnxType; + + /** + * Constructs a TensorInfo with the specified shape, Java type and native type. + * @param shape The tensor shape. + * @param type The Java type. + * @param onnxType The native type. + */ + TensorInfo(long[] shape, OnnxJavaType type, OnnxTensorType onnxType) { + this.shape = shape; + this.type = type; + this.onnxType = onnxType; + } + + /** + * Get a copy of the tensor's shape. + * @return A copy of the tensor's shape. + */ + public long[] getShape() { + return Arrays.copyOf(shape,shape.length); + } + + @Override + public String toString() { + return "TensorInfo(javaType="+type.toString()+",onnxType="+onnxType.toString()+",shape="+ Arrays.toString(shape)+")"; + } + + /** + * Returns true if the shape represents a scalar value (i.e. it has zero dimensions). + * @return True if the shape is a scalar. + */ + public boolean isScalar() { + return shape.length == 0; + } + + /** + * Checks that the shape of this tensor info is valid (i.e. positive and within the bounds of a Java int). + * @return True if the shape is valid. + */ + private boolean validateShape() { + return OrtUtil.validateShape(shape); + } + + /** + * Constructs an array the right shape and type to hold this tensor. + * @return A multidimensional array of the appropriate primitive type (or String). + * @throws OrtException If the shape isn't representable in Java (i.e. if one of it's indices is greater than an int). + */ + public Object makeCarrier() throws OrtException { + if (!validateShape()) { + throw new OrtException("This tensor is not representable in Java, it's too big - shape = " + Arrays.toString(shape)); + } + switch (type) { + case FLOAT: + return OrtUtil.newFloatArray(shape); + case DOUBLE: + return OrtUtil.newDoubleArray(shape); + case INT8: + return OrtUtil.newByteArray(shape); + case INT16: + return OrtUtil.newShortArray(shape); + case INT32: + return OrtUtil.newIntArray(shape); + case INT64: + return OrtUtil.newLongArray(shape); + case BOOL: + return OrtUtil.newBooleanArray(shape); + case STRING: + return new String[(int) OrtUtil.elementCount(shape)]; + case UNKNOWN: + throw new OrtException("Can't construct a carrier for an invalid type."); + default: + throw new OrtException("Unsupported type - " + type); + } + } + + /** + * Constructs a TensorInfo from the supplied multidimensional Java array, + * used to allocate the appropriate amount of native memory. + * @param obj The object to inspect. + * @return A TensorInfo which can be used to make the right size Tensor. + * @throws OrtException If the supplied Object isn't an array, or is an invalid type. + */ + public static TensorInfo constructFromJavaArray(Object obj) throws OrtException { + Class objClass = obj.getClass(); + if (!objClass.isArray() && !objClass.isPrimitive() && !objClass.equals(String.class)) { + throw new OrtException("Cannot convert " + objClass + " to a OnnxTensor."); + } + // Figure out base type and number of dimensions. + int dimensions = 0; + while (objClass.isArray()) { + objClass = objClass.getComponentType(); + dimensions++; + } + if (!objClass.isPrimitive() && !objClass.equals(String.class)) { + throw new OrtException("Cannot create an OnnxTensor from a base type of " + objClass); + } else if (dimensions > MAX_DIMENSIONS) { + throw new OrtException("Cannot create an OnnxTensor with more than " + MAX_DIMENSIONS + " dimensions. Found " + dimensions + " dimensions."); + } + OnnxJavaType javaType = OnnxJavaType.mapFromClass(objClass); + + // Now we extract the shape and validate that the java array is rectangular (i.e. not ragged). + // this is pretty nasty as we have to look at every object array recursively. + // Thanks Java! + long[] shape = new long[dimensions]; + extractShape(shape,0,obj); + + return new TensorInfo(shape,javaType, OnnxTensorType.mapFromJavaType(javaType)); + } + + /** + * Constructs a TensorInfo from the supplied byte buffer. + * @param buffer The buffer to inspect. + * @param shape The shape of the tensor. + * @param type The Java type. + * @return A TensorInfo for a tensor. + * @throws OrtException If the supplied buffer doesn't match the shape. + */ + public static TensorInfo constructFromBuffer(Buffer buffer, long[] shape, OnnxJavaType type) throws OrtException { + if ((type == OnnxJavaType.STRING) || (type == OnnxJavaType.UNKNOWN)) { + throw new OrtException("Cannot create a tensor from a string or unknown buffer."); + } + + long elementCount = OrtUtil.elementCount(shape); + + long bufferCapacity = buffer.capacity(); + + if (elementCount != bufferCapacity) { + throw new OrtException("Shape " + Arrays.toString(shape) + ", requires " + elementCount + " elements but the buffer has " + bufferCapacity + " elements."); + } + + return new TensorInfo(Arrays.copyOf(shape,shape.length),type, OnnxTensorType.mapFromJavaType(type)); + } + + /** + * Extracts the shape from a multidimensional array. Checks to see if the array is ragged or not. + * @param shape The shape array to write to. + * @param curDim The current dimension to check. + * @param obj The multidimensional array to inspect. + * @throws OrtException If the array has a zero dimension, or is ragged. + */ + private static void extractShape(long[] shape, int curDim, Object obj) throws OrtException { + if (shape.length != curDim) { + int curLength = Array.getLength(obj); + if (curLength == 0) { + throw new OrtException("Supplied array has a zero dimension at " + curDim + ", all dimensions must be positive"); + } else if (shape[curDim] == 0L) { + shape[curDim] = curLength; + } else if (shape[curDim] != curLength) { + throw new OrtException("Supplied array is ragged, expected " + shape[curDim] + ", found " + curLength); + } + for (int i = 0; i < curLength; i++) { + extractShape(shape,curDim+1,Array.get(obj,i)); + } + } + } +} diff --git a/java/src/main/java/ai/onnxruntime/ValueInfo.java b/java/src/main/java/ai/onnxruntime/ValueInfo.java new file mode 100644 index 0000000000000..d4c6bbe931456 --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/ValueInfo.java @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +/** + * Interface for info objects describing an {@link OnnxValue}. + *

+ * Will be sealed to {@link MapInfo}, {@link TensorInfo} and {@link SequenceInfo} when Java + * supports sealed interfaces. + */ +public interface ValueInfo { } diff --git a/java/src/main/java/ai/onnxruntime/package-info.java b/java/src/main/java/ai/onnxruntime/package-info.java new file mode 100644 index 0000000000000..9d6786cd59081 --- /dev/null +++ b/java/src/main/java/ai/onnxruntime/package-info.java @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ + +/** + * A Java interface to the onnxruntime. + *

+ * Provides access to the same execution backends as the C library. + * Non-representable types in Java (such as fp16) are converted + * into the nearest Java primitive type when accessed through this API. + */ +package ai.onnxruntime; \ No newline at end of file diff --git a/java/src/main/native/OrtJniUtil.c b/java/src/main/native/OrtJniUtil.c new file mode 100644 index 0000000000000..66fda206501aa --- /dev/null +++ b/java/src/main/native/OrtJniUtil.c @@ -0,0 +1,914 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include +#include "OrtJniUtil.h" + +jint JNI_OnLoad(JavaVM *vm, void *reserved) { + // To silence unused-parameter error. + // This function must exist according to the JNI spec, but the arguments aren't necessary for the library to request a specific version. + (void)vm; (void) reserved; + return JNI_VERSION_1_8; +} + +/** + * Must be kept in sync with ORT_LOGGING_LEVEL and OrtEnvironment#LoggingLevel + */ +OrtLoggingLevel convertLoggingLevel(jint level) { + switch (level) { + case 0: + return ORT_LOGGING_LEVEL_VERBOSE; + case 1: + return ORT_LOGGING_LEVEL_INFO; + case 2: + return ORT_LOGGING_LEVEL_WARNING; + case 3: + return ORT_LOGGING_LEVEL_ERROR; + case 4: + return ORT_LOGGING_LEVEL_FATAL; + default: + return ORT_LOGGING_LEVEL_VERBOSE; + } +} + +/** + * Must be kept in sync with GraphOptimizationLevel and SessionOptions#OptLevel + */ +GraphOptimizationLevel convertOptimizationLevel(jint level) { + switch (level) { + case 0: + return ORT_DISABLE_ALL; + case 1: + return ORT_ENABLE_BASIC; + case 2: + return ORT_ENABLE_EXTENDED; + case 99: + return ORT_ENABLE_ALL; + default: + return ORT_DISABLE_ALL; + } +} + +/** + * Must be kept in sync with ExecutionMode and SessionOptions#ExecutionMode + */ +ExecutionMode convertExecutionMode(jint mode) { + switch (mode) { + case 0: + return ORT_SEQUENTIAL; + case 1: + return ORT_PARALLEL; + default: + return ORT_SEQUENTIAL; + } +} + +/** + * Must be kept in sync with convertToONNXDataFormat + */ +jint convertFromONNXDataFormat(ONNXTensorElementDataType type) { + switch (type) { + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED: + return 0; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8: // maps to c type uint8_t + return 1; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8: // maps to c type int8_t + return 2; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16: // maps to c type uint16_t + return 3; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16: // maps to c type int16_t + return 4; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32: // maps to c type uint32_t + return 5; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32: // maps to c type int32_t + return 6; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64: // maps to c type uint64_t + return 7; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64: // maps to c type int64_t + return 8; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16: + return 9; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT: // maps to c type float + return 10; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE: // maps to c type double + return 11; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING: // maps to c++ type std::string + return 12; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL: + return 13; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64: // complex with float32 real and imaginary components + return 14; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128: // complex with float64 real and imaginary components + return 15; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16: // Non-IEEE floating-point format based on IEEE754 single-precision + return 16; + default: + return -1; + } +} + +/** + * Must be kept in sync with convertFromONNXDataFormat + */ +ONNXTensorElementDataType convertToONNXDataFormat(jint type) { + switch (type) { + case 0: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED; + case 1: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8; // maps to c type uint8_t + case 2: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8; // maps to c type int8_t + case 3: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16; // maps to c type uint16_t + case 4: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16; // maps to c type int16_t + case 5: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32; // maps to c type uint32_t + case 6: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32; // maps to c type int32_t + case 7: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64; // maps to c type uint64_t + case 8: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64; // maps to c type int64_t + case 9: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16; + case 10: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; // maps to c type float + case 11: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE; // maps to c type double + case 12: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING; // maps to c++ type std::string + case 13: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL; + case 14: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64; // complex with float32 real and imaginary components + case 15: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128; // complex with float64 real and imaginary components + case 16: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16; // Non-IEEE floating-point format based on IEEE754 single-precision + default: + return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED; + } +} + +size_t onnxTypeSize(ONNXTensorElementDataType type) { + switch (type) { + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8: // maps to c type uint8_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8: // maps to c type int8_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL: + return 1; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16: // maps to c type uint16_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16: // maps to c type int16_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16: + return 2; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32: // maps to c type uint32_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32: // maps to c type int32_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT: // maps to c type float + return 4; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64: // maps to c type uint64_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64: // maps to c type int64_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE: // maps to c type double + return 8; + case ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING: // maps to c++ type std::string + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED: + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16: // Non-IEEE floating-point format based on IEEE754 single-precision + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64: // complex with float32 real and imaginary components + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128: // complex with float64 real and imaginary components + default: + return 0; + } +} + +typedef union FP32 { + int intVal; + float floatVal; +} FP32; + +jfloat convertHalfToFloat(uint16_t half) { + FP32 output; + output.intVal = (((half&0x8000)<<16) | (((half&0x7c00)+0x1C000)<<13) | ((half&0x03FF)<<13)); + return output.floatVal; +} + +jobject convertToValueInfo(JNIEnv *jniEnv, const OrtApi * api, OrtTypeInfo * info) { + ONNXType type; + checkOrtStatus(jniEnv,api,api->GetOnnxTypeFromTypeInfo(info,&type)); + + switch (type) { + case ONNX_TYPE_TENSOR: { + const OrtTensorTypeAndShapeInfo* tensorInfo; + checkOrtStatus(jniEnv,api,api->CastTypeInfoToTensorInfo(info,&tensorInfo)); + return convertToTensorInfo(jniEnv, api, (const OrtTensorTypeAndShapeInfo *) tensorInfo); + } + case ONNX_TYPE_SEQUENCE: { + return createEmptySequenceInfo(jniEnv); + } + case ONNX_TYPE_MAP: { + return createEmptyMapInfo(jniEnv); + } + case ONNX_TYPE_UNKNOWN: + case ONNX_TYPE_OPAQUE: + case ONNX_TYPE_SPARSETENSOR: + default: { + throwOrtException(jniEnv,convertErrorCode(ORT_NOT_IMPLEMENTED),"Invalid ONNXType found."); + return NULL; + } + } +} + +jobject convertToTensorInfo(JNIEnv *jniEnv, const OrtApi * api, const OrtTensorTypeAndShapeInfo * info) { + // Extract the information from the info struct. + ONNXTensorElementDataType onnxType; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(info,&onnxType)); + size_t numDim; + checkOrtStatus(jniEnv,api,api->GetDimensionsCount(info,&numDim)); + //printf("numDim %d\n",numDim); + int64_t* dimensions = (int64_t*) malloc(sizeof(int64_t)*numDim); + checkOrtStatus(jniEnv,api,api->GetDimensions(info, dimensions, numDim)); + jint onnxTypeInt = convertFromONNXDataFormat(onnxType); + + // Create the long array for the shape. + jlongArray shape = (*jniEnv)->NewLongArray(jniEnv, numDim); + (*jniEnv)->SetLongArrayRegion(jniEnv, shape, 0, numDim, (jlong*)dimensions); + // Free the dimensions array + free(dimensions); + dimensions = NULL; + + // Create the ONNXTensorType enum + char *onnxTensorTypeClassName = "ai/onnxruntime/TensorInfo$OnnxTensorType"; + jclass clazz = (*jniEnv)->FindClass(jniEnv, onnxTensorTypeClassName); + jmethodID onnxTensorTypeMapFromInt = (*jniEnv)->GetStaticMethodID(jniEnv,clazz, "mapFromInt", "(I)Lai/onnxruntime/TensorInfo$OnnxTensorType;"); + jobject onnxTensorTypeJava = (*jniEnv)->CallStaticObjectMethod(jniEnv,clazz,onnxTensorTypeMapFromInt,onnxTypeInt); + //printf("ONNXTensorType class %p, methodID %p, object %p\n",clazz,onnxTensorTypeMapFromInt,onnxTensorTypeJava); + + // Create the ONNXJavaType enum + char *javaDataTypeClassName = "ai/onnxruntime/OnnxJavaType"; + clazz = (*jniEnv)->FindClass(jniEnv, javaDataTypeClassName); + jmethodID javaDataTypeMapFromONNXTensorType = (*jniEnv)->GetStaticMethodID(jniEnv,clazz, "mapFromOnnxTensorType", "(Lai/onnxruntime/TensorInfo$OnnxTensorType;)Lai/onnxruntime/OnnxJavaType;"); + jobject javaDataType = (*jniEnv)->CallStaticObjectMethod(jniEnv,clazz,javaDataTypeMapFromONNXTensorType,onnxTensorTypeJava); + //printf("JavaDataType class %p, methodID %p, object %p\n",clazz,javaDataTypeMapFromONNXTensorType,javaDataType); + + // Create the TensorInfo object + char *tensorInfoClassName = "ai/onnxruntime/TensorInfo"; + clazz = (*jniEnv)->FindClass(jniEnv, tensorInfoClassName); + jmethodID tensorInfoConstructor = (*jniEnv)->GetMethodID(jniEnv,clazz, "", "([JLai/onnxruntime/OnnxJavaType;Lai/onnxruntime/TensorInfo$OnnxTensorType;)V"); + //printf("TensorInfo class %p, methodID %p\n",clazz,tensorInfoConstructor); + jobject tensorInfo = (*jniEnv)->NewObject(jniEnv, clazz, tensorInfoConstructor, shape, javaDataType, onnxTensorTypeJava); + return tensorInfo; +} + +//jobject convertToMapInfo(JNIEnv *jniEnv, const OrtApi * api, const OrtTypeInfo * info) { +// As map info isn't available at this point, it creates an empty map info type. +jobject createEmptyMapInfo(JNIEnv *jniEnv) { + // Create the ONNXJavaType enum + char *onnxJavaTypeClassName = "ai/onnxruntime/OnnxJavaType"; + jclass clazz = (*jniEnv)->FindClass(jniEnv, onnxJavaTypeClassName); + jmethodID onnxJavaTypeMapFromInt = (*jniEnv)->GetStaticMethodID(jniEnv,clazz, "mapFromInt", "(I)Lai/onnxruntime/OnnxJavaType;"); + jobject unknownType = (*jniEnv)->CallStaticObjectMethod(jniEnv,clazz,onnxJavaTypeMapFromInt,0); + + char *mapInfoClassName = "ai/onnxruntime/MapInfo"; + clazz = (*jniEnv)->FindClass(jniEnv, mapInfoClassName); + jmethodID mapInfoConstructor = (*jniEnv)->GetMethodID(jniEnv,clazz,"","(Lai/onnxruntime/OnnxJavaType;Lai/onnxruntime/OnnxJavaType;)V"); + jobject mapInfo = (*jniEnv)->NewObject(jniEnv,clazz,mapInfoConstructor,unknownType,unknownType); + + return mapInfo; +} + +//jobject convertToSequenceInfo(JNIEnv *jniEnv, const OrtApi * api, const OrtTypeInfo * info) { +// As sequence info isn't available at this point, it creates an empty sequence info type. +jobject createEmptySequenceInfo(JNIEnv *jniEnv) { + // Create the ONNXJavaType enum + char *onnxJavaTypeClassName = "ai/onnxruntime/OnnxJavaType"; + jclass clazz = (*jniEnv)->FindClass(jniEnv, onnxJavaTypeClassName); + jmethodID onnxJavaTypeMapFromInt = (*jniEnv)->GetStaticMethodID(jniEnv,clazz, "mapFromInt", "(I)Lai/onnxruntime/OnnxJavaType;"); + jobject unknownType = (*jniEnv)->CallStaticObjectMethod(jniEnv,clazz,onnxJavaTypeMapFromInt,0); + + char *sequenceInfoClassName = "ai/onnxruntime/SequenceInfo"; + clazz = (*jniEnv)->FindClass(jniEnv, sequenceInfoClassName); + jmethodID sequenceInfoConstructor = (*jniEnv)->GetMethodID(jniEnv,clazz,"","(ILai/onnxruntime/OnnxJavaType;)V"); + jobject sequenceInfo = (*jniEnv)->NewObject(jniEnv,clazz,sequenceInfoConstructor,-1,unknownType); + + return sequenceInfo; +} + +size_t copyJavaToPrimitiveArray(JNIEnv *jniEnv, ONNXTensorElementDataType onnxType, uint8_t* tensor, jarray input) { + uint32_t inputLength = (*jniEnv)->GetArrayLength(jniEnv,input); + size_t consumedSize = inputLength * onnxTypeSize(onnxType); + switch (onnxType) { + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8: // maps to c type uint8_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8: { // maps to c type int8_t + jbyteArray typedArr = (jbyteArray) input; + (*jniEnv)->GetByteArrayRegion(jniEnv, typedArr, 0, inputLength, (jbyte * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16: // maps to c type uint16_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16: { // maps to c type int16_t + jshortArray typedArr = (jshortArray) input; + (*jniEnv)->GetShortArrayRegion(jniEnv, typedArr, 0, inputLength, (jshort * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32: // maps to c type uint32_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32: { // maps to c type int32_t + jintArray typedArr = (jintArray) input; + (*jniEnv)->GetIntArrayRegion(jniEnv, typedArr, 0, inputLength, (jint * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64: // maps to c type uint64_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64: { // maps to c type int64_t + jlongArray typedArr = (jlongArray) input; + (*jniEnv)->GetLongArrayRegion(jniEnv, typedArr, 0, inputLength, (jlong * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16: { + throwOrtException(jniEnv, convertErrorCode(ORT_NOT_IMPLEMENTED), "16-bit float not supported."); + return 0; + /* + float *floatArr = malloc(sizeof(float) * inputLength); + uint16_t *halfArr = (uint16_t *) tensor; + for (uint32_t i = 0; i < inputLength; i++) { + floatArr[i] = convertHalfToFloat(halfArr[i]); + } + jfloatArray typedArr = (jfloatArray) input; + (*jniEnv)->GetFloatArrayRegion(jniEnv, typedArr, 0, inputLength, floatArr); + free(floatArr); + return consumedSize; + */ + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT: { // maps to c type float + jfloatArray typedArr = (jfloatArray) input; + (*jniEnv)->GetFloatArrayRegion(jniEnv, typedArr, 0, inputLength, (jfloat * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE: { // maps to c type double + jdoubleArray typedArr = (jdoubleArray) input; + (*jniEnv)->GetDoubleArrayRegion(jniEnv, typedArr, 0, inputLength, (jdouble * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING: { // maps to c++ type std::string + throwOrtException(jniEnv, convertErrorCode(ORT_NOT_IMPLEMENTED), "String is not supported."); + return 0; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL: { + jbooleanArray typedArr = (jbooleanArray) input; + (*jniEnv)->GetBooleanArrayRegion(jniEnv, typedArr, 0, inputLength, (jboolean *) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64: // complex with float32 real and imaginary components + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128: // complex with float64 real and imaginary components + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16: // Non-IEEE floating-point format based on IEEE754 single-precision + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED: + default: { + throwOrtException(jniEnv, convertErrorCode(ORT_INVALID_ARGUMENT), "Invalid tensor element type."); + return 0; + } + } +} + +size_t copyJavaToTensor(JNIEnv *jniEnv, ONNXTensorElementDataType onnxType, uint8_t* tensor, size_t tensorSize, + uint32_t dimensionsRemaining, jarray input) { + if (dimensionsRemaining == 1) { + // write out 1d array of the respective primitive type + return copyJavaToPrimitiveArray(jniEnv,onnxType,tensor,input); + } else { + // recurse through the dimensions + // Java arrays are objects until the final dimension + jobjectArray inputObjArr = (jobjectArray) input; + uint32_t dimLength = (*jniEnv)->GetArrayLength(jniEnv,inputObjArr); + size_t sizeConsumed = 0; + for (uint32_t i = 0; i < dimLength; i++) { + jarray childArr = (jarray) (*jniEnv)->GetObjectArrayElement(jniEnv,inputObjArr,i); + sizeConsumed += copyJavaToTensor(jniEnv, onnxType, tensor + sizeConsumed, tensorSize - sizeConsumed, dimensionsRemaining - 1, childArr); + // Cleanup reference to childArr so it doesn't prevent GC. + (*jniEnv)->DeleteLocalRef(jniEnv,childArr); + } + return sizeConsumed; + } +} + +size_t copyPrimitiveArrayToJava(JNIEnv *jniEnv, ONNXTensorElementDataType onnxType, uint8_t* tensor, jarray output) { + uint32_t outputLength = (*jniEnv)->GetArrayLength(jniEnv,output); + size_t consumedSize = outputLength * onnxTypeSize(onnxType); + switch (onnxType) { + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8: // maps to c type uint8_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT8: { // maps to c type int8_t + jbyteArray typedArr = (jbyteArray) output; + (*jniEnv)->SetByteArrayRegion(jniEnv, typedArr, 0, outputLength, (jbyte * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT16: // maps to c type uint16_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16: { // maps to c type int16_t + jshortArray typedArr = (jshortArray) output; + (*jniEnv)->SetShortArrayRegion(jniEnv, typedArr, 0, outputLength, (jshort * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT32: // maps to c type uint32_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32: { // maps to c type int32_t + jintArray typedArr = (jintArray) output; + (*jniEnv)->SetIntArrayRegion(jniEnv, typedArr, 0, outputLength, (jint * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT64: // maps to c type uint64_t + case ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64: { // maps to c type int64_t + jlongArray typedArr = (jlongArray) output; + (*jniEnv)->SetLongArrayRegion(jniEnv, typedArr, 0, outputLength, (jlong * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16: { // stored as a uint16_t + float *floatArr = malloc(sizeof(float) * outputLength); + uint16_t *halfArr = (uint16_t *) tensor; + for (uint32_t i = 0; i < outputLength; i++) { + floatArr[i] = convertHalfToFloat(halfArr[i]); + } + jfloatArray typedArr = (jfloatArray) output; + (*jniEnv)->SetFloatArrayRegion(jniEnv, typedArr, 0, outputLength, floatArr); + free(floatArr); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT: { // maps to c type float + jfloatArray typedArr = (jfloatArray) output; + (*jniEnv)->SetFloatArrayRegion(jniEnv, typedArr, 0, outputLength, (jfloat * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE: { // maps to c type double + jdoubleArray typedArr = (jdoubleArray) output; + (*jniEnv)->SetDoubleArrayRegion(jniEnv, typedArr, 0, outputLength, (jdouble * ) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING: { // maps to c++ type std::string + // Shouldn't reach here, as it's caught by a different codepath in the initial OnnxTensor.getArray call. + throwOrtException(jniEnv, convertErrorCode(ORT_NOT_IMPLEMENTED), "String is not supported by this codepath, please raise a Github issue as it should not reach here."); + return 0; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL: { + jbooleanArray typedArr = (jbooleanArray) output; + (*jniEnv)->SetBooleanArrayRegion(jniEnv, typedArr, 0, outputLength, (jboolean *) tensor); + return consumedSize; + } + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX64: // complex with float32 real and imaginary components + case ONNX_TENSOR_ELEMENT_DATA_TYPE_COMPLEX128: // complex with float64 real and imaginary components + case ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16: // Non-IEEE floating-point format based on IEEE754 single-precision + case ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED: + default: { + throwOrtException(jniEnv, convertErrorCode(ORT_NOT_IMPLEMENTED), "Invalid tensor element type."); + return 0; + } + } +} + +size_t copyTensorToJava(JNIEnv *jniEnv, ONNXTensorElementDataType onnxType, uint8_t* tensor, size_t tensorSize, + uint32_t dimensionsRemaining, jarray output) { + if (dimensionsRemaining == 1) { + // write out 1d array of the respective primitive type + return copyPrimitiveArrayToJava(jniEnv,onnxType,tensor,output); + } else { + // recurse through the dimensions + // Java arrays are objects until the final dimension + jobjectArray outputObjArr = (jobjectArray) output; + uint32_t dimLength = (*jniEnv)->GetArrayLength(jniEnv,outputObjArr); + size_t sizeConsumed = 0; + for (uint32_t i = 0; i < dimLength; i++) { + jarray childArr = (jarray) (*jniEnv)->GetObjectArrayElement(jniEnv,outputObjArr,i); + sizeConsumed += copyTensorToJava(jniEnv, onnxType, tensor + sizeConsumed, tensorSize - sizeConsumed, dimensionsRemaining - 1, childArr); + // Cleanup reference to childArr so it doesn't prevent GC. + (*jniEnv)->DeleteLocalRef(jniEnv,childArr); + } + return sizeConsumed; + } +} + +jobject createStringFromStringTensor(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* tensor) { + // Get the buffer size needed + size_t totalStringLength; + checkOrtStatus(jniEnv,api,api->GetStringTensorDataLength(tensor,&totalStringLength)); + + // Create the character and offset buffers + char * characterBuffer; + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,sizeof(char)*(totalStringLength+1),(void**)&characterBuffer)); + size_t * offsets; + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,sizeof(size_t),(void**)&offsets)); + + // Get a view on the String data + checkOrtStatus(jniEnv,api,api->GetStringTensorContent(tensor,characterBuffer,totalStringLength,offsets,1)); + + size_t curSize = (offsets[0]) + 1; + characterBuffer[curSize-1] = '\0'; + jobject tempString = (*jniEnv)->NewStringUTF(jniEnv,characterBuffer); + + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,characterBuffer)); + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,offsets)); + + return tempString; +} + +void copyStringTensorToArray(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* tensor, size_t length, jobjectArray outputArray) { + // Get the buffer size needed + size_t totalStringLength; + checkOrtStatus(jniEnv,api,api->GetStringTensorDataLength(tensor,&totalStringLength)); + + // Create the character and offset buffers + char * characterBuffer; + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,sizeof(char)*(totalStringLength+length),(void**)&characterBuffer)); + // length + 1 as we need to write out the final offset + size_t * offsets; + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,sizeof(size_t)*(length+1),(void**)&offsets)); + + // Get a view on the String data + checkOrtStatus(jniEnv,api,api->GetStringTensorContent(tensor,characterBuffer,totalStringLength,offsets,length)); + + // Get the final offset, write to the end of the array. + checkOrtStatus(jniEnv,api,api->GetStringTensorDataLength(tensor,offsets+length)); + + char * tempBuffer = NULL; + size_t bufferSize = 0; + for (size_t i = 0; i < length; i++) { + size_t curSize = (offsets[i+1] - offsets[i]) + 1; + if (curSize > bufferSize) { + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,tempBuffer)); + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,curSize,(void**)&tempBuffer)); + bufferSize = curSize; + } + memcpy(tempBuffer,characterBuffer+offsets[i],curSize); + tempBuffer[curSize-1] = '\0'; + jobject tempString = (*jniEnv)->NewStringUTF(jniEnv,tempBuffer); + (*jniEnv)->SetObjectArrayElement(jniEnv,outputArray,i,tempString); + } + + if (tempBuffer != NULL) { + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,tempBuffer)); + } + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,characterBuffer)); + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,offsets)); +} + +jobjectArray createStringArrayFromTensor(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* tensor) { + // Extract tensor info + OrtTensorTypeAndShapeInfo* tensorInfo; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(tensor,&tensorInfo)); + + // Get the element count of this tensor + size_t length; + checkOrtStatus(jniEnv,api,api->GetTensorShapeElementCount(tensorInfo,&length)); + api->ReleaseTensorTypeAndShapeInfo(tensorInfo); + + // Create the java array + jclass stringClazz = (*jniEnv)->FindClass(jniEnv,"java/lang/String"); + jobjectArray outputArray = (*jniEnv)->NewObjectArray(jniEnv,length,stringClazz,NULL); + + copyStringTensorToArray(jniEnv, api, allocator, tensor, length, outputArray); + + return outputArray; +} + +jlongArray createLongArrayFromTensor(JNIEnv *jniEnv, const OrtApi * api, OrtValue* tensor) { + // Extract tensor type + OrtTensorTypeAndShapeInfo* tensorInfo; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(tensor,&tensorInfo)); + ONNXTensorElementDataType value; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(tensorInfo,&value)); + + // Get the element count of this tensor + size_t length; + checkOrtStatus(jniEnv,api,api->GetTensorShapeElementCount(tensorInfo,&length)); + api->ReleaseTensorTypeAndShapeInfo(tensorInfo); + + // Extract the values + uint8_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)tensor,(void**)&arr)); + + // Create the java array and copy to it. + jlongArray outputArray = (*jniEnv)->NewLongArray(jniEnv,length); + copyPrimitiveArrayToJava(jniEnv, value, arr, outputArray); + return outputArray; +} + +jfloatArray createFloatArrayFromTensor(JNIEnv *jniEnv, const OrtApi * api, OrtValue* tensor) { + // Extract tensor type + OrtTensorTypeAndShapeInfo* tensorInfo; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(tensor,&tensorInfo)); + ONNXTensorElementDataType value; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(tensorInfo,&value)); + + // Get the element count of this tensor + size_t length; + checkOrtStatus(jniEnv,api,api->GetTensorShapeElementCount(tensorInfo,&length)); + api->ReleaseTensorTypeAndShapeInfo(tensorInfo); + + // Extract the values + uint8_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)tensor,(void**)&arr)); + + // Create the java array and copy to it. + jfloatArray outputArray = (*jniEnv)->NewFloatArray(jniEnv,length); + copyPrimitiveArrayToJava(jniEnv, value, arr, outputArray); + return outputArray; +} + +jdoubleArray createDoubleArrayFromTensor(JNIEnv *jniEnv, const OrtApi * api, OrtValue* tensor) { + // Extract tensor type + OrtTensorTypeAndShapeInfo* tensorInfo; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(tensor,&tensorInfo)); + ONNXTensorElementDataType value; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(tensorInfo,&value)); + + // Get the element count of this tensor + size_t length; + checkOrtStatus(jniEnv,api,api->GetTensorShapeElementCount(tensorInfo,&length)); + api->ReleaseTensorTypeAndShapeInfo(tensorInfo); + + // Extract the values + uint8_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)tensor,(void**)&arr)); + + // Create the java array and copy to it. + jdoubleArray outputArray = (*jniEnv)->NewDoubleArray(jniEnv,length); + copyPrimitiveArrayToJava(jniEnv, value, arr, outputArray); + return outputArray; +} + +jobject createJavaTensorFromONNX(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* tensor) { + // Extract the type information + OrtTensorTypeAndShapeInfo* info; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(tensor, &info)); + + // Construct the TensorInfo object + jobject tensorInfo = convertToTensorInfo(jniEnv, api, info); + + // Release the info object + api->ReleaseTensorTypeAndShapeInfo(info); + + // Construct the ONNXTensor object + char *tensorClassName = "ai/onnxruntime/OnnxTensor"; + jclass clazz = (*jniEnv)->FindClass(jniEnv, tensorClassName); + jmethodID tensorConstructor = (*jniEnv)->GetMethodID(jniEnv,clazz, "", "(JJLai/onnxruntime/TensorInfo;)V"); + jobject javaTensor = (*jniEnv)->NewObject(jniEnv, clazz, tensorConstructor, (jlong) tensor, (jlong) allocator, tensorInfo); + + return javaTensor; +} + +jobject createJavaSequenceFromONNX(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* sequence) { + // Setup + // Get the ONNXTensorType enum static method + char *onnxTensorTypeClassName = "ai/onnxruntime/TensorInfo$OnnxTensorType"; + jclass onnxTensorTypeClazz = (*jniEnv)->FindClass(jniEnv, onnxTensorTypeClassName); + jmethodID onnxTensorTypeMapFromInt = (*jniEnv)->GetStaticMethodID(jniEnv,onnxTensorTypeClazz, "mapFromInt", "(I)Lai/onnxruntime/TensorInfo$OnnxTensorType;"); + + // Get the ONNXJavaType enum static method + char *javaDataTypeClassName = "ai/onnxruntime/OnnxJavaType"; + jclass onnxJavaTypeClazz = (*jniEnv)->FindClass(jniEnv, javaDataTypeClassName); + jmethodID onnxJavaTypeMapFromONNXTensorType = (*jniEnv)->GetStaticMethodID(jniEnv,onnxJavaTypeClazz, "mapFromOnnxTensorType", "(Lai/onnxruntime/TensorInfo$OnnxTensorType;)Lai/onnxruntime/OnnxJavaType;"); + + // Get the sequence info class + char *sequenceInfoClassName = "ai/onnxruntime/SequenceInfo"; + jclass sequenceInfoClazz = (*jniEnv)->FindClass(jniEnv, sequenceInfoClassName); + + // Get the element count of this sequence + size_t count; + checkOrtStatus(jniEnv,api,api->GetValueCount(sequence,&count)); + + // Extract the first element + OrtValue* firstElement; + checkOrtStatus(jniEnv,api,api->GetValue(sequence,0,allocator,&firstElement)); + ONNXType elementType; + checkOrtStatus(jniEnv,api,api->GetValueType(firstElement,&elementType)); + jobject sequenceInfo; + switch (elementType) { + case ONNX_TYPE_TENSOR: { + // Figure out element type + OrtTensorTypeAndShapeInfo* firstElementInfo; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(firstElement,&firstElementInfo)); + ONNXTensorElementDataType element; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(firstElementInfo,&element)); + api->ReleaseTensorTypeAndShapeInfo(firstElementInfo); + + // Convert element type into ONNXTensorType + jint onnxTypeInt = convertFromONNXDataFormat(element); + jobject onnxTensorTypeJava = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxTensorTypeClazz,onnxTensorTypeMapFromInt,onnxTypeInt); + jobject onnxJavaType = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxJavaTypeClazz,onnxJavaTypeMapFromONNXTensorType,onnxTensorTypeJava); + + // Construct sequence info + jmethodID sequenceInfoConstructor = (*jniEnv)->GetMethodID(jniEnv,sequenceInfoClazz,"","(ILai/onnxruntime/OnnxJavaType;)V"); + sequenceInfo = (*jniEnv)->NewObject(jniEnv,sequenceInfoClazz,sequenceInfoConstructor,(jint)count,onnxJavaType); + break; + } + case ONNX_TYPE_MAP: { + // Extract key + OrtValue* keys; + checkOrtStatus(jniEnv,api,api->GetValue(firstElement,0,allocator,&keys)); + + // Extract key type + OrtTensorTypeAndShapeInfo* keysInfo; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(keys,&keysInfo)); + ONNXTensorElementDataType key; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(keysInfo,&key)); + + // Get the element count of this map + size_t mapCount; + checkOrtStatus(jniEnv,api,api->GetTensorShapeElementCount(keysInfo,&mapCount)); + + api->ReleaseTensorTypeAndShapeInfo(keysInfo); + + // Convert key type to java + jint onnxTypeKey = convertFromONNXDataFormat(key); + jobject onnxTensorTypeJavaKey = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxTensorTypeClazz,onnxTensorTypeMapFromInt,onnxTypeKey); + jobject onnxJavaTypeKey = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxJavaTypeClazz,onnxJavaTypeMapFromONNXTensorType,onnxTensorTypeJavaKey); + + // Extract value + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue(firstElement,1,allocator,&values)); + + // Extract value type + OrtTensorTypeAndShapeInfo* valuesInfo; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(values,&valuesInfo)); + ONNXTensorElementDataType value; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(valuesInfo,&value)); + api->ReleaseTensorTypeAndShapeInfo(valuesInfo); + + // Convert value type to java + jint onnxTypeValue = convertFromONNXDataFormat(value); + jobject onnxTensorTypeJavaValue = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxTensorTypeClazz,onnxTensorTypeMapFromInt,onnxTypeValue); + jobject onnxJavaTypeValue = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxJavaTypeClazz,onnxJavaTypeMapFromONNXTensorType,onnxTensorTypeJavaValue); + + // Get the map info class + char *mapInfoClassName = "ai/onnxruntime/MapInfo"; + jclass mapInfoClazz = (*jniEnv)->FindClass(jniEnv, mapInfoClassName); + // Construct map info + jmethodID mapInfoConstructor = (*jniEnv)->GetMethodID(jniEnv,mapInfoClazz,"","(ILai/onnxruntime/OnnxJavaType;Lai/onnxruntime/OnnxJavaType;)V"); + jobject mapInfo = (*jniEnv)->NewObject(jniEnv,mapInfoClazz,mapInfoConstructor,(jint)mapCount,onnxJavaTypeKey,onnxJavaTypeValue); + + // Free the intermediate tensors. + api->ReleaseValue(keys); + api->ReleaseValue(values); + + // Construct sequence info + jmethodID sequenceInfoConstructor = (*jniEnv)->GetMethodID(jniEnv,sequenceInfoClazz,"","(ILai/onnxruntime/MapInfo;)V"); + sequenceInfo = (*jniEnv)->NewObject(jniEnv,sequenceInfoClazz,sequenceInfoConstructor,(jint)count,mapInfo); + break; + } + default: { + sequenceInfo = createEmptySequenceInfo(jniEnv); + throwOrtException(jniEnv,convertErrorCode(ORT_INVALID_ARGUMENT),"Invalid element type found in sequence"); + break; + } + } + + // Free the intermediate tensor. + api->ReleaseValue(firstElement); + + // Construct the ONNXSequence object + char *sequenceClassName = "ai/onnxruntime/OnnxSequence"; + jclass sequenceClazz = (*jniEnv)->FindClass(jniEnv, sequenceClassName); + jmethodID sequenceConstructor = (*jniEnv)->GetMethodID(jniEnv,sequenceClazz, "", "(JJLai/onnxruntime/SequenceInfo;)V"); + jobject javaSequence = (*jniEnv)->NewObject(jniEnv, sequenceClazz, sequenceConstructor, (jlong)sequence, (jlong)allocator, sequenceInfo); + + return javaSequence; +} + +jobject createJavaMapFromONNX(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* map) { + // Setup + // Get the ONNXTensorType enum static method + char *onnxTensorTypeClassName = "ai/onnxruntime/TensorInfo$OnnxTensorType"; + jclass onnxTensorTypeClazz = (*jniEnv)->FindClass(jniEnv, onnxTensorTypeClassName); + jmethodID onnxTensorTypeMapFromInt = (*jniEnv)->GetStaticMethodID(jniEnv,onnxTensorTypeClazz, "mapFromInt", "(I)Lai/onnxruntime/TensorInfo$OnnxTensorType;"); + + // Get the ONNXJavaType enum static method + char *javaDataTypeClassName = "ai/onnxruntime/OnnxJavaType"; + jclass onnxJavaTypeClazz = (*jniEnv)->FindClass(jniEnv, javaDataTypeClassName); + jmethodID onnxJavaTypeMapFromONNXTensorType = (*jniEnv)->GetStaticMethodID(jniEnv,onnxJavaTypeClazz, "mapFromOnnxTensorType", "(Lai/onnxruntime/TensorInfo$OnnxTensorType;)Lai/onnxruntime/OnnxJavaType;"); + + // Get the map info class + char *mapInfoClassName = "ai/onnxruntime/MapInfo"; + jclass mapInfoClazz = (*jniEnv)->FindClass(jniEnv, mapInfoClassName); + + // Extract key + OrtValue* keys; + checkOrtStatus(jniEnv,api,api->GetValue(map,0,allocator,&keys)); + + // Extract key type + OrtTensorTypeAndShapeInfo* keysInfo; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(keys,&keysInfo)); + ONNXTensorElementDataType key; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(keysInfo,&key)); + + // Get the element count of this map + size_t mapCount; + checkOrtStatus(jniEnv,api,api->GetTensorShapeElementCount(keysInfo,&mapCount)); + + api->ReleaseTensorTypeAndShapeInfo(keysInfo); + + // Convert key type to java + jint onnxTypeKey = convertFromONNXDataFormat(key); + jobject onnxTensorTypeJavaKey = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxTensorTypeClazz,onnxTensorTypeMapFromInt,onnxTypeKey); + jobject onnxJavaTypeKey = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxJavaTypeClazz,onnxJavaTypeMapFromONNXTensorType,onnxTensorTypeJavaKey); + + // Extract value + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue(map,1,allocator,&values)); + + // Extract value type + OrtTensorTypeAndShapeInfo* valuesInfo; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(values,&valuesInfo)); + ONNXTensorElementDataType value; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(valuesInfo,&value)); + api->ReleaseTensorTypeAndShapeInfo(valuesInfo); + + // Convert value type to java + jint onnxTypeValue = convertFromONNXDataFormat(value); + jobject onnxTensorTypeJavaValue = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxTensorTypeClazz,onnxTensorTypeMapFromInt,onnxTypeValue); + jobject onnxJavaTypeValue = (*jniEnv)->CallStaticObjectMethod(jniEnv,onnxJavaTypeClazz,onnxJavaTypeMapFromONNXTensorType,onnxTensorTypeJavaValue); + + // Construct map info + jmethodID mapInfoConstructor = (*jniEnv)->GetMethodID(jniEnv,mapInfoClazz,"","(ILai/onnxruntime/OnnxJavaType;Lai/onnxruntime/OnnxJavaType;)V"); + jobject mapInfo = (*jniEnv)->NewObject(jniEnv,mapInfoClazz,mapInfoConstructor,(jint)mapCount,onnxJavaTypeKey,onnxJavaTypeValue); + + // Free the intermediate tensors. + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,keys)); + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,values)); + + // Construct the ONNXMap object + char *mapClassName = "ai/onnxruntime/OnnxMap"; + jclass mapClazz = (*jniEnv)->FindClass(jniEnv, mapClassName); + jmethodID mapConstructor = (*jniEnv)->GetMethodID(jniEnv,mapClazz, "", "(JJLai/onnxruntime/MapInfo;)V"); + jobject javaMap = (*jniEnv)->NewObject(jniEnv, mapClazz, mapConstructor, (jlong)map, (jlong) allocator, mapInfo); + + return javaMap; +} + +jobject convertOrtValueToONNXValue(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* onnxValue) { + // Note this is the ONNXType C enum + ONNXType valueType; + checkOrtStatus(jniEnv,api,api->GetValueType(onnxValue,&valueType)); + switch (valueType) { + case ONNX_TYPE_TENSOR: { + return createJavaTensorFromONNX(jniEnv, api, allocator, onnxValue); + } + case ONNX_TYPE_SEQUENCE: { + return createJavaSequenceFromONNX(jniEnv, api, allocator, onnxValue); + } + case ONNX_TYPE_MAP: { + return createJavaMapFromONNX(jniEnv, api, allocator, onnxValue); + } + case ONNX_TYPE_UNKNOWN: + case ONNX_TYPE_OPAQUE: + case ONNX_TYPE_SPARSETENSOR: { + throwOrtException(jniEnv,convertErrorCode(ORT_NOT_IMPLEMENTED),"These types are unsupported - ONNX_TYPE_UNKNOWN, ONNX_TYPE_OPAQUE, ONNX_TYPE_SPARSETENSOR."); + break; + } + } + return NULL; +} + +jint throwOrtException(JNIEnv *jniEnv, int messageId, const char *message) { + jstring messageStr = (*jniEnv)->NewStringUTF(jniEnv, message); + + char *className = "ai/onnxruntime/OrtException"; + jclass exClazz = (*jniEnv)->FindClass(jniEnv,className); + jmethodID exConstructor = (*jniEnv)->GetMethodID(jniEnv, exClazz, "", "(ILjava/lang/String;)V"); + jobject javaException = (*jniEnv)->NewObject(jniEnv, exClazz, exConstructor, messageId, messageStr); + + return (*jniEnv)->Throw(jniEnv,javaException); +} + +jint convertErrorCode(OrtErrorCode code) { + switch (code) { + case ORT_OK: + return 0; + case ORT_FAIL: + return 1; + case ORT_INVALID_ARGUMENT: + return 2; + case ORT_NO_SUCHFILE: + return 3; + case ORT_NO_MODEL: + return 4; + case ORT_ENGINE_ERROR: + return 5; + case ORT_RUNTIME_EXCEPTION: + return 6; + case ORT_INVALID_PROTOBUF: + return 7; + case ORT_MODEL_LOADED: + return 8; + case ORT_NOT_IMPLEMENTED: + return 9; + case ORT_INVALID_GRAPH: + return 10; + case ORT_EP_FAIL: + return 11; + default: + return -1; // Unknown error code + } +} + +void checkOrtStatus(JNIEnv *jniEnv, const OrtApi * api, OrtStatus * status) { + if (status != NULL) { + const char* message = api->GetErrorMessage(status); + int len = strlen(message)+1; + char* copy = malloc(sizeof(char)*len); + memcpy(copy,message,len); + int messageId = convertErrorCode(api->GetErrorCode(status)); + api->ReleaseStatus(status); + throwOrtException(jniEnv,messageId,copy); + } +} diff --git a/java/src/main/native/OrtJniUtil.h b/java/src/main/native/OrtJniUtil.h new file mode 100644 index 0000000000000..4f05096215685 --- /dev/null +++ b/java/src/main/native/OrtJniUtil.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include "onnxruntime/core/session/onnxruntime_c_api.h" + +#ifndef __ONNXUtil_h +#define __ONNXUtil_h +#ifdef __cplusplus +extern "C" { +#endif + +jint JNI_OnLoad(JavaVM *vm, void *reserved); + +OrtLoggingLevel convertLoggingLevel(jint level); + +GraphOptimizationLevel convertOptimizationLevel(jint level); + +ExecutionMode convertExecutionMode(jint mode); + +jint convertFromONNXDataFormat(ONNXTensorElementDataType type); + +ONNXTensorElementDataType convertToONNXDataFormat(jint type); + +size_t onnxTypeSize(ONNXTensorElementDataType type); + +jfloat convertHalfToFloat(uint16_t half); + +jobject convertToValueInfo(JNIEnv *jniEnv, const OrtApi * api, OrtTypeInfo * info); + +jobject convertToTensorInfo(JNIEnv *jniEnv, const OrtApi * api, const OrtTensorTypeAndShapeInfo * info); + +//TODO when C API supports inspecting the types of map and sequence types from OutputInfos +//jobject convertToMapInfo(JNIEnv *jniEnv, const OrtApi * api, const OrtTypeInfo * info); +//jobject convertToSequenceInfo(JNIEnv *jniEnv, const OrtApi * api, const OrtTypeInfo * info); + +jobject createEmptyMapInfo(JNIEnv *jniEnv); +jobject createEmptySequenceInfo(JNIEnv *jniEnv); + +size_t copyJavaToPrimitiveArray(JNIEnv *jniEnv, ONNXTensorElementDataType onnxType, uint8_t* tensor, jarray input); + +size_t copyJavaToTensor(JNIEnv *jniEnv, ONNXTensorElementDataType onnxType, uint8_t* tensor, size_t tensorSize, uint32_t dimensionsRemaining, jarray input); + +size_t copyPrimitiveArrayToJava(JNIEnv *jniEnv, ONNXTensorElementDataType onnxType, uint8_t* tensor, jarray output); + +size_t copyTensorToJava(JNIEnv *jniEnv, ONNXTensorElementDataType onnxType, uint8_t* tensor, size_t tensorSize, uint32_t dimensionsRemaining, jarray output); + +jobject createStringFromStringTensor(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* tensor); + +void copyStringTensorToArray(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* tensor, size_t length, jobjectArray outputArray); + +jobjectArray createStringArrayFromTensor(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* tensor); + +jlongArray createLongArrayFromTensor(JNIEnv *jniEnv, const OrtApi * api, OrtValue* tensor); + +jfloatArray createFloatArrayFromTensor(JNIEnv *jniEnv, const OrtApi * api, OrtValue* tensor); + +jdoubleArray createDoubleArrayFromTensor(JNIEnv *jniEnv, const OrtApi * api, OrtValue* tensor); + +jobject createJavaTensorFromONNX(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* tensor); + +jobject createJavaSequenceFromONNX(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* sequence); + +jobject createJavaMapFromONNX(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* map); + +jobject convertOrtValueToONNXValue(JNIEnv *jniEnv, const OrtApi * api, OrtAllocator* allocator, OrtValue* onnxValue); + +jint throwOrtException(JNIEnv *env, int messageId, const char *message); + +jint convertErrorCode(OrtErrorCode code); + +void checkOrtStatus(JNIEnv * env, const OrtApi * api, OrtStatus * status); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/src/main/native/ai_onnxruntime_OnnxMap.c b/java/src/main/native/ai_onnxruntime_OnnxMap.c new file mode 100644 index 0000000000000..cc83c4dc3ae26 --- /dev/null +++ b/java/src/main/native/ai_onnxruntime_OnnxMap.c @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include "onnxruntime/core/session/onnxruntime_c_api.h" +#include "OrtJniUtil.h" +#include "ai_onnxruntime_OnnxMap.h" + +/* + * Class: ai_onnxruntime_OnnxMap + * Method: getStringKeys + * Signature: (J)[Ljava/lang/String; + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OnnxMap_getStringKeys + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract key + OrtValue* keys; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,0,allocator,&keys)); + + // Convert to Java String array + jobjectArray output = createStringArrayFromTensor(jniEnv, api, allocator, keys); + + api->ReleaseValue(keys); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxMap + * Method: getLongKeys + * Signature: (JJ)[J + */ +JNIEXPORT jlongArray JNICALL Java_ai_onnxruntime_OnnxMap_getLongKeys + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract key + OrtValue* keys; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,0,allocator,&keys)); + + jlongArray output = createLongArrayFromTensor(jniEnv, api, keys); + + api->ReleaseValue(keys); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxMap + * Method: getStringValues + * Signature: (JJ)[Ljava/lang/String; + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OnnxMap_getStringValues + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract value + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,1,allocator,&values)); + + // Convert to Java String array + jobjectArray output = createStringArrayFromTensor(jniEnv, api, allocator, values); + + api->ReleaseValue(values); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxMap + * Method: getLongValues + * Signature: (JJ)[J + */ +JNIEXPORT jlongArray JNICALL Java_ai_onnxruntime_OnnxMap_getLongValues + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract value + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,1,allocator,&values)); + + jlongArray output = createLongArrayFromTensor(jniEnv, api, values); + + api->ReleaseValue(values); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxMap + * Method: getFloatValues + * Signature: (JJ)[F + */ +JNIEXPORT jfloatArray JNICALL Java_ai_onnxruntime_OnnxMap_getFloatValues + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract value + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,1,allocator,&values)); + + jfloatArray output = createFloatArrayFromTensor(jniEnv, api, values); + + api->ReleaseValue(values); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxMap + * Method: getDoubleValues + * Signature: (JJ)[D + */ +JNIEXPORT jdoubleArray JNICALL Java_ai_onnxruntime_OnnxMap_getDoubleValues + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract value + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,1,allocator,&values)); + + jdoubleArray output = createDoubleArrayFromTensor(jniEnv, api, values); + + api->ReleaseValue(values); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxMap + * Method: close + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OnnxMap_close + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jniEnv; (void) jobj; // Required JNI parameters not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + api->ReleaseValue((OrtValue*)handle); +} diff --git a/java/src/main/native/ai_onnxruntime_OnnxRuntime.c b/java/src/main/native/ai_onnxruntime_OnnxRuntime.c new file mode 100644 index 0000000000000..5e47f372711d1 --- /dev/null +++ b/java/src/main/native/ai_onnxruntime_OnnxRuntime.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include "onnxruntime/core/session/onnxruntime_c_api.h" +#include "ai_onnxruntime_OnnxRuntime.h" + +/* + * Class: ai_onnxruntime_OnnxRuntime + * Method: initialiseAPIBase + * Signature: (I)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OnnxRuntime_initialiseAPIBase + (JNIEnv * jniEnv, jclass clazz, jint apiVersion) { + (void) jniEnv; (void) clazz; // required JNI parameters not needed by functions which don't call back into Java. + const OrtApi* ortPtr = OrtGetApiBase()->GetApi((uint32_t) apiVersion); + return (jlong) ortPtr; +} + diff --git a/java/src/main/native/ai_onnxruntime_OnnxSequence.c b/java/src/main/native/ai_onnxruntime_OnnxSequence.c new file mode 100644 index 0000000000000..b045ce4665e21 --- /dev/null +++ b/java/src/main/native/ai_onnxruntime_OnnxSequence.c @@ -0,0 +1,325 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include "onnxruntime/core/session/onnxruntime_c_api.h" +#include "OrtJniUtil.h" +#include "ai_onnxruntime_OnnxSequence.h" +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getStringKeys + * Signature: (JJI)[Ljava/lang/String; + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OnnxSequence_getStringKeys + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle, jint index) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,index,allocator,&element)); + + // Extract keys from element + OrtValue* keys; + checkOrtStatus(jniEnv,api,api->GetValue(element,0,allocator,&keys)); + + // Convert to Java String array + jobjectArray output = createStringArrayFromTensor(jniEnv, api, allocator, keys); + + api->ReleaseValue(keys); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getLongKeys + * Signature: (JJI)[J + */ +JNIEXPORT jlongArray JNICALL Java_ai_onnxruntime_OnnxSequence_getLongKeys + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle, jint index) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,index,allocator,&element)); + + // Extract keys from element + OrtValue* keys; + checkOrtStatus(jniEnv,api,api->GetValue(element,0,allocator,&keys)); + + jlongArray output = createLongArrayFromTensor(jniEnv, api, keys); + + api->ReleaseValue(keys); + api->ReleaseValue(element); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getStringValues + * Signature: (JJI)[Ljava/lang/String; + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OnnxSequence_getStringValues + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle, jint index) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,index,allocator,&element)); + + // Extract values from element + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue(element,1,allocator,&values)); + + // Convert to Java String array + jobjectArray output = createStringArrayFromTensor(jniEnv, api, allocator, values); + + api->ReleaseValue(values); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getLongValues + * Signature: (JJI)[J + */ +JNIEXPORT jlongArray JNICALL Java_ai_onnxruntime_OnnxSequence_getLongValues + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle, jint index) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,index,allocator,&element)); + + // Extract values from element + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue(element,1,allocator,&values)); + + jlongArray output = createLongArrayFromTensor(jniEnv, api, values); + + api->ReleaseValue(values); + api->ReleaseValue(element); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getFloatValues + * Signature: (JJI)[F + */ +JNIEXPORT jfloatArray JNICALL Java_ai_onnxruntime_OnnxSequence_getFloatValues + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle, jint index) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,index,allocator,&element)); + + // Extract values from element + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue(element,1,allocator,&values)); + + jfloatArray output = createFloatArrayFromTensor(jniEnv, api,values); + + api->ReleaseValue(values); + api->ReleaseValue(element); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getDoubleValues + * Signature: (JJI)[D + */ +JNIEXPORT jdoubleArray JNICALL Java_ai_onnxruntime_OnnxSequence_getDoubleValues + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle, jint index) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue((OrtValue*)handle,index,allocator,&element)); + + // Extract values from element + OrtValue* values; + checkOrtStatus(jniEnv,api,api->GetValue(element,1,allocator,&values)); + + jdoubleArray output = createDoubleArrayFromTensor(jniEnv, api,values); + + api->ReleaseValue(values); + api->ReleaseValue(element); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getStrings + * Signature: (JJ)[Ljava/lang/String; + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OnnxSequence_getStrings + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtValue* sequence = (OrtValue*) handle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Get the element count of this sequence + size_t count; + checkOrtStatus(jniEnv,api,api->GetValueCount(sequence,&count)); + + jclass stringClazz = (*jniEnv)->FindClass(jniEnv,"java/lang/String"); + jobjectArray outputArray = (*jniEnv)->NewObjectArray(jniEnv,count,stringClazz,NULL); + for (size_t i = 0; i < count; i++) { + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue(sequence,i,allocator,&element)); + + createStringFromStringTensor(jniEnv,api,allocator,element); + + api->ReleaseValue(element); + } + + return outputArray; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getLongs + * Signature: (JJ)[J + */ +JNIEXPORT jlongArray JNICALL Java_ai_onnxruntime_OnnxSequence_getLongs + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtValue* sequence = (OrtValue*) handle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Get the element count of this sequence + size_t count; + checkOrtStatus(jniEnv,api,api->GetValueCount(sequence,&count)); + + int64_t* values; + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,sizeof(int64_t)*count,(void**)&values)); + + for (size_t i = 0; i < count; i++) { + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue(sequence,i,allocator,&element)); + + // Extract the values + int64_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData(element,(void**)&arr)); + values[i] = arr[0]; + + api->ReleaseValue(element); + } + + jlongArray outputArray = (*jniEnv)->NewLongArray(jniEnv,count); + (*jniEnv)->SetLongArrayRegion(jniEnv,outputArray,0,count,(jlong*)values); + + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,values)); + + return outputArray; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getFloats + * Signature: (JJ)[F + */ +JNIEXPORT jfloatArray JNICALL Java_ai_onnxruntime_OnnxSequence_getFloats + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtValue* sequence = (OrtValue*) handle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Get the element count of this sequence + size_t count; + checkOrtStatus(jniEnv,api,api->GetValueCount(sequence,&count)); + + float* values; + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,sizeof(float)*count,(void**)&values)); + + for (size_t i = 0; i < count; i++) { + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue(sequence,i,allocator,&element)); + + // Extract the values + float* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData(element,(void**)&arr)); + values[i] = arr[0]; + + api->ReleaseValue(element); + } + + jfloatArray outputArray = (*jniEnv)->NewFloatArray(jniEnv,count); + (*jniEnv)->SetFloatArrayRegion(jniEnv,outputArray,0,count,values); + + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,values)); + + return outputArray; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: getDoubles + * Signature: (JJ)[D + */ +JNIEXPORT jdoubleArray JNICALL Java_ai_onnxruntime_OnnxSequence_getDoubles + (JNIEnv *jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtValue* sequence = (OrtValue*) handle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Get the element count of this sequence + size_t count; + checkOrtStatus(jniEnv,api,api->GetValueCount(sequence,&count)); + + double* values; + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,sizeof(double)*count,(void**)&values)); + + for (size_t i = 0; i < count; i++) { + // Extract element + OrtValue* element; + checkOrtStatus(jniEnv,api,api->GetValue(sequence,i,allocator,&element)); + + // Extract the values + double* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData(element,(void**)&arr)); + values[i] = arr[0]; + + api->ReleaseValue(element); + } + + jdoubleArray outputArray = (*jniEnv)->NewDoubleArray(jniEnv,count); + (*jniEnv)->SetDoubleArrayRegion(jniEnv,outputArray,0,count,values); + + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,values)); + + return outputArray; +} + +/* + * Class: ai_onnxruntime_OnnxSequence + * Method: close + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OnnxSequence_close(JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jniEnv; (void) jobj; // Required JNI parameters not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + api->ReleaseValue((OrtValue*)handle); +} diff --git a/java/src/main/native/ai_onnxruntime_OnnxTensor.c b/java/src/main/native/ai_onnxruntime_OnnxTensor.c new file mode 100644 index 0000000000000..b24e7a62b2960 --- /dev/null +++ b/java/src/main/native/ai_onnxruntime_OnnxTensor.c @@ -0,0 +1,398 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include +#include "onnxruntime/core/session/onnxruntime_c_api.h" +#include "OrtJniUtil.h" +#include "ai_onnxruntime_OnnxTensor.h" + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: createTensor + * Signature: (JJLjava/lang/Object;[JI)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OnnxTensor_createTensor + (JNIEnv * jniEnv, jclass jobj, jlong apiHandle, jlong allocatorHandle, jobject dataObj, jlongArray shape, jint onnxTypeJava) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Convert type to ONNX C enum + ONNXTensorElementDataType onnxType = convertToONNXDataFormat(onnxTypeJava); + + // Extract the shape information + jboolean mkCopy; + jlong* shapeArr = (*jniEnv)->GetLongArrayElements(jniEnv,shape,&mkCopy); + jsize shapeLen = (*jniEnv)->GetArrayLength(jniEnv,shape); + + // Create the OrtValue + OrtValue* ortValue; + checkOrtStatus(jniEnv, api, api->CreateTensorAsOrtValue(allocator,(int64_t*)shapeArr,shapeLen,onnxType,&ortValue)); + (*jniEnv)->ReleaseLongArrayElements(jniEnv,shape,shapeArr,JNI_ABORT); + + // Get a reference to the OrtValue's data + uint8_t* tensorData; + checkOrtStatus(jniEnv, api, api->GetTensorMutableData(ortValue, (void**) &tensorData)); + + // Extract the tensor shape information + OrtTensorTypeAndShapeInfo* info; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape(ortValue, &info)); + size_t dimensions; + checkOrtStatus(jniEnv,api,api->GetDimensionsCount(info,&dimensions)); + size_t arrSize; + checkOrtStatus(jniEnv,api,api->GetTensorShapeElementCount(info,&arrSize)); + ONNXTensorElementDataType onnxTypeEnum; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(info,&onnxTypeEnum)); + api->ReleaseTensorTypeAndShapeInfo(info); + + // Copy the java array into the tensor + copyJavaToTensor(jniEnv, onnxType, tensorData, arrSize, dimensions, dataObj); + + // Return the pointer to the OrtValue + return (jlong) ortValue; +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: createTensorFromBuffer + * Signature: (JJLjava/nio/Buffer;J[JI)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OnnxTensor_createTensorFromBuffer + (JNIEnv * jniEnv, jclass jobj, jlong apiHandle, jlong allocatorHandle, jobject buffer, jlong bufferSize, jlongArray shape, jint onnxTypeJava) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + const OrtMemoryInfo* allocatorInfo; + checkOrtStatus(jniEnv, api, api->AllocatorGetInfo(allocator,&allocatorInfo)); + + // Convert type to ONNX C enum + ONNXTensorElementDataType onnxType = convertToONNXDataFormat(onnxTypeJava); + + // Extract the buffer + void* bufferArr = (*jniEnv)->GetDirectBufferAddress(jniEnv,buffer); + + // Extract the shape information + jboolean mkCopy; + jlong* shapeArr = (*jniEnv)->GetLongArrayElements(jniEnv,shape,&mkCopy); + jsize shapeLen = (*jniEnv)->GetArrayLength(jniEnv,shape); + + // Create the OrtValue + OrtValue* ortValue; + checkOrtStatus(jniEnv, api, api->CreateTensorWithDataAsOrtValue(allocatorInfo,bufferArr,bufferSize,(int64_t*)shapeArr,shapeLen,onnxType,&ortValue)); + (*jniEnv)->ReleaseLongArrayElements(jniEnv,shape,shapeArr,JNI_ABORT); + + // Return the pointer to the OrtValue + return (jlong) ortValue; +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: createString + * Signature: (JJLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OnnxTensor_createString + (JNIEnv * jniEnv, jclass jobj, jlong apiHandle, jlong allocatorHandle, jstring input) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Extract the shape information + int64_t* shapeArr; + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,sizeof(int64_t),(void**)&shapeArr)); + shapeArr[0] = 1; + + // Create the OrtValue + OrtValue* ortValue; + checkOrtStatus(jniEnv, api, api->CreateTensorAsOrtValue(allocator,shapeArr,1,ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING,&ortValue)); + + // Release the shape + checkOrtStatus(jniEnv, api, api->AllocatorFree(allocator,shapeArr)); + + // Create the buffer for the Java string + const char* stringBuffer = (*jniEnv)->GetStringUTFChars(jniEnv,input,NULL); + + // Assign the strings into the Tensor + checkOrtStatus(jniEnv, api, api->FillStringTensor(ortValue,&stringBuffer,1)); + + // Release the Java string + (*jniEnv)->ReleaseStringUTFChars(jniEnv,input,stringBuffer); + + return (jlong) ortValue; +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: createStringTensor + * Signature: (JJ[Ljava/lang/Object;[J)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OnnxTensor_createStringTensor + (JNIEnv * jniEnv, jclass jobj, jlong apiHandle, jlong allocatorHandle, jobjectArray stringArr, jlongArray shape) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Extract the shape information + jboolean mkCopy; + jlong* shapeArr = (*jniEnv)->GetLongArrayElements(jniEnv,shape,&mkCopy); + jsize shapeLen = (*jniEnv)->GetArrayLength(jniEnv,shape); + + // Array length + jsize length = (*jniEnv)->GetArrayLength(jniEnv, stringArr); + + // Create the OrtValue + OrtValue* ortValue; + checkOrtStatus(jniEnv, api, api->CreateTensorAsOrtValue(allocator,(int64_t*)shapeArr,shapeLen,ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING,&ortValue)); + (*jniEnv)->ReleaseLongArrayElements(jniEnv,shape,shapeArr,JNI_ABORT); + + // Create the buffers for the Java strings + const char** strings; + checkOrtStatus(jniEnv, api, api->AllocatorAlloc(allocator,sizeof(char*)*length,(void**)&strings)); + jobject* javaStrings; + checkOrtStatus(jniEnv, api, api->AllocatorAlloc(allocator,sizeof(jobject)*length,(void**)&javaStrings)); + + // Copy the java strings into the buffers + for (int i = 0; i < length; i++) { + javaStrings[i] = (*jniEnv)->GetObjectArrayElement(jniEnv,stringArr,i); + strings[i] = (*jniEnv)->GetStringUTFChars(jniEnv,javaStrings[i],NULL); + } + + // Assign the strings into the Tensor + checkOrtStatus(jniEnv, api, api->FillStringTensor(ortValue,strings,length)); + + // Release the Java strings + for (int i = 0; i < length; i++) { + (*jniEnv)->ReleaseStringUTFChars(jniEnv,javaStrings[i],strings[i]); + } + + // Release the buffers + checkOrtStatus(jniEnv, api, api->AllocatorFree(allocator, strings)); + checkOrtStatus(jniEnv, api, api->AllocatorFree(allocator, javaStrings)); + + return (jlong) ortValue; +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getBuffer + * Signature: (JJ)Ljava/nio/ByteBuffer; + */ +JNIEXPORT jobject JNICALL Java_ai_onnxruntime_OnnxTensor_getBuffer + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtTensorTypeAndShapeInfo* info; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape((OrtValue*) handle, &info)); + size_t arrSize; + checkOrtStatus(jniEnv,api,api->GetTensorShapeElementCount(info,&arrSize)); + ONNXTensorElementDataType onnxTypeEnum; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(info,&onnxTypeEnum)); + api->ReleaseTensorTypeAndShapeInfo(info); + + size_t typeSize = onnxTypeSize(onnxTypeEnum); + size_t sizeBytes = arrSize*typeSize; + + uint8_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + + return (*jniEnv)->NewDirectByteBuffer(jniEnv, arr, sizeBytes); +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getFloat + * Signature: (JI)F + */ +JNIEXPORT jfloat JNICALL Java_ai_onnxruntime_OnnxTensor_getFloat + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint onnxType) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + if (onnxType == 9) { + uint16_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + jfloat floatVal = convertHalfToFloat(*arr); + return floatVal; + } else if (onnxType == 10) { + jfloat* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return *arr; + } else { + return NAN; + } +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getDouble + * Signature: (J)D + */ +JNIEXPORT jdouble JNICALL Java_ai_onnxruntime_OnnxTensor_getDouble + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + jdouble* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return *arr; +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getByte + * Signature: (JI)B + */ +JNIEXPORT jbyte JNICALL Java_ai_onnxruntime_OnnxTensor_getByte + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint onnxType) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + if (onnxType == 1) { + uint8_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return (jbyte) *arr; + } else if (onnxType == 2) { + int8_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return (jbyte) *arr; + } else { + return (jbyte) 0; + } +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getShort + * Signature: (JI)S + */ +JNIEXPORT jshort JNICALL Java_ai_onnxruntime_OnnxTensor_getShort + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint onnxType) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + if (onnxType == 3) { + uint16_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return (jshort) *arr; + } else if (onnxType == 4) { + int16_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return (jshort) *arr; + } else { + return (jshort) 0; + } +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getInt + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_ai_onnxruntime_OnnxTensor_getInt + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint onnxType) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + if (onnxType == 5) { + uint32_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return (jint) *arr; + } else if (onnxType == 6) { + int32_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return (jint) *arr; + } else { + return (jint) 0; + } +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getLong + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OnnxTensor_getLong + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint onnxType) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + if (onnxType == 7) { + uint64_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return (jlong) *arr; + } else if (onnxType == 8) { + int64_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return (jlong) *arr; + } else { + return (jlong) 0; + } +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getString + * Signature: (JJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_ai_onnxruntime_OnnxTensor_getString + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + // Extract a String array - if this becomes a performance issue we'll refactor later. + jobjectArray outputArray = createStringArrayFromTensor(jniEnv,api, (OrtAllocator*) allocatorHandle, (OrtValue*) handle); + + // Get reference to the string + jobject output = (*jniEnv)->GetObjectArrayElement(jniEnv, outputArray, 0); + + // Free array + (*jniEnv)->DeleteLocalRef(jniEnv,outputArray); + + return output; +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getBool + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_ai_onnxruntime_OnnxTensor_getBool + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + jboolean* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + return *arr; +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: getArray + * Signature: (JJLjava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OnnxTensor_getArray + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jlong allocatorHandle, jobject carrier) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtTensorTypeAndShapeInfo* info; + checkOrtStatus(jniEnv,api,api->GetTensorTypeAndShape((OrtValue*) handle, &info)); + size_t dimensions; + checkOrtStatus(jniEnv,api,api->GetDimensionsCount(info,&dimensions)); + size_t arrSize; + checkOrtStatus(jniEnv,api,api->GetTensorShapeElementCount(info,&arrSize)); + ONNXTensorElementDataType onnxTypeEnum; + checkOrtStatus(jniEnv,api,api->GetTensorElementType(info,&onnxTypeEnum)); + api->ReleaseTensorTypeAndShapeInfo(info); + + if (onnxTypeEnum == ONNX_TENSOR_ELEMENT_DATA_TYPE_STRING) { + copyStringTensorToArray(jniEnv,api, (OrtAllocator*) allocatorHandle, (OrtValue*)handle, arrSize, carrier); + } else { + uint8_t* arr; + checkOrtStatus(jniEnv,api,api->GetTensorMutableData((OrtValue*)handle,(void**)&arr)); + copyTensorToJava(jniEnv,onnxTypeEnum,arr,arrSize,dimensions,(jarray)carrier); + } +} + +/* + * Class: ai_onnxruntime_OnnxTensor + * Method: close + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OnnxTensor_close(JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jniEnv; (void) jobj; // Required JNI parameters not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + api->ReleaseValue((OrtValue*)handle); +} diff --git a/java/src/main/native/ai_onnxruntime_OrtAllocator.c b/java/src/main/native/ai_onnxruntime_OrtAllocator.c new file mode 100644 index 0000000000000..3416ebd584173 --- /dev/null +++ b/java/src/main/native/ai_onnxruntime_OrtAllocator.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include "onnxruntime/core/session/onnxruntime_c_api.h" +#include "OrtJniUtil.h" +#include "ai_onnxruntime_OrtAllocator.h" +/* + * Class: ai_onnxruntime_OrtAllocator + * Method: closeAllocator + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtAllocator_closeAllocator + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong allocatorHandle) { + (void) jniEnv; (void) jobj; (void) apiHandle; (void) allocatorHandle; +} + + diff --git a/java/src/main/native/ai_onnxruntime_OrtEnvironment.c b/java/src/main/native/ai_onnxruntime_OrtEnvironment.c new file mode 100644 index 0000000000000..d4698b4f3850f --- /dev/null +++ b/java/src/main/native/ai_onnxruntime_OrtEnvironment.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include "onnxruntime/core/session/onnxruntime_c_api.h" +#include "OrtJniUtil.h" +#include "ai_onnxruntime_OrtEnvironment.h" + +/* + * Class: ai_onnxruntime_OrtEnvironment + * Method: createHandle + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OrtEnvironment_createHandle(JNIEnv * jniEnv, jclass jobj, jlong apiHandle, jint loggingLevel, jstring name) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtEnv* env; + jboolean copy; + const char* cName = (*jniEnv)->GetStringUTFChars(jniEnv, name, ©); + checkOrtStatus(jniEnv,api,api->CreateEnv(convertLoggingLevel(loggingLevel), cName, &env)); + (*jniEnv)->ReleaseStringUTFChars(jniEnv,name,cName); + return (jlong) env; +} + +/* + * Class: ai_onnxruntime_OrtEnvironment + * Method: getDefaultAllocator + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OrtEnvironment_getDefaultAllocator + (JNIEnv * jniEnv, jclass jobj, jlong apiHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator; + checkOrtStatus(jniEnv,api,api->GetAllocatorWithDefaultOptions(&allocator)); + return (jlong)allocator; +} + +/* + * Class: ai_onnxruntime_OrtEnvironment + * Method: close + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtEnvironment_close(JNIEnv * jniEnv, jclass jobj, jlong apiHandle, jlong handle) { + (void) jniEnv; (void) jobj; // Required JNI parameters not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + api->ReleaseEnv((OrtEnv*)handle); +} + +/* + * Class: ai_onnxruntime_OrtEnvironment + * Method: setTelemetry + * Signature: (JJZ)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtEnvironment_setTelemetry + (JNIEnv * jniEnv, jclass jobj, jlong apiHandle, jlong nativeHandle, jboolean sendTelemetry) { + (void) jobj; // Required JNI parameters not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtEnv* env = (OrtEnv*) nativeHandle; + if (sendTelemetry) { + checkOrtStatus(jniEnv,api,api->EnableTelemetryEvents(env)); + } else { + checkOrtStatus(jniEnv,api,api->DisableTelemetryEvents(env)); + } +} diff --git a/java/src/main/native/ai_onnxruntime_OrtSession.c b/java/src/main/native/ai_onnxruntime_OrtSession.c new file mode 100644 index 0000000000000..6e1c7ea48820c --- /dev/null +++ b/java/src/main/native/ai_onnxruntime_OrtSession.c @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include +#include "onnxruntime/core/session/onnxruntime_c_api.h" +#include "OrtJniUtil.h" +#include "ai_onnxruntime_OrtSession.h" + +/* + * Class: ai_onnxruntime_OrtSession + * Method: createSession + * Signature: (JJLjava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OrtSession_createSession__JJLjava_lang_String_2J + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong envHandle, jstring modelPath, jlong optsHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtSession* session; + + jboolean copy; +#ifdef _WIN32 + const jchar* cPath = (*jniEnv)->GetStringChars(jniEnv, modelPath, ©); + size_t stringLength = (*jniEnv)->GetStringLength(jniEnv, modelPath); + wchar_t* newString = (wchar_t*)calloc(stringLength+1,sizeof(jchar)); + wcsncpy_s(newString, stringLength+1, (const wchar_t*) cPath, stringLength); + checkOrtStatus(jniEnv,api,api->CreateSession((OrtEnv*)envHandle, (const wchar_t*)newString, (OrtSessionOptions*)optsHandle, &session)); + free(newString); + (*jniEnv)->ReleaseStringChars(jniEnv,modelPath,cPath); +#else + const char* cPath = (*jniEnv)->GetStringUTFChars(jniEnv, modelPath, ©); + checkOrtStatus(jniEnv,api,api->CreateSession((OrtEnv*)envHandle, cPath, (OrtSessionOptions*)optsHandle, &session)); + (*jniEnv)->ReleaseStringUTFChars(jniEnv,modelPath,cPath); +#endif + + return (jlong) session; +} + +/* + * Class: ai_onnxruntime_OrtSession + * Method: createSession + * Signature: (JJ[BJ)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OrtSession_createSession__JJ_3BJ + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong envHandle, jbyteArray jModelArray, jlong optsHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtSession* session; + + // Get a reference to the byte array elements + jbyte* modelArr = (*jniEnv)->GetByteArrayElements(jniEnv,jModelArray,NULL); + size_t modelLength = (*jniEnv)->GetArrayLength(jniEnv,jModelArray); + checkOrtStatus(jniEnv,api,api->CreateSessionFromArray((OrtEnv*)envHandle, modelArr, modelLength, (OrtSessionOptions*)optsHandle, &session)); + // Release the C array. + (*jniEnv)->ReleaseByteArrayElements(jniEnv,jModelArray,modelArr,JNI_ABORT); + + return (jlong) session; + } + +/* + * Class: ai_onnxruntime_OrtSession + * Method: getNumInputs + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OrtSession_getNumInputs + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + size_t numInputs; + checkOrtStatus(jniEnv,api,api->SessionGetInputCount((OrtSession*)handle, &numInputs)); + return numInputs; +} + +/* + * Class: ai_onnxruntime_OrtSession + * Method: getInputNames + * Signature: (JJJ)[Ljava/lang/String; + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OrtSession_getInputNames + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong sessionHandle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Setup + char *stringClassName = "java/lang/String"; + jclass stringClazz = (*jniEnv)->FindClass(jniEnv, stringClassName); + + // Get the number of inputs + size_t numInputs = Java_ai_onnxruntime_OrtSession_getNumInputs(jniEnv, jobj, apiHandle, sessionHandle); + + // Allocate the return array + jobjectArray array = (*jniEnv)->NewObjectArray(jniEnv,numInputs,stringClazz,NULL); + for (uint32_t i = 0; i < numInputs; i++) { + // Read out the input name and convert it to a java.lang.String + char* inputName; + checkOrtStatus(jniEnv,api,api->SessionGetInputName((OrtSession*)sessionHandle, i, allocator, &inputName)); + jstring name = (*jniEnv)->NewStringUTF(jniEnv,inputName); + (*jniEnv)->SetObjectArrayElement(jniEnv, array, i, name); + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,inputName)); + } + + return array; +} + +/* + * Class: ai_onnxruntime_OrtSession + * Method: getNumOutputs + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OrtSession_getNumOutputs + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + size_t numOutputs; + checkOrtStatus(jniEnv,api,api->SessionGetOutputCount((OrtSession*)handle, &numOutputs)); + return numOutputs; +} + +/* + * Class: ai_onnxruntime_OrtSession + * Method: getOutputNames + * Signature: (JJJ)[Ljava/lang/String; + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OrtSession_getOutputNames + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong sessionHandle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Setup + char *stringClassName = "java/lang/String"; + jclass stringClazz = (*jniEnv)->FindClass(jniEnv, stringClassName); + + // Get the number of outputs + size_t numOutputs = Java_ai_onnxruntime_OrtSession_getNumOutputs(jniEnv, jobj, apiHandle, sessionHandle); + + // Allocate the return array + jobjectArray array = (*jniEnv)->NewObjectArray(jniEnv,numOutputs,stringClazz,NULL); + for (uint32_t i = 0; i < numOutputs; i++) { + // Read out the output name and convert it to a java.lang.String + char* outputName; + checkOrtStatus(jniEnv,api,api->SessionGetOutputName((OrtSession*)sessionHandle, i, allocator, &outputName)); + jstring name = (*jniEnv)->NewStringUTF(jniEnv,outputName); + (*jniEnv)->SetObjectArrayElement(jniEnv, array, i, name); + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,outputName)); + } + + return array; +} + +/* + * Class: ai_onnxruntime_OrtSession + * Method: getInputInfo + * Signature: (JJJ)[Lai/onnxruntime/NodeInfo; + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OrtSession_getInputInfo + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong sessionHandle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Setup + char *nodeInfoClassName = "ai/onnxruntime/NodeInfo"; + jclass nodeInfoClazz = (*jniEnv)->FindClass(jniEnv, nodeInfoClassName); + jmethodID nodeInfoConstructor = (*jniEnv)->GetMethodID(jniEnv,nodeInfoClazz, "", "(Ljava/lang/String;Lai/onnxruntime/ValueInfo;)V"); + + // Get the number of inputs + size_t numInputs = Java_ai_onnxruntime_OrtSession_getNumInputs(jniEnv, jobj, apiHandle, sessionHandle); + + // Allocate the return array + jobjectArray array = (*jniEnv)->NewObjectArray(jniEnv,numInputs,nodeInfoClazz,NULL); + for (uint32_t i = 0; i < numInputs; i++) { + // Read out the input name and convert it to a java.lang.String + char* inputName; + checkOrtStatus(jniEnv,api,api->SessionGetInputName((OrtSession*)sessionHandle, i, allocator, &inputName)); + jstring name = (*jniEnv)->NewStringUTF(jniEnv,inputName); + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,inputName)); + + // Create a ValueInfo from the OrtTypeInfo + OrtTypeInfo* typeInfo; + checkOrtStatus(jniEnv,api,api->SessionGetInputTypeInfo((OrtSession*)sessionHandle, i, &typeInfo)); + jobject valueInfoJava = convertToValueInfo(jniEnv,api,typeInfo); + api->ReleaseTypeInfo(typeInfo); + + // Create a NodeInfo and assign into the array + jobject nodeInfo = (*jniEnv)->NewObject(jniEnv, nodeInfoClazz, nodeInfoConstructor, name, valueInfoJava); + (*jniEnv)->SetObjectArrayElement(jniEnv, array, i, nodeInfo); + } + + return array; +} + +/* + * Class: ai_onnxruntime_OrtSession + * Method: getOutputInfo + * Signature: (JJJ)[Lai/onnxruntime/NodeInfo; + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OrtSession_getOutputInfo + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong sessionHandle, jlong allocatorHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + // Setup + char *nodeInfoClassName = "ai/onnxruntime/NodeInfo"; + jclass nodeInfoClazz = (*jniEnv)->FindClass(jniEnv, nodeInfoClassName); + jmethodID nodeInfoConstructor = (*jniEnv)->GetMethodID(jniEnv, nodeInfoClazz, "", "(Ljava/lang/String;Lai/onnxruntime/ValueInfo;)V"); + + // Get the number of outputs + size_t numOutputs = Java_ai_onnxruntime_OrtSession_getNumOutputs(jniEnv, jobj, apiHandle, sessionHandle); + + // Allocate the return array + jobjectArray array = (*jniEnv)->NewObjectArray(jniEnv,numOutputs,nodeInfoClazz,NULL); + for (uint32_t i = 0; i < numOutputs; i++) { + // Read out the output name and convert it to a java.lang.String + char* outputName; + checkOrtStatus(jniEnv,api,api->SessionGetOutputName((OrtSession*)sessionHandle, i, allocator, &outputName)); + jstring name = (*jniEnv)->NewStringUTF(jniEnv,outputName); + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,outputName)); + + // Create a ValueInfo from the OrtTypeInfo + OrtTypeInfo* typeInfo; + checkOrtStatus(jniEnv,api,api->SessionGetOutputTypeInfo((OrtSession*)sessionHandle, i, &typeInfo)); + jobject valueInfoJava = convertToValueInfo(jniEnv,api,typeInfo); + api->ReleaseTypeInfo(typeInfo); + + // Create a NodeInfo and assign into the array + jobject nodeInfo = (*jniEnv)->NewObject(jniEnv, nodeInfoClazz, nodeInfoConstructor, name, valueInfoJava); + (*jniEnv)->SetObjectArrayElement(jniEnv, array, i, nodeInfo); + } + + return array; +} + +/* + * Class: ai_onnxruntime_OrtSession + * Method: run + * Signature: (JJJ[Ljava/lang/String;[JJ[Ljava/lang/String;J)[Lai/onnxruntime/OnnxValue; + * private native OnnxValue[] run(long apiHandle, long nativeHandle, long allocatorHandle, String[] inputNamesArray, long[] inputs, long numInputs, String[] outputNamesArray, long numOutputs) + */ +JNIEXPORT jobjectArray JNICALL Java_ai_onnxruntime_OrtSession_run + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong sessionHandle, jlong allocatorHandle, jobjectArray inputNamesArr, jlongArray tensorArr, jlong numInputs, jobjectArray outputNamesArr, jlong numOutputs) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + + // Create the buffers for the Java input and output strings + const char** inputNames; + checkOrtStatus(jniEnv, api, api->AllocatorAlloc(allocator,sizeof(char*)*numInputs,(void**)&inputNames)); + const char** outputNames; + checkOrtStatus(jniEnv, api, api->AllocatorAlloc(allocator,sizeof(char*)*numOutputs,(void**)&outputNames)); + jobject* javaInputStrings; + checkOrtStatus(jniEnv, api, api->AllocatorAlloc(allocator,sizeof(jobject)*numInputs,(void**)&javaInputStrings)); + jobject* javaOutputStrings; + checkOrtStatus(jniEnv, api, api->AllocatorAlloc(allocator,sizeof(jobject)*numOutputs,(void**)&javaOutputStrings)); + + // Extract the names of the input values. + for (int i = 0; i < numInputs; i++) { + javaInputStrings[i] = (*jniEnv)->GetObjectArrayElement(jniEnv,inputNamesArr,i); + inputNames[i] = (*jniEnv)->GetStringUTFChars(jniEnv,javaInputStrings[i],NULL); + } + + // Extract a C array of longs which are pointers to the input tensors. + jlong* inputTensors = (*jniEnv)->GetLongArrayElements(jniEnv,tensorArr,NULL); + + // Extract the names of the output values, and allocate their output array. + OrtValue** outputValues; + checkOrtStatus(jniEnv,api,api->AllocatorAlloc(allocator,sizeof(OrtValue*)*numOutputs,(void**)&outputValues)); + for (int i = 0; i < numOutputs; i++) { + javaOutputStrings[i] = (*jniEnv)->GetObjectArrayElement(jniEnv,outputNamesArr,i); + outputNames[i] = (*jniEnv)->GetStringUTFChars(jniEnv,javaOutputStrings[i],NULL); + outputValues[i] = NULL; + } + + // Actually score the inputs. + //printf("inputTensors = %p, first tensor = %p, numInputs = %ld, outputValues = %p, numOutputs = %ld\n",inputTensors,(OrtValue*)inputTensors[0],numInputs,outputValues,numOutputs); + //ORT_API_STATUS(OrtRun, _Inout_ OrtSession* sess, _In_ OrtRunOptions* run_options, _In_ const char* const* input_names, _In_ const OrtValue* const* input, size_t input_len, _In_ const char* const* output_names, size_t output_names_len, _Out_ OrtValue** output); + checkOrtStatus(jniEnv,api,api->Run((OrtSession*)sessionHandle, NULL, (const char* const*) inputNames, (const OrtValue* const*) inputTensors, numInputs, (const char* const*) outputNames, numOutputs, outputValues)); + // Release the C array of pointers to the tensors. + (*jniEnv)->ReleaseLongArrayElements(jniEnv,tensorArr,inputTensors,JNI_ABORT); + + // Construct the output array of ONNXValues + char *onnxValueClassName = "ai/onnxruntime/OnnxValue"; + jclass onnxValueClass = (*jniEnv)->FindClass(jniEnv, onnxValueClassName); + jobjectArray outputArray = (*jniEnv)->NewObjectArray(jniEnv,numOutputs,onnxValueClass,NULL); + + // Convert the output tensors into ONNXValues and release the output strings. + for (int i = 0; i < numOutputs; i++) { + if (outputValues[i] != NULL) { + jobject onnxValue = convertOrtValueToONNXValue(jniEnv,api,allocator,outputValues[i]); + (*jniEnv)->SetObjectArrayElement(jniEnv,outputArray,i,onnxValue); + } + (*jniEnv)->ReleaseStringUTFChars(jniEnv,javaOutputStrings[i],outputNames[i]); + } + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,outputValues)); + + // Release the Java input strings + for (int i = 0; i < numInputs; i++) { + (*jniEnv)->ReleaseStringUTFChars(jniEnv,javaInputStrings[i],inputNames[i]); + } + + // Release the buffers + checkOrtStatus(jniEnv, api, api->AllocatorFree(allocator, inputNames)); + checkOrtStatus(jniEnv, api, api->AllocatorFree(allocator, outputNames)); + checkOrtStatus(jniEnv, api, api->AllocatorFree(allocator, javaInputStrings)); + checkOrtStatus(jniEnv, api, api->AllocatorFree(allocator, javaOutputStrings)); + + return outputArray; +} + +/* + * Class: ai_onnxruntime_OrtSession + * Method: closeSession + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_closeSession + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jniEnv; (void) jobj; // Required JNI parameters not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + api->ReleaseSession((OrtSession*)handle); +} + +/* + * Class: ai_onnxruntime_OrtSession + * Method: releaseNamesHandle + * Signature: (JJJ)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_releaseNamesHandle + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong allocatorHandle, jlong namesHandle, jlong length) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtAllocator* allocator = (OrtAllocator*) allocatorHandle; + char** names = (char**) namesHandle; + for (uint32_t i = 0; i < length; i++) { + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,names[i])); + } + checkOrtStatus(jniEnv,api,api->AllocatorFree(allocator,names)); +} diff --git a/java/src/main/native/ai_onnxruntime_OrtSession_SessionOptions.c b/java/src/main/native/ai_onnxruntime_OrtSession_SessionOptions.c new file mode 100644 index 0000000000000..c3a5d16a3b9c7 --- /dev/null +++ b/java/src/main/native/ai_onnxruntime_OrtSession_SessionOptions.c @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +#include +#include +#include "onnxruntime/core/session/onnxruntime_c_api.h" +#include "OrtJniUtil.h" +#include "ai_onnxruntime_OrtSession_SessionOptions.h" + +// Providers +#include "onnxruntime/core/providers/cpu/cpu_provider_factory.h" +#include "onnxruntime/core/providers/cuda/cuda_provider_factory.h" +#include "onnxruntime/core/providers/dnnl/dnnl_provider_factory.h" +#include "onnxruntime/core/providers/ngraph/ngraph_provider_factory.h" +#include "onnxruntime/core/providers/nnapi/nnapi_provider_factory.h" +#include "onnxruntime/core/providers/nuphar/nuphar_provider_factory.h" +#include "onnxruntime/core/providers/openvino/openvino_provider_factory.h" +#include "onnxruntime/core/providers/tensorrt/tensorrt_provider_factory.h" + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: setExecutionMode + * Signature: (JJI)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_setExecutionMode + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint mode) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + ExecutionMode exMode = convertExecutionMode(mode); + checkOrtStatus(jniEnv,api,api->SetSessionExecutionMode((OrtSessionOptions*) handle,exMode)); +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: setOptimizationLevel + * Signature: (JJI)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_setOptimizationLevel + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint optLevel) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + checkOrtStatus(jniEnv,api,api->SetSessionGraphOptimizationLevel((OrtSessionOptions*) handle, convertOptimizationLevel(optLevel))); +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: setIntraOpNumThreads + * Signature: (JJI)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_setIntraOpNumThreads + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint numThreads) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + checkOrtStatus(jniEnv,api,api->SetIntraOpNumThreads((OrtSessionOptions*) handle, numThreads)); +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: setInterOpNumThreads + * Signature: (JJI)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_setInterOpNumThreads + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint numThreads) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + checkOrtStatus(jniEnv,api,api->SetInterOpNumThreads((OrtSessionOptions*) handle, numThreads)); +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: setOptimizationModelFilePath + * Signature: (JJLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_setOptimizationModelFilePath + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jstring pathString) { + (void) jobj; // Required JNI parameter not needed by function which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; +#ifdef _WIN32 + const jchar* path = (*jniEnv)->GetStringChars(jniEnv, pathString, NULL); + size_t stringLength = (*jniEnv)->GetStringLength(jniEnv, pathString); + wchar_t* newString = (wchar_t*)calloc(stringLength+1,sizeof(jchar)); + wcsncpy_s(newString, stringLength+1, (const wchar_t*) path, stringLength); + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,api->SetOptimizedModelFilePath((OrtSessionOptions*) handle, (const wchar_t*) newString)); + free(newString); + (*jniEnv)->ReleaseStringChars(jniEnv,pathString,path); +#else + const char* path = (*jniEnv)->GetStringUTFChars(jniEnv, pathString, NULL); + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,api->SetOptimizedModelFilePath((OrtSessionOptions*) handle, path)); + (*jniEnv)->ReleaseStringUTFChars(jniEnv,pathString,path); +#endif +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: createOptions + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_createOptions + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + OrtSessionOptions* opts; + checkOrtStatus(jniEnv,api,api->CreateSessionOptions(&opts)); + checkOrtStatus(jniEnv,api,api->SetInterOpNumThreads(opts, 1)); + checkOrtStatus(jniEnv,api,api->SetIntraOpNumThreads(opts, 1)); + return (jlong) opts; +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: closeOptions + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_closeOptions + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void) jniEnv; (void) jobj; // Required JNI parameters not needed by functions which don't need to access their host object. + const OrtApi* api = (const OrtApi*) apiHandle; + api->ReleaseSessionOptions((OrtSessionOptions*) handle); +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: addCPU + * Signature: (JJI)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_addCPU + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint useArena) { + (void) jobj; // Required JNI parameter not needed by functions which don't need to access their host object. + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,OrtSessionOptionsAppendExecutionProvider_CPU((OrtSessionOptions*)handle,useArena)); +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: addCUDA + * Signature: (JJI)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_addCUDA + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint deviceID) { + (void)jobj; + #ifdef USE_CUDA + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,OrtSessionOptionsAppendExecutionProvider_CUDA((OrtSessionOptions*) handle, deviceID)); + #else + (void)apiHandle;(void)handle;(void)deviceID; // Parameters used when CUDA is defined. + throwOrtException(jniEnv,convertErrorCode(ORT_INVALID_ARGUMENT),"This binary was not compiled with CUDA support."); + #endif +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: addDnnl + * Signature: (JJI)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_addDnnl + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint useArena) { + (void)jobj; + #ifdef USE_DNNL + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,OrtSessionOptionsAppendExecutionProvider_Dnnl((OrtSessionOptions*) handle,useArena)); + #else + (void)apiHandle;(void)handle;(void)useArena; // Parameters used when DNNL is defined. + throwOrtException(jniEnv,convertErrorCode(ORT_INVALID_ARGUMENT),"This binary was not compiled with DNNL support."); + #endif +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: addNGraph + * Signature: (JJLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_addNGraph + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jstring backendString) { + (void)jobj; + #ifdef USE_NGRAPH + const char* backendType = (*jniEnv)->GetStringUTFChars(jniEnv, backendString, NULL); + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,OrtSessionOptionsAppendExecutionProvider_NGraph((OrtSessionOptions*) handle, backendType)); + (*jniEnv)->ReleaseStringUTFChars(jniEnv,backendString,backendType); + #else + (void)apiHandle;(void)handle;(void)backendString; // Parameters used when NGraph is defined. + throwOrtException(jniEnv,convertErrorCode(ORT_INVALID_ARGUMENT),"This binary was not compiled with NGraph support."); + #endif +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: addOpenVINO + * Signature: (JJLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_addOpenVINO + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jstring deviceIDString) { + (void)jobj; + #ifdef USE_OPENVINO + const char* deviceID = (*jniEnv)->GetStringUTFChars(jniEnv, deviceIDString, NULL); + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,OrtSessionOptionsAppendExecutionProvider_OpenVINO((OrtSessionOptions*) handle, deviceID)); + (*jniEnv)->ReleaseStringUTFChars(jniEnv,deviceIDString,deviceID); + #else + (void)apiHandle;(void)handle;(void)deviceIDString; // Parameters used when OpenVINO is defined. + throwOrtException(jniEnv,convertErrorCode(ORT_INVALID_ARGUMENT),"This binary was not compiled with OpenVINO support."); + #endif +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: addTensorrt + * Signature: (JJI)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_addTensorrt + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint deviceNum) { + (void)jobj; + #ifdef USE_TENSORRT + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,OrtSessionOptionsAppendExecutionProvider_Tensorrt((OrtSessionOptions*) handle, deviceNum)); + #else + (void)apiHandle;(void)handle;(void)deviceNum; // Parameters used when TensorRT is defined. + throwOrtException(jniEnv,convertErrorCode(ORT_INVALID_ARGUMENT),"This binary was not compiled with TensorRT support."); + #endif +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: addNnapi + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_addNnapi + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle) { + (void)jobj; + #ifdef USE_NNAPI + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,OrtSessionOptionsAppendExecutionProvider_Nnapi((OrtSessionOptions*) handle)); + #else + (void)apiHandle;(void)handle; // Parameters used when NNAPI is defined. + throwOrtException(jniEnv,convertErrorCode(ORT_INVALID_ARGUMENT),"This binary was not compiled with NNAPI support."); + #endif +} + +/* + * Class: ai_onnxruntime_OrtSession_SessionOptions + * Method: addNuphar + * Signature: (JILjava/lang/String { + })V + */ +JNIEXPORT void JNICALL Java_ai_onnxruntime_OrtSession_00024SessionOptions_addNuphar + (JNIEnv * jniEnv, jobject jobj, jlong apiHandle, jlong handle, jint allowUnalignedBuffers, jstring settingsString) { + (void)jobj; + #ifdef USE_NUPHAR + const char* settings = (*jniEnv)->GetStringUTFChars(jniEnv, settingsString, NULL); + checkOrtStatus(jniEnv,(const OrtApi*)apiHandle,OrtSessionOptionsAppendExecutionProvider_Nuphar((OrtSessionOptions*) handle, allowUnalignedBuffers, settings)); + (*jniEnv)->ReleaseStringUTFChars(jniEnv,settingsString,settings); + #else + (void)apiHandle;(void)handle;(void)allowUnalignedBuffers;(void)settingsString; // Parameters used when Nuphar is defined. + throwOrtException(jniEnv,convertErrorCode(ORT_INVALID_ARGUMENT),"This binary was not compiled with Nuphar support."); + #endif +} diff --git a/java/src/test/java/ai/onnxruntime/InferenceTest.java b/java/src/test/java/ai/onnxruntime/InferenceTest.java new file mode 100644 index 0000000000000..ff0f086a1523d --- /dev/null +++ b/java/src/test/java/ai/onnxruntime/InferenceTest.java @@ -0,0 +1,1037 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import ai.onnxruntime.OnnxMl.TensorProto; +import ai.onnxruntime.OnnxMl.TensorProto.DataType; +import ai.onnxruntime.OrtSession.Result; +import ai.onnxruntime.OrtSession.SessionOptions; +import ai.onnxruntime.OrtSession.SessionOptions.ExecutionMode; +import ai.onnxruntime.OrtSession.SessionOptions.OptLevel; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Tests for the onnx-runtime Java interface. + */ +public class InferenceTest { + private static final Pattern LOAD_PATTERN = Pattern.compile("[,\\[\\] ]"); + private static Path resourcePath; + private static Path otherTestPath; + + private static String propertiesFile = "Properties.txt"; + + private static Pattern inputPBPattern = Pattern.compile("input_*.pb"); + private static Pattern outputPBPattern = Pattern.compile("output_*.pb"); + + static { + if (System.getProperty("GRADLE_TEST") != null) { + resourcePath = Paths.get("..","csharp","testdata"); + otherTestPath = Paths.get("..","onnxruntime","test", "testdata"); + } else { + resourcePath = Paths.get("csharp","testdata"); + otherTestPath = Paths.get("onnxruntime","test", "testdata"); + } + } + + @Test + public void createSessionFromPath() throws OrtException { + String modelPath = resourcePath.resolve("squeezenet.onnx").toString(); + try (OrtEnvironment env = OrtEnvironment.getEnvironment("createSessionFromPath"); + OrtSession.SessionOptions options = new SessionOptions()) { + try (OrtSession session = env.createSession(modelPath,options)) { + assertNotNull(session); + assertEquals(1, session.getNumInputs()); // 1 input node + Map inputInfoList = session.getInputInfo(); + assertNotNull(inputInfoList); + assertEquals(1,inputInfoList.size()); + NodeInfo input = inputInfoList.get("data_0"); + assertEquals("data_0",input.getName()); // input node name + assertTrue(input.getInfo() instanceof TensorInfo); + TensorInfo inputInfo = (TensorInfo) input.getInfo(); + assertEquals(OnnxJavaType.FLOAT, inputInfo.type); + int[] expectedInputDimensions = new int[] { 1, 3, 224, 224 }; + assertEquals(expectedInputDimensions.length, inputInfo.shape.length); + for (int i = 0; i < expectedInputDimensions.length; i++) { + assertEquals(expectedInputDimensions[i], inputInfo.shape[i]); + } + + assertEquals(1, session.getNumOutputs()); // 1 output node + Map outputInfoList = session.getOutputInfo(); + assertNotNull(outputInfoList); + assertEquals(1,outputInfoList.size()); + NodeInfo output = outputInfoList.get("softmaxout_1"); + assertEquals("softmaxout_1",output.getName()); // output node name + assertTrue(output.getInfo() instanceof TensorInfo); + TensorInfo outputInfo = (TensorInfo) output.getInfo(); + assertEquals(OnnxJavaType.FLOAT, outputInfo.type); + int[] expectedOutputDimensions = new int[] { 1, 1000, 1, 1 }; + assertEquals(expectedOutputDimensions.length, outputInfo.shape.length); + for (int i = 0; i < expectedOutputDimensions.length; i++) { + assertEquals(expectedOutputDimensions[i], outputInfo.shape[i]); + } + } + } + } + @Test + public void createSessionFromByteArray() throws IOException, OrtException { + Path modelPath = resourcePath.resolve("squeezenet.onnx"); + byte[] modelBytes = Files.readAllBytes(modelPath); + try (OrtEnvironment env = OrtEnvironment.getEnvironment("createSessionFromByteArray"); + OrtSession.SessionOptions options = new SessionOptions()) { + try (OrtSession session = env.createSession(modelBytes,options)) { + assertNotNull(session); + assertEquals(1, session.getNumInputs()); // 1 input node + Map inputInfoList = session.getInputInfo(); + assertNotNull(inputInfoList); + assertEquals(1,inputInfoList.size()); + NodeInfo input = inputInfoList.get("data_0"); + assertEquals("data_0",input.getName()); // input node name + assertTrue(input.getInfo() instanceof TensorInfo); + TensorInfo inputInfo = (TensorInfo) input.getInfo(); + assertEquals(OnnxJavaType.FLOAT, inputInfo.type); + int[] expectedInputDimensions = new int[] { 1, 3, 224, 224 }; + assertEquals(expectedInputDimensions.length, inputInfo.shape.length); + for (int i = 0; i < expectedInputDimensions.length; i++) { + assertEquals(expectedInputDimensions[i], inputInfo.shape[i]); + } + + assertEquals(1, session.getNumOutputs()); // 1 output node + Map outputInfoList = session.getOutputInfo(); + assertNotNull(outputInfoList); + assertEquals(1,outputInfoList.size()); + NodeInfo output = outputInfoList.get("softmaxout_1"); + assertEquals("softmaxout_1",output.getName()); // output node name + assertTrue(output.getInfo() instanceof TensorInfo); + TensorInfo outputInfo = (TensorInfo) output.getInfo(); + assertEquals(OnnxJavaType.FLOAT, outputInfo.type); + int[] expectedOutputDimensions = new int[] { 1, 1000, 1, 1 }; + assertEquals(expectedOutputDimensions.length, outputInfo.shape.length); + for (int i = 0; i < expectedOutputDimensions.length; i++) { + assertEquals(expectedOutputDimensions[i], outputInfo.shape[i]); + } + } + } + } + + @Test + public void inferenceTest() throws OrtException { + canRunInferenceOnAModel(OptLevel.NO_OPT,ExecutionMode.PARALLEL); + canRunInferenceOnAModel(OptLevel.NO_OPT,ExecutionMode.SEQUENTIAL); + canRunInferenceOnAModel(OptLevel.ALL_OPT,ExecutionMode.PARALLEL); + canRunInferenceOnAModel(OptLevel.ALL_OPT,ExecutionMode.SEQUENTIAL); + } + + private void canRunInferenceOnAModel(OptLevel graphOptimizationLevel, ExecutionMode exectionMode) throws OrtException { + String modelPath = resourcePath.resolve("squeezenet.onnx").toString(); + + // Set the graph optimization level for this session. + try (OrtEnvironment env = OrtEnvironment.getEnvironment("canRunInferenceOnAModel"); + SessionOptions options = new SessionOptions()) { + options.setOptimizationLevel(graphOptimizationLevel); + options.setExecutionMode(exectionMode); + + try (OrtSession session = env.createSession(modelPath, options)) { + Map inputMetaMap = session.getInputInfo(); + Map container = new HashMap<>(); + NodeInfo inputMeta = inputMetaMap.values().iterator().next(); + + float[] inputData = loadTensorFromFile(resourcePath.resolve("bench.in")); + // this is the data for only one input tensor for this model + Object tensorData = OrtUtil.reshape(inputData,((TensorInfo) inputMeta.getInfo()).getShape()); + OnnxTensor inputTensor = OnnxTensor.createTensor(env,tensorData); + container.put(inputMeta.getName(),inputTensor); + + // Run the inference + try (OrtSession.Result results = session.run(container)) { + assertEquals(1, results.size()); + + float[] expectedOutput = loadTensorFromFile(resourcePath.resolve("bench.expected_out")); + // validate the results + // Only iterates once + for (Map.Entry r : results) { + OnnxValue resultValue = r.getValue(); + assertTrue(resultValue instanceof OnnxTensor); + OnnxTensor resultTensor = (OnnxTensor) resultValue; + int[] expectedDimensions = new int[]{1, 1000, 1, 1}; // hardcoded for now for the test data + long[] resultDimensions = resultTensor.getInfo().getShape(); + assertEquals(expectedDimensions.length, resultDimensions.length); + + for (int i = 0; i < expectedDimensions.length; i++) { + assertEquals(expectedDimensions[i], resultDimensions[i]); + } + + float[] resultArray = TestHelpers.flattenFloat(resultTensor.getValue()); + assertEquals(expectedOutput.length, resultArray.length); + assertArrayEquals(expectedOutput, resultArray, 1e-6f); + } + } finally { + inputTensor.close(); + } + } + } + } + + @Test + public void throwWrongInputName() throws OrtException { + SqueezeNetTuple tuple = openSessionSqueezeNet(); + try (OrtEnvironment env = tuple.env; + OrtSession session = tuple.session) { + float[] inputData = tuple.inputData; + NodeInfo inputMeta = session.getInputInfo().values().iterator().next(); + Map container = new HashMap<>(); + long[] inputShape = ((TensorInfo)inputMeta.getInfo()).shape; + int[] inputDataInt = new int[inputData.length]; + for (int i = 0; i < inputData.length; i++) { + inputDataInt[i] = (int) inputData[i]; + } + Object tensor = OrtUtil.reshape(inputDataInt,inputShape); + container.put("wrong_name",OnnxTensor.createTensor(env,tensor)); + try { + session.run(container); + OnnxValue.close(container.values()); + fail("Should throw exception for incorrect name."); + } catch (OrtException e) { + OnnxValue.close(container.values()); + String msg = e.getMessage(); + assertTrue(msg.contains("Unknown input name")); + } + } + } + + @Test + public void throwWrongInputType() throws OrtException { + SqueezeNetTuple tuple = openSessionSqueezeNet(); + try (OrtEnvironment env = tuple.env; + OrtSession session = tuple.session) { + + float[] inputData = tuple.inputData; NodeInfo inputMeta = session.getInputInfo().values().iterator().next(); + Map container = new HashMap<>(); + long[] inputShape = ((TensorInfo)inputMeta.getInfo()).shape; + int[] inputDataInt = new int[inputData.length]; + for (int i = 0; i < inputData.length; i++) { + inputDataInt[i] = (int) inputData[i]; + } + Object tensor = OrtUtil.reshape(inputDataInt,inputShape); + container.put(inputMeta.getName(),OnnxTensor.createTensor(env,tensor)); + try { + session.run(container); + OnnxValue.close(container.values()); + fail("Should throw exception for incorrect type."); + } catch (OrtException e) { + OnnxValue.close(container.values()); + String msg = e.getMessage(); + assertTrue(msg.contains("Unexpected input data type")); + } + } + } + + @Test + public void throwExtraInputs() throws OrtException { + SqueezeNetTuple tuple = openSessionSqueezeNet(); + try (OrtEnvironment env = tuple.env; + OrtSession session = tuple.session) { + + float[] inputData = tuple.inputData; NodeInfo inputMeta = session.getInputInfo().values().iterator().next(); + Map container = new HashMap<>(); + long[] inputShape = ((TensorInfo)inputMeta.getInfo()).shape; + int[] inputDataInt = new int[inputData.length]; + for (int i = 0; i < inputData.length; i++) { + inputDataInt[i] = (int) inputData[i]; + } + Object tensor = OrtUtil.reshape(inputDataInt,inputShape); + container.put(inputMeta.getName(),OnnxTensor.createTensor(env,tensor)); + container.put("extra",OnnxTensor.createTensor(env,tensor)); + try { + session.run(container); + OnnxValue.close(container.values()); + fail("Should throw exception for too many inputs."); + } catch (OrtException e) { + OnnxValue.close(container.values()); + String msg = e.getMessage(); + assertTrue(msg.contains("Unexpected number of inputs")); + } + } + } + + @Test + public void testMultiThreads() throws OrtException, InterruptedException { + int numThreads = 10; + int loop = 10; + SqueezeNetTuple tuple = openSessionSqueezeNet(); + try (OrtEnvironment env = tuple.env; + OrtSession session = tuple.session) { + + float[] inputData = tuple.inputData; + float[] expectedOutput = tuple.outputData; + NodeInfo inputMeta = session.getInputInfo().values().iterator().next(); + Map container = new HashMap<>(); + long[] inputShape = ((TensorInfo) inputMeta.getInfo()).shape; + Object tensor = OrtUtil.reshape(inputData, inputShape); + container.put(inputMeta.getName(), OnnxTensor.createTensor(env, tensor)); + ExecutorService executor = Executors.newFixedThreadPool(numThreads); + for (int i = 0; i < numThreads; i++) { + executor.submit(() -> { + for (int j = 0; j < loop; j++) { + try (OrtSession.Result result = session.run(container)) { + OnnxValue resultTensor = result.get(0); + float[] resultArray = TestHelpers.flattenFloat(resultTensor.getValue()); + assertEquals(expectedOutput.length, resultArray.length); + assertArrayEquals(expectedOutput, resultArray, 1e-6f); + } catch (OrtException e) { + throw new IllegalStateException("Failed to execute a scoring operation", e); + } + } + }); + } + executor.shutdown(); + executor.awaitTermination(1, TimeUnit.MINUTES); + OnnxValue.close(container.values()); + assertTrue(executor.isTerminated()); + } + } + + private static File getTestModelsDir() throws IOException { + // get build directory, append downloaded models location + String cwd = System.getProperty("user.dir"); + List props = Files.readAllLines(Paths.get(cwd, propertiesFile)); + String modelsRelDir = props.get(0).split("=")[1].trim(); + File modelsDir = Paths.get(cwd, "../../..", modelsRelDir, "models").toFile(); + return modelsDir; + } + + private static Map getSkippedModels() { + Map skipModels = new HashMap<>(); + skipModels.put( "mxnet_arcface", "Model is an invalid ONNX model"); + skipModels.put( "tf_inception_v2", "TODO: Debug failing model, skipping for now" ); + skipModels.put( "fp16_inception_v1", "16-bit float not supported type in C#." ); + skipModels.put( "fp16_shufflenet", "16-bit float not supported type in C#." ); + skipModels.put( "fp16_tiny_yolov2", "16-bit float not supported type in C#." ); + skipModels.put( "BERT_Squad", "Could not find an implementation for the node bert / embeddings / one_hot:OneHot(9)" ); + skipModels.put( "mlperf_ssd_mobilenet_300", "Could not find file output_0.pb" ); + skipModels.put( "tf_resnet_v1_50", "result mismatch when Conv BN Fusion is applied" ); + skipModels.put( "tf_resnet_v1_101", "result mismatch when Conv BN Fusion is applied" ); + skipModels.put( "tf_resnet_v1_152", "result mismatch when Conv BN Fusion is applied" ); + + // The following models fails on nocontribops win CI + skipModels.put("test_tiny_yolov2","Fails when ContribOps is disabled"); + skipModels.put("mask_rcnn_keras","Pad is not a registered function/op"); + + return skipModels; + } + + public static List getModelsForTest() throws IOException { + File modelsDir = getTestModelsDir(); + Map skipModels = getSkippedModels(); + ArrayList output = new ArrayList<>(); + + for (File opsetDirectory : modelsDir.listFiles(File::isDirectory)) { + for (File modelDir : opsetDirectory.listFiles(File::isDirectory)){ + if (!skipModels.containsKey(modelDir.getName())) { + output.add(new String[]{modelDir.getParentFile().getName(), modelDir.getName()}); + } + } //model + } //opset + + return output; + } + + public static Set getSkippedModelForTest() throws IOException { + File modelsDir = getTestModelsDir(); + Map skipModels = getSkippedModels(); + Set output = new HashSet<>(); + + for (File opsetDirectory : modelsDir.listFiles(File::isDirectory)) { + for (File modelDir : opsetDirectory.listFiles(File::isDirectory)){ + if (skipModels.containsKey(modelDir.getName())) { + output.add(new String[]{modelDir.getParentFile().getName(), modelDir.getName()}); + } + } //model + } //opset + + return output; + } + + @Disabled + @Test + public void testAllPretrainedModels() throws IOException { + List testModels = getModelsForTest(); + Set skipModels = getSkippedModelForTest(); + for (String[] model : testModels) { + if (!skipModels.contains(model)) { + testPreTrainedModel(model[0],model[1]); + } + } + } + + public void testPreTrainedModel(String opset, String modelName) throws IOException { + File modelsDir = getTestModelsDir(); + String onnxModelFileName = null; + + Path modelDir = Paths.get(modelsDir.getAbsolutePath(), opset, modelName); + + try { + File[] onnxModelFiles = modelDir.toFile().listFiles((dir,filename) -> filename.contains(".onnx")); + boolean validModelFound = false; + if (onnxModelFiles.length > 0) { + // TODO remove file "._resnet34v2.onnx" from test set + for (int i = 0; i < onnxModelFiles.length; i++) { + if (!onnxModelFiles[i].getName().equals("._resnet34v2.onnx")) { + onnxModelFiles[0] = onnxModelFiles[i]; + validModelFound = true; + } + } + } + + if (validModelFound) { + onnxModelFileName = onnxModelFiles[0].getAbsolutePath(); + } else { + String modelNamesList = Stream.of(onnxModelFiles).map(File::getName).collect(Collectors.joining(",")); + throw new RuntimeException("Opset " + opset + " Model " + modelName + ". Can't determine model file name. Found these: " + modelNamesList); + } + + try (OrtEnvironment env = OrtEnvironment.getEnvironment(); + OrtSession session = env.createSession(onnxModelFileName)) { + String testDataDirNamePattern; + if (opset.equals("opset9") && modelName.equals("LSTM_Seq_lens_unpacked")) { + testDataDirNamePattern = "seq_lens"; // discrepency in data directory + } else { + testDataDirNamePattern = "test_data"; + } + Map inMeta = session.getInputInfo(); + Map outMeta = session.getOutputInfo(); + File testDataDir = modelDir.toFile().listFiles(f -> f.getName().startsWith(testDataDirNamePattern))[0]; + Map inputContainer = new HashMap<>(); + Map outputContainer = new HashMap<>(); + for (File f : testDataDir.listFiles((dir,name) -> inputPBPattern.matcher(name).matches())) { + StringTensorPair o = loadTensorFromFilePb(env, f, inMeta); + inputContainer.put(o.string,o.tensor); + } + for (File f : testDataDir.listFiles((dir,name) -> outputPBPattern.matcher(name).matches())) { + StringTensorPair o = loadTensorFromFilePb(env, f, outMeta); + outputContainer.put(o.string,o.tensor); + } + + try (Result resultCollection = session.run(inputContainer)) { + for (Map.Entry result : resultCollection) { + Assertions.assertTrue(outMeta.containsKey(result.getKey())); + OnnxTensor outputValue = outputContainer.get(result.getKey()); + if (outputValue == null) { + outputValue = outputContainer.values().iterator().next(); // in case the output data file does not contain the name + } + if (result.getValue() instanceof OnnxTensor) { + OnnxTensor resultTensor = (OnnxTensor) result.getValue(); + Assertions.assertEquals(outputValue.getByteBuffer(),resultTensor.getByteBuffer()); + } else { + fail("testPretrainedModel cannot handle non-tensor outputs yet"); + } + } + } + } + } catch (OrtException ex) { + String msg = "Opset "+opset+", Model " + modelName +": ModelFile = "+onnxModelFileName+" error = "+ex.getMessage(); + throw new RuntimeException(msg,ex); + } + } + + @Test + public void testModelInputFLOAT() throws OrtException { + // model takes 1x5 input of fixed type, echoes back + String modelPath = resourcePath.resolve("test_types_FLOAT.pb").toString(); + + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testModelInputFLOAT"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + String inputName = session.getInputNames().iterator().next(); + long[] shape = new long[]{1, 5}; + Map container = new HashMap<>(); + float[] flatInput = new float[]{1.0f, 2.0f, -3.0f, Float.MIN_VALUE, Float.MAX_VALUE}; + Object tensorIn = OrtUtil.reshape(flatInput, shape); + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(inputName, ov); + float[] resultArray; + try (OrtSession.Result res = session.run(container)) { + resultArray = TestHelpers.flattenFloat(res.get(0).getValue()); + assertArrayEquals(flatInput, resultArray, 1e-6f); + float[] resultBufferArray = new float[flatInput.length]; + ((OnnxTensor)res.get(0)).getFloatBuffer().get(resultBufferArray); + assertArrayEquals(flatInput,resultBufferArray,1e-6f); + OnnxValue.close(container); + } + container.clear(); + + // Now test loading from buffer + FloatBuffer buffer = FloatBuffer.wrap(flatInput); + OnnxTensor newTensor = OnnxTensor.createTensor(env,buffer,shape); + container.put(inputName,newTensor); + try (OrtSession.Result res = session.run(container)) { + resultArray = TestHelpers.flattenFloat(res.get(0).getValue()); + assertArrayEquals(flatInput, resultArray, 1e-6f); + OnnxValue.close(container); + } + } + } + + @Test + public void testModelInputBOOL() throws OrtException { + // model takes 1x5 input of fixed type, echoes back + String modelPath = resourcePath.resolve("test_types_BOOL.pb").toString(); + + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testModelInputBOOL"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + String inputName = session.getInputNames().iterator().next(); + Map container = new HashMap<>(); + boolean[] flatInput = new boolean[] { true, false, true, false, true }; + Object tensorIn = OrtUtil.reshape(flatInput, new long[] { 1, 5 }); + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(inputName,ov); + try (OrtSession.Result res = session.run(container)) { + boolean[] resultArray = TestHelpers.flattenBoolean(res.get(0).getValue()); + assertArrayEquals(flatInput, resultArray); + } + OnnxValue.close(container); + } + } + + @Test + public void testModelInputINT32() throws OrtException { + // model takes 1x5 input of fixed type, echoes back + String modelPath = resourcePath.resolve("test_types_INT32.pb").toString(); + + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testModelInputINT32"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + String inputName = session.getInputNames().iterator().next(); + Map container = new HashMap<>(); + int[] flatInput = new int[] { 1, -2, -3, Integer.MIN_VALUE, Integer.MAX_VALUE }; + Object tensorIn = OrtUtil.reshape(flatInput, new long[] { 1, 5 }); + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(inputName,ov); + try (OrtSession.Result res = session.run(container)) { + int[] resultArray = TestHelpers.flattenInteger(res.get(0).getValue()); + assertArrayEquals(flatInput, resultArray); + } + OnnxValue.close(container); + } + } + + @Test + public void testModelInputDOUBLE() throws OrtException { + // model takes 1x5 input of fixed type, echoes back + String modelPath = resourcePath.resolve("test_types_DOUBLE.pb").toString(); + + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testModelInputDOUBLE"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + String inputName = session.getInputNames().iterator().next(); + Map container = new HashMap<>(); + double[] flatInput = new double[] { 1.0, 2.0, -3.0, 5, 5 }; + Object tensorIn = OrtUtil.reshape(flatInput, new long[] { 1, 5 }); + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(inputName,ov); + try (OrtSession.Result res = session.run(container)) { + double[] resultArray = TestHelpers.flattenDouble(res.get(0).getValue()); + assertArrayEquals(flatInput, resultArray, 1e-6f); + } + OnnxValue.close(container); + } + } + + @Test + public void testModelInputINT8() throws OrtException { + // model takes 1x5 input of fixed type, echoes back + String modelPath = resourcePath.resolve("test_types_INT8.pb").toString(); + + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testModelInputINT8"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + String inputName = session.getInputNames().iterator().next(); + Map container = new HashMap<>(); + byte[] flatInput = new byte[] { 1, 2, -3, Byte.MIN_VALUE, Byte.MAX_VALUE }; + Object tensorIn = OrtUtil.reshape(flatInput, new long[] { 1, 5 }); + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(inputName,ov); + try (OrtSession.Result res = session.run(container)) { + byte[] resultArray = TestHelpers.flattenByte(res.get(0).getValue()); + assertArrayEquals(flatInput, resultArray); + } + OnnxValue.close(container); + } + } + + @Test + public void testModelInputINT16() throws OrtException { + // model takes 1x5 input of fixed type, echoes back + String modelPath = resourcePath.resolve("test_types_INT16.pb").toString(); + + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testModelInputINT16"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + String inputName = session.getInputNames().iterator().next(); + Map container = new HashMap<>(); + short[] flatInput = new short[] { 1, 2, 3, Short.MIN_VALUE, Short.MAX_VALUE }; + Object tensorIn = OrtUtil.reshape(flatInput, new long[] { 1, 5 }); + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(inputName,ov); + try (OrtSession.Result res = session.run(container)) { + short[] resultArray = TestHelpers.flattenShort(res.get(0).getValue()); + assertArrayEquals(flatInput, resultArray); + } + OnnxValue.close(container); + } + } + + @Test + public void testModelInputINT64() throws OrtException { + // model takes 1x5 input of fixed type, echoes back + String modelPath = resourcePath.resolve("test_types_INT64.pb").toString(); + + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testModelInputINT64"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + String inputName = session.getInputNames().iterator().next(); + Map container = new HashMap<>(); + long[] flatInput = new long[] { 1, 2, -3, Long.MIN_VALUE, Long.MAX_VALUE }; + Object tensorIn = OrtUtil.reshape(flatInput, new long[] { 1, 5 }); + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(inputName,ov); + try (OrtSession.Result res = session.run(container)) { + long[] resultArray = TestHelpers.flattenLong(res.get(0).getValue()); + assertArrayEquals(flatInput, resultArray); + } + OnnxValue.close(container); + } + } + + @Test + public void testModelSequenceOfMapIntFloat() throws OrtException { + // test model trained using lightgbm classifier + // produces 2 named outputs + // "label" is a tensor, + // "probabilities" is a sequence> + // https://github.com/onnx/sklearn-onnx/blob/master/docs/examples/plot_pipeline_lightgbm.py + + String modelPath = resourcePath.resolve("test_sequence_map_int_float.pb").toString(); + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testModelSequenceOfMapIntFloat"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + + Map outputInfos = session.getOutputInfo(); + Iterator valuesItr = outputInfos.values().iterator(); + NodeInfo firstOutputInfo = valuesItr.next(); + NodeInfo secondOutputInfo = valuesItr.next(); + assertTrue(firstOutputInfo.getInfo() instanceof TensorInfo); + assertTrue(secondOutputInfo.getInfo() instanceof SequenceInfo); + assertEquals(OnnxJavaType.INT64,((TensorInfo)firstOutputInfo.getInfo()).type); + + Map container = new HashMap<>(); + long[] shape = new long[] { 1, 2 }; + float[] flatInput = new float[] {5.8f, 2.8f}; + Object tensorIn = OrtUtil.reshape(flatInput,shape); + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(session.getInputNames().iterator().next(),ov); + + try (OrtSession.Result outputs = session.run(container)) { + assertEquals(2, outputs.size()); + + // first output is a tensor containing label + OnnxValue firstOutput = outputs.get(firstOutputInfo.getName()).get(); + assertTrue(firstOutput instanceof OnnxTensor); + + // try-cast as a tensor + long[] labelOutput = (long[]) firstOutput.getValue(); + + // Label 1 should have highest probability + assertEquals(1, labelOutput[0]); + assertEquals(1, labelOutput.length); + + // second output is a sequence> + // try-cast to an sequence of NOV + OnnxValue secondOutput = outputs.get(secondOutputInfo.getName()).get(); + assertTrue(secondOutput instanceof OnnxSequence); + SequenceInfo sequenceInfo = ((OnnxSequence) secondOutput).getInfo(); + assertTrue(sequenceInfo.sequenceOfMaps); + assertEquals(OnnxJavaType.INT64, sequenceInfo.mapInfo.keyType); + assertEquals(OnnxJavaType.FLOAT, sequenceInfo.mapInfo.valueType); + + // try-cast first element in sequence to map/dictionary type + Map map = (Map) ((List) secondOutput.getValue()).get(0); + assertEquals(0.25938290, map.get(0L), 1e-6); + assertEquals(0.40904793, map.get(1L), 1e-6); + assertEquals(0.33156919, map.get(2L), 1e-6); + } + ov.close(); + } + } + + @Test + public void testModelSequenceOfMapStringFloat() throws OrtException { + // test model trained using lightgbm classifier + // produces 2 named outputs + // "label" is a tensor, + // "probabilities" is a sequence> + // https://github.com/onnx/sklearn-onnx/blob/master/docs/examples/plot_pipeline_lightgbm.py + String modelPath = resourcePath.resolve("test_sequence_map_string_float.pb").toString(); + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testModelSequenceOfMapStringFloat"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + + Map outputInfos = session.getOutputInfo(); + Iterator valuesItr = outputInfos.values().iterator(); + NodeInfo firstOutputInfo = valuesItr.next(); + NodeInfo secondOutputInfo = valuesItr.next(); + assertTrue(firstOutputInfo.getInfo() instanceof TensorInfo); + assertTrue(secondOutputInfo.getInfo() instanceof SequenceInfo); + assertEquals(OnnxJavaType.STRING,((TensorInfo)firstOutputInfo.getInfo()).type); + + Map container = new HashMap<>(); + long[] shape = new long[] { 1, 2 }; + float[] flatInput = new float[] {5.8f, 2.8f}; + Object tensorIn = OrtUtil.reshape(flatInput,shape); + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(session.getInputNames().iterator().next(),ov); + + try (OrtSession.Result outputs = session.run(container)) { + assertEquals(2, outputs.size()); + + // first output is a tensor containing label + OnnxValue firstOutput = outputs.get(firstOutputInfo.getName()).get(); + assertTrue(firstOutput instanceof OnnxTensor); + + // try-cast as a tensor + String[] labelOutput = (String[]) firstOutput.getValue(); + + // Label 1 should have highest probability + assertEquals("1", labelOutput[0]); + assertEquals(1, labelOutput.length); + + // second output is a sequence> + // try-cast to an sequence of NOV + OnnxValue secondOutput = outputs.get(secondOutputInfo.getName()).get(); + assertTrue(secondOutput instanceof OnnxSequence); + SequenceInfo sequenceInfo = ((OnnxSequence) secondOutput).getInfo(); + assertTrue(sequenceInfo.sequenceOfMaps); + assertEquals(OnnxJavaType.STRING, sequenceInfo.mapInfo.keyType); + assertEquals(OnnxJavaType.FLOAT, sequenceInfo.mapInfo.valueType); + + // try-cast first element in sequence to map/dictionary type + Map map = (Map) ((List) secondOutput.getValue()).get(0); + assertEquals(0.25938290, map.get("0"), 1e-6); + assertEquals(0.40904793, map.get("1"), 1e-6); + assertEquals(0.33156919, map.get("2"), 1e-6); + } + ov.close(); + } + } + + @Test + public void testModelSerialization() throws OrtException { + String cwd = System.getProperty("user.dir"); + Path squeezeNet = resourcePath.resolve("squeezenet.onnx"); + String modelPath = squeezeNet.toString(); + String modelOutputPath = Paths.get(cwd, "optimized-squeezenet.onnx").toString(); + try (OrtEnvironment env = OrtEnvironment.getEnvironment()) { + // Set the optimized model file path to assert that no exception are thrown. + SessionOptions options = new SessionOptions(); + options.setOptimizedModelFilePath(modelOutputPath); + options.setOptimizationLevel(OptLevel.BASIC_OPT); + try (OrtSession session = env.createSession(modelPath, options)) { + Assertions.assertNotNull(session); + Assertions.assertTrue((new File(modelOutputPath)).exists()); + } + } + } + + @Test + public void testStringIdentity() throws OrtException { + String modelPath = otherTestPath.resolve("identity_string.onnx").toString(); + try (OrtEnvironment env = OrtEnvironment.getEnvironment("testStringIdentity"); + SessionOptions options = new SessionOptions(); + OrtSession session = env.createSession(modelPath, options)) { + + Map outputInfos = session.getOutputInfo(); + ValueInfo firstOutputInfo = outputInfos.values().iterator().next().getInfo(); + assertTrue(firstOutputInfo instanceof TensorInfo); + assertEquals(OnnxJavaType.STRING,((TensorInfo)firstOutputInfo).type); + + String inputName = session.getInputNames().iterator().next(); + + Map container = new HashMap<>(); + String[][] tensorIn = new String[][]{new String[] {"this", "is"}, new String[] {"identity", "test"}}; + OnnxTensor ov = OnnxTensor.createTensor(env,tensorIn); + container.put(inputName,ov); + + try (OrtSession.Result outputs = session.run(container)) { + assertEquals(1, outputs.size()); + + OnnxValue firstOutput = outputs.get(0); + assertTrue(firstOutput instanceof OnnxTensor); + + String[] labelOutput = (String[]) firstOutput.getValue(); + + assertEquals("this", labelOutput[0]); + assertEquals("is", labelOutput[1]); + assertEquals("identity", labelOutput[2]); + assertEquals("test", labelOutput[3]); + assertEquals(4, labelOutput.length); + + OnnxValue.close(container); + container.clear(); + } + + String[] tensorInFlatArr = new String[]{"this", "is", "identity", "test"}; + ov = OnnxTensor.createTensor(env,tensorInFlatArr, new long[]{2,2}); + container.put(inputName,ov); + + try (OrtSession.Result outputs = session.run(container)) { + assertEquals(1, outputs.size()); + + OnnxValue firstOutput = outputs.get(0); + assertTrue(firstOutput instanceof OnnxTensor); + + String[] labelOutput = (String[]) firstOutput.getValue(); + + assertEquals("this", labelOutput[0]); + assertEquals("is", labelOutput[1]); + assertEquals("identity", labelOutput[2]); + assertEquals("test", labelOutput[3]); + assertEquals(4, labelOutput.length); + } + } + } + + /** + * Carrier tuple for the squeeze net model. + */ + private static class SqueezeNetTuple { + public final OrtEnvironment env; + public final OrtSession session; + public final float[] inputData; + public final float[] outputData; + + public SqueezeNetTuple(OrtEnvironment env, OrtSession session, float[] inputData, float[] outputData) { + this.env = env; + this.session = session; + this.inputData = inputData; + this.outputData = outputData; + } + } + + private static SqueezeNetTuple openSessionSqueezeNet() throws OrtException { + return openSessionSqueezeNet(-1); + } + + private static SqueezeNetTuple openSessionSqueezeNet(int cudaDeviceId) throws OrtException { + Path squeezeNet = resourcePath.resolve("squeezenet.onnx"); + String modelPath = squeezeNet.toString(); + OrtEnvironment env = OrtEnvironment.getEnvironment(); + SessionOptions options = new SessionOptions(); + if (cudaDeviceId != -1) { + options.addCUDA(cudaDeviceId); + } + OrtSession session = env.createSession(modelPath,options); + float[] inputData = loadTensorFromFile(resourcePath.resolve("bench.in")); + float[] expectedOutput = loadTensorFromFile(resourcePath.resolve("bench.expected_out")); + return new SqueezeNetTuple(env, session, inputData, expectedOutput); + } + + private static float[] loadTensorFromFile(Path filename) { + return loadTensorFromFile(filename,true); + } + + private static float[] loadTensorFromFile(Path filename, boolean skipHeader) { + // read data from file + try (BufferedReader reader = new BufferedReader(new FileReader(filename.toFile()))) { + if (skipHeader) { + reader.readLine(); //skip the input name + } + String[] dataStr = LOAD_PATTERN.split(reader.readLine()); + List tensorData = new ArrayList<>(); + for (int i = 0; i < dataStr.length; i++) { + if (!dataStr[i].isEmpty()) { + tensorData.add(Float.parseFloat(dataStr[i])); + } + } + return TestHelpers.toPrimitiveFloat(tensorData); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + private static class TypeWidth { + public final OnnxJavaType type; + public final int width; + public TypeWidth(OnnxJavaType type, int width) { + this.type = type; + this.width = width; + } + } + + private static TypeWidth getTypeAndWidth(TensorProto.DataType elemType) { + OnnxJavaType type; + int width; + switch (elemType) { + case FLOAT: + type = OnnxJavaType.FLOAT; + width = 4; + break; + case UINT8: + case INT8: + type = OnnxJavaType.INT8; + width = 1; + break; + case UINT16: + case INT16: + type = OnnxJavaType.INT16; + width = 2; + break; + case INT32: + case UINT32: + type = OnnxJavaType.INT32; + width = 4; + break; + case INT64: + case UINT64: + type = OnnxJavaType.INT64; + width = 8; + break; + case STRING: + type = OnnxJavaType.STRING; + width = 1; + break; + case BOOL: + type = OnnxJavaType.BOOL; + width = 1; + break; + case FLOAT16: + type = OnnxJavaType.FLOAT; + width = 2; + break; + case DOUBLE: + type = OnnxJavaType.DOUBLE; + width = 8; + break; + default: + type = null; + width = 0; + break; + } + return new TypeWidth(type,width); + } + + private static StringTensorPair loadTensorFromFilePb(OrtEnvironment env, File filename, Map nodeMetaDict) throws IOException, OrtException { + InputStream is = new BufferedInputStream(new FileInputStream(filename)); + OnnxMl.TensorProto tensor = OnnxMl.TensorProto.parseFrom(is); + is.close(); + + TypeWidth tw = getTypeAndWidth(DataType.forNumber(tensor.getDataType())); + int width = tw.width; + OnnxJavaType tensorElemType = tw.type; + long[] intDims = new long[tensor.getDimsCount()]; + for (int i = 0; i < tensor.getDimsCount(); i++) { + intDims[i] = tensor.getDims(i); + } + + TensorInfo nodeMeta = null; + String nodeName = ""; + if (nodeMetaDict.size() == 1) { + for (Map.Entry e : nodeMetaDict.entrySet()) { + nodeMeta = (TensorInfo) e.getValue().getInfo(); + nodeName = e.getKey(); // valid for single node input + } + } else if (nodeMetaDict.size() > 1) { + if (!tensor.getName().isEmpty()) { + nodeMeta = (TensorInfo) nodeMetaDict.get(tensor.getName()).getInfo(); + nodeName = tensor.getName(); + } else { + boolean matchfound = false; + // try to find from matching type and shape + for (Map.Entry e : nodeMetaDict.entrySet()) { + if (e.getValue().getInfo() instanceof TensorInfo) { + TensorInfo meta = (TensorInfo) e.getValue().getInfo(); + if (tensorElemType == meta.type && tensor.getDimsCount() == meta.shape.length) { + int i = 0; + for (; i < meta.shape.length; i++) { + if (meta.shape[i] != -1 && meta.shape[i] != intDims[i]) { + break; + } + } + if (i >= meta.shape.length) { + matchfound = true; + nodeMeta = meta; + nodeName = e.getKey(); + break; + } + } + } + } + if (!matchfound) { + // throw error + throw new IllegalStateException("No matching Tensor found in InputOutputMetadata corresponding to the serialized tensor loaded from " + filename); + } + } + } else { + // throw error + throw new IllegalStateException("While reading the serialized tensor loaded from " + filename + ", metaDataDict has 0 elements"); + } + + Assertions.assertEquals(tensorElemType, nodeMeta.type); + Assertions.assertEquals(nodeMeta.shape.length, tensor.getDimsCount()); + for (int i = 0; i < nodeMeta.shape.length; i++) { + Assertions.assertTrue((nodeMeta.shape[i] == -1) || (nodeMeta.shape[i] == intDims[i])); + } + + ByteBuffer buffer = ByteBuffer.wrap(tensor.getRawData().toByteArray()); + + OnnxTensor onnxTensor = OnnxTensor.createTensor(env,buffer,intDims,tensorElemType); + + return new StringTensorPair(nodeName,onnxTensor); + } + + private static class StringTensorPair { + public final String string; + public final OnnxTensor tensor; + public StringTensorPair(String string, OnnxTensor tensor) { + this.string = string; + this.tensor = tensor; + } + } + +} diff --git a/java/src/test/java/ai/onnxruntime/OnnxMl.java b/java/src/test/java/ai/onnxruntime/OnnxMl.java new file mode 100644 index 0000000000000..94ba78a32bac6 --- /dev/null +++ b/java/src/test/java/ai/onnxruntime/OnnxMl.java @@ -0,0 +1,34028 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: onnx-ml.proto3 + +package ai.onnxruntime; + +public final class OnnxMl { + private OnnxMl() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + /** + *
+   * Versioning
+   * ONNX versioning is specified in docs/IR.md and elaborated on in docs/Versioning.md
+   * To be compatible with both proto2 and proto3, we will use a version number
+   * that is not defined by the default value but an explicit enum number.
+   * 
+ * + * Protobuf enum {@code onnx.Version} + */ + public enum Version + implements com.google.protobuf.ProtocolMessageEnum { + /** + *
+     * proto3 requires the first enum value to be zero.
+     * We add this just to appease the compiler.
+     * 
+ * + * _START_VERSION = 0; + */ + _START_VERSION(0), + /** + *
+     * The version field is always serialized and we will use it to store the
+     * version that the  graph is generated from. This helps us set up version
+     * control. 
+     * For the IR, we are using simple numbers starting with with 0x00000001, 
+     * which was the version we published on Oct 10, 2017.
+     * 
+ * + * IR_VERSION_2017_10_10 = 1; + */ + IR_VERSION_2017_10_10(1), + /** + *
+     * IR_VERSION 2 published on Oct 30, 2017
+     * - Added type discriminator to AttributeProto to support proto3 users
+     * 
+ * + * IR_VERSION_2017_10_30 = 2; + */ + IR_VERSION_2017_10_30(2), + /** + *
+     * IR VERSION 3 published on Nov 3, 2017
+     * - For operator versioning:
+     *    - Added new message OperatorSetIdProto
+     *    - Added opset_import in ModelProto
+     * - For vendor extensions, added domain in NodeProto
+     * 
+ * + * IR_VERSION_2017_11_3 = 3; + */ + IR_VERSION_2017_11_3(3), + /** + *
+     * IR VERSION 4 published on Jan 22, 2019
+     * - Relax constraint that initializers should be a subset of graph inputs
+     * - Add type BFLOAT16
+     * 
+ * + * IR_VERSION_2019_1_22 = 4; + */ + IR_VERSION_2019_1_22(4), + /** + *
+     * IR VERSION 5 published on March 18, 2019
+     * - Add message TensorAnnotation.
+     * - Add quantization annotation in GraphProto to map tensor with its scale and zero point quantization parameters.
+     * 
+ * + * IR_VERSION_2019_3_18 = 5; + */ + IR_VERSION_2019_3_18(5), + /** + *
+     * IR VERSION 6 published on Sep 19, 2019
+     * - Add support for sparse tensor constants stored in model.
+     *   - Add message SparseTensorProto
+     *   - Add sparse initializers
+     * 
+ * + * IR_VERSION = 6; + */ + IR_VERSION(6), + UNRECOGNIZED(-1), + ; + + /** + *
+     * proto3 requires the first enum value to be zero.
+     * We add this just to appease the compiler.
+     * 
+ * + * _START_VERSION = 0; + */ + public static final int _START_VERSION_VALUE = 0; + /** + *
+     * The version field is always serialized and we will use it to store the
+     * version that the  graph is generated from. This helps us set up version
+     * control. 
+     * For the IR, we are using simple numbers starting with with 0x00000001, 
+     * which was the version we published on Oct 10, 2017.
+     * 
+ * + * IR_VERSION_2017_10_10 = 1; + */ + public static final int IR_VERSION_2017_10_10_VALUE = 1; + /** + *
+     * IR_VERSION 2 published on Oct 30, 2017
+     * - Added type discriminator to AttributeProto to support proto3 users
+     * 
+ * + * IR_VERSION_2017_10_30 = 2; + */ + public static final int IR_VERSION_2017_10_30_VALUE = 2; + /** + *
+     * IR VERSION 3 published on Nov 3, 2017
+     * - For operator versioning:
+     *    - Added new message OperatorSetIdProto
+     *    - Added opset_import in ModelProto
+     * - For vendor extensions, added domain in NodeProto
+     * 
+ * + * IR_VERSION_2017_11_3 = 3; + */ + public static final int IR_VERSION_2017_11_3_VALUE = 3; + /** + *
+     * IR VERSION 4 published on Jan 22, 2019
+     * - Relax constraint that initializers should be a subset of graph inputs
+     * - Add type BFLOAT16
+     * 
+ * + * IR_VERSION_2019_1_22 = 4; + */ + public static final int IR_VERSION_2019_1_22_VALUE = 4; + /** + *
+     * IR VERSION 5 published on March 18, 2019
+     * - Add message TensorAnnotation.
+     * - Add quantization annotation in GraphProto to map tensor with its scale and zero point quantization parameters.
+     * 
+ * + * IR_VERSION_2019_3_18 = 5; + */ + public static final int IR_VERSION_2019_3_18_VALUE = 5; + /** + *
+     * IR VERSION 6 published on Sep 19, 2019
+     * - Add support for sparse tensor constants stored in model.
+     *   - Add message SparseTensorProto
+     *   - Add sparse initializers
+     * 
+ * + * IR_VERSION = 6; + */ + public static final int IR_VERSION_VALUE = 6; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Version valueOf(int value) { + return forNumber(value); + } + + public static Version forNumber(int value) { + switch (value) { + case 0: return _START_VERSION; + case 1: return IR_VERSION_2017_10_10; + case 2: return IR_VERSION_2017_10_30; + case 3: return IR_VERSION_2017_11_3; + case 4: return IR_VERSION_2019_1_22; + case 5: return IR_VERSION_2019_3_18; + case 6: return IR_VERSION; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + Version> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Version findValueByNumber(int number) { + return Version.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return OnnxMl.getDescriptor().getEnumTypes().get(0); + } + + private static final Version[] VALUES = values(); + + public static Version valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Version(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:onnx.Version) + } + + /** + *
+   * Operator/function status.
+   * 
+ * + * Protobuf enum {@code onnx.OperatorStatus} + */ + public enum OperatorStatus + implements com.google.protobuf.ProtocolMessageEnum { + /** + * EXPERIMENTAL = 0; + */ + EXPERIMENTAL(0), + /** + * STABLE = 1; + */ + STABLE(1), + UNRECOGNIZED(-1), + ; + + /** + * EXPERIMENTAL = 0; + */ + public static final int EXPERIMENTAL_VALUE = 0; + /** + * STABLE = 1; + */ + public static final int STABLE_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static OperatorStatus valueOf(int value) { + return forNumber(value); + } + + public static OperatorStatus forNumber(int value) { + switch (value) { + case 0: return EXPERIMENTAL; + case 1: return STABLE; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + OperatorStatus> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public OperatorStatus findValueByNumber(int number) { + return OperatorStatus.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return OnnxMl.getDescriptor().getEnumTypes().get(1); + } + + private static final OperatorStatus[] VALUES = values(); + + public static OperatorStatus valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private OperatorStatus(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:onnx.OperatorStatus) + } + + public interface AttributeProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.AttributeProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * The name field MUST be present for this version of the IR.
+     * 
+ * + * string name = 1; + */ + java.lang.String getName(); + /** + *
+     * The name field MUST be present for this version of the IR.
+     * 
+ * + * string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     * if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
+     * In this case, this AttributeProto does not contain data, and it's a reference of attribute
+     * in parent scope.
+     * NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
+     * 
+ * + * string ref_attr_name = 21; + */ + java.lang.String getRefAttrName(); + /** + *
+     * if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
+     * In this case, this AttributeProto does not contain data, and it's a reference of attribute
+     * in parent scope.
+     * NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
+     * 
+ * + * string ref_attr_name = 21; + */ + com.google.protobuf.ByteString + getRefAttrNameBytes(); + + /** + *
+     * A human-readable documentation for this attribute. Markdown is allowed.
+     * 
+ * + * string doc_string = 13; + */ + java.lang.String getDocString(); + /** + *
+     * A human-readable documentation for this attribute. Markdown is allowed.
+     * 
+ * + * string doc_string = 13; + */ + com.google.protobuf.ByteString + getDocStringBytes(); + + /** + *
+     * The type field MUST be present for this version of the IR.
+     * For 0.0.1 versions of the IR, this field was not defined, and
+     * implementations needed to use has_field hueristics to determine
+     * which value field was in use.  For IR_VERSION 0.0.2 or later, this
+     * field MUST be set and match the f|i|s|t|... field in use.  This
+     * change was made to accomodate proto3 implementations.
+     * 
+ * + * .onnx.AttributeProto.AttributeType type = 20; + */ + int getTypeValue(); + /** + *
+     * The type field MUST be present for this version of the IR.
+     * For 0.0.1 versions of the IR, this field was not defined, and
+     * implementations needed to use has_field hueristics to determine
+     * which value field was in use.  For IR_VERSION 0.0.2 or later, this
+     * field MUST be set and match the f|i|s|t|... field in use.  This
+     * change was made to accomodate proto3 implementations.
+     * 
+ * + * .onnx.AttributeProto.AttributeType type = 20; + */ + OnnxMl.AttributeProto.AttributeType getType(); + + /** + *
+     * Exactly ONE of the following fields must be present for this version of the IR
+     * 
+ * + * float f = 2; + */ + float getF(); + + /** + *
+     * int
+     * 
+ * + * int64 i = 3; + */ + long getI(); + + /** + *
+     * UTF-8 string
+     * 
+ * + * bytes s = 4; + */ + com.google.protobuf.ByteString getS(); + + /** + *
+     * tensor value
+     * 
+ * + * .onnx.TensorProto t = 5; + */ + boolean hasT(); + /** + *
+     * tensor value
+     * 
+ * + * .onnx.TensorProto t = 5; + */ + OnnxMl.TensorProto getT(); + /** + *
+     * tensor value
+     * 
+ * + * .onnx.TensorProto t = 5; + */ + OnnxMl.TensorProtoOrBuilder getTOrBuilder(); + + /** + *
+     * graph
+     * 
+ * + * .onnx.GraphProto g = 6; + */ + boolean hasG(); + /** + *
+     * graph
+     * 
+ * + * .onnx.GraphProto g = 6; + */ + OnnxMl.GraphProto getG(); + /** + *
+     * graph
+     * 
+ * + * .onnx.GraphProto g = 6; + */ + OnnxMl.GraphProtoOrBuilder getGOrBuilder(); + + /** + *
+     * sparse tensor value
+     * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + boolean hasSparseTensor(); + /** + *
+     * sparse tensor value
+     * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + OnnxMl.SparseTensorProto getSparseTensor(); + /** + *
+     * sparse tensor value
+     * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + OnnxMl.SparseTensorProtoOrBuilder getSparseTensorOrBuilder(); + + /** + *
+     * list of floats
+     * 
+ * + * repeated float floats = 7; + */ + java.util.List getFloatsList(); + /** + *
+     * list of floats
+     * 
+ * + * repeated float floats = 7; + */ + int getFloatsCount(); + /** + *
+     * list of floats
+     * 
+ * + * repeated float floats = 7; + */ + float getFloats(int index); + + /** + *
+     * list of ints
+     * 
+ * + * repeated int64 ints = 8; + */ + java.util.List getIntsList(); + /** + *
+     * list of ints
+     * 
+ * + * repeated int64 ints = 8; + */ + int getIntsCount(); + /** + *
+     * list of ints
+     * 
+ * + * repeated int64 ints = 8; + */ + long getInts(int index); + + /** + *
+     * list of UTF-8 strings
+     * 
+ * + * repeated bytes strings = 9; + */ + java.util.List getStringsList(); + /** + *
+     * list of UTF-8 strings
+     * 
+ * + * repeated bytes strings = 9; + */ + int getStringsCount(); + /** + *
+     * list of UTF-8 strings
+     * 
+ * + * repeated bytes strings = 9; + */ + com.google.protobuf.ByteString getStrings(int index); + + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + java.util.List + getTensorsList(); + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + OnnxMl.TensorProto getTensors(int index); + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + int getTensorsCount(); + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + java.util.List + getTensorsOrBuilderList(); + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + OnnxMl.TensorProtoOrBuilder getTensorsOrBuilder( + int index); + + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + java.util.List + getGraphsList(); + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + OnnxMl.GraphProto getGraphs(int index); + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + int getGraphsCount(); + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + java.util.List + getGraphsOrBuilderList(); + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + OnnxMl.GraphProtoOrBuilder getGraphsOrBuilder( + int index); + + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + java.util.List + getSparseTensorsList(); + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + OnnxMl.SparseTensorProto getSparseTensors(int index); + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + int getSparseTensorsCount(); + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + java.util.List + getSparseTensorsOrBuilderList(); + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + OnnxMl.SparseTensorProtoOrBuilder getSparseTensorsOrBuilder( + int index); + } + /** + *
+   * Attributes
+   * A named attribute containing either singular float, integer, string, graph,
+   * and tensor values, or repeated float, integer, string, graph, and tensor values.
+   * An AttributeProto MUST contain the name field, and *only one* of the
+   * following content fields, effectively enforcing a C/C++ union equivalent.
+   * 
+ * + * Protobuf type {@code onnx.AttributeProto} + */ + public static final class AttributeProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.AttributeProto) + AttributeProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use AttributeProto.newBuilder() to construct. + private AttributeProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private AttributeProto() { + name_ = ""; + refAttrName_ = ""; + docString_ = ""; + type_ = 0; + f_ = 0F; + i_ = 0L; + s_ = com.google.protobuf.ByteString.EMPTY; + floats_ = java.util.Collections.emptyList(); + ints_ = java.util.Collections.emptyList(); + strings_ = java.util.Collections.emptyList(); + tensors_ = java.util.Collections.emptyList(); + graphs_ = java.util.Collections.emptyList(); + sparseTensors_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private AttributeProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 21: { + + f_ = input.readFloat(); + break; + } + case 24: { + + i_ = input.readInt64(); + break; + } + case 34: { + + s_ = input.readBytes(); + break; + } + case 42: { + OnnxMl.TensorProto.Builder subBuilder = null; + if (t_ != null) { + subBuilder = t_.toBuilder(); + } + t_ = input.readMessage(OnnxMl.TensorProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(t_); + t_ = subBuilder.buildPartial(); + } + + break; + } + case 50: { + OnnxMl.GraphProto.Builder subBuilder = null; + if (g_ != null) { + subBuilder = g_.toBuilder(); + } + g_ = input.readMessage(OnnxMl.GraphProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(g_); + g_ = subBuilder.buildPartial(); + } + + break; + } + case 61: { + if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) { + floats_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000400; + } + floats_.add(input.readFloat()); + break; + } + case 58: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000400) == 0x00000400) && input.getBytesUntilLimit() > 0) { + floats_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000400; + } + while (input.getBytesUntilLimit() > 0) { + floats_.add(input.readFloat()); + } + input.popLimit(limit); + break; + } + case 64: { + if (!((mutable_bitField0_ & 0x00000800) == 0x00000800)) { + ints_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000800; + } + ints_.add(input.readInt64()); + break; + } + case 66: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000800) == 0x00000800) && input.getBytesUntilLimit() > 0) { + ints_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000800; + } + while (input.getBytesUntilLimit() > 0) { + ints_.add(input.readInt64()); + } + input.popLimit(limit); + break; + } + case 74: { + if (!((mutable_bitField0_ & 0x00001000) == 0x00001000)) { + strings_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00001000; + } + strings_.add(input.readBytes()); + break; + } + case 82: { + if (!((mutable_bitField0_ & 0x00002000) == 0x00002000)) { + tensors_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00002000; + } + tensors_.add( + input.readMessage(OnnxMl.TensorProto.parser(), extensionRegistry)); + break; + } + case 90: { + if (!((mutable_bitField0_ & 0x00004000) == 0x00004000)) { + graphs_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00004000; + } + graphs_.add( + input.readMessage(OnnxMl.GraphProto.parser(), extensionRegistry)); + break; + } + case 106: { + java.lang.String s = input.readStringRequireUtf8(); + + docString_ = s; + break; + } + case 160: { + int rawValue = input.readEnum(); + + type_ = rawValue; + break; + } + case 170: { + java.lang.String s = input.readStringRequireUtf8(); + + refAttrName_ = s; + break; + } + case 178: { + OnnxMl.SparseTensorProto.Builder subBuilder = null; + if (sparseTensor_ != null) { + subBuilder = sparseTensor_.toBuilder(); + } + sparseTensor_ = input.readMessage(OnnxMl.SparseTensorProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sparseTensor_); + sparseTensor_ = subBuilder.buildPartial(); + } + + break; + } + case 186: { + if (!((mutable_bitField0_ & 0x00008000) == 0x00008000)) { + sparseTensors_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00008000; + } + sparseTensors_.add( + input.readMessage(OnnxMl.SparseTensorProto.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000400) == 0x00000400)) { + floats_ = java.util.Collections.unmodifiableList(floats_); + } + if (((mutable_bitField0_ & 0x00000800) == 0x00000800)) { + ints_ = java.util.Collections.unmodifiableList(ints_); + } + if (((mutable_bitField0_ & 0x00001000) == 0x00001000)) { + strings_ = java.util.Collections.unmodifiableList(strings_); + } + if (((mutable_bitField0_ & 0x00002000) == 0x00002000)) { + tensors_ = java.util.Collections.unmodifiableList(tensors_); + } + if (((mutable_bitField0_ & 0x00004000) == 0x00004000)) { + graphs_ = java.util.Collections.unmodifiableList(graphs_); + } + if (((mutable_bitField0_ & 0x00008000) == 0x00008000)) { + sparseTensors_ = java.util.Collections.unmodifiableList(sparseTensors_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_AttributeProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_AttributeProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.AttributeProto.class, OnnxMl.AttributeProto.Builder.class); + } + + /** + *
+     * Note: this enum is structurally identical to the OpSchema::AttrType
+     * enum defined in schema.h.  If you rev one, you likely need to rev the other.
+     * 
+ * + * Protobuf enum {@code onnx.AttributeProto.AttributeType} + */ + public enum AttributeType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * UNDEFINED = 0; + */ + UNDEFINED(0), + /** + * FLOAT = 1; + */ + FLOAT(1), + /** + * INT = 2; + */ + INT(2), + /** + * STRING = 3; + */ + STRING(3), + /** + * TENSOR = 4; + */ + TENSOR(4), + /** + * GRAPH = 5; + */ + GRAPH(5), + /** + * SPARSE_TENSOR = 11; + */ + SPARSE_TENSOR(11), + /** + * FLOATS = 6; + */ + FLOATS(6), + /** + * INTS = 7; + */ + INTS(7), + /** + * STRINGS = 8; + */ + STRINGS(8), + /** + * TENSORS = 9; + */ + TENSORS(9), + /** + * GRAPHS = 10; + */ + GRAPHS(10), + /** + * SPARSE_TENSORS = 12; + */ + SPARSE_TENSORS(12), + UNRECOGNIZED(-1), + ; + + /** + * UNDEFINED = 0; + */ + public static final int UNDEFINED_VALUE = 0; + /** + * FLOAT = 1; + */ + public static final int FLOAT_VALUE = 1; + /** + * INT = 2; + */ + public static final int INT_VALUE = 2; + /** + * STRING = 3; + */ + public static final int STRING_VALUE = 3; + /** + * TENSOR = 4; + */ + public static final int TENSOR_VALUE = 4; + /** + * GRAPH = 5; + */ + public static final int GRAPH_VALUE = 5; + /** + * SPARSE_TENSOR = 11; + */ + public static final int SPARSE_TENSOR_VALUE = 11; + /** + * FLOATS = 6; + */ + public static final int FLOATS_VALUE = 6; + /** + * INTS = 7; + */ + public static final int INTS_VALUE = 7; + /** + * STRINGS = 8; + */ + public static final int STRINGS_VALUE = 8; + /** + * TENSORS = 9; + */ + public static final int TENSORS_VALUE = 9; + /** + * GRAPHS = 10; + */ + public static final int GRAPHS_VALUE = 10; + /** + * SPARSE_TENSORS = 12; + */ + public static final int SPARSE_TENSORS_VALUE = 12; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static AttributeType valueOf(int value) { + return forNumber(value); + } + + public static AttributeType forNumber(int value) { + switch (value) { + case 0: return UNDEFINED; + case 1: return FLOAT; + case 2: return INT; + case 3: return STRING; + case 4: return TENSOR; + case 5: return GRAPH; + case 11: return SPARSE_TENSOR; + case 6: return FLOATS; + case 7: return INTS; + case 8: return STRINGS; + case 9: return TENSORS; + case 10: return GRAPHS; + case 12: return SPARSE_TENSORS; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + AttributeType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public AttributeType findValueByNumber(int number) { + return AttributeType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return OnnxMl.AttributeProto.getDescriptor().getEnumTypes().get(0); + } + + private static final AttributeType[] VALUES = values(); + + public static AttributeType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private AttributeType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:onnx.AttributeProto.AttributeType) + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + *
+     * The name field MUST be present for this version of the IR.
+     * 
+ * + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     * The name field MUST be present for this version of the IR.
+     * 
+ * + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REF_ATTR_NAME_FIELD_NUMBER = 21; + private volatile java.lang.Object refAttrName_; + /** + *
+     * if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
+     * In this case, this AttributeProto does not contain data, and it's a reference of attribute
+     * in parent scope.
+     * NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
+     * 
+ * + * string ref_attr_name = 21; + */ + public java.lang.String getRefAttrName() { + java.lang.Object ref = refAttrName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + refAttrName_ = s; + return s; + } + } + /** + *
+     * if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
+     * In this case, this AttributeProto does not contain data, and it's a reference of attribute
+     * in parent scope.
+     * NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
+     * 
+ * + * string ref_attr_name = 21; + */ + public com.google.protobuf.ByteString + getRefAttrNameBytes() { + java.lang.Object ref = refAttrName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + refAttrName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DOC_STRING_FIELD_NUMBER = 13; + private volatile java.lang.Object docString_; + /** + *
+     * A human-readable documentation for this attribute. Markdown is allowed.
+     * 
+ * + * string doc_string = 13; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } + } + /** + *
+     * A human-readable documentation for this attribute. Markdown is allowed.
+     * 
+ * + * string doc_string = 13; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 20; + private int type_; + /** + *
+     * The type field MUST be present for this version of the IR.
+     * For 0.0.1 versions of the IR, this field was not defined, and
+     * implementations needed to use has_field hueristics to determine
+     * which value field was in use.  For IR_VERSION 0.0.2 or later, this
+     * field MUST be set and match the f|i|s|t|... field in use.  This
+     * change was made to accomodate proto3 implementations.
+     * 
+ * + * .onnx.AttributeProto.AttributeType type = 20; + */ + public int getTypeValue() { + return type_; + } + /** + *
+     * The type field MUST be present for this version of the IR.
+     * For 0.0.1 versions of the IR, this field was not defined, and
+     * implementations needed to use has_field hueristics to determine
+     * which value field was in use.  For IR_VERSION 0.0.2 or later, this
+     * field MUST be set and match the f|i|s|t|... field in use.  This
+     * change was made to accomodate proto3 implementations.
+     * 
+ * + * .onnx.AttributeProto.AttributeType type = 20; + */ + public OnnxMl.AttributeProto.AttributeType getType() { + @SuppressWarnings("deprecation") + OnnxMl.AttributeProto.AttributeType result = OnnxMl.AttributeProto.AttributeType.valueOf(type_); + return result == null ? OnnxMl.AttributeProto.AttributeType.UNRECOGNIZED : result; + } + + public static final int F_FIELD_NUMBER = 2; + private float f_; + /** + *
+     * Exactly ONE of the following fields must be present for this version of the IR
+     * 
+ * + * float f = 2; + */ + public float getF() { + return f_; + } + + public static final int I_FIELD_NUMBER = 3; + private long i_; + /** + *
+     * int
+     * 
+ * + * int64 i = 3; + */ + public long getI() { + return i_; + } + + public static final int S_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString s_; + /** + *
+     * UTF-8 string
+     * 
+ * + * bytes s = 4; + */ + public com.google.protobuf.ByteString getS() { + return s_; + } + + public static final int T_FIELD_NUMBER = 5; + private OnnxMl.TensorProto t_; + /** + *
+     * tensor value
+     * 
+ * + * .onnx.TensorProto t = 5; + */ + public boolean hasT() { + return t_ != null; + } + /** + *
+     * tensor value
+     * 
+ * + * .onnx.TensorProto t = 5; + */ + public OnnxMl.TensorProto getT() { + return t_ == null ? OnnxMl.TensorProto.getDefaultInstance() : t_; + } + /** + *
+     * tensor value
+     * 
+ * + * .onnx.TensorProto t = 5; + */ + public OnnxMl.TensorProtoOrBuilder getTOrBuilder() { + return getT(); + } + + public static final int G_FIELD_NUMBER = 6; + private OnnxMl.GraphProto g_; + /** + *
+     * graph
+     * 
+ * + * .onnx.GraphProto g = 6; + */ + public boolean hasG() { + return g_ != null; + } + /** + *
+     * graph
+     * 
+ * + * .onnx.GraphProto g = 6; + */ + public OnnxMl.GraphProto getG() { + return g_ == null ? OnnxMl.GraphProto.getDefaultInstance() : g_; + } + /** + *
+     * graph
+     * 
+ * + * .onnx.GraphProto g = 6; + */ + public OnnxMl.GraphProtoOrBuilder getGOrBuilder() { + return getG(); + } + + public static final int SPARSE_TENSOR_FIELD_NUMBER = 22; + private OnnxMl.SparseTensorProto sparseTensor_; + /** + *
+     * sparse tensor value
+     * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public boolean hasSparseTensor() { + return sparseTensor_ != null; + } + /** + *
+     * sparse tensor value
+     * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public OnnxMl.SparseTensorProto getSparseTensor() { + return sparseTensor_ == null ? OnnxMl.SparseTensorProto.getDefaultInstance() : sparseTensor_; + } + /** + *
+     * sparse tensor value
+     * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public OnnxMl.SparseTensorProtoOrBuilder getSparseTensorOrBuilder() { + return getSparseTensor(); + } + + public static final int FLOATS_FIELD_NUMBER = 7; + private java.util.List floats_; + /** + *
+     * list of floats
+     * 
+ * + * repeated float floats = 7; + */ + public java.util.List + getFloatsList() { + return floats_; + } + /** + *
+     * list of floats
+     * 
+ * + * repeated float floats = 7; + */ + public int getFloatsCount() { + return floats_.size(); + } + /** + *
+     * list of floats
+     * 
+ * + * repeated float floats = 7; + */ + public float getFloats(int index) { + return floats_.get(index); + } + private int floatsMemoizedSerializedSize = -1; + + public static final int INTS_FIELD_NUMBER = 8; + private java.util.List ints_; + /** + *
+     * list of ints
+     * 
+ * + * repeated int64 ints = 8; + */ + public java.util.List + getIntsList() { + return ints_; + } + /** + *
+     * list of ints
+     * 
+ * + * repeated int64 ints = 8; + */ + public int getIntsCount() { + return ints_.size(); + } + /** + *
+     * list of ints
+     * 
+ * + * repeated int64 ints = 8; + */ + public long getInts(int index) { + return ints_.get(index); + } + private int intsMemoizedSerializedSize = -1; + + public static final int STRINGS_FIELD_NUMBER = 9; + private java.util.List strings_; + /** + *
+     * list of UTF-8 strings
+     * 
+ * + * repeated bytes strings = 9; + */ + public java.util.List + getStringsList() { + return strings_; + } + /** + *
+     * list of UTF-8 strings
+     * 
+ * + * repeated bytes strings = 9; + */ + public int getStringsCount() { + return strings_.size(); + } + /** + *
+     * list of UTF-8 strings
+     * 
+ * + * repeated bytes strings = 9; + */ + public com.google.protobuf.ByteString getStrings(int index) { + return strings_.get(index); + } + + public static final int TENSORS_FIELD_NUMBER = 10; + private java.util.List tensors_; + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public java.util.List getTensorsList() { + return tensors_; + } + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public java.util.List + getTensorsOrBuilderList() { + return tensors_; + } + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public int getTensorsCount() { + return tensors_.size(); + } + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public OnnxMl.TensorProto getTensors(int index) { + return tensors_.get(index); + } + /** + *
+     * list of tensors
+     * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public OnnxMl.TensorProtoOrBuilder getTensorsOrBuilder( + int index) { + return tensors_.get(index); + } + + public static final int GRAPHS_FIELD_NUMBER = 11; + private java.util.List graphs_; + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public java.util.List getGraphsList() { + return graphs_; + } + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public java.util.List + getGraphsOrBuilderList() { + return graphs_; + } + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public int getGraphsCount() { + return graphs_.size(); + } + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public OnnxMl.GraphProto getGraphs(int index) { + return graphs_.get(index); + } + /** + *
+     * list of graph
+     * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public OnnxMl.GraphProtoOrBuilder getGraphsOrBuilder( + int index) { + return graphs_.get(index); + } + + public static final int SPARSE_TENSORS_FIELD_NUMBER = 23; + private java.util.List sparseTensors_; + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public java.util.List getSparseTensorsList() { + return sparseTensors_; + } + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public java.util.List + getSparseTensorsOrBuilderList() { + return sparseTensors_; + } + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public int getSparseTensorsCount() { + return sparseTensors_.size(); + } + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public OnnxMl.SparseTensorProto getSparseTensors(int index) { + return sparseTensors_.get(index); + } + /** + *
+     * list of sparse tensors
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public OnnxMl.SparseTensorProtoOrBuilder getSparseTensorsOrBuilder( + int index) { + return sparseTensors_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (f_ != 0F) { + output.writeFloat(2, f_); + } + if (i_ != 0L) { + output.writeInt64(3, i_); + } + if (!s_.isEmpty()) { + output.writeBytes(4, s_); + } + if (t_ != null) { + output.writeMessage(5, getT()); + } + if (g_ != null) { + output.writeMessage(6, getG()); + } + if (getFloatsList().size() > 0) { + output.writeUInt32NoTag(58); + output.writeUInt32NoTag(floatsMemoizedSerializedSize); + } + for (int i = 0; i < floats_.size(); i++) { + output.writeFloatNoTag(floats_.get(i)); + } + if (getIntsList().size() > 0) { + output.writeUInt32NoTag(66); + output.writeUInt32NoTag(intsMemoizedSerializedSize); + } + for (int i = 0; i < ints_.size(); i++) { + output.writeInt64NoTag(ints_.get(i)); + } + for (int i = 0; i < strings_.size(); i++) { + output.writeBytes(9, strings_.get(i)); + } + for (int i = 0; i < tensors_.size(); i++) { + output.writeMessage(10, tensors_.get(i)); + } + for (int i = 0; i < graphs_.size(); i++) { + output.writeMessage(11, graphs_.get(i)); + } + if (!getDocStringBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 13, docString_); + } + if (type_ != OnnxMl.AttributeProto.AttributeType.UNDEFINED.getNumber()) { + output.writeEnum(20, type_); + } + if (!getRefAttrNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 21, refAttrName_); + } + if (sparseTensor_ != null) { + output.writeMessage(22, getSparseTensor()); + } + for (int i = 0; i < sparseTensors_.size(); i++) { + output.writeMessage(23, sparseTensors_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (f_ != 0F) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(2, f_); + } + if (i_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, i_); + } + if (!s_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, s_); + } + if (t_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getT()); + } + if (g_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getG()); + } + { + int dataSize = 0; + dataSize = 4 * getFloatsList().size(); + size += dataSize; + if (!getFloatsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + floatsMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + for (int i = 0; i < ints_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeInt64SizeNoTag(ints_.get(i)); + } + size += dataSize; + if (!getIntsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + intsMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + for (int i = 0; i < strings_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(strings_.get(i)); + } + size += dataSize; + size += 1 * getStringsList().size(); + } + for (int i = 0; i < tensors_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(10, tensors_.get(i)); + } + for (int i = 0; i < graphs_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(11, graphs_.get(i)); + } + if (!getDocStringBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(13, docString_); + } + if (type_ != OnnxMl.AttributeProto.AttributeType.UNDEFINED.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(20, type_); + } + if (!getRefAttrNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(21, refAttrName_); + } + if (sparseTensor_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(22, getSparseTensor()); + } + for (int i = 0; i < sparseTensors_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(23, sparseTensors_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.AttributeProto)) { + return super.equals(obj); + } + OnnxMl.AttributeProto other = (OnnxMl.AttributeProto) obj; + + boolean result = true; + result = result && getName() + .equals(other.getName()); + result = result && getRefAttrName() + .equals(other.getRefAttrName()); + result = result && getDocString() + .equals(other.getDocString()); + result = result && type_ == other.type_; + result = result && ( + java.lang.Float.floatToIntBits(getF()) + == java.lang.Float.floatToIntBits( + other.getF())); + result = result && (getI() + == other.getI()); + result = result && getS() + .equals(other.getS()); + result = result && (hasT() == other.hasT()); + if (hasT()) { + result = result && getT() + .equals(other.getT()); + } + result = result && (hasG() == other.hasG()); + if (hasG()) { + result = result && getG() + .equals(other.getG()); + } + result = result && (hasSparseTensor() == other.hasSparseTensor()); + if (hasSparseTensor()) { + result = result && getSparseTensor() + .equals(other.getSparseTensor()); + } + result = result && getFloatsList() + .equals(other.getFloatsList()); + result = result && getIntsList() + .equals(other.getIntsList()); + result = result && getStringsList() + .equals(other.getStringsList()); + result = result && getTensorsList() + .equals(other.getTensorsList()); + result = result && getGraphsList() + .equals(other.getGraphsList()); + result = result && getSparseTensorsList() + .equals(other.getSparseTensorsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + REF_ATTR_NAME_FIELD_NUMBER; + hash = (53 * hash) + getRefAttrName().hashCode(); + hash = (37 * hash) + DOC_STRING_FIELD_NUMBER; + hash = (53 * hash) + getDocString().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (37 * hash) + F_FIELD_NUMBER; + hash = (53 * hash) + java.lang.Float.floatToIntBits( + getF()); + hash = (37 * hash) + I_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getI()); + hash = (37 * hash) + S_FIELD_NUMBER; + hash = (53 * hash) + getS().hashCode(); + if (hasT()) { + hash = (37 * hash) + T_FIELD_NUMBER; + hash = (53 * hash) + getT().hashCode(); + } + if (hasG()) { + hash = (37 * hash) + G_FIELD_NUMBER; + hash = (53 * hash) + getG().hashCode(); + } + if (hasSparseTensor()) { + hash = (37 * hash) + SPARSE_TENSOR_FIELD_NUMBER; + hash = (53 * hash) + getSparseTensor().hashCode(); + } + if (getFloatsCount() > 0) { + hash = (37 * hash) + FLOATS_FIELD_NUMBER; + hash = (53 * hash) + getFloatsList().hashCode(); + } + if (getIntsCount() > 0) { + hash = (37 * hash) + INTS_FIELD_NUMBER; + hash = (53 * hash) + getIntsList().hashCode(); + } + if (getStringsCount() > 0) { + hash = (37 * hash) + STRINGS_FIELD_NUMBER; + hash = (53 * hash) + getStringsList().hashCode(); + } + if (getTensorsCount() > 0) { + hash = (37 * hash) + TENSORS_FIELD_NUMBER; + hash = (53 * hash) + getTensorsList().hashCode(); + } + if (getGraphsCount() > 0) { + hash = (37 * hash) + GRAPHS_FIELD_NUMBER; + hash = (53 * hash) + getGraphsList().hashCode(); + } + if (getSparseTensorsCount() > 0) { + hash = (37 * hash) + SPARSE_TENSORS_FIELD_NUMBER; + hash = (53 * hash) + getSparseTensorsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.AttributeProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.AttributeProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.AttributeProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.AttributeProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.AttributeProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.AttributeProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.AttributeProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.AttributeProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.AttributeProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.AttributeProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.AttributeProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.AttributeProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.AttributeProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Attributes
+     * A named attribute containing either singular float, integer, string, graph,
+     * and tensor values, or repeated float, integer, string, graph, and tensor values.
+     * An AttributeProto MUST contain the name field, and *only one* of the
+     * following content fields, effectively enforcing a C/C++ union equivalent.
+     * 
+ * + * Protobuf type {@code onnx.AttributeProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.AttributeProto) + OnnxMl.AttributeProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_AttributeProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_AttributeProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.AttributeProto.class, OnnxMl.AttributeProto.Builder.class); + } + + // Construct using OnnxMlProto3.AttributeProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getTensorsFieldBuilder(); + getGraphsFieldBuilder(); + getSparseTensorsFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + refAttrName_ = ""; + + docString_ = ""; + + type_ = 0; + + f_ = 0F; + + i_ = 0L; + + s_ = com.google.protobuf.ByteString.EMPTY; + + if (tBuilder_ == null) { + t_ = null; + } else { + t_ = null; + tBuilder_ = null; + } + if (gBuilder_ == null) { + g_ = null; + } else { + g_ = null; + gBuilder_ = null; + } + if (sparseTensorBuilder_ == null) { + sparseTensor_ = null; + } else { + sparseTensor_ = null; + sparseTensorBuilder_ = null; + } + floats_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000400); + ints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000800); + strings_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00001000); + if (tensorsBuilder_ == null) { + tensors_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00002000); + } else { + tensorsBuilder_.clear(); + } + if (graphsBuilder_ == null) { + graphs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00004000); + } else { + graphsBuilder_.clear(); + } + if (sparseTensorsBuilder_ == null) { + sparseTensors_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00008000); + } else { + sparseTensorsBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_AttributeProto_descriptor; + } + + @java.lang.Override + public OnnxMl.AttributeProto getDefaultInstanceForType() { + return OnnxMl.AttributeProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.AttributeProto build() { + OnnxMl.AttributeProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.AttributeProto buildPartial() { + OnnxMl.AttributeProto result = new OnnxMl.AttributeProto(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.name_ = name_; + result.refAttrName_ = refAttrName_; + result.docString_ = docString_; + result.type_ = type_; + result.f_ = f_; + result.i_ = i_; + result.s_ = s_; + if (tBuilder_ == null) { + result.t_ = t_; + } else { + result.t_ = tBuilder_.build(); + } + if (gBuilder_ == null) { + result.g_ = g_; + } else { + result.g_ = gBuilder_.build(); + } + if (sparseTensorBuilder_ == null) { + result.sparseTensor_ = sparseTensor_; + } else { + result.sparseTensor_ = sparseTensorBuilder_.build(); + } + if (((bitField0_ & 0x00000400) == 0x00000400)) { + floats_ = java.util.Collections.unmodifiableList(floats_); + bitField0_ = (bitField0_ & ~0x00000400); + } + result.floats_ = floats_; + if (((bitField0_ & 0x00000800) == 0x00000800)) { + ints_ = java.util.Collections.unmodifiableList(ints_); + bitField0_ = (bitField0_ & ~0x00000800); + } + result.ints_ = ints_; + if (((bitField0_ & 0x00001000) == 0x00001000)) { + strings_ = java.util.Collections.unmodifiableList(strings_); + bitField0_ = (bitField0_ & ~0x00001000); + } + result.strings_ = strings_; + if (tensorsBuilder_ == null) { + if (((bitField0_ & 0x00002000) == 0x00002000)) { + tensors_ = java.util.Collections.unmodifiableList(tensors_); + bitField0_ = (bitField0_ & ~0x00002000); + } + result.tensors_ = tensors_; + } else { + result.tensors_ = tensorsBuilder_.build(); + } + if (graphsBuilder_ == null) { + if (((bitField0_ & 0x00004000) == 0x00004000)) { + graphs_ = java.util.Collections.unmodifiableList(graphs_); + bitField0_ = (bitField0_ & ~0x00004000); + } + result.graphs_ = graphs_; + } else { + result.graphs_ = graphsBuilder_.build(); + } + if (sparseTensorsBuilder_ == null) { + if (((bitField0_ & 0x00008000) == 0x00008000)) { + sparseTensors_ = java.util.Collections.unmodifiableList(sparseTensors_); + bitField0_ = (bitField0_ & ~0x00008000); + } + result.sparseTensors_ = sparseTensors_; + } else { + result.sparseTensors_ = sparseTensorsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.AttributeProto) { + return mergeFrom((OnnxMl.AttributeProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.AttributeProto other) { + if (other == OnnxMl.AttributeProto.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getRefAttrName().isEmpty()) { + refAttrName_ = other.refAttrName_; + onChanged(); + } + if (!other.getDocString().isEmpty()) { + docString_ = other.docString_; + onChanged(); + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (other.getF() != 0F) { + setF(other.getF()); + } + if (other.getI() != 0L) { + setI(other.getI()); + } + if (other.getS() != com.google.protobuf.ByteString.EMPTY) { + setS(other.getS()); + } + if (other.hasT()) { + mergeT(other.getT()); + } + if (other.hasG()) { + mergeG(other.getG()); + } + if (other.hasSparseTensor()) { + mergeSparseTensor(other.getSparseTensor()); + } + if (!other.floats_.isEmpty()) { + if (floats_.isEmpty()) { + floats_ = other.floats_; + bitField0_ = (bitField0_ & ~0x00000400); + } else { + ensureFloatsIsMutable(); + floats_.addAll(other.floats_); + } + onChanged(); + } + if (!other.ints_.isEmpty()) { + if (ints_.isEmpty()) { + ints_ = other.ints_; + bitField0_ = (bitField0_ & ~0x00000800); + } else { + ensureIntsIsMutable(); + ints_.addAll(other.ints_); + } + onChanged(); + } + if (!other.strings_.isEmpty()) { + if (strings_.isEmpty()) { + strings_ = other.strings_; + bitField0_ = (bitField0_ & ~0x00001000); + } else { + ensureStringsIsMutable(); + strings_.addAll(other.strings_); + } + onChanged(); + } + if (tensorsBuilder_ == null) { + if (!other.tensors_.isEmpty()) { + if (tensors_.isEmpty()) { + tensors_ = other.tensors_; + bitField0_ = (bitField0_ & ~0x00002000); + } else { + ensureTensorsIsMutable(); + tensors_.addAll(other.tensors_); + } + onChanged(); + } + } else { + if (!other.tensors_.isEmpty()) { + if (tensorsBuilder_.isEmpty()) { + tensorsBuilder_.dispose(); + tensorsBuilder_ = null; + tensors_ = other.tensors_; + bitField0_ = (bitField0_ & ~0x00002000); + tensorsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getTensorsFieldBuilder() : null; + } else { + tensorsBuilder_.addAllMessages(other.tensors_); + } + } + } + if (graphsBuilder_ == null) { + if (!other.graphs_.isEmpty()) { + if (graphs_.isEmpty()) { + graphs_ = other.graphs_; + bitField0_ = (bitField0_ & ~0x00004000); + } else { + ensureGraphsIsMutable(); + graphs_.addAll(other.graphs_); + } + onChanged(); + } + } else { + if (!other.graphs_.isEmpty()) { + if (graphsBuilder_.isEmpty()) { + graphsBuilder_.dispose(); + graphsBuilder_ = null; + graphs_ = other.graphs_; + bitField0_ = (bitField0_ & ~0x00004000); + graphsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getGraphsFieldBuilder() : null; + } else { + graphsBuilder_.addAllMessages(other.graphs_); + } + } + } + if (sparseTensorsBuilder_ == null) { + if (!other.sparseTensors_.isEmpty()) { + if (sparseTensors_.isEmpty()) { + sparseTensors_ = other.sparseTensors_; + bitField0_ = (bitField0_ & ~0x00008000); + } else { + ensureSparseTensorsIsMutable(); + sparseTensors_.addAll(other.sparseTensors_); + } + onChanged(); + } + } else { + if (!other.sparseTensors_.isEmpty()) { + if (sparseTensorsBuilder_.isEmpty()) { + sparseTensorsBuilder_.dispose(); + sparseTensorsBuilder_ = null; + sparseTensors_ = other.sparseTensors_; + bitField0_ = (bitField0_ & ~0x00008000); + sparseTensorsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSparseTensorsFieldBuilder() : null; + } else { + sparseTensorsBuilder_.addAllMessages(other.sparseTensors_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.AttributeProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.AttributeProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + *
+       * The name field MUST be present for this version of the IR.
+       * 
+ * + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * The name field MUST be present for this version of the IR.
+       * 
+ * + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * The name field MUST be present for this version of the IR.
+       * 
+ * + * string name = 1; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       * The name field MUST be present for this version of the IR.
+       * 
+ * + * string name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       * The name field MUST be present for this version of the IR.
+       * 
+ * + * string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object refAttrName_ = ""; + /** + *
+       * if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
+       * In this case, this AttributeProto does not contain data, and it's a reference of attribute
+       * in parent scope.
+       * NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
+       * 
+ * + * string ref_attr_name = 21; + */ + public java.lang.String getRefAttrName() { + java.lang.Object ref = refAttrName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + refAttrName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
+       * In this case, this AttributeProto does not contain data, and it's a reference of attribute
+       * in parent scope.
+       * NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
+       * 
+ * + * string ref_attr_name = 21; + */ + public com.google.protobuf.ByteString + getRefAttrNameBytes() { + java.lang.Object ref = refAttrName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + refAttrName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
+       * In this case, this AttributeProto does not contain data, and it's a reference of attribute
+       * in parent scope.
+       * NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
+       * 
+ * + * string ref_attr_name = 21; + */ + public Builder setRefAttrName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + refAttrName_ = value; + onChanged(); + return this; + } + /** + *
+       * if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
+       * In this case, this AttributeProto does not contain data, and it's a reference of attribute
+       * in parent scope.
+       * NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
+       * 
+ * + * string ref_attr_name = 21; + */ + public Builder clearRefAttrName() { + + refAttrName_ = getDefaultInstance().getRefAttrName(); + onChanged(); + return this; + } + /** + *
+       * if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
+       * In this case, this AttributeProto does not contain data, and it's a reference of attribute
+       * in parent scope.
+       * NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
+       * 
+ * + * string ref_attr_name = 21; + */ + public Builder setRefAttrNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + refAttrName_ = value; + onChanged(); + return this; + } + + private java.lang.Object docString_ = ""; + /** + *
+       * A human-readable documentation for this attribute. Markdown is allowed.
+       * 
+ * + * string doc_string = 13; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * A human-readable documentation for this attribute. Markdown is allowed.
+       * 
+ * + * string doc_string = 13; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * A human-readable documentation for this attribute. Markdown is allowed.
+       * 
+ * + * string doc_string = 13; + */ + public Builder setDocString( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + docString_ = value; + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this attribute. Markdown is allowed.
+       * 
+ * + * string doc_string = 13; + */ + public Builder clearDocString() { + + docString_ = getDefaultInstance().getDocString(); + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this attribute. Markdown is allowed.
+       * 
+ * + * string doc_string = 13; + */ + public Builder setDocStringBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + docString_ = value; + onChanged(); + return this; + } + + private int type_ = 0; + /** + *
+       * The type field MUST be present for this version of the IR.
+       * For 0.0.1 versions of the IR, this field was not defined, and
+       * implementations needed to use has_field hueristics to determine
+       * which value field was in use.  For IR_VERSION 0.0.2 or later, this
+       * field MUST be set and match the f|i|s|t|... field in use.  This
+       * change was made to accomodate proto3 implementations.
+       * 
+ * + * .onnx.AttributeProto.AttributeType type = 20; + */ + public int getTypeValue() { + return type_; + } + /** + *
+       * The type field MUST be present for this version of the IR.
+       * For 0.0.1 versions of the IR, this field was not defined, and
+       * implementations needed to use has_field hueristics to determine
+       * which value field was in use.  For IR_VERSION 0.0.2 or later, this
+       * field MUST be set and match the f|i|s|t|... field in use.  This
+       * change was made to accomodate proto3 implementations.
+       * 
+ * + * .onnx.AttributeProto.AttributeType type = 20; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + /** + *
+       * The type field MUST be present for this version of the IR.
+       * For 0.0.1 versions of the IR, this field was not defined, and
+       * implementations needed to use has_field hueristics to determine
+       * which value field was in use.  For IR_VERSION 0.0.2 or later, this
+       * field MUST be set and match the f|i|s|t|... field in use.  This
+       * change was made to accomodate proto3 implementations.
+       * 
+ * + * .onnx.AttributeProto.AttributeType type = 20; + */ + public OnnxMl.AttributeProto.AttributeType getType() { + @SuppressWarnings("deprecation") + OnnxMl.AttributeProto.AttributeType result = OnnxMl.AttributeProto.AttributeType.valueOf(type_); + return result == null ? OnnxMl.AttributeProto.AttributeType.UNRECOGNIZED : result; + } + /** + *
+       * The type field MUST be present for this version of the IR.
+       * For 0.0.1 versions of the IR, this field was not defined, and
+       * implementations needed to use has_field hueristics to determine
+       * which value field was in use.  For IR_VERSION 0.0.2 or later, this
+       * field MUST be set and match the f|i|s|t|... field in use.  This
+       * change was made to accomodate proto3 implementations.
+       * 
+ * + * .onnx.AttributeProto.AttributeType type = 20; + */ + public Builder setType(OnnxMl.AttributeProto.AttributeType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + /** + *
+       * The type field MUST be present for this version of the IR.
+       * For 0.0.1 versions of the IR, this field was not defined, and
+       * implementations needed to use has_field hueristics to determine
+       * which value field was in use.  For IR_VERSION 0.0.2 or later, this
+       * field MUST be set and match the f|i|s|t|... field in use.  This
+       * change was made to accomodate proto3 implementations.
+       * 
+ * + * .onnx.AttributeProto.AttributeType type = 20; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private float f_ ; + /** + *
+       * Exactly ONE of the following fields must be present for this version of the IR
+       * 
+ * + * float f = 2; + */ + public float getF() { + return f_; + } + /** + *
+       * Exactly ONE of the following fields must be present for this version of the IR
+       * 
+ * + * float f = 2; + */ + public Builder setF(float value) { + + f_ = value; + onChanged(); + return this; + } + /** + *
+       * Exactly ONE of the following fields must be present for this version of the IR
+       * 
+ * + * float f = 2; + */ + public Builder clearF() { + + f_ = 0F; + onChanged(); + return this; + } + + private long i_ ; + /** + *
+       * int
+       * 
+ * + * int64 i = 3; + */ + public long getI() { + return i_; + } + /** + *
+       * int
+       * 
+ * + * int64 i = 3; + */ + public Builder setI(long value) { + + i_ = value; + onChanged(); + return this; + } + /** + *
+       * int
+       * 
+ * + * int64 i = 3; + */ + public Builder clearI() { + + i_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString s_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * UTF-8 string
+       * 
+ * + * bytes s = 4; + */ + public com.google.protobuf.ByteString getS() { + return s_; + } + /** + *
+       * UTF-8 string
+       * 
+ * + * bytes s = 4; + */ + public Builder setS(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + s_ = value; + onChanged(); + return this; + } + /** + *
+       * UTF-8 string
+       * 
+ * + * bytes s = 4; + */ + public Builder clearS() { + + s_ = getDefaultInstance().getS(); + onChanged(); + return this; + } + + private OnnxMl.TensorProto t_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> tBuilder_; + /** + *
+       * tensor value
+       * 
+ * + * .onnx.TensorProto t = 5; + */ + public boolean hasT() { + return tBuilder_ != null || t_ != null; + } + /** + *
+       * tensor value
+       * 
+ * + * .onnx.TensorProto t = 5; + */ + public OnnxMl.TensorProto getT() { + if (tBuilder_ == null) { + return t_ == null ? OnnxMl.TensorProto.getDefaultInstance() : t_; + } else { + return tBuilder_.getMessage(); + } + } + /** + *
+       * tensor value
+       * 
+ * + * .onnx.TensorProto t = 5; + */ + public Builder setT(OnnxMl.TensorProto value) { + if (tBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + t_ = value; + onChanged(); + } else { + tBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       * tensor value
+       * 
+ * + * .onnx.TensorProto t = 5; + */ + public Builder setT( + OnnxMl.TensorProto.Builder builderForValue) { + if (tBuilder_ == null) { + t_ = builderForValue.build(); + onChanged(); + } else { + tBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       * tensor value
+       * 
+ * + * .onnx.TensorProto t = 5; + */ + public Builder mergeT(OnnxMl.TensorProto value) { + if (tBuilder_ == null) { + if (t_ != null) { + t_ = + OnnxMl.TensorProto.newBuilder(t_).mergeFrom(value).buildPartial(); + } else { + t_ = value; + } + onChanged(); + } else { + tBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       * tensor value
+       * 
+ * + * .onnx.TensorProto t = 5; + */ + public Builder clearT() { + if (tBuilder_ == null) { + t_ = null; + onChanged(); + } else { + t_ = null; + tBuilder_ = null; + } + + return this; + } + /** + *
+       * tensor value
+       * 
+ * + * .onnx.TensorProto t = 5; + */ + public OnnxMl.TensorProto.Builder getTBuilder() { + + onChanged(); + return getTFieldBuilder().getBuilder(); + } + /** + *
+       * tensor value
+       * 
+ * + * .onnx.TensorProto t = 5; + */ + public OnnxMl.TensorProtoOrBuilder getTOrBuilder() { + if (tBuilder_ != null) { + return tBuilder_.getMessageOrBuilder(); + } else { + return t_ == null ? + OnnxMl.TensorProto.getDefaultInstance() : t_; + } + } + /** + *
+       * tensor value
+       * 
+ * + * .onnx.TensorProto t = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> + getTFieldBuilder() { + if (tBuilder_ == null) { + tBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder>( + getT(), + getParentForChildren(), + isClean()); + t_ = null; + } + return tBuilder_; + } + + private OnnxMl.GraphProto g_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.GraphProto, OnnxMl.GraphProto.Builder, OnnxMl.GraphProtoOrBuilder> gBuilder_; + /** + *
+       * graph
+       * 
+ * + * .onnx.GraphProto g = 6; + */ + public boolean hasG() { + return gBuilder_ != null || g_ != null; + } + /** + *
+       * graph
+       * 
+ * + * .onnx.GraphProto g = 6; + */ + public OnnxMl.GraphProto getG() { + if (gBuilder_ == null) { + return g_ == null ? OnnxMl.GraphProto.getDefaultInstance() : g_; + } else { + return gBuilder_.getMessage(); + } + } + /** + *
+       * graph
+       * 
+ * + * .onnx.GraphProto g = 6; + */ + public Builder setG(OnnxMl.GraphProto value) { + if (gBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + g_ = value; + onChanged(); + } else { + gBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       * graph
+       * 
+ * + * .onnx.GraphProto g = 6; + */ + public Builder setG( + OnnxMl.GraphProto.Builder builderForValue) { + if (gBuilder_ == null) { + g_ = builderForValue.build(); + onChanged(); + } else { + gBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       * graph
+       * 
+ * + * .onnx.GraphProto g = 6; + */ + public Builder mergeG(OnnxMl.GraphProto value) { + if (gBuilder_ == null) { + if (g_ != null) { + g_ = + OnnxMl.GraphProto.newBuilder(g_).mergeFrom(value).buildPartial(); + } else { + g_ = value; + } + onChanged(); + } else { + gBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       * graph
+       * 
+ * + * .onnx.GraphProto g = 6; + */ + public Builder clearG() { + if (gBuilder_ == null) { + g_ = null; + onChanged(); + } else { + g_ = null; + gBuilder_ = null; + } + + return this; + } + /** + *
+       * graph
+       * 
+ * + * .onnx.GraphProto g = 6; + */ + public OnnxMl.GraphProto.Builder getGBuilder() { + + onChanged(); + return getGFieldBuilder().getBuilder(); + } + /** + *
+       * graph
+       * 
+ * + * .onnx.GraphProto g = 6; + */ + public OnnxMl.GraphProtoOrBuilder getGOrBuilder() { + if (gBuilder_ != null) { + return gBuilder_.getMessageOrBuilder(); + } else { + return g_ == null ? + OnnxMl.GraphProto.getDefaultInstance() : g_; + } + } + /** + *
+       * graph
+       * 
+ * + * .onnx.GraphProto g = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.GraphProto, OnnxMl.GraphProto.Builder, OnnxMl.GraphProtoOrBuilder> + getGFieldBuilder() { + if (gBuilder_ == null) { + gBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.GraphProto, OnnxMl.GraphProto.Builder, OnnxMl.GraphProtoOrBuilder>( + getG(), + getParentForChildren(), + isClean()); + g_ = null; + } + return gBuilder_; + } + + private OnnxMl.SparseTensorProto sparseTensor_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.SparseTensorProto, OnnxMl.SparseTensorProto.Builder, OnnxMl.SparseTensorProtoOrBuilder> sparseTensorBuilder_; + /** + *
+       * sparse tensor value
+       * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public boolean hasSparseTensor() { + return sparseTensorBuilder_ != null || sparseTensor_ != null; + } + /** + *
+       * sparse tensor value
+       * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public OnnxMl.SparseTensorProto getSparseTensor() { + if (sparseTensorBuilder_ == null) { + return sparseTensor_ == null ? OnnxMl.SparseTensorProto.getDefaultInstance() : sparseTensor_; + } else { + return sparseTensorBuilder_.getMessage(); + } + } + /** + *
+       * sparse tensor value
+       * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public Builder setSparseTensor(OnnxMl.SparseTensorProto value) { + if (sparseTensorBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sparseTensor_ = value; + onChanged(); + } else { + sparseTensorBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       * sparse tensor value
+       * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public Builder setSparseTensor( + OnnxMl.SparseTensorProto.Builder builderForValue) { + if (sparseTensorBuilder_ == null) { + sparseTensor_ = builderForValue.build(); + onChanged(); + } else { + sparseTensorBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       * sparse tensor value
+       * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public Builder mergeSparseTensor(OnnxMl.SparseTensorProto value) { + if (sparseTensorBuilder_ == null) { + if (sparseTensor_ != null) { + sparseTensor_ = + OnnxMl.SparseTensorProto.newBuilder(sparseTensor_).mergeFrom(value).buildPartial(); + } else { + sparseTensor_ = value; + } + onChanged(); + } else { + sparseTensorBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       * sparse tensor value
+       * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public Builder clearSparseTensor() { + if (sparseTensorBuilder_ == null) { + sparseTensor_ = null; + onChanged(); + } else { + sparseTensor_ = null; + sparseTensorBuilder_ = null; + } + + return this; + } + /** + *
+       * sparse tensor value
+       * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public OnnxMl.SparseTensorProto.Builder getSparseTensorBuilder() { + + onChanged(); + return getSparseTensorFieldBuilder().getBuilder(); + } + /** + *
+       * sparse tensor value
+       * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + public OnnxMl.SparseTensorProtoOrBuilder getSparseTensorOrBuilder() { + if (sparseTensorBuilder_ != null) { + return sparseTensorBuilder_.getMessageOrBuilder(); + } else { + return sparseTensor_ == null ? + OnnxMl.SparseTensorProto.getDefaultInstance() : sparseTensor_; + } + } + /** + *
+       * sparse tensor value
+       * 
+ * + * .onnx.SparseTensorProto sparse_tensor = 22; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.SparseTensorProto, OnnxMl.SparseTensorProto.Builder, OnnxMl.SparseTensorProtoOrBuilder> + getSparseTensorFieldBuilder() { + if (sparseTensorBuilder_ == null) { + sparseTensorBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.SparseTensorProto, OnnxMl.SparseTensorProto.Builder, OnnxMl.SparseTensorProtoOrBuilder>( + getSparseTensor(), + getParentForChildren(), + isClean()); + sparseTensor_ = null; + } + return sparseTensorBuilder_; + } + + private java.util.List floats_ = java.util.Collections.emptyList(); + private void ensureFloatsIsMutable() { + if (!((bitField0_ & 0x00000400) == 0x00000400)) { + floats_ = new java.util.ArrayList(floats_); + bitField0_ |= 0x00000400; + } + } + /** + *
+       * list of floats
+       * 
+ * + * repeated float floats = 7; + */ + public java.util.List + getFloatsList() { + return java.util.Collections.unmodifiableList(floats_); + } + /** + *
+       * list of floats
+       * 
+ * + * repeated float floats = 7; + */ + public int getFloatsCount() { + return floats_.size(); + } + /** + *
+       * list of floats
+       * 
+ * + * repeated float floats = 7; + */ + public float getFloats(int index) { + return floats_.get(index); + } + /** + *
+       * list of floats
+       * 
+ * + * repeated float floats = 7; + */ + public Builder setFloats( + int index, float value) { + ensureFloatsIsMutable(); + floats_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * list of floats
+       * 
+ * + * repeated float floats = 7; + */ + public Builder addFloats(float value) { + ensureFloatsIsMutable(); + floats_.add(value); + onChanged(); + return this; + } + /** + *
+       * list of floats
+       * 
+ * + * repeated float floats = 7; + */ + public Builder addAllFloats( + java.lang.Iterable values) { + ensureFloatsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, floats_); + onChanged(); + return this; + } + /** + *
+       * list of floats
+       * 
+ * + * repeated float floats = 7; + */ + public Builder clearFloats() { + floats_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000400); + onChanged(); + return this; + } + + private java.util.List ints_ = java.util.Collections.emptyList(); + private void ensureIntsIsMutable() { + if (!((bitField0_ & 0x00000800) == 0x00000800)) { + ints_ = new java.util.ArrayList(ints_); + bitField0_ |= 0x00000800; + } + } + /** + *
+       * list of ints
+       * 
+ * + * repeated int64 ints = 8; + */ + public java.util.List + getIntsList() { + return java.util.Collections.unmodifiableList(ints_); + } + /** + *
+       * list of ints
+       * 
+ * + * repeated int64 ints = 8; + */ + public int getIntsCount() { + return ints_.size(); + } + /** + *
+       * list of ints
+       * 
+ * + * repeated int64 ints = 8; + */ + public long getInts(int index) { + return ints_.get(index); + } + /** + *
+       * list of ints
+       * 
+ * + * repeated int64 ints = 8; + */ + public Builder setInts( + int index, long value) { + ensureIntsIsMutable(); + ints_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * list of ints
+       * 
+ * + * repeated int64 ints = 8; + */ + public Builder addInts(long value) { + ensureIntsIsMutable(); + ints_.add(value); + onChanged(); + return this; + } + /** + *
+       * list of ints
+       * 
+ * + * repeated int64 ints = 8; + */ + public Builder addAllInts( + java.lang.Iterable values) { + ensureIntsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, ints_); + onChanged(); + return this; + } + /** + *
+       * list of ints
+       * 
+ * + * repeated int64 ints = 8; + */ + public Builder clearInts() { + ints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000800); + onChanged(); + return this; + } + + private java.util.List strings_ = java.util.Collections.emptyList(); + private void ensureStringsIsMutable() { + if (!((bitField0_ & 0x00001000) == 0x00001000)) { + strings_ = new java.util.ArrayList(strings_); + bitField0_ |= 0x00001000; + } + } + /** + *
+       * list of UTF-8 strings
+       * 
+ * + * repeated bytes strings = 9; + */ + public java.util.List + getStringsList() { + return java.util.Collections.unmodifiableList(strings_); + } + /** + *
+       * list of UTF-8 strings
+       * 
+ * + * repeated bytes strings = 9; + */ + public int getStringsCount() { + return strings_.size(); + } + /** + *
+       * list of UTF-8 strings
+       * 
+ * + * repeated bytes strings = 9; + */ + public com.google.protobuf.ByteString getStrings(int index) { + return strings_.get(index); + } + /** + *
+       * list of UTF-8 strings
+       * 
+ * + * repeated bytes strings = 9; + */ + public Builder setStrings( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureStringsIsMutable(); + strings_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * list of UTF-8 strings
+       * 
+ * + * repeated bytes strings = 9; + */ + public Builder addStrings(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureStringsIsMutable(); + strings_.add(value); + onChanged(); + return this; + } + /** + *
+       * list of UTF-8 strings
+       * 
+ * + * repeated bytes strings = 9; + */ + public Builder addAllStrings( + java.lang.Iterable values) { + ensureStringsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, strings_); + onChanged(); + return this; + } + /** + *
+       * list of UTF-8 strings
+       * 
+ * + * repeated bytes strings = 9; + */ + public Builder clearStrings() { + strings_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00001000); + onChanged(); + return this; + } + + private java.util.List tensors_ = + java.util.Collections.emptyList(); + private void ensureTensorsIsMutable() { + if (!((bitField0_ & 0x00002000) == 0x00002000)) { + tensors_ = new java.util.ArrayList(tensors_); + bitField0_ |= 0x00002000; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> tensorsBuilder_; + + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public java.util.List getTensorsList() { + if (tensorsBuilder_ == null) { + return java.util.Collections.unmodifiableList(tensors_); + } else { + return tensorsBuilder_.getMessageList(); + } + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public int getTensorsCount() { + if (tensorsBuilder_ == null) { + return tensors_.size(); + } else { + return tensorsBuilder_.getCount(); + } + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public OnnxMl.TensorProto getTensors(int index) { + if (tensorsBuilder_ == null) { + return tensors_.get(index); + } else { + return tensorsBuilder_.getMessage(index); + } + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public Builder setTensors( + int index, OnnxMl.TensorProto value) { + if (tensorsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTensorsIsMutable(); + tensors_.set(index, value); + onChanged(); + } else { + tensorsBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public Builder setTensors( + int index, OnnxMl.TensorProto.Builder builderForValue) { + if (tensorsBuilder_ == null) { + ensureTensorsIsMutable(); + tensors_.set(index, builderForValue.build()); + onChanged(); + } else { + tensorsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public Builder addTensors(OnnxMl.TensorProto value) { + if (tensorsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTensorsIsMutable(); + tensors_.add(value); + onChanged(); + } else { + tensorsBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public Builder addTensors( + int index, OnnxMl.TensorProto value) { + if (tensorsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTensorsIsMutable(); + tensors_.add(index, value); + onChanged(); + } else { + tensorsBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public Builder addTensors( + OnnxMl.TensorProto.Builder builderForValue) { + if (tensorsBuilder_ == null) { + ensureTensorsIsMutable(); + tensors_.add(builderForValue.build()); + onChanged(); + } else { + tensorsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public Builder addTensors( + int index, OnnxMl.TensorProto.Builder builderForValue) { + if (tensorsBuilder_ == null) { + ensureTensorsIsMutable(); + tensors_.add(index, builderForValue.build()); + onChanged(); + } else { + tensorsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public Builder addAllTensors( + java.lang.Iterable values) { + if (tensorsBuilder_ == null) { + ensureTensorsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, tensors_); + onChanged(); + } else { + tensorsBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public Builder clearTensors() { + if (tensorsBuilder_ == null) { + tensors_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00002000); + onChanged(); + } else { + tensorsBuilder_.clear(); + } + return this; + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public Builder removeTensors(int index) { + if (tensorsBuilder_ == null) { + ensureTensorsIsMutable(); + tensors_.remove(index); + onChanged(); + } else { + tensorsBuilder_.remove(index); + } + return this; + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public OnnxMl.TensorProto.Builder getTensorsBuilder( + int index) { + return getTensorsFieldBuilder().getBuilder(index); + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public OnnxMl.TensorProtoOrBuilder getTensorsOrBuilder( + int index) { + if (tensorsBuilder_ == null) { + return tensors_.get(index); } else { + return tensorsBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public java.util.List + getTensorsOrBuilderList() { + if (tensorsBuilder_ != null) { + return tensorsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(tensors_); + } + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public OnnxMl.TensorProto.Builder addTensorsBuilder() { + return getTensorsFieldBuilder().addBuilder( + OnnxMl.TensorProto.getDefaultInstance()); + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public OnnxMl.TensorProto.Builder addTensorsBuilder( + int index) { + return getTensorsFieldBuilder().addBuilder( + index, OnnxMl.TensorProto.getDefaultInstance()); + } + /** + *
+       * list of tensors
+       * 
+ * + * repeated .onnx.TensorProto tensors = 10; + */ + public java.util.List + getTensorsBuilderList() { + return getTensorsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> + getTensorsFieldBuilder() { + if (tensorsBuilder_ == null) { + tensorsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder>( + tensors_, + ((bitField0_ & 0x00002000) == 0x00002000), + getParentForChildren(), + isClean()); + tensors_ = null; + } + return tensorsBuilder_; + } + + private java.util.List graphs_ = + java.util.Collections.emptyList(); + private void ensureGraphsIsMutable() { + if (!((bitField0_ & 0x00004000) == 0x00004000)) { + graphs_ = new java.util.ArrayList(graphs_); + bitField0_ |= 0x00004000; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.GraphProto, OnnxMl.GraphProto.Builder, OnnxMl.GraphProtoOrBuilder> graphsBuilder_; + + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public java.util.List getGraphsList() { + if (graphsBuilder_ == null) { + return java.util.Collections.unmodifiableList(graphs_); + } else { + return graphsBuilder_.getMessageList(); + } + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public int getGraphsCount() { + if (graphsBuilder_ == null) { + return graphs_.size(); + } else { + return graphsBuilder_.getCount(); + } + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public OnnxMl.GraphProto getGraphs(int index) { + if (graphsBuilder_ == null) { + return graphs_.get(index); + } else { + return graphsBuilder_.getMessage(index); + } + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public Builder setGraphs( + int index, OnnxMl.GraphProto value) { + if (graphsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureGraphsIsMutable(); + graphs_.set(index, value); + onChanged(); + } else { + graphsBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public Builder setGraphs( + int index, OnnxMl.GraphProto.Builder builderForValue) { + if (graphsBuilder_ == null) { + ensureGraphsIsMutable(); + graphs_.set(index, builderForValue.build()); + onChanged(); + } else { + graphsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public Builder addGraphs(OnnxMl.GraphProto value) { + if (graphsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureGraphsIsMutable(); + graphs_.add(value); + onChanged(); + } else { + graphsBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public Builder addGraphs( + int index, OnnxMl.GraphProto value) { + if (graphsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureGraphsIsMutable(); + graphs_.add(index, value); + onChanged(); + } else { + graphsBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public Builder addGraphs( + OnnxMl.GraphProto.Builder builderForValue) { + if (graphsBuilder_ == null) { + ensureGraphsIsMutable(); + graphs_.add(builderForValue.build()); + onChanged(); + } else { + graphsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public Builder addGraphs( + int index, OnnxMl.GraphProto.Builder builderForValue) { + if (graphsBuilder_ == null) { + ensureGraphsIsMutable(); + graphs_.add(index, builderForValue.build()); + onChanged(); + } else { + graphsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public Builder addAllGraphs( + java.lang.Iterable values) { + if (graphsBuilder_ == null) { + ensureGraphsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, graphs_); + onChanged(); + } else { + graphsBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public Builder clearGraphs() { + if (graphsBuilder_ == null) { + graphs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00004000); + onChanged(); + } else { + graphsBuilder_.clear(); + } + return this; + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public Builder removeGraphs(int index) { + if (graphsBuilder_ == null) { + ensureGraphsIsMutable(); + graphs_.remove(index); + onChanged(); + } else { + graphsBuilder_.remove(index); + } + return this; + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public OnnxMl.GraphProto.Builder getGraphsBuilder( + int index) { + return getGraphsFieldBuilder().getBuilder(index); + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public OnnxMl.GraphProtoOrBuilder getGraphsOrBuilder( + int index) { + if (graphsBuilder_ == null) { + return graphs_.get(index); } else { + return graphsBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public java.util.List + getGraphsOrBuilderList() { + if (graphsBuilder_ != null) { + return graphsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(graphs_); + } + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public OnnxMl.GraphProto.Builder addGraphsBuilder() { + return getGraphsFieldBuilder().addBuilder( + OnnxMl.GraphProto.getDefaultInstance()); + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public OnnxMl.GraphProto.Builder addGraphsBuilder( + int index) { + return getGraphsFieldBuilder().addBuilder( + index, OnnxMl.GraphProto.getDefaultInstance()); + } + /** + *
+       * list of graph
+       * 
+ * + * repeated .onnx.GraphProto graphs = 11; + */ + public java.util.List + getGraphsBuilderList() { + return getGraphsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.GraphProto, OnnxMl.GraphProto.Builder, OnnxMl.GraphProtoOrBuilder> + getGraphsFieldBuilder() { + if (graphsBuilder_ == null) { + graphsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.GraphProto, OnnxMl.GraphProto.Builder, OnnxMl.GraphProtoOrBuilder>( + graphs_, + ((bitField0_ & 0x00004000) == 0x00004000), + getParentForChildren(), + isClean()); + graphs_ = null; + } + return graphsBuilder_; + } + + private java.util.List sparseTensors_ = + java.util.Collections.emptyList(); + private void ensureSparseTensorsIsMutable() { + if (!((bitField0_ & 0x00008000) == 0x00008000)) { + sparseTensors_ = new java.util.ArrayList(sparseTensors_); + bitField0_ |= 0x00008000; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.SparseTensorProto, OnnxMl.SparseTensorProto.Builder, OnnxMl.SparseTensorProtoOrBuilder> sparseTensorsBuilder_; + + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public java.util.List getSparseTensorsList() { + if (sparseTensorsBuilder_ == null) { + return java.util.Collections.unmodifiableList(sparseTensors_); + } else { + return sparseTensorsBuilder_.getMessageList(); + } + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public int getSparseTensorsCount() { + if (sparseTensorsBuilder_ == null) { + return sparseTensors_.size(); + } else { + return sparseTensorsBuilder_.getCount(); + } + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public OnnxMl.SparseTensorProto getSparseTensors(int index) { + if (sparseTensorsBuilder_ == null) { + return sparseTensors_.get(index); + } else { + return sparseTensorsBuilder_.getMessage(index); + } + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public Builder setSparseTensors( + int index, OnnxMl.SparseTensorProto value) { + if (sparseTensorsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSparseTensorsIsMutable(); + sparseTensors_.set(index, value); + onChanged(); + } else { + sparseTensorsBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public Builder setSparseTensors( + int index, OnnxMl.SparseTensorProto.Builder builderForValue) { + if (sparseTensorsBuilder_ == null) { + ensureSparseTensorsIsMutable(); + sparseTensors_.set(index, builderForValue.build()); + onChanged(); + } else { + sparseTensorsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public Builder addSparseTensors(OnnxMl.SparseTensorProto value) { + if (sparseTensorsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSparseTensorsIsMutable(); + sparseTensors_.add(value); + onChanged(); + } else { + sparseTensorsBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public Builder addSparseTensors( + int index, OnnxMl.SparseTensorProto value) { + if (sparseTensorsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSparseTensorsIsMutable(); + sparseTensors_.add(index, value); + onChanged(); + } else { + sparseTensorsBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public Builder addSparseTensors( + OnnxMl.SparseTensorProto.Builder builderForValue) { + if (sparseTensorsBuilder_ == null) { + ensureSparseTensorsIsMutable(); + sparseTensors_.add(builderForValue.build()); + onChanged(); + } else { + sparseTensorsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public Builder addSparseTensors( + int index, OnnxMl.SparseTensorProto.Builder builderForValue) { + if (sparseTensorsBuilder_ == null) { + ensureSparseTensorsIsMutable(); + sparseTensors_.add(index, builderForValue.build()); + onChanged(); + } else { + sparseTensorsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public Builder addAllSparseTensors( + java.lang.Iterable values) { + if (sparseTensorsBuilder_ == null) { + ensureSparseTensorsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sparseTensors_); + onChanged(); + } else { + sparseTensorsBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public Builder clearSparseTensors() { + if (sparseTensorsBuilder_ == null) { + sparseTensors_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00008000); + onChanged(); + } else { + sparseTensorsBuilder_.clear(); + } + return this; + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public Builder removeSparseTensors(int index) { + if (sparseTensorsBuilder_ == null) { + ensureSparseTensorsIsMutable(); + sparseTensors_.remove(index); + onChanged(); + } else { + sparseTensorsBuilder_.remove(index); + } + return this; + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public OnnxMl.SparseTensorProto.Builder getSparseTensorsBuilder( + int index) { + return getSparseTensorsFieldBuilder().getBuilder(index); + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public OnnxMl.SparseTensorProtoOrBuilder getSparseTensorsOrBuilder( + int index) { + if (sparseTensorsBuilder_ == null) { + return sparseTensors_.get(index); } else { + return sparseTensorsBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public java.util.List + getSparseTensorsOrBuilderList() { + if (sparseTensorsBuilder_ != null) { + return sparseTensorsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sparseTensors_); + } + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public OnnxMl.SparseTensorProto.Builder addSparseTensorsBuilder() { + return getSparseTensorsFieldBuilder().addBuilder( + OnnxMl.SparseTensorProto.getDefaultInstance()); + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public OnnxMl.SparseTensorProto.Builder addSparseTensorsBuilder( + int index) { + return getSparseTensorsFieldBuilder().addBuilder( + index, OnnxMl.SparseTensorProto.getDefaultInstance()); + } + /** + *
+       * list of sparse tensors
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_tensors = 23; + */ + public java.util.List + getSparseTensorsBuilderList() { + return getSparseTensorsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.SparseTensorProto, OnnxMl.SparseTensorProto.Builder, OnnxMl.SparseTensorProtoOrBuilder> + getSparseTensorsFieldBuilder() { + if (sparseTensorsBuilder_ == null) { + sparseTensorsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.SparseTensorProto, OnnxMl.SparseTensorProto.Builder, OnnxMl.SparseTensorProtoOrBuilder>( + sparseTensors_, + ((bitField0_ & 0x00008000) == 0x00008000), + getParentForChildren(), + isClean()); + sparseTensors_ = null; + } + return sparseTensorsBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.AttributeProto) + } + + // @@protoc_insertion_point(class_scope:onnx.AttributeProto) + private static final OnnxMl.AttributeProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.AttributeProto(); + } + + public static OnnxMl.AttributeProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AttributeProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AttributeProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.AttributeProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ValueInfoProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.ValueInfoProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * This field MUST be present in this version of the IR.
+     * 
+ * + * string name = 1; + */ + java.lang.String getName(); + /** + *
+     * This field MUST be present in this version of the IR.
+     * 
+ * + * string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     * This field MUST be present in this version of the IR for
+     * inputs and outputs of the top-level graph.
+     * 
+ * + * .onnx.TypeProto type = 2; + */ + boolean hasType(); + /** + *
+     * This field MUST be present in this version of the IR for
+     * inputs and outputs of the top-level graph.
+     * 
+ * + * .onnx.TypeProto type = 2; + */ + OnnxMl.TypeProto getType(); + /** + *
+     * This field MUST be present in this version of the IR for
+     * inputs and outputs of the top-level graph.
+     * 
+ * + * .onnx.TypeProto type = 2; + */ + OnnxMl.TypeProtoOrBuilder getTypeOrBuilder(); + + /** + *
+     * A human-readable documentation for this value. Markdown is allowed.
+     * 
+ * + * string doc_string = 3; + */ + java.lang.String getDocString(); + /** + *
+     * A human-readable documentation for this value. Markdown is allowed.
+     * 
+ * + * string doc_string = 3; + */ + com.google.protobuf.ByteString + getDocStringBytes(); + } + /** + *
+   * Defines information on value, including the name, the type, and
+   * the shape of the value.
+   * 
+ * + * Protobuf type {@code onnx.ValueInfoProto} + */ + public static final class ValueInfoProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.ValueInfoProto) + ValueInfoProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use ValueInfoProto.newBuilder() to construct. + private ValueInfoProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ValueInfoProto() { + name_ = ""; + docString_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ValueInfoProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: { + OnnxMl.TypeProto.Builder subBuilder = null; + if (type_ != null) { + subBuilder = type_.toBuilder(); + } + type_ = input.readMessage(OnnxMl.TypeProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(type_); + type_ = subBuilder.buildPartial(); + } + + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + docString_ = s; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_ValueInfoProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_ValueInfoProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.ValueInfoProto.class, OnnxMl.ValueInfoProto.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + *
+     * This field MUST be present in this version of the IR.
+     * 
+ * + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     * This field MUST be present in this version of the IR.
+     * 
+ * + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 2; + private OnnxMl.TypeProto type_; + /** + *
+     * This field MUST be present in this version of the IR for
+     * inputs and outputs of the top-level graph.
+     * 
+ * + * .onnx.TypeProto type = 2; + */ + public boolean hasType() { + return type_ != null; + } + /** + *
+     * This field MUST be present in this version of the IR for
+     * inputs and outputs of the top-level graph.
+     * 
+ * + * .onnx.TypeProto type = 2; + */ + public OnnxMl.TypeProto getType() { + return type_ == null ? OnnxMl.TypeProto.getDefaultInstance() : type_; + } + /** + *
+     * This field MUST be present in this version of the IR for
+     * inputs and outputs of the top-level graph.
+     * 
+ * + * .onnx.TypeProto type = 2; + */ + public OnnxMl.TypeProtoOrBuilder getTypeOrBuilder() { + return getType(); + } + + public static final int DOC_STRING_FIELD_NUMBER = 3; + private volatile java.lang.Object docString_; + /** + *
+     * A human-readable documentation for this value. Markdown is allowed.
+     * 
+ * + * string doc_string = 3; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } + } + /** + *
+     * A human-readable documentation for this value. Markdown is allowed.
+     * 
+ * + * string doc_string = 3; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (type_ != null) { + output.writeMessage(2, getType()); + } + if (!getDocStringBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, docString_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (type_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getType()); + } + if (!getDocStringBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, docString_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.ValueInfoProto)) { + return super.equals(obj); + } + OnnxMl.ValueInfoProto other = (OnnxMl.ValueInfoProto) obj; + + boolean result = true; + result = result && getName() + .equals(other.getName()); + result = result && (hasType() == other.hasType()); + if (hasType()) { + result = result && getType() + .equals(other.getType()); + } + result = result && getDocString() + .equals(other.getDocString()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasType()) { + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType().hashCode(); + } + hash = (37 * hash) + DOC_STRING_FIELD_NUMBER; + hash = (53 * hash) + getDocString().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.ValueInfoProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.ValueInfoProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.ValueInfoProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.ValueInfoProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.ValueInfoProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.ValueInfoProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.ValueInfoProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.ValueInfoProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.ValueInfoProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.ValueInfoProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.ValueInfoProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.ValueInfoProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.ValueInfoProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Defines information on value, including the name, the type, and
+     * the shape of the value.
+     * 
+ * + * Protobuf type {@code onnx.ValueInfoProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.ValueInfoProto) + OnnxMl.ValueInfoProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_ValueInfoProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_ValueInfoProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.ValueInfoProto.class, OnnxMl.ValueInfoProto.Builder.class); + } + + // Construct using OnnxMlProto3.ValueInfoProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + if (typeBuilder_ == null) { + type_ = null; + } else { + type_ = null; + typeBuilder_ = null; + } + docString_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_ValueInfoProto_descriptor; + } + + @java.lang.Override + public OnnxMl.ValueInfoProto getDefaultInstanceForType() { + return OnnxMl.ValueInfoProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.ValueInfoProto build() { + OnnxMl.ValueInfoProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.ValueInfoProto buildPartial() { + OnnxMl.ValueInfoProto result = new OnnxMl.ValueInfoProto(this); + result.name_ = name_; + if (typeBuilder_ == null) { + result.type_ = type_; + } else { + result.type_ = typeBuilder_.build(); + } + result.docString_ = docString_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.ValueInfoProto) { + return mergeFrom((OnnxMl.ValueInfoProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.ValueInfoProto other) { + if (other == OnnxMl.ValueInfoProto.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.hasType()) { + mergeType(other.getType()); + } + if (!other.getDocString().isEmpty()) { + docString_ = other.docString_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.ValueInfoProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.ValueInfoProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + *
+       * This field MUST be present in this version of the IR.
+       * 
+ * + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * This field MUST be present in this version of the IR.
+       * 
+ * + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * This field MUST be present in this version of the IR.
+       * 
+ * + * string name = 1; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       * This field MUST be present in this version of the IR.
+       * 
+ * + * string name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       * This field MUST be present in this version of the IR.
+       * 
+ * + * string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private OnnxMl.TypeProto type_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto, OnnxMl.TypeProto.Builder, OnnxMl.TypeProtoOrBuilder> typeBuilder_; + /** + *
+       * This field MUST be present in this version of the IR for
+       * inputs and outputs of the top-level graph.
+       * 
+ * + * .onnx.TypeProto type = 2; + */ + public boolean hasType() { + return typeBuilder_ != null || type_ != null; + } + /** + *
+       * This field MUST be present in this version of the IR for
+       * inputs and outputs of the top-level graph.
+       * 
+ * + * .onnx.TypeProto type = 2; + */ + public OnnxMl.TypeProto getType() { + if (typeBuilder_ == null) { + return type_ == null ? OnnxMl.TypeProto.getDefaultInstance() : type_; + } else { + return typeBuilder_.getMessage(); + } + } + /** + *
+       * This field MUST be present in this version of the IR for
+       * inputs and outputs of the top-level graph.
+       * 
+ * + * .onnx.TypeProto type = 2; + */ + public Builder setType(OnnxMl.TypeProto value) { + if (typeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + type_ = value; + onChanged(); + } else { + typeBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       * This field MUST be present in this version of the IR for
+       * inputs and outputs of the top-level graph.
+       * 
+ * + * .onnx.TypeProto type = 2; + */ + public Builder setType( + OnnxMl.TypeProto.Builder builderForValue) { + if (typeBuilder_ == null) { + type_ = builderForValue.build(); + onChanged(); + } else { + typeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       * This field MUST be present in this version of the IR for
+       * inputs and outputs of the top-level graph.
+       * 
+ * + * .onnx.TypeProto type = 2; + */ + public Builder mergeType(OnnxMl.TypeProto value) { + if (typeBuilder_ == null) { + if (type_ != null) { + type_ = + OnnxMl.TypeProto.newBuilder(type_).mergeFrom(value).buildPartial(); + } else { + type_ = value; + } + onChanged(); + } else { + typeBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       * This field MUST be present in this version of the IR for
+       * inputs and outputs of the top-level graph.
+       * 
+ * + * .onnx.TypeProto type = 2; + */ + public Builder clearType() { + if (typeBuilder_ == null) { + type_ = null; + onChanged(); + } else { + type_ = null; + typeBuilder_ = null; + } + + return this; + } + /** + *
+       * This field MUST be present in this version of the IR for
+       * inputs and outputs of the top-level graph.
+       * 
+ * + * .onnx.TypeProto type = 2; + */ + public OnnxMl.TypeProto.Builder getTypeBuilder() { + + onChanged(); + return getTypeFieldBuilder().getBuilder(); + } + /** + *
+       * This field MUST be present in this version of the IR for
+       * inputs and outputs of the top-level graph.
+       * 
+ * + * .onnx.TypeProto type = 2; + */ + public OnnxMl.TypeProtoOrBuilder getTypeOrBuilder() { + if (typeBuilder_ != null) { + return typeBuilder_.getMessageOrBuilder(); + } else { + return type_ == null ? + OnnxMl.TypeProto.getDefaultInstance() : type_; + } + } + /** + *
+       * This field MUST be present in this version of the IR for
+       * inputs and outputs of the top-level graph.
+       * 
+ * + * .onnx.TypeProto type = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto, OnnxMl.TypeProto.Builder, OnnxMl.TypeProtoOrBuilder> + getTypeFieldBuilder() { + if (typeBuilder_ == null) { + typeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto, OnnxMl.TypeProto.Builder, OnnxMl.TypeProtoOrBuilder>( + getType(), + getParentForChildren(), + isClean()); + type_ = null; + } + return typeBuilder_; + } + + private java.lang.Object docString_ = ""; + /** + *
+       * A human-readable documentation for this value. Markdown is allowed.
+       * 
+ * + * string doc_string = 3; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * A human-readable documentation for this value. Markdown is allowed.
+       * 
+ * + * string doc_string = 3; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * A human-readable documentation for this value. Markdown is allowed.
+       * 
+ * + * string doc_string = 3; + */ + public Builder setDocString( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + docString_ = value; + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this value. Markdown is allowed.
+       * 
+ * + * string doc_string = 3; + */ + public Builder clearDocString() { + + docString_ = getDefaultInstance().getDocString(); + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this value. Markdown is allowed.
+       * 
+ * + * string doc_string = 3; + */ + public Builder setDocStringBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + docString_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.ValueInfoProto) + } + + // @@protoc_insertion_point(class_scope:onnx.ValueInfoProto) + private static final OnnxMl.ValueInfoProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.ValueInfoProto(); + } + + public static OnnxMl.ValueInfoProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ValueInfoProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ValueInfoProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.ValueInfoProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface NodeProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.NodeProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * namespace Value
+     * 
+ * + * repeated string input = 1; + */ + java.util.List + getInputList(); + /** + *
+     * namespace Value
+     * 
+ * + * repeated string input = 1; + */ + int getInputCount(); + /** + *
+     * namespace Value
+     * 
+ * + * repeated string input = 1; + */ + java.lang.String getInput(int index); + /** + *
+     * namespace Value
+     * 
+ * + * repeated string input = 1; + */ + com.google.protobuf.ByteString + getInputBytes(int index); + + /** + *
+     * namespace Value
+     * 
+ * + * repeated string output = 2; + */ + java.util.List + getOutputList(); + /** + *
+     * namespace Value
+     * 
+ * + * repeated string output = 2; + */ + int getOutputCount(); + /** + *
+     * namespace Value
+     * 
+ * + * repeated string output = 2; + */ + java.lang.String getOutput(int index); + /** + *
+     * namespace Value
+     * 
+ * + * repeated string output = 2; + */ + com.google.protobuf.ByteString + getOutputBytes(int index); + + /** + *
+     * An optional identifier for this node in a graph.
+     * This field MAY be absent in ths version of the IR.
+     * 
+ * + * string name = 3; + */ + java.lang.String getName(); + /** + *
+     * An optional identifier for this node in a graph.
+     * This field MAY be absent in ths version of the IR.
+     * 
+ * + * string name = 3; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     * The symbolic identifier of the Operator to execute.
+     * 
+ * + * string op_type = 4; + */ + java.lang.String getOpType(); + /** + *
+     * The symbolic identifier of the Operator to execute.
+     * 
+ * + * string op_type = 4; + */ + com.google.protobuf.ByteString + getOpTypeBytes(); + + /** + *
+     * The domain of the OperatorSet that specifies the operator named by op_type.
+     * 
+ * + * string domain = 7; + */ + java.lang.String getDomain(); + /** + *
+     * The domain of the OperatorSet that specifies the operator named by op_type.
+     * 
+ * + * string domain = 7; + */ + com.google.protobuf.ByteString + getDomainBytes(); + + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + java.util.List + getAttributeList(); + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + OnnxMl.AttributeProto getAttribute(int index); + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + int getAttributeCount(); + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + java.util.List + getAttributeOrBuilderList(); + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + OnnxMl.AttributeProtoOrBuilder getAttributeOrBuilder( + int index); + + /** + *
+     * A human-readable documentation for this node. Markdown is allowed.
+     * 
+ * + * string doc_string = 6; + */ + java.lang.String getDocString(); + /** + *
+     * A human-readable documentation for this node. Markdown is allowed.
+     * 
+ * + * string doc_string = 6; + */ + com.google.protobuf.ByteString + getDocStringBytes(); + } + /** + *
+   * Nodes
+   * Computation graphs are made up of a DAG of nodes, which represent what is
+   * commonly called a "layer" or "pipeline stage" in machine learning frameworks.
+   * For example, it can be a node of type "Conv" that takes in an image, a filter 
+   * tensor and a bias tensor, and produces the convolved output.
+   * 
+ * + * Protobuf type {@code onnx.NodeProto} + */ + public static final class NodeProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.NodeProto) + NodeProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use NodeProto.newBuilder() to construct. + private NodeProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private NodeProto() { + input_ = com.google.protobuf.LazyStringArrayList.EMPTY; + output_ = com.google.protobuf.LazyStringArrayList.EMPTY; + name_ = ""; + opType_ = ""; + domain_ = ""; + attribute_ = java.util.Collections.emptyList(); + docString_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private NodeProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + input_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + input_.add(s); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + output_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + output_.add(s); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + opType_ = s; + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + attribute_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + attribute_.add( + input.readMessage(OnnxMl.AttributeProto.parser(), extensionRegistry)); + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + docString_ = s; + break; + } + case 58: { + java.lang.String s = input.readStringRequireUtf8(); + + domain_ = s; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + input_ = input_.getUnmodifiableView(); + } + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + output_ = output_.getUnmodifiableView(); + } + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + attribute_ = java.util.Collections.unmodifiableList(attribute_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_NodeProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_NodeProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.NodeProto.class, OnnxMl.NodeProto.Builder.class); + } + + private int bitField0_; + public static final int INPUT_FIELD_NUMBER = 1; + private com.google.protobuf.LazyStringList input_; + /** + *
+     * namespace Value
+     * 
+ * + * repeated string input = 1; + */ + public com.google.protobuf.ProtocolStringList + getInputList() { + return input_; + } + /** + *
+     * namespace Value
+     * 
+ * + * repeated string input = 1; + */ + public int getInputCount() { + return input_.size(); + } + /** + *
+     * namespace Value
+     * 
+ * + * repeated string input = 1; + */ + public java.lang.String getInput(int index) { + return input_.get(index); + } + /** + *
+     * namespace Value
+     * 
+ * + * repeated string input = 1; + */ + public com.google.protobuf.ByteString + getInputBytes(int index) { + return input_.getByteString(index); + } + + public static final int OUTPUT_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList output_; + /** + *
+     * namespace Value
+     * 
+ * + * repeated string output = 2; + */ + public com.google.protobuf.ProtocolStringList + getOutputList() { + return output_; + } + /** + *
+     * namespace Value
+     * 
+ * + * repeated string output = 2; + */ + public int getOutputCount() { + return output_.size(); + } + /** + *
+     * namespace Value
+     * 
+ * + * repeated string output = 2; + */ + public java.lang.String getOutput(int index) { + return output_.get(index); + } + /** + *
+     * namespace Value
+     * 
+ * + * repeated string output = 2; + */ + public com.google.protobuf.ByteString + getOutputBytes(int index) { + return output_.getByteString(index); + } + + public static final int NAME_FIELD_NUMBER = 3; + private volatile java.lang.Object name_; + /** + *
+     * An optional identifier for this node in a graph.
+     * This field MAY be absent in ths version of the IR.
+     * 
+ * + * string name = 3; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     * An optional identifier for this node in a graph.
+     * This field MAY be absent in ths version of the IR.
+     * 
+ * + * string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OP_TYPE_FIELD_NUMBER = 4; + private volatile java.lang.Object opType_; + /** + *
+     * The symbolic identifier of the Operator to execute.
+     * 
+ * + * string op_type = 4; + */ + public java.lang.String getOpType() { + java.lang.Object ref = opType_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + opType_ = s; + return s; + } + } + /** + *
+     * The symbolic identifier of the Operator to execute.
+     * 
+ * + * string op_type = 4; + */ + public com.google.protobuf.ByteString + getOpTypeBytes() { + java.lang.Object ref = opType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + opType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DOMAIN_FIELD_NUMBER = 7; + private volatile java.lang.Object domain_; + /** + *
+     * The domain of the OperatorSet that specifies the operator named by op_type.
+     * 
+ * + * string domain = 7; + */ + public java.lang.String getDomain() { + java.lang.Object ref = domain_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + domain_ = s; + return s; + } + } + /** + *
+     * The domain of the OperatorSet that specifies the operator named by op_type.
+     * 
+ * + * string domain = 7; + */ + public com.google.protobuf.ByteString + getDomainBytes() { + java.lang.Object ref = domain_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + domain_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ATTRIBUTE_FIELD_NUMBER = 5; + private java.util.List attribute_; + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public java.util.List getAttributeList() { + return attribute_; + } + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public java.util.List + getAttributeOrBuilderList() { + return attribute_; + } + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public int getAttributeCount() { + return attribute_.size(); + } + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public OnnxMl.AttributeProto getAttribute(int index) { + return attribute_.get(index); + } + /** + *
+     * Additional named attributes.
+     * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public OnnxMl.AttributeProtoOrBuilder getAttributeOrBuilder( + int index) { + return attribute_.get(index); + } + + public static final int DOC_STRING_FIELD_NUMBER = 6; + private volatile java.lang.Object docString_; + /** + *
+     * A human-readable documentation for this node. Markdown is allowed.
+     * 
+ * + * string doc_string = 6; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } + } + /** + *
+     * A human-readable documentation for this node. Markdown is allowed.
+     * 
+ * + * string doc_string = 6; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < input_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, input_.getRaw(i)); + } + for (int i = 0; i < output_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, output_.getRaw(i)); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, name_); + } + if (!getOpTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, opType_); + } + for (int i = 0; i < attribute_.size(); i++) { + output.writeMessage(5, attribute_.get(i)); + } + if (!getDocStringBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, docString_); + } + if (!getDomainBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, domain_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < input_.size(); i++) { + dataSize += computeStringSizeNoTag(input_.getRaw(i)); + } + size += dataSize; + size += 1 * getInputList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < output_.size(); i++) { + dataSize += computeStringSizeNoTag(output_.getRaw(i)); + } + size += dataSize; + size += 1 * getOutputList().size(); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, name_); + } + if (!getOpTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, opType_); + } + for (int i = 0; i < attribute_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, attribute_.get(i)); + } + if (!getDocStringBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, docString_); + } + if (!getDomainBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, domain_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.NodeProto)) { + return super.equals(obj); + } + OnnxMl.NodeProto other = (OnnxMl.NodeProto) obj; + + boolean result = true; + result = result && getInputList() + .equals(other.getInputList()); + result = result && getOutputList() + .equals(other.getOutputList()); + result = result && getName() + .equals(other.getName()); + result = result && getOpType() + .equals(other.getOpType()); + result = result && getDomain() + .equals(other.getDomain()); + result = result && getAttributeList() + .equals(other.getAttributeList()); + result = result && getDocString() + .equals(other.getDocString()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getInputCount() > 0) { + hash = (37 * hash) + INPUT_FIELD_NUMBER; + hash = (53 * hash) + getInputList().hashCode(); + } + if (getOutputCount() > 0) { + hash = (37 * hash) + OUTPUT_FIELD_NUMBER; + hash = (53 * hash) + getOutputList().hashCode(); + } + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + OP_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getOpType().hashCode(); + hash = (37 * hash) + DOMAIN_FIELD_NUMBER; + hash = (53 * hash) + getDomain().hashCode(); + if (getAttributeCount() > 0) { + hash = (37 * hash) + ATTRIBUTE_FIELD_NUMBER; + hash = (53 * hash) + getAttributeList().hashCode(); + } + hash = (37 * hash) + DOC_STRING_FIELD_NUMBER; + hash = (53 * hash) + getDocString().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.NodeProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.NodeProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.NodeProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.NodeProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.NodeProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.NodeProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.NodeProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.NodeProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.NodeProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.NodeProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.NodeProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.NodeProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.NodeProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Nodes
+     * Computation graphs are made up of a DAG of nodes, which represent what is
+     * commonly called a "layer" or "pipeline stage" in machine learning frameworks.
+     * For example, it can be a node of type "Conv" that takes in an image, a filter 
+     * tensor and a bias tensor, and produces the convolved output.
+     * 
+ * + * Protobuf type {@code onnx.NodeProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.NodeProto) + OnnxMl.NodeProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_NodeProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_NodeProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.NodeProto.class, OnnxMl.NodeProto.Builder.class); + } + + // Construct using OnnxMlProto3.NodeProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getAttributeFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + input_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + output_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + name_ = ""; + + opType_ = ""; + + domain_ = ""; + + if (attributeBuilder_ == null) { + attribute_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + } else { + attributeBuilder_.clear(); + } + docString_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_NodeProto_descriptor; + } + + @java.lang.Override + public OnnxMl.NodeProto getDefaultInstanceForType() { + return OnnxMl.NodeProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.NodeProto build() { + OnnxMl.NodeProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.NodeProto buildPartial() { + OnnxMl.NodeProto result = new OnnxMl.NodeProto(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + input_ = input_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.input_ = input_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output_ = output_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.output_ = output_; + result.name_ = name_; + result.opType_ = opType_; + result.domain_ = domain_; + if (attributeBuilder_ == null) { + if (((bitField0_ & 0x00000020) == 0x00000020)) { + attribute_ = java.util.Collections.unmodifiableList(attribute_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.attribute_ = attribute_; + } else { + result.attribute_ = attributeBuilder_.build(); + } + result.docString_ = docString_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.NodeProto) { + return mergeFrom((OnnxMl.NodeProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.NodeProto other) { + if (other == OnnxMl.NodeProto.getDefaultInstance()) return this; + if (!other.input_.isEmpty()) { + if (input_.isEmpty()) { + input_ = other.input_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureInputIsMutable(); + input_.addAll(other.input_); + } + onChanged(); + } + if (!other.output_.isEmpty()) { + if (output_.isEmpty()) { + output_ = other.output_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureOutputIsMutable(); + output_.addAll(other.output_); + } + onChanged(); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getOpType().isEmpty()) { + opType_ = other.opType_; + onChanged(); + } + if (!other.getDomain().isEmpty()) { + domain_ = other.domain_; + onChanged(); + } + if (attributeBuilder_ == null) { + if (!other.attribute_.isEmpty()) { + if (attribute_.isEmpty()) { + attribute_ = other.attribute_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureAttributeIsMutable(); + attribute_.addAll(other.attribute_); + } + onChanged(); + } + } else { + if (!other.attribute_.isEmpty()) { + if (attributeBuilder_.isEmpty()) { + attributeBuilder_.dispose(); + attributeBuilder_ = null; + attribute_ = other.attribute_; + bitField0_ = (bitField0_ & ~0x00000020); + attributeBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getAttributeFieldBuilder() : null; + } else { + attributeBuilder_.addAllMessages(other.attribute_); + } + } + } + if (!other.getDocString().isEmpty()) { + docString_ = other.docString_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.NodeProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.NodeProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.LazyStringList input_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureInputIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + input_ = new com.google.protobuf.LazyStringArrayList(input_); + bitField0_ |= 0x00000001; + } + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string input = 1; + */ + public com.google.protobuf.ProtocolStringList + getInputList() { + return input_.getUnmodifiableView(); + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string input = 1; + */ + public int getInputCount() { + return input_.size(); + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string input = 1; + */ + public java.lang.String getInput(int index) { + return input_.get(index); + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string input = 1; + */ + public com.google.protobuf.ByteString + getInputBytes(int index) { + return input_.getByteString(index); + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string input = 1; + */ + public Builder setInput( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputIsMutable(); + input_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string input = 1; + */ + public Builder addInput( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputIsMutable(); + input_.add(value); + onChanged(); + return this; + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string input = 1; + */ + public Builder addAllInput( + java.lang.Iterable values) { + ensureInputIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, input_); + onChanged(); + return this; + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string input = 1; + */ + public Builder clearInput() { + input_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string input = 1; + */ + public Builder addInputBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureInputIsMutable(); + input_.add(value); + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList output_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureOutputIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + output_ = new com.google.protobuf.LazyStringArrayList(output_); + bitField0_ |= 0x00000002; + } + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string output = 2; + */ + public com.google.protobuf.ProtocolStringList + getOutputList() { + return output_.getUnmodifiableView(); + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string output = 2; + */ + public int getOutputCount() { + return output_.size(); + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string output = 2; + */ + public java.lang.String getOutput(int index) { + return output_.get(index); + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string output = 2; + */ + public com.google.protobuf.ByteString + getOutputBytes(int index) { + return output_.getByteString(index); + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string output = 2; + */ + public Builder setOutput( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputIsMutable(); + output_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string output = 2; + */ + public Builder addOutput( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputIsMutable(); + output_.add(value); + onChanged(); + return this; + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string output = 2; + */ + public Builder addAllOutput( + java.lang.Iterable values) { + ensureOutputIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, output_); + onChanged(); + return this; + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string output = 2; + */ + public Builder clearOutput() { + output_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + *
+       * namespace Value
+       * 
+ * + * repeated string output = 2; + */ + public Builder addOutputBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureOutputIsMutable(); + output_.add(value); + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + /** + *
+       * An optional identifier for this node in a graph.
+       * This field MAY be absent in ths version of the IR.
+       * 
+ * + * string name = 3; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * An optional identifier for this node in a graph.
+       * This field MAY be absent in ths version of the IR.
+       * 
+ * + * string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * An optional identifier for this node in a graph.
+       * This field MAY be absent in ths version of the IR.
+       * 
+ * + * string name = 3; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       * An optional identifier for this node in a graph.
+       * This field MAY be absent in ths version of the IR.
+       * 
+ * + * string name = 3; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       * An optional identifier for this node in a graph.
+       * This field MAY be absent in ths version of the IR.
+       * 
+ * + * string name = 3; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object opType_ = ""; + /** + *
+       * The symbolic identifier of the Operator to execute.
+       * 
+ * + * string op_type = 4; + */ + public java.lang.String getOpType() { + java.lang.Object ref = opType_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + opType_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * The symbolic identifier of the Operator to execute.
+       * 
+ * + * string op_type = 4; + */ + public com.google.protobuf.ByteString + getOpTypeBytes() { + java.lang.Object ref = opType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + opType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * The symbolic identifier of the Operator to execute.
+       * 
+ * + * string op_type = 4; + */ + public Builder setOpType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + opType_ = value; + onChanged(); + return this; + } + /** + *
+       * The symbolic identifier of the Operator to execute.
+       * 
+ * + * string op_type = 4; + */ + public Builder clearOpType() { + + opType_ = getDefaultInstance().getOpType(); + onChanged(); + return this; + } + /** + *
+       * The symbolic identifier of the Operator to execute.
+       * 
+ * + * string op_type = 4; + */ + public Builder setOpTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + opType_ = value; + onChanged(); + return this; + } + + private java.lang.Object domain_ = ""; + /** + *
+       * The domain of the OperatorSet that specifies the operator named by op_type.
+       * 
+ * + * string domain = 7; + */ + public java.lang.String getDomain() { + java.lang.Object ref = domain_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + domain_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * The domain of the OperatorSet that specifies the operator named by op_type.
+       * 
+ * + * string domain = 7; + */ + public com.google.protobuf.ByteString + getDomainBytes() { + java.lang.Object ref = domain_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + domain_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * The domain of the OperatorSet that specifies the operator named by op_type.
+       * 
+ * + * string domain = 7; + */ + public Builder setDomain( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + domain_ = value; + onChanged(); + return this; + } + /** + *
+       * The domain of the OperatorSet that specifies the operator named by op_type.
+       * 
+ * + * string domain = 7; + */ + public Builder clearDomain() { + + domain_ = getDefaultInstance().getDomain(); + onChanged(); + return this; + } + /** + *
+       * The domain of the OperatorSet that specifies the operator named by op_type.
+       * 
+ * + * string domain = 7; + */ + public Builder setDomainBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + domain_ = value; + onChanged(); + return this; + } + + private java.util.List attribute_ = + java.util.Collections.emptyList(); + private void ensureAttributeIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + attribute_ = new java.util.ArrayList(attribute_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.AttributeProto, OnnxMl.AttributeProto.Builder, OnnxMl.AttributeProtoOrBuilder> attributeBuilder_; + + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public java.util.List getAttributeList() { + if (attributeBuilder_ == null) { + return java.util.Collections.unmodifiableList(attribute_); + } else { + return attributeBuilder_.getMessageList(); + } + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public int getAttributeCount() { + if (attributeBuilder_ == null) { + return attribute_.size(); + } else { + return attributeBuilder_.getCount(); + } + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public OnnxMl.AttributeProto getAttribute(int index) { + if (attributeBuilder_ == null) { + return attribute_.get(index); + } else { + return attributeBuilder_.getMessage(index); + } + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public Builder setAttribute( + int index, OnnxMl.AttributeProto value) { + if (attributeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributeIsMutable(); + attribute_.set(index, value); + onChanged(); + } else { + attributeBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public Builder setAttribute( + int index, OnnxMl.AttributeProto.Builder builderForValue) { + if (attributeBuilder_ == null) { + ensureAttributeIsMutable(); + attribute_.set(index, builderForValue.build()); + onChanged(); + } else { + attributeBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public Builder addAttribute(OnnxMl.AttributeProto value) { + if (attributeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributeIsMutable(); + attribute_.add(value); + onChanged(); + } else { + attributeBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public Builder addAttribute( + int index, OnnxMl.AttributeProto value) { + if (attributeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributeIsMutable(); + attribute_.add(index, value); + onChanged(); + } else { + attributeBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public Builder addAttribute( + OnnxMl.AttributeProto.Builder builderForValue) { + if (attributeBuilder_ == null) { + ensureAttributeIsMutable(); + attribute_.add(builderForValue.build()); + onChanged(); + } else { + attributeBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public Builder addAttribute( + int index, OnnxMl.AttributeProto.Builder builderForValue) { + if (attributeBuilder_ == null) { + ensureAttributeIsMutable(); + attribute_.add(index, builderForValue.build()); + onChanged(); + } else { + attributeBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public Builder addAllAttribute( + java.lang.Iterable values) { + if (attributeBuilder_ == null) { + ensureAttributeIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, attribute_); + onChanged(); + } else { + attributeBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public Builder clearAttribute() { + if (attributeBuilder_ == null) { + attribute_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + attributeBuilder_.clear(); + } + return this; + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public Builder removeAttribute(int index) { + if (attributeBuilder_ == null) { + ensureAttributeIsMutable(); + attribute_.remove(index); + onChanged(); + } else { + attributeBuilder_.remove(index); + } + return this; + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public OnnxMl.AttributeProto.Builder getAttributeBuilder( + int index) { + return getAttributeFieldBuilder().getBuilder(index); + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public OnnxMl.AttributeProtoOrBuilder getAttributeOrBuilder( + int index) { + if (attributeBuilder_ == null) { + return attribute_.get(index); } else { + return attributeBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public java.util.List + getAttributeOrBuilderList() { + if (attributeBuilder_ != null) { + return attributeBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(attribute_); + } + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public OnnxMl.AttributeProto.Builder addAttributeBuilder() { + return getAttributeFieldBuilder().addBuilder( + OnnxMl.AttributeProto.getDefaultInstance()); + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public OnnxMl.AttributeProto.Builder addAttributeBuilder( + int index) { + return getAttributeFieldBuilder().addBuilder( + index, OnnxMl.AttributeProto.getDefaultInstance()); + } + /** + *
+       * Additional named attributes.
+       * 
+ * + * repeated .onnx.AttributeProto attribute = 5; + */ + public java.util.List + getAttributeBuilderList() { + return getAttributeFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.AttributeProto, OnnxMl.AttributeProto.Builder, OnnxMl.AttributeProtoOrBuilder> + getAttributeFieldBuilder() { + if (attributeBuilder_ == null) { + attributeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.AttributeProto, OnnxMl.AttributeProto.Builder, OnnxMl.AttributeProtoOrBuilder>( + attribute_, + ((bitField0_ & 0x00000020) == 0x00000020), + getParentForChildren(), + isClean()); + attribute_ = null; + } + return attributeBuilder_; + } + + private java.lang.Object docString_ = ""; + /** + *
+       * A human-readable documentation for this node. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * A human-readable documentation for this node. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * A human-readable documentation for this node. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public Builder setDocString( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + docString_ = value; + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this node. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public Builder clearDocString() { + + docString_ = getDefaultInstance().getDocString(); + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this node. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public Builder setDocStringBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + docString_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.NodeProto) + } + + // @@protoc_insertion_point(class_scope:onnx.NodeProto) + private static final OnnxMl.NodeProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.NodeProto(); + } + + public static OnnxMl.NodeProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public NodeProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new NodeProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.NodeProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ModelProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.ModelProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * The version of the IR this model targets. See Version enum above.
+     * This field MUST be present.
+     * 
+ * + * int64 ir_version = 1; + */ + long getIrVersion(); + + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + java.util.List + getOpsetImportList(); + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + OnnxMl.OperatorSetIdProto getOpsetImport(int index); + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + int getOpsetImportCount(); + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + java.util.List + getOpsetImportOrBuilderList(); + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + OnnxMl.OperatorSetIdProtoOrBuilder getOpsetImportOrBuilder( + int index); + + /** + *
+     * The name of the framework or tool used to generate this model.
+     * This field SHOULD be present to indicate which implementation/tool/framework
+     * emitted the model.
+     * 
+ * + * string producer_name = 2; + */ + java.lang.String getProducerName(); + /** + *
+     * The name of the framework or tool used to generate this model.
+     * This field SHOULD be present to indicate which implementation/tool/framework
+     * emitted the model.
+     * 
+ * + * string producer_name = 2; + */ + com.google.protobuf.ByteString + getProducerNameBytes(); + + /** + *
+     * The version of the framework or tool used to generate this model.
+     * This field SHOULD be present to indicate which implementation/tool/framework
+     * emitted the model.
+     * 
+ * + * string producer_version = 3; + */ + java.lang.String getProducerVersion(); + /** + *
+     * The version of the framework or tool used to generate this model.
+     * This field SHOULD be present to indicate which implementation/tool/framework
+     * emitted the model.
+     * 
+ * + * string producer_version = 3; + */ + com.google.protobuf.ByteString + getProducerVersionBytes(); + + /** + *
+     * Domain name of the model.
+     * We use reverse domain names as name space indicators. For example:
+     * `com.facebook.fair` or `com.microsoft.cognitiveservices`
+     * Together with `model_version` and GraphProto.name, this forms the unique identity of
+     * the graph.
+     * 
+ * + * string domain = 4; + */ + java.lang.String getDomain(); + /** + *
+     * Domain name of the model.
+     * We use reverse domain names as name space indicators. For example:
+     * `com.facebook.fair` or `com.microsoft.cognitiveservices`
+     * Together with `model_version` and GraphProto.name, this forms the unique identity of
+     * the graph.
+     * 
+ * + * string domain = 4; + */ + com.google.protobuf.ByteString + getDomainBytes(); + + /** + *
+     * The version of the graph encoded. See Version enum below.
+     * 
+ * + * int64 model_version = 5; + */ + long getModelVersion(); + + /** + *
+     * A human-readable documentation for this model. Markdown is allowed.
+     * 
+ * + * string doc_string = 6; + */ + java.lang.String getDocString(); + /** + *
+     * A human-readable documentation for this model. Markdown is allowed.
+     * 
+ * + * string doc_string = 6; + */ + com.google.protobuf.ByteString + getDocStringBytes(); + + /** + *
+     * The parameterized graph that is evaluated to execute the model.
+     * 
+ * + * .onnx.GraphProto graph = 7; + */ + boolean hasGraph(); + /** + *
+     * The parameterized graph that is evaluated to execute the model.
+     * 
+ * + * .onnx.GraphProto graph = 7; + */ + OnnxMl.GraphProto getGraph(); + /** + *
+     * The parameterized graph that is evaluated to execute the model.
+     * 
+ * + * .onnx.GraphProto graph = 7; + */ + OnnxMl.GraphProtoOrBuilder getGraphOrBuilder(); + + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + java.util.List + getFunctionsList(); + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + OnnxMl.FunctionProto getFunctions(int index); + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + int getFunctionsCount(); + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + java.util.List + getFunctionsOrBuilderList(); + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + OnnxMl.FunctionProtoOrBuilder getFunctionsOrBuilder( + int index); + + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + java.util.List + getMetadataPropsList(); + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + OnnxMl.StringStringEntryProto getMetadataProps(int index); + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + int getMetadataPropsCount(); + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + java.util.List + getMetadataPropsOrBuilderList(); + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + OnnxMl.StringStringEntryProtoOrBuilder getMetadataPropsOrBuilder( + int index); + } + /** + *
+   * Models
+   * ModelProto is a top-level file/container format for bundling a ML model and
+   * associating its computation graph with metadata.
+   * The semantics of the model are described by the associated GraphProto.
+   * 
+ * + * Protobuf type {@code onnx.ModelProto} + */ + public static final class ModelProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.ModelProto) + ModelProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use ModelProto.newBuilder() to construct. + private ModelProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ModelProto() { + irVersion_ = 0L; + opsetImport_ = java.util.Collections.emptyList(); + producerName_ = ""; + producerVersion_ = ""; + domain_ = ""; + modelVersion_ = 0L; + docString_ = ""; + functions_ = java.util.Collections.emptyList(); + metadataProps_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ModelProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + irVersion_ = input.readInt64(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + producerName_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + producerVersion_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + domain_ = s; + break; + } + case 40: { + + modelVersion_ = input.readInt64(); + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + docString_ = s; + break; + } + case 58: { + OnnxMl.GraphProto.Builder subBuilder = null; + if (graph_ != null) { + subBuilder = graph_.toBuilder(); + } + graph_ = input.readMessage(OnnxMl.GraphProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(graph_); + graph_ = subBuilder.buildPartial(); + } + + break; + } + case 66: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + opsetImport_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + opsetImport_.add( + input.readMessage(OnnxMl.OperatorSetIdProto.parser(), extensionRegistry)); + break; + } + case 114: { + if (!((mutable_bitField0_ & 0x00000200) == 0x00000200)) { + metadataProps_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000200; + } + metadataProps_.add( + input.readMessage(OnnxMl.StringStringEntryProto.parser(), extensionRegistry)); + break; + } + case 802: { + if (!((mutable_bitField0_ & 0x00000100) == 0x00000100)) { + functions_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000100; + } + functions_.add( + input.readMessage(OnnxMl.FunctionProto.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + opsetImport_ = java.util.Collections.unmodifiableList(opsetImport_); + } + if (((mutable_bitField0_ & 0x00000200) == 0x00000200)) { + metadataProps_ = java.util.Collections.unmodifiableList(metadataProps_); + } + if (((mutable_bitField0_ & 0x00000100) == 0x00000100)) { + functions_ = java.util.Collections.unmodifiableList(functions_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_ModelProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_ModelProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.ModelProto.class, OnnxMl.ModelProto.Builder.class); + } + + private int bitField0_; + public static final int IR_VERSION_FIELD_NUMBER = 1; + private long irVersion_; + /** + *
+     * The version of the IR this model targets. See Version enum above.
+     * This field MUST be present.
+     * 
+ * + * int64 ir_version = 1; + */ + public long getIrVersion() { + return irVersion_; + } + + public static final int OPSET_IMPORT_FIELD_NUMBER = 8; + private java.util.List opsetImport_; + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public java.util.List getOpsetImportList() { + return opsetImport_; + } + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public java.util.List + getOpsetImportOrBuilderList() { + return opsetImport_; + } + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public int getOpsetImportCount() { + return opsetImport_.size(); + } + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public OnnxMl.OperatorSetIdProto getOpsetImport(int index) { + return opsetImport_.get(index); + } + /** + *
+     * The OperatorSets this model relies on.
+     * All ModelProtos MUST have at least one entry that
+     * specifies which version of the ONNX OperatorSet is
+     * being imported.
+     * All nodes in the ModelProto's graph will bind against the operator
+     * with the same-domain/same-op_type operator with the HIGHEST version
+     * in the referenced operator sets.
+     * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public OnnxMl.OperatorSetIdProtoOrBuilder getOpsetImportOrBuilder( + int index) { + return opsetImport_.get(index); + } + + public static final int PRODUCER_NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object producerName_; + /** + *
+     * The name of the framework or tool used to generate this model.
+     * This field SHOULD be present to indicate which implementation/tool/framework
+     * emitted the model.
+     * 
+ * + * string producer_name = 2; + */ + public java.lang.String getProducerName() { + java.lang.Object ref = producerName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + producerName_ = s; + return s; + } + } + /** + *
+     * The name of the framework or tool used to generate this model.
+     * This field SHOULD be present to indicate which implementation/tool/framework
+     * emitted the model.
+     * 
+ * + * string producer_name = 2; + */ + public com.google.protobuf.ByteString + getProducerNameBytes() { + java.lang.Object ref = producerName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + producerName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PRODUCER_VERSION_FIELD_NUMBER = 3; + private volatile java.lang.Object producerVersion_; + /** + *
+     * The version of the framework or tool used to generate this model.
+     * This field SHOULD be present to indicate which implementation/tool/framework
+     * emitted the model.
+     * 
+ * + * string producer_version = 3; + */ + public java.lang.String getProducerVersion() { + java.lang.Object ref = producerVersion_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + producerVersion_ = s; + return s; + } + } + /** + *
+     * The version of the framework or tool used to generate this model.
+     * This field SHOULD be present to indicate which implementation/tool/framework
+     * emitted the model.
+     * 
+ * + * string producer_version = 3; + */ + public com.google.protobuf.ByteString + getProducerVersionBytes() { + java.lang.Object ref = producerVersion_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + producerVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DOMAIN_FIELD_NUMBER = 4; + private volatile java.lang.Object domain_; + /** + *
+     * Domain name of the model.
+     * We use reverse domain names as name space indicators. For example:
+     * `com.facebook.fair` or `com.microsoft.cognitiveservices`
+     * Together with `model_version` and GraphProto.name, this forms the unique identity of
+     * the graph.
+     * 
+ * + * string domain = 4; + */ + public java.lang.String getDomain() { + java.lang.Object ref = domain_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + domain_ = s; + return s; + } + } + /** + *
+     * Domain name of the model.
+     * We use reverse domain names as name space indicators. For example:
+     * `com.facebook.fair` or `com.microsoft.cognitiveservices`
+     * Together with `model_version` and GraphProto.name, this forms the unique identity of
+     * the graph.
+     * 
+ * + * string domain = 4; + */ + public com.google.protobuf.ByteString + getDomainBytes() { + java.lang.Object ref = domain_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + domain_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MODEL_VERSION_FIELD_NUMBER = 5; + private long modelVersion_; + /** + *
+     * The version of the graph encoded. See Version enum below.
+     * 
+ * + * int64 model_version = 5; + */ + public long getModelVersion() { + return modelVersion_; + } + + public static final int DOC_STRING_FIELD_NUMBER = 6; + private volatile java.lang.Object docString_; + /** + *
+     * A human-readable documentation for this model. Markdown is allowed.
+     * 
+ * + * string doc_string = 6; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } + } + /** + *
+     * A human-readable documentation for this model. Markdown is allowed.
+     * 
+ * + * string doc_string = 6; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int GRAPH_FIELD_NUMBER = 7; + private OnnxMl.GraphProto graph_; + /** + *
+     * The parameterized graph that is evaluated to execute the model.
+     * 
+ * + * .onnx.GraphProto graph = 7; + */ + public boolean hasGraph() { + return graph_ != null; + } + /** + *
+     * The parameterized graph that is evaluated to execute the model.
+     * 
+ * + * .onnx.GraphProto graph = 7; + */ + public OnnxMl.GraphProto getGraph() { + return graph_ == null ? OnnxMl.GraphProto.getDefaultInstance() : graph_; + } + /** + *
+     * The parameterized graph that is evaluated to execute the model.
+     * 
+ * + * .onnx.GraphProto graph = 7; + */ + public OnnxMl.GraphProtoOrBuilder getGraphOrBuilder() { + return getGraph(); + } + + public static final int FUNCTIONS_FIELD_NUMBER = 100; + private java.util.List functions_; + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public java.util.List getFunctionsList() { + return functions_; + } + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public java.util.List + getFunctionsOrBuilderList() { + return functions_; + } + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public int getFunctionsCount() { + return functions_.size(); + } + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public OnnxMl.FunctionProto getFunctions(int index) { + return functions_.get(index); + } + /** + *
+     * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+     * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public OnnxMl.FunctionProtoOrBuilder getFunctionsOrBuilder( + int index) { + return functions_.get(index); + } + + public static final int METADATA_PROPS_FIELD_NUMBER = 14; + private java.util.List metadataProps_; + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public java.util.List getMetadataPropsList() { + return metadataProps_; + } + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public java.util.List + getMetadataPropsOrBuilderList() { + return metadataProps_; + } + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public int getMetadataPropsCount() { + return metadataProps_.size(); + } + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public OnnxMl.StringStringEntryProto getMetadataProps(int index) { + return metadataProps_.get(index); + } + /** + *
+     * Named metadata values; keys should be distinct.
+     * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public OnnxMl.StringStringEntryProtoOrBuilder getMetadataPropsOrBuilder( + int index) { + return metadataProps_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (irVersion_ != 0L) { + output.writeInt64(1, irVersion_); + } + if (!getProducerNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, producerName_); + } + if (!getProducerVersionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, producerVersion_); + } + if (!getDomainBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, domain_); + } + if (modelVersion_ != 0L) { + output.writeInt64(5, modelVersion_); + } + if (!getDocStringBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, docString_); + } + if (graph_ != null) { + output.writeMessage(7, getGraph()); + } + for (int i = 0; i < opsetImport_.size(); i++) { + output.writeMessage(8, opsetImport_.get(i)); + } + for (int i = 0; i < metadataProps_.size(); i++) { + output.writeMessage(14, metadataProps_.get(i)); + } + for (int i = 0; i < functions_.size(); i++) { + output.writeMessage(100, functions_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (irVersion_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, irVersion_); + } + if (!getProducerNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, producerName_); + } + if (!getProducerVersionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, producerVersion_); + } + if (!getDomainBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, domain_); + } + if (modelVersion_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, modelVersion_); + } + if (!getDocStringBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, docString_); + } + if (graph_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, getGraph()); + } + for (int i = 0; i < opsetImport_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, opsetImport_.get(i)); + } + for (int i = 0; i < metadataProps_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(14, metadataProps_.get(i)); + } + for (int i = 0; i < functions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(100, functions_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.ModelProto)) { + return super.equals(obj); + } + OnnxMl.ModelProto other = (OnnxMl.ModelProto) obj; + + boolean result = true; + result = result && (getIrVersion() + == other.getIrVersion()); + result = result && getOpsetImportList() + .equals(other.getOpsetImportList()); + result = result && getProducerName() + .equals(other.getProducerName()); + result = result && getProducerVersion() + .equals(other.getProducerVersion()); + result = result && getDomain() + .equals(other.getDomain()); + result = result && (getModelVersion() + == other.getModelVersion()); + result = result && getDocString() + .equals(other.getDocString()); + result = result && (hasGraph() == other.hasGraph()); + if (hasGraph()) { + result = result && getGraph() + .equals(other.getGraph()); + } + result = result && getFunctionsList() + .equals(other.getFunctionsList()); + result = result && getMetadataPropsList() + .equals(other.getMetadataPropsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + IR_VERSION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getIrVersion()); + if (getOpsetImportCount() > 0) { + hash = (37 * hash) + OPSET_IMPORT_FIELD_NUMBER; + hash = (53 * hash) + getOpsetImportList().hashCode(); + } + hash = (37 * hash) + PRODUCER_NAME_FIELD_NUMBER; + hash = (53 * hash) + getProducerName().hashCode(); + hash = (37 * hash) + PRODUCER_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getProducerVersion().hashCode(); + hash = (37 * hash) + DOMAIN_FIELD_NUMBER; + hash = (53 * hash) + getDomain().hashCode(); + hash = (37 * hash) + MODEL_VERSION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getModelVersion()); + hash = (37 * hash) + DOC_STRING_FIELD_NUMBER; + hash = (53 * hash) + getDocString().hashCode(); + if (hasGraph()) { + hash = (37 * hash) + GRAPH_FIELD_NUMBER; + hash = (53 * hash) + getGraph().hashCode(); + } + if (getFunctionsCount() > 0) { + hash = (37 * hash) + FUNCTIONS_FIELD_NUMBER; + hash = (53 * hash) + getFunctionsList().hashCode(); + } + if (getMetadataPropsCount() > 0) { + hash = (37 * hash) + METADATA_PROPS_FIELD_NUMBER; + hash = (53 * hash) + getMetadataPropsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.ModelProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.ModelProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.ModelProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.ModelProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.ModelProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.ModelProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.ModelProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.ModelProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.ModelProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.ModelProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.ModelProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.ModelProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.ModelProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Models
+     * ModelProto is a top-level file/container format for bundling a ML model and
+     * associating its computation graph with metadata.
+     * The semantics of the model are described by the associated GraphProto.
+     * 
+ * + * Protobuf type {@code onnx.ModelProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.ModelProto) + OnnxMl.ModelProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_ModelProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_ModelProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.ModelProto.class, OnnxMl.ModelProto.Builder.class); + } + + // Construct using OnnxMlProto3.ModelProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getOpsetImportFieldBuilder(); + getFunctionsFieldBuilder(); + getMetadataPropsFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + irVersion_ = 0L; + + if (opsetImportBuilder_ == null) { + opsetImport_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + opsetImportBuilder_.clear(); + } + producerName_ = ""; + + producerVersion_ = ""; + + domain_ = ""; + + modelVersion_ = 0L; + + docString_ = ""; + + if (graphBuilder_ == null) { + graph_ = null; + } else { + graph_ = null; + graphBuilder_ = null; + } + if (functionsBuilder_ == null) { + functions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000100); + } else { + functionsBuilder_.clear(); + } + if (metadataPropsBuilder_ == null) { + metadataProps_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000200); + } else { + metadataPropsBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_ModelProto_descriptor; + } + + @java.lang.Override + public OnnxMl.ModelProto getDefaultInstanceForType() { + return OnnxMl.ModelProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.ModelProto build() { + OnnxMl.ModelProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.ModelProto buildPartial() { + OnnxMl.ModelProto result = new OnnxMl.ModelProto(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.irVersion_ = irVersion_; + if (opsetImportBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + opsetImport_ = java.util.Collections.unmodifiableList(opsetImport_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.opsetImport_ = opsetImport_; + } else { + result.opsetImport_ = opsetImportBuilder_.build(); + } + result.producerName_ = producerName_; + result.producerVersion_ = producerVersion_; + result.domain_ = domain_; + result.modelVersion_ = modelVersion_; + result.docString_ = docString_; + if (graphBuilder_ == null) { + result.graph_ = graph_; + } else { + result.graph_ = graphBuilder_.build(); + } + if (functionsBuilder_ == null) { + if (((bitField0_ & 0x00000100) == 0x00000100)) { + functions_ = java.util.Collections.unmodifiableList(functions_); + bitField0_ = (bitField0_ & ~0x00000100); + } + result.functions_ = functions_; + } else { + result.functions_ = functionsBuilder_.build(); + } + if (metadataPropsBuilder_ == null) { + if (((bitField0_ & 0x00000200) == 0x00000200)) { + metadataProps_ = java.util.Collections.unmodifiableList(metadataProps_); + bitField0_ = (bitField0_ & ~0x00000200); + } + result.metadataProps_ = metadataProps_; + } else { + result.metadataProps_ = metadataPropsBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.ModelProto) { + return mergeFrom((OnnxMl.ModelProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.ModelProto other) { + if (other == OnnxMl.ModelProto.getDefaultInstance()) return this; + if (other.getIrVersion() != 0L) { + setIrVersion(other.getIrVersion()); + } + if (opsetImportBuilder_ == null) { + if (!other.opsetImport_.isEmpty()) { + if (opsetImport_.isEmpty()) { + opsetImport_ = other.opsetImport_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureOpsetImportIsMutable(); + opsetImport_.addAll(other.opsetImport_); + } + onChanged(); + } + } else { + if (!other.opsetImport_.isEmpty()) { + if (opsetImportBuilder_.isEmpty()) { + opsetImportBuilder_.dispose(); + opsetImportBuilder_ = null; + opsetImport_ = other.opsetImport_; + bitField0_ = (bitField0_ & ~0x00000002); + opsetImportBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getOpsetImportFieldBuilder() : null; + } else { + opsetImportBuilder_.addAllMessages(other.opsetImport_); + } + } + } + if (!other.getProducerName().isEmpty()) { + producerName_ = other.producerName_; + onChanged(); + } + if (!other.getProducerVersion().isEmpty()) { + producerVersion_ = other.producerVersion_; + onChanged(); + } + if (!other.getDomain().isEmpty()) { + domain_ = other.domain_; + onChanged(); + } + if (other.getModelVersion() != 0L) { + setModelVersion(other.getModelVersion()); + } + if (!other.getDocString().isEmpty()) { + docString_ = other.docString_; + onChanged(); + } + if (other.hasGraph()) { + mergeGraph(other.getGraph()); + } + if (functionsBuilder_ == null) { + if (!other.functions_.isEmpty()) { + if (functions_.isEmpty()) { + functions_ = other.functions_; + bitField0_ = (bitField0_ & ~0x00000100); + } else { + ensureFunctionsIsMutable(); + functions_.addAll(other.functions_); + } + onChanged(); + } + } else { + if (!other.functions_.isEmpty()) { + if (functionsBuilder_.isEmpty()) { + functionsBuilder_.dispose(); + functionsBuilder_ = null; + functions_ = other.functions_; + bitField0_ = (bitField0_ & ~0x00000100); + functionsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getFunctionsFieldBuilder() : null; + } else { + functionsBuilder_.addAllMessages(other.functions_); + } + } + } + if (metadataPropsBuilder_ == null) { + if (!other.metadataProps_.isEmpty()) { + if (metadataProps_.isEmpty()) { + metadataProps_ = other.metadataProps_; + bitField0_ = (bitField0_ & ~0x00000200); + } else { + ensureMetadataPropsIsMutable(); + metadataProps_.addAll(other.metadataProps_); + } + onChanged(); + } + } else { + if (!other.metadataProps_.isEmpty()) { + if (metadataPropsBuilder_.isEmpty()) { + metadataPropsBuilder_.dispose(); + metadataPropsBuilder_ = null; + metadataProps_ = other.metadataProps_; + bitField0_ = (bitField0_ & ~0x00000200); + metadataPropsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getMetadataPropsFieldBuilder() : null; + } else { + metadataPropsBuilder_.addAllMessages(other.metadataProps_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.ModelProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.ModelProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long irVersion_ ; + /** + *
+       * The version of the IR this model targets. See Version enum above.
+       * This field MUST be present.
+       * 
+ * + * int64 ir_version = 1; + */ + public long getIrVersion() { + return irVersion_; + } + /** + *
+       * The version of the IR this model targets. See Version enum above.
+       * This field MUST be present.
+       * 
+ * + * int64 ir_version = 1; + */ + public Builder setIrVersion(long value) { + + irVersion_ = value; + onChanged(); + return this; + } + /** + *
+       * The version of the IR this model targets. See Version enum above.
+       * This field MUST be present.
+       * 
+ * + * int64 ir_version = 1; + */ + public Builder clearIrVersion() { + + irVersion_ = 0L; + onChanged(); + return this; + } + + private java.util.List opsetImport_ = + java.util.Collections.emptyList(); + private void ensureOpsetImportIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + opsetImport_ = new java.util.ArrayList(opsetImport_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.OperatorSetIdProto, OnnxMl.OperatorSetIdProto.Builder, OnnxMl.OperatorSetIdProtoOrBuilder> opsetImportBuilder_; + + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public java.util.List getOpsetImportList() { + if (opsetImportBuilder_ == null) { + return java.util.Collections.unmodifiableList(opsetImport_); + } else { + return opsetImportBuilder_.getMessageList(); + } + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public int getOpsetImportCount() { + if (opsetImportBuilder_ == null) { + return opsetImport_.size(); + } else { + return opsetImportBuilder_.getCount(); + } + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public OnnxMl.OperatorSetIdProto getOpsetImport(int index) { + if (opsetImportBuilder_ == null) { + return opsetImport_.get(index); + } else { + return opsetImportBuilder_.getMessage(index); + } + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public Builder setOpsetImport( + int index, OnnxMl.OperatorSetIdProto value) { + if (opsetImportBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOpsetImportIsMutable(); + opsetImport_.set(index, value); + onChanged(); + } else { + opsetImportBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public Builder setOpsetImport( + int index, OnnxMl.OperatorSetIdProto.Builder builderForValue) { + if (opsetImportBuilder_ == null) { + ensureOpsetImportIsMutable(); + opsetImport_.set(index, builderForValue.build()); + onChanged(); + } else { + opsetImportBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public Builder addOpsetImport(OnnxMl.OperatorSetIdProto value) { + if (opsetImportBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOpsetImportIsMutable(); + opsetImport_.add(value); + onChanged(); + } else { + opsetImportBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public Builder addOpsetImport( + int index, OnnxMl.OperatorSetIdProto value) { + if (opsetImportBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOpsetImportIsMutable(); + opsetImport_.add(index, value); + onChanged(); + } else { + opsetImportBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public Builder addOpsetImport( + OnnxMl.OperatorSetIdProto.Builder builderForValue) { + if (opsetImportBuilder_ == null) { + ensureOpsetImportIsMutable(); + opsetImport_.add(builderForValue.build()); + onChanged(); + } else { + opsetImportBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public Builder addOpsetImport( + int index, OnnxMl.OperatorSetIdProto.Builder builderForValue) { + if (opsetImportBuilder_ == null) { + ensureOpsetImportIsMutable(); + opsetImport_.add(index, builderForValue.build()); + onChanged(); + } else { + opsetImportBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public Builder addAllOpsetImport( + java.lang.Iterable values) { + if (opsetImportBuilder_ == null) { + ensureOpsetImportIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, opsetImport_); + onChanged(); + } else { + opsetImportBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public Builder clearOpsetImport() { + if (opsetImportBuilder_ == null) { + opsetImport_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + opsetImportBuilder_.clear(); + } + return this; + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public Builder removeOpsetImport(int index) { + if (opsetImportBuilder_ == null) { + ensureOpsetImportIsMutable(); + opsetImport_.remove(index); + onChanged(); + } else { + opsetImportBuilder_.remove(index); + } + return this; + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public OnnxMl.OperatorSetIdProto.Builder getOpsetImportBuilder( + int index) { + return getOpsetImportFieldBuilder().getBuilder(index); + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public OnnxMl.OperatorSetIdProtoOrBuilder getOpsetImportOrBuilder( + int index) { + if (opsetImportBuilder_ == null) { + return opsetImport_.get(index); } else { + return opsetImportBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public java.util.List + getOpsetImportOrBuilderList() { + if (opsetImportBuilder_ != null) { + return opsetImportBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(opsetImport_); + } + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public OnnxMl.OperatorSetIdProto.Builder addOpsetImportBuilder() { + return getOpsetImportFieldBuilder().addBuilder( + OnnxMl.OperatorSetIdProto.getDefaultInstance()); + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public OnnxMl.OperatorSetIdProto.Builder addOpsetImportBuilder( + int index) { + return getOpsetImportFieldBuilder().addBuilder( + index, OnnxMl.OperatorSetIdProto.getDefaultInstance()); + } + /** + *
+       * The OperatorSets this model relies on.
+       * All ModelProtos MUST have at least one entry that
+       * specifies which version of the ONNX OperatorSet is
+       * being imported.
+       * All nodes in the ModelProto's graph will bind against the operator
+       * with the same-domain/same-op_type operator with the HIGHEST version
+       * in the referenced operator sets.
+       * 
+ * + * repeated .onnx.OperatorSetIdProto opset_import = 8; + */ + public java.util.List + getOpsetImportBuilderList() { + return getOpsetImportFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.OperatorSetIdProto, OnnxMl.OperatorSetIdProto.Builder, OnnxMl.OperatorSetIdProtoOrBuilder> + getOpsetImportFieldBuilder() { + if (opsetImportBuilder_ == null) { + opsetImportBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.OperatorSetIdProto, OnnxMl.OperatorSetIdProto.Builder, OnnxMl.OperatorSetIdProtoOrBuilder>( + opsetImport_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + opsetImport_ = null; + } + return opsetImportBuilder_; + } + + private java.lang.Object producerName_ = ""; + /** + *
+       * The name of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_name = 2; + */ + public java.lang.String getProducerName() { + java.lang.Object ref = producerName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + producerName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * The name of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_name = 2; + */ + public com.google.protobuf.ByteString + getProducerNameBytes() { + java.lang.Object ref = producerName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + producerName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * The name of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_name = 2; + */ + public Builder setProducerName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + producerName_ = value; + onChanged(); + return this; + } + /** + *
+       * The name of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_name = 2; + */ + public Builder clearProducerName() { + + producerName_ = getDefaultInstance().getProducerName(); + onChanged(); + return this; + } + /** + *
+       * The name of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_name = 2; + */ + public Builder setProducerNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + producerName_ = value; + onChanged(); + return this; + } + + private java.lang.Object producerVersion_ = ""; + /** + *
+       * The version of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_version = 3; + */ + public java.lang.String getProducerVersion() { + java.lang.Object ref = producerVersion_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + producerVersion_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * The version of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_version = 3; + */ + public com.google.protobuf.ByteString + getProducerVersionBytes() { + java.lang.Object ref = producerVersion_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + producerVersion_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * The version of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_version = 3; + */ + public Builder setProducerVersion( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + producerVersion_ = value; + onChanged(); + return this; + } + /** + *
+       * The version of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_version = 3; + */ + public Builder clearProducerVersion() { + + producerVersion_ = getDefaultInstance().getProducerVersion(); + onChanged(); + return this; + } + /** + *
+       * The version of the framework or tool used to generate this model.
+       * This field SHOULD be present to indicate which implementation/tool/framework
+       * emitted the model.
+       * 
+ * + * string producer_version = 3; + */ + public Builder setProducerVersionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + producerVersion_ = value; + onChanged(); + return this; + } + + private java.lang.Object domain_ = ""; + /** + *
+       * Domain name of the model.
+       * We use reverse domain names as name space indicators. For example:
+       * `com.facebook.fair` or `com.microsoft.cognitiveservices`
+       * Together with `model_version` and GraphProto.name, this forms the unique identity of
+       * the graph.
+       * 
+ * + * string domain = 4; + */ + public java.lang.String getDomain() { + java.lang.Object ref = domain_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + domain_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * Domain name of the model.
+       * We use reverse domain names as name space indicators. For example:
+       * `com.facebook.fair` or `com.microsoft.cognitiveservices`
+       * Together with `model_version` and GraphProto.name, this forms the unique identity of
+       * the graph.
+       * 
+ * + * string domain = 4; + */ + public com.google.protobuf.ByteString + getDomainBytes() { + java.lang.Object ref = domain_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + domain_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * Domain name of the model.
+       * We use reverse domain names as name space indicators. For example:
+       * `com.facebook.fair` or `com.microsoft.cognitiveservices`
+       * Together with `model_version` and GraphProto.name, this forms the unique identity of
+       * the graph.
+       * 
+ * + * string domain = 4; + */ + public Builder setDomain( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + domain_ = value; + onChanged(); + return this; + } + /** + *
+       * Domain name of the model.
+       * We use reverse domain names as name space indicators. For example:
+       * `com.facebook.fair` or `com.microsoft.cognitiveservices`
+       * Together with `model_version` and GraphProto.name, this forms the unique identity of
+       * the graph.
+       * 
+ * + * string domain = 4; + */ + public Builder clearDomain() { + + domain_ = getDefaultInstance().getDomain(); + onChanged(); + return this; + } + /** + *
+       * Domain name of the model.
+       * We use reverse domain names as name space indicators. For example:
+       * `com.facebook.fair` or `com.microsoft.cognitiveservices`
+       * Together with `model_version` and GraphProto.name, this forms the unique identity of
+       * the graph.
+       * 
+ * + * string domain = 4; + */ + public Builder setDomainBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + domain_ = value; + onChanged(); + return this; + } + + private long modelVersion_ ; + /** + *
+       * The version of the graph encoded. See Version enum below.
+       * 
+ * + * int64 model_version = 5; + */ + public long getModelVersion() { + return modelVersion_; + } + /** + *
+       * The version of the graph encoded. See Version enum below.
+       * 
+ * + * int64 model_version = 5; + */ + public Builder setModelVersion(long value) { + + modelVersion_ = value; + onChanged(); + return this; + } + /** + *
+       * The version of the graph encoded. See Version enum below.
+       * 
+ * + * int64 model_version = 5; + */ + public Builder clearModelVersion() { + + modelVersion_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object docString_ = ""; + /** + *
+       * A human-readable documentation for this model. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * A human-readable documentation for this model. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * A human-readable documentation for this model. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public Builder setDocString( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + docString_ = value; + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this model. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public Builder clearDocString() { + + docString_ = getDefaultInstance().getDocString(); + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this model. Markdown is allowed.
+       * 
+ * + * string doc_string = 6; + */ + public Builder setDocStringBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + docString_ = value; + onChanged(); + return this; + } + + private OnnxMl.GraphProto graph_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.GraphProto, OnnxMl.GraphProto.Builder, OnnxMl.GraphProtoOrBuilder> graphBuilder_; + /** + *
+       * The parameterized graph that is evaluated to execute the model.
+       * 
+ * + * .onnx.GraphProto graph = 7; + */ + public boolean hasGraph() { + return graphBuilder_ != null || graph_ != null; + } + /** + *
+       * The parameterized graph that is evaluated to execute the model.
+       * 
+ * + * .onnx.GraphProto graph = 7; + */ + public OnnxMl.GraphProto getGraph() { + if (graphBuilder_ == null) { + return graph_ == null ? OnnxMl.GraphProto.getDefaultInstance() : graph_; + } else { + return graphBuilder_.getMessage(); + } + } + /** + *
+       * The parameterized graph that is evaluated to execute the model.
+       * 
+ * + * .onnx.GraphProto graph = 7; + */ + public Builder setGraph(OnnxMl.GraphProto value) { + if (graphBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + graph_ = value; + onChanged(); + } else { + graphBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       * The parameterized graph that is evaluated to execute the model.
+       * 
+ * + * .onnx.GraphProto graph = 7; + */ + public Builder setGraph( + OnnxMl.GraphProto.Builder builderForValue) { + if (graphBuilder_ == null) { + graph_ = builderForValue.build(); + onChanged(); + } else { + graphBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       * The parameterized graph that is evaluated to execute the model.
+       * 
+ * + * .onnx.GraphProto graph = 7; + */ + public Builder mergeGraph(OnnxMl.GraphProto value) { + if (graphBuilder_ == null) { + if (graph_ != null) { + graph_ = + OnnxMl.GraphProto.newBuilder(graph_).mergeFrom(value).buildPartial(); + } else { + graph_ = value; + } + onChanged(); + } else { + graphBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       * The parameterized graph that is evaluated to execute the model.
+       * 
+ * + * .onnx.GraphProto graph = 7; + */ + public Builder clearGraph() { + if (graphBuilder_ == null) { + graph_ = null; + onChanged(); + } else { + graph_ = null; + graphBuilder_ = null; + } + + return this; + } + /** + *
+       * The parameterized graph that is evaluated to execute the model.
+       * 
+ * + * .onnx.GraphProto graph = 7; + */ + public OnnxMl.GraphProto.Builder getGraphBuilder() { + + onChanged(); + return getGraphFieldBuilder().getBuilder(); + } + /** + *
+       * The parameterized graph that is evaluated to execute the model.
+       * 
+ * + * .onnx.GraphProto graph = 7; + */ + public OnnxMl.GraphProtoOrBuilder getGraphOrBuilder() { + if (graphBuilder_ != null) { + return graphBuilder_.getMessageOrBuilder(); + } else { + return graph_ == null ? + OnnxMl.GraphProto.getDefaultInstance() : graph_; + } + } + /** + *
+       * The parameterized graph that is evaluated to execute the model.
+       * 
+ * + * .onnx.GraphProto graph = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.GraphProto, OnnxMl.GraphProto.Builder, OnnxMl.GraphProtoOrBuilder> + getGraphFieldBuilder() { + if (graphBuilder_ == null) { + graphBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.GraphProto, OnnxMl.GraphProto.Builder, OnnxMl.GraphProtoOrBuilder>( + getGraph(), + getParentForChildren(), + isClean()); + graph_ = null; + } + return graphBuilder_; + } + + private java.util.List functions_ = + java.util.Collections.emptyList(); + private void ensureFunctionsIsMutable() { + if (!((bitField0_ & 0x00000100) == 0x00000100)) { + functions_ = new java.util.ArrayList(functions_); + bitField0_ |= 0x00000100; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.FunctionProto, OnnxMl.FunctionProto.Builder, OnnxMl.FunctionProtoOrBuilder> functionsBuilder_; + + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public java.util.List getFunctionsList() { + if (functionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(functions_); + } else { + return functionsBuilder_.getMessageList(); + } + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public int getFunctionsCount() { + if (functionsBuilder_ == null) { + return functions_.size(); + } else { + return functionsBuilder_.getCount(); + } + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public OnnxMl.FunctionProto getFunctions(int index) { + if (functionsBuilder_ == null) { + return functions_.get(index); + } else { + return functionsBuilder_.getMessage(index); + } + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public Builder setFunctions( + int index, OnnxMl.FunctionProto value) { + if (functionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFunctionsIsMutable(); + functions_.set(index, value); + onChanged(); + } else { + functionsBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public Builder setFunctions( + int index, OnnxMl.FunctionProto.Builder builderForValue) { + if (functionsBuilder_ == null) { + ensureFunctionsIsMutable(); + functions_.set(index, builderForValue.build()); + onChanged(); + } else { + functionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public Builder addFunctions(OnnxMl.FunctionProto value) { + if (functionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFunctionsIsMutable(); + functions_.add(value); + onChanged(); + } else { + functionsBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public Builder addFunctions( + int index, OnnxMl.FunctionProto value) { + if (functionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFunctionsIsMutable(); + functions_.add(index, value); + onChanged(); + } else { + functionsBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public Builder addFunctions( + OnnxMl.FunctionProto.Builder builderForValue) { + if (functionsBuilder_ == null) { + ensureFunctionsIsMutable(); + functions_.add(builderForValue.build()); + onChanged(); + } else { + functionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public Builder addFunctions( + int index, OnnxMl.FunctionProto.Builder builderForValue) { + if (functionsBuilder_ == null) { + ensureFunctionsIsMutable(); + functions_.add(index, builderForValue.build()); + onChanged(); + } else { + functionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public Builder addAllFunctions( + java.lang.Iterable values) { + if (functionsBuilder_ == null) { + ensureFunctionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, functions_); + onChanged(); + } else { + functionsBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public Builder clearFunctions() { + if (functionsBuilder_ == null) { + functions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000100); + onChanged(); + } else { + functionsBuilder_.clear(); + } + return this; + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public Builder removeFunctions(int index) { + if (functionsBuilder_ == null) { + ensureFunctionsIsMutable(); + functions_.remove(index); + onChanged(); + } else { + functionsBuilder_.remove(index); + } + return this; + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public OnnxMl.FunctionProto.Builder getFunctionsBuilder( + int index) { + return getFunctionsFieldBuilder().getBuilder(index); + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public OnnxMl.FunctionProtoOrBuilder getFunctionsOrBuilder( + int index) { + if (functionsBuilder_ == null) { + return functions_.get(index); } else { + return functionsBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public java.util.List + getFunctionsOrBuilderList() { + if (functionsBuilder_ != null) { + return functionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(functions_); + } + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public OnnxMl.FunctionProto.Builder addFunctionsBuilder() { + return getFunctionsFieldBuilder().addBuilder( + OnnxMl.FunctionProto.getDefaultInstance()); + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public OnnxMl.FunctionProto.Builder addFunctionsBuilder( + int index) { + return getFunctionsFieldBuilder().addBuilder( + index, OnnxMl.FunctionProto.getDefaultInstance()); + } + /** + *
+       * kezhan: This field is not in ONNX, and will be pushed into ONNX with good use cases in microsoft.
+       * 
+ * + * repeated .onnx.FunctionProto functions = 100; + */ + public java.util.List + getFunctionsBuilderList() { + return getFunctionsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.FunctionProto, OnnxMl.FunctionProto.Builder, OnnxMl.FunctionProtoOrBuilder> + getFunctionsFieldBuilder() { + if (functionsBuilder_ == null) { + functionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.FunctionProto, OnnxMl.FunctionProto.Builder, OnnxMl.FunctionProtoOrBuilder>( + functions_, + ((bitField0_ & 0x00000100) == 0x00000100), + getParentForChildren(), + isClean()); + functions_ = null; + } + return functionsBuilder_; + } + + private java.util.List metadataProps_ = + java.util.Collections.emptyList(); + private void ensureMetadataPropsIsMutable() { + if (!((bitField0_ & 0x00000200) == 0x00000200)) { + metadataProps_ = new java.util.ArrayList(metadataProps_); + bitField0_ |= 0x00000200; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.StringStringEntryProto, OnnxMl.StringStringEntryProto.Builder, OnnxMl.StringStringEntryProtoOrBuilder> metadataPropsBuilder_; + + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public java.util.List getMetadataPropsList() { + if (metadataPropsBuilder_ == null) { + return java.util.Collections.unmodifiableList(metadataProps_); + } else { + return metadataPropsBuilder_.getMessageList(); + } + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public int getMetadataPropsCount() { + if (metadataPropsBuilder_ == null) { + return metadataProps_.size(); + } else { + return metadataPropsBuilder_.getCount(); + } + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public OnnxMl.StringStringEntryProto getMetadataProps(int index) { + if (metadataPropsBuilder_ == null) { + return metadataProps_.get(index); + } else { + return metadataPropsBuilder_.getMessage(index); + } + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public Builder setMetadataProps( + int index, OnnxMl.StringStringEntryProto value) { + if (metadataPropsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMetadataPropsIsMutable(); + metadataProps_.set(index, value); + onChanged(); + } else { + metadataPropsBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public Builder setMetadataProps( + int index, OnnxMl.StringStringEntryProto.Builder builderForValue) { + if (metadataPropsBuilder_ == null) { + ensureMetadataPropsIsMutable(); + metadataProps_.set(index, builderForValue.build()); + onChanged(); + } else { + metadataPropsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public Builder addMetadataProps(OnnxMl.StringStringEntryProto value) { + if (metadataPropsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMetadataPropsIsMutable(); + metadataProps_.add(value); + onChanged(); + } else { + metadataPropsBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public Builder addMetadataProps( + int index, OnnxMl.StringStringEntryProto value) { + if (metadataPropsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMetadataPropsIsMutable(); + metadataProps_.add(index, value); + onChanged(); + } else { + metadataPropsBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public Builder addMetadataProps( + OnnxMl.StringStringEntryProto.Builder builderForValue) { + if (metadataPropsBuilder_ == null) { + ensureMetadataPropsIsMutable(); + metadataProps_.add(builderForValue.build()); + onChanged(); + } else { + metadataPropsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public Builder addMetadataProps( + int index, OnnxMl.StringStringEntryProto.Builder builderForValue) { + if (metadataPropsBuilder_ == null) { + ensureMetadataPropsIsMutable(); + metadataProps_.add(index, builderForValue.build()); + onChanged(); + } else { + metadataPropsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public Builder addAllMetadataProps( + java.lang.Iterable values) { + if (metadataPropsBuilder_ == null) { + ensureMetadataPropsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, metadataProps_); + onChanged(); + } else { + metadataPropsBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public Builder clearMetadataProps() { + if (metadataPropsBuilder_ == null) { + metadataProps_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000200); + onChanged(); + } else { + metadataPropsBuilder_.clear(); + } + return this; + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public Builder removeMetadataProps(int index) { + if (metadataPropsBuilder_ == null) { + ensureMetadataPropsIsMutable(); + metadataProps_.remove(index); + onChanged(); + } else { + metadataPropsBuilder_.remove(index); + } + return this; + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public OnnxMl.StringStringEntryProto.Builder getMetadataPropsBuilder( + int index) { + return getMetadataPropsFieldBuilder().getBuilder(index); + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public OnnxMl.StringStringEntryProtoOrBuilder getMetadataPropsOrBuilder( + int index) { + if (metadataPropsBuilder_ == null) { + return metadataProps_.get(index); } else { + return metadataPropsBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public java.util.List + getMetadataPropsOrBuilderList() { + if (metadataPropsBuilder_ != null) { + return metadataPropsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(metadataProps_); + } + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public OnnxMl.StringStringEntryProto.Builder addMetadataPropsBuilder() { + return getMetadataPropsFieldBuilder().addBuilder( + OnnxMl.StringStringEntryProto.getDefaultInstance()); + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public OnnxMl.StringStringEntryProto.Builder addMetadataPropsBuilder( + int index) { + return getMetadataPropsFieldBuilder().addBuilder( + index, OnnxMl.StringStringEntryProto.getDefaultInstance()); + } + /** + *
+       * Named metadata values; keys should be distinct.
+       * 
+ * + * repeated .onnx.StringStringEntryProto metadata_props = 14; + */ + public java.util.List + getMetadataPropsBuilderList() { + return getMetadataPropsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.StringStringEntryProto, OnnxMl.StringStringEntryProto.Builder, OnnxMl.StringStringEntryProtoOrBuilder> + getMetadataPropsFieldBuilder() { + if (metadataPropsBuilder_ == null) { + metadataPropsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.StringStringEntryProto, OnnxMl.StringStringEntryProto.Builder, OnnxMl.StringStringEntryProtoOrBuilder>( + metadataProps_, + ((bitField0_ & 0x00000200) == 0x00000200), + getParentForChildren(), + isClean()); + metadataProps_ = null; + } + return metadataPropsBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.ModelProto) + } + + // @@protoc_insertion_point(class_scope:onnx.ModelProto) + private static final OnnxMl.ModelProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.ModelProto(); + } + + public static OnnxMl.ModelProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ModelProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ModelProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.ModelProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface StringStringEntryProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.StringStringEntryProto) + com.google.protobuf.MessageOrBuilder { + + /** + * string key = 1; + */ + java.lang.String getKey(); + /** + * string key = 1; + */ + com.google.protobuf.ByteString + getKeyBytes(); + + /** + * string value = 2; + */ + java.lang.String getValue(); + /** + * string value = 2; + */ + com.google.protobuf.ByteString + getValueBytes(); + } + /** + *
+   * StringStringEntryProto follows the pattern for cross-proto-version maps.
+   * See https://developers.google.com/protocol-buffers/docs/proto3#maps
+   * 
+ * + * Protobuf type {@code onnx.StringStringEntryProto} + */ + public static final class StringStringEntryProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.StringStringEntryProto) + StringStringEntryProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use StringStringEntryProto.newBuilder() to construct. + private StringStringEntryProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private StringStringEntryProto() { + key_ = ""; + value_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private StringStringEntryProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + key_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + value_ = s; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_StringStringEntryProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_StringStringEntryProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.StringStringEntryProto.class, OnnxMl.StringStringEntryProto.Builder.class); + } + + public static final int KEY_FIELD_NUMBER = 1; + private volatile java.lang.Object key_; + /** + * string key = 1; + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + key_ = s; + return s; + } + } + /** + * string key = 1; + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VALUE_FIELD_NUMBER = 2; + private volatile java.lang.Object value_; + /** + * string value = 2; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + value_ = s; + return s; + } + } + /** + * string value = 2; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getKeyBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, key_); + } + if (!getValueBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, value_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getKeyBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, key_); + } + if (!getValueBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, value_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.StringStringEntryProto)) { + return super.equals(obj); + } + OnnxMl.StringStringEntryProto other = (OnnxMl.StringStringEntryProto) obj; + + boolean result = true; + result = result && getKey() + .equals(other.getKey()); + result = result && getValue() + .equals(other.getValue()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + KEY_FIELD_NUMBER; + hash = (53 * hash) + getKey().hashCode(); + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + getValue().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.StringStringEntryProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.StringStringEntryProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.StringStringEntryProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.StringStringEntryProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.StringStringEntryProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.StringStringEntryProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.StringStringEntryProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.StringStringEntryProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.StringStringEntryProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.StringStringEntryProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.StringStringEntryProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.StringStringEntryProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.StringStringEntryProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * StringStringEntryProto follows the pattern for cross-proto-version maps.
+     * See https://developers.google.com/protocol-buffers/docs/proto3#maps
+     * 
+ * + * Protobuf type {@code onnx.StringStringEntryProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.StringStringEntryProto) + OnnxMl.StringStringEntryProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_StringStringEntryProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_StringStringEntryProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.StringStringEntryProto.class, OnnxMl.StringStringEntryProto.Builder.class); + } + + // Construct using OnnxMlProto3.StringStringEntryProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + key_ = ""; + + value_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_StringStringEntryProto_descriptor; + } + + @java.lang.Override + public OnnxMl.StringStringEntryProto getDefaultInstanceForType() { + return OnnxMl.StringStringEntryProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.StringStringEntryProto build() { + OnnxMl.StringStringEntryProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.StringStringEntryProto buildPartial() { + OnnxMl.StringStringEntryProto result = new OnnxMl.StringStringEntryProto(this); + result.key_ = key_; + result.value_ = value_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.StringStringEntryProto) { + return mergeFrom((OnnxMl.StringStringEntryProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.StringStringEntryProto other) { + if (other == OnnxMl.StringStringEntryProto.getDefaultInstance()) return this; + if (!other.getKey().isEmpty()) { + key_ = other.key_; + onChanged(); + } + if (!other.getValue().isEmpty()) { + value_ = other.value_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.StringStringEntryProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.StringStringEntryProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object key_ = ""; + /** + * string key = 1; + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + key_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string key = 1; + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string key = 1; + */ + public Builder setKey( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + key_ = value; + onChanged(); + return this; + } + /** + * string key = 1; + */ + public Builder clearKey() { + + key_ = getDefaultInstance().getKey(); + onChanged(); + return this; + } + /** + * string key = 1; + */ + public Builder setKeyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + key_ = value; + onChanged(); + return this; + } + + private java.lang.Object value_ = ""; + /** + * string value = 2; + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + value_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string value = 2; + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string value = 2; + */ + public Builder setValue( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + value_ = value; + onChanged(); + return this; + } + /** + * string value = 2; + */ + public Builder clearValue() { + + value_ = getDefaultInstance().getValue(); + onChanged(); + return this; + } + /** + * string value = 2; + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + value_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.StringStringEntryProto) + } + + // @@protoc_insertion_point(class_scope:onnx.StringStringEntryProto) + private static final OnnxMl.StringStringEntryProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.StringStringEntryProto(); + } + + public static OnnxMl.StringStringEntryProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StringStringEntryProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new StringStringEntryProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.StringStringEntryProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TensorAnnotationOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TensorAnnotation) + com.google.protobuf.MessageOrBuilder { + + /** + * string tensor_name = 1; + */ + java.lang.String getTensorName(); + /** + * string tensor_name = 1; + */ + com.google.protobuf.ByteString + getTensorNameBytes(); + + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + java.util.List + getQuantParameterTensorNamesList(); + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + OnnxMl.StringStringEntryProto getQuantParameterTensorNames(int index); + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + int getQuantParameterTensorNamesCount(); + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + java.util.List + getQuantParameterTensorNamesOrBuilderList(); + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + OnnxMl.StringStringEntryProtoOrBuilder getQuantParameterTensorNamesOrBuilder( + int index); + } + /** + * Protobuf type {@code onnx.TensorAnnotation} + */ + public static final class TensorAnnotation extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TensorAnnotation) + TensorAnnotationOrBuilder { + private static final long serialVersionUID = 0L; + // Use TensorAnnotation.newBuilder() to construct. + private TensorAnnotation(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TensorAnnotation() { + tensorName_ = ""; + quantParameterTensorNames_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TensorAnnotation( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + tensorName_ = s; + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + quantParameterTensorNames_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + quantParameterTensorNames_.add( + input.readMessage(OnnxMl.StringStringEntryProto.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + quantParameterTensorNames_ = java.util.Collections.unmodifiableList(quantParameterTensorNames_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorAnnotation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorAnnotation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorAnnotation.class, OnnxMl.TensorAnnotation.Builder.class); + } + + private int bitField0_; + public static final int TENSOR_NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object tensorName_; + /** + * string tensor_name = 1; + */ + public java.lang.String getTensorName() { + java.lang.Object ref = tensorName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + tensorName_ = s; + return s; + } + } + /** + * string tensor_name = 1; + */ + public com.google.protobuf.ByteString + getTensorNameBytes() { + java.lang.Object ref = tensorName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tensorName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int QUANT_PARAMETER_TENSOR_NAMES_FIELD_NUMBER = 2; + private java.util.List quantParameterTensorNames_; + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public java.util.List getQuantParameterTensorNamesList() { + return quantParameterTensorNames_; + } + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public java.util.List + getQuantParameterTensorNamesOrBuilderList() { + return quantParameterTensorNames_; + } + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public int getQuantParameterTensorNamesCount() { + return quantParameterTensorNames_.size(); + } + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public OnnxMl.StringStringEntryProto getQuantParameterTensorNames(int index) { + return quantParameterTensorNames_.get(index); + } + /** + *
+     * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+     * The keys used in the mapping below must be pre-defined in ONNX spec.
+     * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+     * quantization parameter keys.
+     * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public OnnxMl.StringStringEntryProtoOrBuilder getQuantParameterTensorNamesOrBuilder( + int index) { + return quantParameterTensorNames_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTensorNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tensorName_); + } + for (int i = 0; i < quantParameterTensorNames_.size(); i++) { + output.writeMessage(2, quantParameterTensorNames_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTensorNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tensorName_); + } + for (int i = 0; i < quantParameterTensorNames_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, quantParameterTensorNames_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TensorAnnotation)) { + return super.equals(obj); + } + OnnxMl.TensorAnnotation other = (OnnxMl.TensorAnnotation) obj; + + boolean result = true; + result = result && getTensorName() + .equals(other.getTensorName()); + result = result && getQuantParameterTensorNamesList() + .equals(other.getQuantParameterTensorNamesList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TENSOR_NAME_FIELD_NUMBER; + hash = (53 * hash) + getTensorName().hashCode(); + if (getQuantParameterTensorNamesCount() > 0) { + hash = (37 * hash) + QUANT_PARAMETER_TENSOR_NAMES_FIELD_NUMBER; + hash = (53 * hash) + getQuantParameterTensorNamesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TensorAnnotation parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorAnnotation parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorAnnotation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorAnnotation parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorAnnotation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorAnnotation parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorAnnotation parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorAnnotation parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorAnnotation parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TensorAnnotation parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorAnnotation parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorAnnotation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TensorAnnotation prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code onnx.TensorAnnotation} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TensorAnnotation) + OnnxMl.TensorAnnotationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorAnnotation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorAnnotation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorAnnotation.class, OnnxMl.TensorAnnotation.Builder.class); + } + + // Construct using OnnxMlProto3.TensorAnnotation.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getQuantParameterTensorNamesFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + tensorName_ = ""; + + if (quantParameterTensorNamesBuilder_ == null) { + quantParameterTensorNames_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + quantParameterTensorNamesBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TensorAnnotation_descriptor; + } + + @java.lang.Override + public OnnxMl.TensorAnnotation getDefaultInstanceForType() { + return OnnxMl.TensorAnnotation.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TensorAnnotation build() { + OnnxMl.TensorAnnotation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TensorAnnotation buildPartial() { + OnnxMl.TensorAnnotation result = new OnnxMl.TensorAnnotation(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.tensorName_ = tensorName_; + if (quantParameterTensorNamesBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + quantParameterTensorNames_ = java.util.Collections.unmodifiableList(quantParameterTensorNames_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.quantParameterTensorNames_ = quantParameterTensorNames_; + } else { + result.quantParameterTensorNames_ = quantParameterTensorNamesBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TensorAnnotation) { + return mergeFrom((OnnxMl.TensorAnnotation)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TensorAnnotation other) { + if (other == OnnxMl.TensorAnnotation.getDefaultInstance()) return this; + if (!other.getTensorName().isEmpty()) { + tensorName_ = other.tensorName_; + onChanged(); + } + if (quantParameterTensorNamesBuilder_ == null) { + if (!other.quantParameterTensorNames_.isEmpty()) { + if (quantParameterTensorNames_.isEmpty()) { + quantParameterTensorNames_ = other.quantParameterTensorNames_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureQuantParameterTensorNamesIsMutable(); + quantParameterTensorNames_.addAll(other.quantParameterTensorNames_); + } + onChanged(); + } + } else { + if (!other.quantParameterTensorNames_.isEmpty()) { + if (quantParameterTensorNamesBuilder_.isEmpty()) { + quantParameterTensorNamesBuilder_.dispose(); + quantParameterTensorNamesBuilder_ = null; + quantParameterTensorNames_ = other.quantParameterTensorNames_; + bitField0_ = (bitField0_ & ~0x00000002); + quantParameterTensorNamesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getQuantParameterTensorNamesFieldBuilder() : null; + } else { + quantParameterTensorNamesBuilder_.addAllMessages(other.quantParameterTensorNames_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TensorAnnotation parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TensorAnnotation) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object tensorName_ = ""; + /** + * string tensor_name = 1; + */ + public java.lang.String getTensorName() { + java.lang.Object ref = tensorName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + tensorName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string tensor_name = 1; + */ + public com.google.protobuf.ByteString + getTensorNameBytes() { + java.lang.Object ref = tensorName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + tensorName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string tensor_name = 1; + */ + public Builder setTensorName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + tensorName_ = value; + onChanged(); + return this; + } + /** + * string tensor_name = 1; + */ + public Builder clearTensorName() { + + tensorName_ = getDefaultInstance().getTensorName(); + onChanged(); + return this; + } + /** + * string tensor_name = 1; + */ + public Builder setTensorNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + tensorName_ = value; + onChanged(); + return this; + } + + private java.util.List quantParameterTensorNames_ = + java.util.Collections.emptyList(); + private void ensureQuantParameterTensorNamesIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + quantParameterTensorNames_ = new java.util.ArrayList(quantParameterTensorNames_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.StringStringEntryProto, OnnxMl.StringStringEntryProto.Builder, OnnxMl.StringStringEntryProtoOrBuilder> quantParameterTensorNamesBuilder_; + + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public java.util.List getQuantParameterTensorNamesList() { + if (quantParameterTensorNamesBuilder_ == null) { + return java.util.Collections.unmodifiableList(quantParameterTensorNames_); + } else { + return quantParameterTensorNamesBuilder_.getMessageList(); + } + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public int getQuantParameterTensorNamesCount() { + if (quantParameterTensorNamesBuilder_ == null) { + return quantParameterTensorNames_.size(); + } else { + return quantParameterTensorNamesBuilder_.getCount(); + } + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public OnnxMl.StringStringEntryProto getQuantParameterTensorNames(int index) { + if (quantParameterTensorNamesBuilder_ == null) { + return quantParameterTensorNames_.get(index); + } else { + return quantParameterTensorNamesBuilder_.getMessage(index); + } + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public Builder setQuantParameterTensorNames( + int index, OnnxMl.StringStringEntryProto value) { + if (quantParameterTensorNamesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuantParameterTensorNamesIsMutable(); + quantParameterTensorNames_.set(index, value); + onChanged(); + } else { + quantParameterTensorNamesBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public Builder setQuantParameterTensorNames( + int index, OnnxMl.StringStringEntryProto.Builder builderForValue) { + if (quantParameterTensorNamesBuilder_ == null) { + ensureQuantParameterTensorNamesIsMutable(); + quantParameterTensorNames_.set(index, builderForValue.build()); + onChanged(); + } else { + quantParameterTensorNamesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public Builder addQuantParameterTensorNames(OnnxMl.StringStringEntryProto value) { + if (quantParameterTensorNamesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuantParameterTensorNamesIsMutable(); + quantParameterTensorNames_.add(value); + onChanged(); + } else { + quantParameterTensorNamesBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public Builder addQuantParameterTensorNames( + int index, OnnxMl.StringStringEntryProto value) { + if (quantParameterTensorNamesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuantParameterTensorNamesIsMutable(); + quantParameterTensorNames_.add(index, value); + onChanged(); + } else { + quantParameterTensorNamesBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public Builder addQuantParameterTensorNames( + OnnxMl.StringStringEntryProto.Builder builderForValue) { + if (quantParameterTensorNamesBuilder_ == null) { + ensureQuantParameterTensorNamesIsMutable(); + quantParameterTensorNames_.add(builderForValue.build()); + onChanged(); + } else { + quantParameterTensorNamesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public Builder addQuantParameterTensorNames( + int index, OnnxMl.StringStringEntryProto.Builder builderForValue) { + if (quantParameterTensorNamesBuilder_ == null) { + ensureQuantParameterTensorNamesIsMutable(); + quantParameterTensorNames_.add(index, builderForValue.build()); + onChanged(); + } else { + quantParameterTensorNamesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public Builder addAllQuantParameterTensorNames( + java.lang.Iterable values) { + if (quantParameterTensorNamesBuilder_ == null) { + ensureQuantParameterTensorNamesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, quantParameterTensorNames_); + onChanged(); + } else { + quantParameterTensorNamesBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public Builder clearQuantParameterTensorNames() { + if (quantParameterTensorNamesBuilder_ == null) { + quantParameterTensorNames_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + quantParameterTensorNamesBuilder_.clear(); + } + return this; + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public Builder removeQuantParameterTensorNames(int index) { + if (quantParameterTensorNamesBuilder_ == null) { + ensureQuantParameterTensorNamesIsMutable(); + quantParameterTensorNames_.remove(index); + onChanged(); + } else { + quantParameterTensorNamesBuilder_.remove(index); + } + return this; + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public OnnxMl.StringStringEntryProto.Builder getQuantParameterTensorNamesBuilder( + int index) { + return getQuantParameterTensorNamesFieldBuilder().getBuilder(index); + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public OnnxMl.StringStringEntryProtoOrBuilder getQuantParameterTensorNamesOrBuilder( + int index) { + if (quantParameterTensorNamesBuilder_ == null) { + return quantParameterTensorNames_.get(index); } else { + return quantParameterTensorNamesBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public java.util.List + getQuantParameterTensorNamesOrBuilderList() { + if (quantParameterTensorNamesBuilder_ != null) { + return quantParameterTensorNamesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(quantParameterTensorNames_); + } + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public OnnxMl.StringStringEntryProto.Builder addQuantParameterTensorNamesBuilder() { + return getQuantParameterTensorNamesFieldBuilder().addBuilder( + OnnxMl.StringStringEntryProto.getDefaultInstance()); + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public OnnxMl.StringStringEntryProto.Builder addQuantParameterTensorNamesBuilder( + int index) { + return getQuantParameterTensorNamesFieldBuilder().addBuilder( + index, OnnxMl.StringStringEntryProto.getDefaultInstance()); + } + /** + *
+       * <key, value> pairs to annotate tensor specified by <tensor_name> above.
+       * The keys used in the mapping below must be pre-defined in ONNX spec.
+       * For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
+       * quantization parameter keys.
+       * 
+ * + * repeated .onnx.StringStringEntryProto quant_parameter_tensor_names = 2; + */ + public java.util.List + getQuantParameterTensorNamesBuilderList() { + return getQuantParameterTensorNamesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.StringStringEntryProto, OnnxMl.StringStringEntryProto.Builder, OnnxMl.StringStringEntryProtoOrBuilder> + getQuantParameterTensorNamesFieldBuilder() { + if (quantParameterTensorNamesBuilder_ == null) { + quantParameterTensorNamesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.StringStringEntryProto, OnnxMl.StringStringEntryProto.Builder, OnnxMl.StringStringEntryProtoOrBuilder>( + quantParameterTensorNames_, + ((bitField0_ & 0x00000002) == 0x00000002), + getParentForChildren(), + isClean()); + quantParameterTensorNames_ = null; + } + return quantParameterTensorNamesBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TensorAnnotation) + } + + // @@protoc_insertion_point(class_scope:onnx.TensorAnnotation) + private static final OnnxMl.TensorAnnotation DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TensorAnnotation(); + } + + public static OnnxMl.TensorAnnotation getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TensorAnnotation parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TensorAnnotation(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TensorAnnotation getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface GraphProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.GraphProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + java.util.List + getNodeList(); + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + OnnxMl.NodeProto getNode(int index); + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + int getNodeCount(); + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + java.util.List + getNodeOrBuilderList(); + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + OnnxMl.NodeProtoOrBuilder getNodeOrBuilder( + int index); + + /** + *
+     * The name of the graph.
+     * 
+ * + * string name = 2; + */ + java.lang.String getName(); + /** + *
+     * The name of the graph.
+     * 
+ * + * string name = 2; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + java.util.List + getInitializerList(); + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + OnnxMl.TensorProto getInitializer(int index); + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + int getInitializerCount(); + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + java.util.List + getInitializerOrBuilderList(); + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + OnnxMl.TensorProtoOrBuilder getInitializerOrBuilder( + int index); + + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + java.util.List + getSparseInitializerList(); + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + OnnxMl.SparseTensorProto getSparseInitializer(int index); + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + int getSparseInitializerCount(); + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + java.util.List + getSparseInitializerOrBuilderList(); + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + OnnxMl.SparseTensorProtoOrBuilder getSparseInitializerOrBuilder( + int index); + + /** + *
+     * A human-readable documentation for this graph. Markdown is allowed.
+     * 
+ * + * string doc_string = 10; + */ + java.lang.String getDocString(); + /** + *
+     * A human-readable documentation for this graph. Markdown is allowed.
+     * 
+ * + * string doc_string = 10; + */ + com.google.protobuf.ByteString + getDocStringBytes(); + + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + java.util.List + getInputList(); + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + OnnxMl.ValueInfoProto getInput(int index); + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + int getInputCount(); + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + java.util.List + getInputOrBuilderList(); + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + OnnxMl.ValueInfoProtoOrBuilder getInputOrBuilder( + int index); + + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + java.util.List + getOutputList(); + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + OnnxMl.ValueInfoProto getOutput(int index); + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + int getOutputCount(); + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + java.util.List + getOutputOrBuilderList(); + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + OnnxMl.ValueInfoProtoOrBuilder getOutputOrBuilder( + int index); + + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + java.util.List + getValueInfoList(); + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + OnnxMl.ValueInfoProto getValueInfo(int index); + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + int getValueInfoCount(); + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + java.util.List + getValueInfoOrBuilderList(); + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + OnnxMl.ValueInfoProtoOrBuilder getValueInfoOrBuilder( + int index); + + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + java.util.List + getQuantizationAnnotationList(); + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + OnnxMl.TensorAnnotation getQuantizationAnnotation(int index); + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + int getQuantizationAnnotationCount(); + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + java.util.List + getQuantizationAnnotationOrBuilderList(); + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + OnnxMl.TensorAnnotationOrBuilder getQuantizationAnnotationOrBuilder( + int index); + } + /** + *
+   * Graphs
+   * A graph defines the computational logic of a model and is comprised of a parameterized 
+   * list of nodes that form a directed acyclic graph based on their inputs and outputs.
+   * This is the equivalent of the "network" or "graph" in many deep learning
+   * frameworks.
+   * 
+ * + * Protobuf type {@code onnx.GraphProto} + */ + public static final class GraphProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.GraphProto) + GraphProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use GraphProto.newBuilder() to construct. + private GraphProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private GraphProto() { + node_ = java.util.Collections.emptyList(); + name_ = ""; + initializer_ = java.util.Collections.emptyList(); + sparseInitializer_ = java.util.Collections.emptyList(); + docString_ = ""; + input_ = java.util.Collections.emptyList(); + output_ = java.util.Collections.emptyList(); + valueInfo_ = java.util.Collections.emptyList(); + quantizationAnnotation_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private GraphProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + node_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + node_.add( + input.readMessage(OnnxMl.NodeProto.parser(), extensionRegistry)); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + initializer_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + initializer_.add( + input.readMessage(OnnxMl.TensorProto.parser(), extensionRegistry)); + break; + } + case 82: { + java.lang.String s = input.readStringRequireUtf8(); + + docString_ = s; + break; + } + case 90: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + input_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + input_.add( + input.readMessage(OnnxMl.ValueInfoProto.parser(), extensionRegistry)); + break; + } + case 98: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + output_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000040; + } + output_.add( + input.readMessage(OnnxMl.ValueInfoProto.parser(), extensionRegistry)); + break; + } + case 106: { + if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + valueInfo_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000080; + } + valueInfo_.add( + input.readMessage(OnnxMl.ValueInfoProto.parser(), extensionRegistry)); + break; + } + case 114: { + if (!((mutable_bitField0_ & 0x00000100) == 0x00000100)) { + quantizationAnnotation_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000100; + } + quantizationAnnotation_.add( + input.readMessage(OnnxMl.TensorAnnotation.parser(), extensionRegistry)); + break; + } + case 122: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + sparseInitializer_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + sparseInitializer_.add( + input.readMessage(OnnxMl.SparseTensorProto.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + node_ = java.util.Collections.unmodifiableList(node_); + } + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + initializer_ = java.util.Collections.unmodifiableList(initializer_); + } + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + input_ = java.util.Collections.unmodifiableList(input_); + } + if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + output_ = java.util.Collections.unmodifiableList(output_); + } + if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + valueInfo_ = java.util.Collections.unmodifiableList(valueInfo_); + } + if (((mutable_bitField0_ & 0x00000100) == 0x00000100)) { + quantizationAnnotation_ = java.util.Collections.unmodifiableList(quantizationAnnotation_); + } + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + sparseInitializer_ = java.util.Collections.unmodifiableList(sparseInitializer_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_GraphProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_GraphProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.GraphProto.class, OnnxMl.GraphProto.Builder.class); + } + + private int bitField0_; + public static final int NODE_FIELD_NUMBER = 1; + private java.util.List node_; + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public java.util.List getNodeList() { + return node_; + } + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public java.util.List + getNodeOrBuilderList() { + return node_; + } + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public int getNodeCount() { + return node_.size(); + } + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public OnnxMl.NodeProto getNode(int index) { + return node_.get(index); + } + /** + *
+     * The nodes in the graph, sorted topologically.
+     * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public OnnxMl.NodeProtoOrBuilder getNodeOrBuilder( + int index) { + return node_.get(index); + } + + public static final int NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object name_; + /** + *
+     * The name of the graph.
+     * 
+ * + * string name = 2; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     * The name of the graph.
+     * 
+ * + * string name = 2; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INITIALIZER_FIELD_NUMBER = 5; + private java.util.List initializer_; + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public java.util.List getInitializerList() { + return initializer_; + } + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public java.util.List + getInitializerOrBuilderList() { + return initializer_; + } + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public int getInitializerCount() { + return initializer_.size(); + } + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public OnnxMl.TensorProto getInitializer(int index) { + return initializer_.get(index); + } + /** + *
+     * A list of named tensor values, used to specify constant inputs of the graph.
+     * Each TensorProto entry must have a distinct name (within the list) that
+     * MAY also appear in the input list.
+     * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public OnnxMl.TensorProtoOrBuilder getInitializerOrBuilder( + int index) { + return initializer_.get(index); + } + + public static final int SPARSE_INITIALIZER_FIELD_NUMBER = 15; + private java.util.List sparseInitializer_; + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public java.util.List getSparseInitializerList() { + return sparseInitializer_; + } + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public java.util.List + getSparseInitializerOrBuilderList() { + return sparseInitializer_; + } + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public int getSparseInitializerCount() { + return sparseInitializer_.size(); + } + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public OnnxMl.SparseTensorProto getSparseInitializer(int index) { + return sparseInitializer_.get(index); + } + /** + *
+     * Initializers (see above) stored in sparse format.
+     * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public OnnxMl.SparseTensorProtoOrBuilder getSparseInitializerOrBuilder( + int index) { + return sparseInitializer_.get(index); + } + + public static final int DOC_STRING_FIELD_NUMBER = 10; + private volatile java.lang.Object docString_; + /** + *
+     * A human-readable documentation for this graph. Markdown is allowed.
+     * 
+ * + * string doc_string = 10; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } + } + /** + *
+     * A human-readable documentation for this graph. Markdown is allowed.
+     * 
+ * + * string doc_string = 10; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INPUT_FIELD_NUMBER = 11; + private java.util.List input_; + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public java.util.List getInputList() { + return input_; + } + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public java.util.List + getInputOrBuilderList() { + return input_; + } + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public int getInputCount() { + return input_.size(); + } + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public OnnxMl.ValueInfoProto getInput(int index) { + return input_.get(index); + } + /** + *
+     * The inputs and outputs of the graph.
+     * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public OnnxMl.ValueInfoProtoOrBuilder getInputOrBuilder( + int index) { + return input_.get(index); + } + + public static final int OUTPUT_FIELD_NUMBER = 12; + private java.util.List output_; + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public java.util.List getOutputList() { + return output_; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public java.util.List + getOutputOrBuilderList() { + return output_; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public int getOutputCount() { + return output_.size(); + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public OnnxMl.ValueInfoProto getOutput(int index) { + return output_.get(index); + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public OnnxMl.ValueInfoProtoOrBuilder getOutputOrBuilder( + int index) { + return output_.get(index); + } + + public static final int VALUE_INFO_FIELD_NUMBER = 13; + private java.util.List valueInfo_; + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public java.util.List getValueInfoList() { + return valueInfo_; + } + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public java.util.List + getValueInfoOrBuilderList() { + return valueInfo_; + } + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public int getValueInfoCount() { + return valueInfo_.size(); + } + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public OnnxMl.ValueInfoProto getValueInfo(int index) { + return valueInfo_.get(index); + } + /** + *
+     * Information for the values in the graph. The ValueInfoProto.name's
+     * must be distinct. It is optional for a value to appear in value_info list.
+     * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public OnnxMl.ValueInfoProtoOrBuilder getValueInfoOrBuilder( + int index) { + return valueInfo_.get(index); + } + + public static final int QUANTIZATION_ANNOTATION_FIELD_NUMBER = 14; + private java.util.List quantizationAnnotation_; + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public java.util.List getQuantizationAnnotationList() { + return quantizationAnnotation_; + } + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public java.util.List + getQuantizationAnnotationOrBuilderList() { + return quantizationAnnotation_; + } + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public int getQuantizationAnnotationCount() { + return quantizationAnnotation_.size(); + } + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public OnnxMl.TensorAnnotation getQuantizationAnnotation(int index) { + return quantizationAnnotation_.get(index); + } + /** + *
+     * This field carries information to indicate the mapping among a tensor and its
+     * quantization parameter tensors. For example:
+     * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+     * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+     * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public OnnxMl.TensorAnnotationOrBuilder getQuantizationAnnotationOrBuilder( + int index) { + return quantizationAnnotation_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < node_.size(); i++) { + output.writeMessage(1, node_.get(i)); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); + } + for (int i = 0; i < initializer_.size(); i++) { + output.writeMessage(5, initializer_.get(i)); + } + if (!getDocStringBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, docString_); + } + for (int i = 0; i < input_.size(); i++) { + output.writeMessage(11, input_.get(i)); + } + for (int i = 0; i < output_.size(); i++) { + output.writeMessage(12, output_.get(i)); + } + for (int i = 0; i < valueInfo_.size(); i++) { + output.writeMessage(13, valueInfo_.get(i)); + } + for (int i = 0; i < quantizationAnnotation_.size(); i++) { + output.writeMessage(14, quantizationAnnotation_.get(i)); + } + for (int i = 0; i < sparseInitializer_.size(); i++) { + output.writeMessage(15, sparseInitializer_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < node_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, node_.get(i)); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); + } + for (int i = 0; i < initializer_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, initializer_.get(i)); + } + if (!getDocStringBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, docString_); + } + for (int i = 0; i < input_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(11, input_.get(i)); + } + for (int i = 0; i < output_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(12, output_.get(i)); + } + for (int i = 0; i < valueInfo_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(13, valueInfo_.get(i)); + } + for (int i = 0; i < quantizationAnnotation_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(14, quantizationAnnotation_.get(i)); + } + for (int i = 0; i < sparseInitializer_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(15, sparseInitializer_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.GraphProto)) { + return super.equals(obj); + } + OnnxMl.GraphProto other = (OnnxMl.GraphProto) obj; + + boolean result = true; + result = result && getNodeList() + .equals(other.getNodeList()); + result = result && getName() + .equals(other.getName()); + result = result && getInitializerList() + .equals(other.getInitializerList()); + result = result && getSparseInitializerList() + .equals(other.getSparseInitializerList()); + result = result && getDocString() + .equals(other.getDocString()); + result = result && getInputList() + .equals(other.getInputList()); + result = result && getOutputList() + .equals(other.getOutputList()); + result = result && getValueInfoList() + .equals(other.getValueInfoList()); + result = result && getQuantizationAnnotationList() + .equals(other.getQuantizationAnnotationList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getNodeCount() > 0) { + hash = (37 * hash) + NODE_FIELD_NUMBER; + hash = (53 * hash) + getNodeList().hashCode(); + } + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getInitializerCount() > 0) { + hash = (37 * hash) + INITIALIZER_FIELD_NUMBER; + hash = (53 * hash) + getInitializerList().hashCode(); + } + if (getSparseInitializerCount() > 0) { + hash = (37 * hash) + SPARSE_INITIALIZER_FIELD_NUMBER; + hash = (53 * hash) + getSparseInitializerList().hashCode(); + } + hash = (37 * hash) + DOC_STRING_FIELD_NUMBER; + hash = (53 * hash) + getDocString().hashCode(); + if (getInputCount() > 0) { + hash = (37 * hash) + INPUT_FIELD_NUMBER; + hash = (53 * hash) + getInputList().hashCode(); + } + if (getOutputCount() > 0) { + hash = (37 * hash) + OUTPUT_FIELD_NUMBER; + hash = (53 * hash) + getOutputList().hashCode(); + } + if (getValueInfoCount() > 0) { + hash = (37 * hash) + VALUE_INFO_FIELD_NUMBER; + hash = (53 * hash) + getValueInfoList().hashCode(); + } + if (getQuantizationAnnotationCount() > 0) { + hash = (37 * hash) + QUANTIZATION_ANNOTATION_FIELD_NUMBER; + hash = (53 * hash) + getQuantizationAnnotationList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.GraphProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.GraphProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.GraphProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.GraphProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.GraphProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.GraphProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.GraphProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.GraphProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.GraphProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.GraphProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.GraphProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.GraphProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.GraphProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Graphs
+     * A graph defines the computational logic of a model and is comprised of a parameterized 
+     * list of nodes that form a directed acyclic graph based on their inputs and outputs.
+     * This is the equivalent of the "network" or "graph" in many deep learning
+     * frameworks.
+     * 
+ * + * Protobuf type {@code onnx.GraphProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.GraphProto) + OnnxMl.GraphProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_GraphProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_GraphProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.GraphProto.class, OnnxMl.GraphProto.Builder.class); + } + + // Construct using OnnxMlProto3.GraphProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getNodeFieldBuilder(); + getInitializerFieldBuilder(); + getSparseInitializerFieldBuilder(); + getInputFieldBuilder(); + getOutputFieldBuilder(); + getValueInfoFieldBuilder(); + getQuantizationAnnotationFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (nodeBuilder_ == null) { + node_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + nodeBuilder_.clear(); + } + name_ = ""; + + if (initializerBuilder_ == null) { + initializer_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + initializerBuilder_.clear(); + } + if (sparseInitializerBuilder_ == null) { + sparseInitializer_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + sparseInitializerBuilder_.clear(); + } + docString_ = ""; + + if (inputBuilder_ == null) { + input_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + } else { + inputBuilder_.clear(); + } + if (outputBuilder_ == null) { + output_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + } else { + outputBuilder_.clear(); + } + if (valueInfoBuilder_ == null) { + valueInfo_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + } else { + valueInfoBuilder_.clear(); + } + if (quantizationAnnotationBuilder_ == null) { + quantizationAnnotation_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000100); + } else { + quantizationAnnotationBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_GraphProto_descriptor; + } + + @java.lang.Override + public OnnxMl.GraphProto getDefaultInstanceForType() { + return OnnxMl.GraphProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.GraphProto build() { + OnnxMl.GraphProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.GraphProto buildPartial() { + OnnxMl.GraphProto result = new OnnxMl.GraphProto(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (nodeBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + node_ = java.util.Collections.unmodifiableList(node_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.node_ = node_; + } else { + result.node_ = nodeBuilder_.build(); + } + result.name_ = name_; + if (initializerBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + initializer_ = java.util.Collections.unmodifiableList(initializer_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.initializer_ = initializer_; + } else { + result.initializer_ = initializerBuilder_.build(); + } + if (sparseInitializerBuilder_ == null) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { + sparseInitializer_ = java.util.Collections.unmodifiableList(sparseInitializer_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.sparseInitializer_ = sparseInitializer_; + } else { + result.sparseInitializer_ = sparseInitializerBuilder_.build(); + } + result.docString_ = docString_; + if (inputBuilder_ == null) { + if (((bitField0_ & 0x00000020) == 0x00000020)) { + input_ = java.util.Collections.unmodifiableList(input_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.input_ = input_; + } else { + result.input_ = inputBuilder_.build(); + } + if (outputBuilder_ == null) { + if (((bitField0_ & 0x00000040) == 0x00000040)) { + output_ = java.util.Collections.unmodifiableList(output_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.output_ = output_; + } else { + result.output_ = outputBuilder_.build(); + } + if (valueInfoBuilder_ == null) { + if (((bitField0_ & 0x00000080) == 0x00000080)) { + valueInfo_ = java.util.Collections.unmodifiableList(valueInfo_); + bitField0_ = (bitField0_ & ~0x00000080); + } + result.valueInfo_ = valueInfo_; + } else { + result.valueInfo_ = valueInfoBuilder_.build(); + } + if (quantizationAnnotationBuilder_ == null) { + if (((bitField0_ & 0x00000100) == 0x00000100)) { + quantizationAnnotation_ = java.util.Collections.unmodifiableList(quantizationAnnotation_); + bitField0_ = (bitField0_ & ~0x00000100); + } + result.quantizationAnnotation_ = quantizationAnnotation_; + } else { + result.quantizationAnnotation_ = quantizationAnnotationBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.GraphProto) { + return mergeFrom((OnnxMl.GraphProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.GraphProto other) { + if (other == OnnxMl.GraphProto.getDefaultInstance()) return this; + if (nodeBuilder_ == null) { + if (!other.node_.isEmpty()) { + if (node_.isEmpty()) { + node_ = other.node_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureNodeIsMutable(); + node_.addAll(other.node_); + } + onChanged(); + } + } else { + if (!other.node_.isEmpty()) { + if (nodeBuilder_.isEmpty()) { + nodeBuilder_.dispose(); + nodeBuilder_ = null; + node_ = other.node_; + bitField0_ = (bitField0_ & ~0x00000001); + nodeBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getNodeFieldBuilder() : null; + } else { + nodeBuilder_.addAllMessages(other.node_); + } + } + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (initializerBuilder_ == null) { + if (!other.initializer_.isEmpty()) { + if (initializer_.isEmpty()) { + initializer_ = other.initializer_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureInitializerIsMutable(); + initializer_.addAll(other.initializer_); + } + onChanged(); + } + } else { + if (!other.initializer_.isEmpty()) { + if (initializerBuilder_.isEmpty()) { + initializerBuilder_.dispose(); + initializerBuilder_ = null; + initializer_ = other.initializer_; + bitField0_ = (bitField0_ & ~0x00000004); + initializerBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getInitializerFieldBuilder() : null; + } else { + initializerBuilder_.addAllMessages(other.initializer_); + } + } + } + if (sparseInitializerBuilder_ == null) { + if (!other.sparseInitializer_.isEmpty()) { + if (sparseInitializer_.isEmpty()) { + sparseInitializer_ = other.sparseInitializer_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureSparseInitializerIsMutable(); + sparseInitializer_.addAll(other.sparseInitializer_); + } + onChanged(); + } + } else { + if (!other.sparseInitializer_.isEmpty()) { + if (sparseInitializerBuilder_.isEmpty()) { + sparseInitializerBuilder_.dispose(); + sparseInitializerBuilder_ = null; + sparseInitializer_ = other.sparseInitializer_; + bitField0_ = (bitField0_ & ~0x00000008); + sparseInitializerBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getSparseInitializerFieldBuilder() : null; + } else { + sparseInitializerBuilder_.addAllMessages(other.sparseInitializer_); + } + } + } + if (!other.getDocString().isEmpty()) { + docString_ = other.docString_; + onChanged(); + } + if (inputBuilder_ == null) { + if (!other.input_.isEmpty()) { + if (input_.isEmpty()) { + input_ = other.input_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureInputIsMutable(); + input_.addAll(other.input_); + } + onChanged(); + } + } else { + if (!other.input_.isEmpty()) { + if (inputBuilder_.isEmpty()) { + inputBuilder_.dispose(); + inputBuilder_ = null; + input_ = other.input_; + bitField0_ = (bitField0_ & ~0x00000020); + inputBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getInputFieldBuilder() : null; + } else { + inputBuilder_.addAllMessages(other.input_); + } + } + } + if (outputBuilder_ == null) { + if (!other.output_.isEmpty()) { + if (output_.isEmpty()) { + output_ = other.output_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensureOutputIsMutable(); + output_.addAll(other.output_); + } + onChanged(); + } + } else { + if (!other.output_.isEmpty()) { + if (outputBuilder_.isEmpty()) { + outputBuilder_.dispose(); + outputBuilder_ = null; + output_ = other.output_; + bitField0_ = (bitField0_ & ~0x00000040); + outputBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getOutputFieldBuilder() : null; + } else { + outputBuilder_.addAllMessages(other.output_); + } + } + } + if (valueInfoBuilder_ == null) { + if (!other.valueInfo_.isEmpty()) { + if (valueInfo_.isEmpty()) { + valueInfo_ = other.valueInfo_; + bitField0_ = (bitField0_ & ~0x00000080); + } else { + ensureValueInfoIsMutable(); + valueInfo_.addAll(other.valueInfo_); + } + onChanged(); + } + } else { + if (!other.valueInfo_.isEmpty()) { + if (valueInfoBuilder_.isEmpty()) { + valueInfoBuilder_.dispose(); + valueInfoBuilder_ = null; + valueInfo_ = other.valueInfo_; + bitField0_ = (bitField0_ & ~0x00000080); + valueInfoBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getValueInfoFieldBuilder() : null; + } else { + valueInfoBuilder_.addAllMessages(other.valueInfo_); + } + } + } + if (quantizationAnnotationBuilder_ == null) { + if (!other.quantizationAnnotation_.isEmpty()) { + if (quantizationAnnotation_.isEmpty()) { + quantizationAnnotation_ = other.quantizationAnnotation_; + bitField0_ = (bitField0_ & ~0x00000100); + } else { + ensureQuantizationAnnotationIsMutable(); + quantizationAnnotation_.addAll(other.quantizationAnnotation_); + } + onChanged(); + } + } else { + if (!other.quantizationAnnotation_.isEmpty()) { + if (quantizationAnnotationBuilder_.isEmpty()) { + quantizationAnnotationBuilder_.dispose(); + quantizationAnnotationBuilder_ = null; + quantizationAnnotation_ = other.quantizationAnnotation_; + bitField0_ = (bitField0_ & ~0x00000100); + quantizationAnnotationBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getQuantizationAnnotationFieldBuilder() : null; + } else { + quantizationAnnotationBuilder_.addAllMessages(other.quantizationAnnotation_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.GraphProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.GraphProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List node_ = + java.util.Collections.emptyList(); + private void ensureNodeIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + node_ = new java.util.ArrayList(node_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.NodeProto, OnnxMl.NodeProto.Builder, OnnxMl.NodeProtoOrBuilder> nodeBuilder_; + + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public java.util.List getNodeList() { + if (nodeBuilder_ == null) { + return java.util.Collections.unmodifiableList(node_); + } else { + return nodeBuilder_.getMessageList(); + } + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public int getNodeCount() { + if (nodeBuilder_ == null) { + return node_.size(); + } else { + return nodeBuilder_.getCount(); + } + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public OnnxMl.NodeProto getNode(int index) { + if (nodeBuilder_ == null) { + return node_.get(index); + } else { + return nodeBuilder_.getMessage(index); + } + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public Builder setNode( + int index, OnnxMl.NodeProto value) { + if (nodeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNodeIsMutable(); + node_.set(index, value); + onChanged(); + } else { + nodeBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public Builder setNode( + int index, OnnxMl.NodeProto.Builder builderForValue) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + node_.set(index, builderForValue.build()); + onChanged(); + } else { + nodeBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public Builder addNode(OnnxMl.NodeProto value) { + if (nodeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNodeIsMutable(); + node_.add(value); + onChanged(); + } else { + nodeBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public Builder addNode( + int index, OnnxMl.NodeProto value) { + if (nodeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNodeIsMutable(); + node_.add(index, value); + onChanged(); + } else { + nodeBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public Builder addNode( + OnnxMl.NodeProto.Builder builderForValue) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + node_.add(builderForValue.build()); + onChanged(); + } else { + nodeBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public Builder addNode( + int index, OnnxMl.NodeProto.Builder builderForValue) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + node_.add(index, builderForValue.build()); + onChanged(); + } else { + nodeBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public Builder addAllNode( + java.lang.Iterable values) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, node_); + onChanged(); + } else { + nodeBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public Builder clearNode() { + if (nodeBuilder_ == null) { + node_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + nodeBuilder_.clear(); + } + return this; + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public Builder removeNode(int index) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + node_.remove(index); + onChanged(); + } else { + nodeBuilder_.remove(index); + } + return this; + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public OnnxMl.NodeProto.Builder getNodeBuilder( + int index) { + return getNodeFieldBuilder().getBuilder(index); + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public OnnxMl.NodeProtoOrBuilder getNodeOrBuilder( + int index) { + if (nodeBuilder_ == null) { + return node_.get(index); } else { + return nodeBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public java.util.List + getNodeOrBuilderList() { + if (nodeBuilder_ != null) { + return nodeBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(node_); + } + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public OnnxMl.NodeProto.Builder addNodeBuilder() { + return getNodeFieldBuilder().addBuilder( + OnnxMl.NodeProto.getDefaultInstance()); + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public OnnxMl.NodeProto.Builder addNodeBuilder( + int index) { + return getNodeFieldBuilder().addBuilder( + index, OnnxMl.NodeProto.getDefaultInstance()); + } + /** + *
+       * The nodes in the graph, sorted topologically.
+       * 
+ * + * repeated .onnx.NodeProto node = 1; + */ + public java.util.List + getNodeBuilderList() { + return getNodeFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.NodeProto, OnnxMl.NodeProto.Builder, OnnxMl.NodeProtoOrBuilder> + getNodeFieldBuilder() { + if (nodeBuilder_ == null) { + nodeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.NodeProto, OnnxMl.NodeProto.Builder, OnnxMl.NodeProtoOrBuilder>( + node_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + node_ = null; + } + return nodeBuilder_; + } + + private java.lang.Object name_ = ""; + /** + *
+       * The name of the graph.
+       * 
+ * + * string name = 2; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * The name of the graph.
+       * 
+ * + * string name = 2; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * The name of the graph.
+       * 
+ * + * string name = 2; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       * The name of the graph.
+       * 
+ * + * string name = 2; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       * The name of the graph.
+       * 
+ * + * string name = 2; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.util.List initializer_ = + java.util.Collections.emptyList(); + private void ensureInitializerIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + initializer_ = new java.util.ArrayList(initializer_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> initializerBuilder_; + + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public java.util.List getInitializerList() { + if (initializerBuilder_ == null) { + return java.util.Collections.unmodifiableList(initializer_); + } else { + return initializerBuilder_.getMessageList(); + } + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public int getInitializerCount() { + if (initializerBuilder_ == null) { + return initializer_.size(); + } else { + return initializerBuilder_.getCount(); + } + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public OnnxMl.TensorProto getInitializer(int index) { + if (initializerBuilder_ == null) { + return initializer_.get(index); + } else { + return initializerBuilder_.getMessage(index); + } + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public Builder setInitializer( + int index, OnnxMl.TensorProto value) { + if (initializerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInitializerIsMutable(); + initializer_.set(index, value); + onChanged(); + } else { + initializerBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public Builder setInitializer( + int index, OnnxMl.TensorProto.Builder builderForValue) { + if (initializerBuilder_ == null) { + ensureInitializerIsMutable(); + initializer_.set(index, builderForValue.build()); + onChanged(); + } else { + initializerBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public Builder addInitializer(OnnxMl.TensorProto value) { + if (initializerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInitializerIsMutable(); + initializer_.add(value); + onChanged(); + } else { + initializerBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public Builder addInitializer( + int index, OnnxMl.TensorProto value) { + if (initializerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInitializerIsMutable(); + initializer_.add(index, value); + onChanged(); + } else { + initializerBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public Builder addInitializer( + OnnxMl.TensorProto.Builder builderForValue) { + if (initializerBuilder_ == null) { + ensureInitializerIsMutable(); + initializer_.add(builderForValue.build()); + onChanged(); + } else { + initializerBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public Builder addInitializer( + int index, OnnxMl.TensorProto.Builder builderForValue) { + if (initializerBuilder_ == null) { + ensureInitializerIsMutable(); + initializer_.add(index, builderForValue.build()); + onChanged(); + } else { + initializerBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public Builder addAllInitializer( + java.lang.Iterable values) { + if (initializerBuilder_ == null) { + ensureInitializerIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, initializer_); + onChanged(); + } else { + initializerBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public Builder clearInitializer() { + if (initializerBuilder_ == null) { + initializer_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + initializerBuilder_.clear(); + } + return this; + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public Builder removeInitializer(int index) { + if (initializerBuilder_ == null) { + ensureInitializerIsMutable(); + initializer_.remove(index); + onChanged(); + } else { + initializerBuilder_.remove(index); + } + return this; + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public OnnxMl.TensorProto.Builder getInitializerBuilder( + int index) { + return getInitializerFieldBuilder().getBuilder(index); + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public OnnxMl.TensorProtoOrBuilder getInitializerOrBuilder( + int index) { + if (initializerBuilder_ == null) { + return initializer_.get(index); } else { + return initializerBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public java.util.List + getInitializerOrBuilderList() { + if (initializerBuilder_ != null) { + return initializerBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(initializer_); + } + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public OnnxMl.TensorProto.Builder addInitializerBuilder() { + return getInitializerFieldBuilder().addBuilder( + OnnxMl.TensorProto.getDefaultInstance()); + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public OnnxMl.TensorProto.Builder addInitializerBuilder( + int index) { + return getInitializerFieldBuilder().addBuilder( + index, OnnxMl.TensorProto.getDefaultInstance()); + } + /** + *
+       * A list of named tensor values, used to specify constant inputs of the graph.
+       * Each TensorProto entry must have a distinct name (within the list) that
+       * MAY also appear in the input list.
+       * 
+ * + * repeated .onnx.TensorProto initializer = 5; + */ + public java.util.List + getInitializerBuilderList() { + return getInitializerFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> + getInitializerFieldBuilder() { + if (initializerBuilder_ == null) { + initializerBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder>( + initializer_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + initializer_ = null; + } + return initializerBuilder_; + } + + private java.util.List sparseInitializer_ = + java.util.Collections.emptyList(); + private void ensureSparseInitializerIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + sparseInitializer_ = new java.util.ArrayList(sparseInitializer_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.SparseTensorProto, OnnxMl.SparseTensorProto.Builder, OnnxMl.SparseTensorProtoOrBuilder> sparseInitializerBuilder_; + + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public java.util.List getSparseInitializerList() { + if (sparseInitializerBuilder_ == null) { + return java.util.Collections.unmodifiableList(sparseInitializer_); + } else { + return sparseInitializerBuilder_.getMessageList(); + } + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public int getSparseInitializerCount() { + if (sparseInitializerBuilder_ == null) { + return sparseInitializer_.size(); + } else { + return sparseInitializerBuilder_.getCount(); + } + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public OnnxMl.SparseTensorProto getSparseInitializer(int index) { + if (sparseInitializerBuilder_ == null) { + return sparseInitializer_.get(index); + } else { + return sparseInitializerBuilder_.getMessage(index); + } + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public Builder setSparseInitializer( + int index, OnnxMl.SparseTensorProto value) { + if (sparseInitializerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSparseInitializerIsMutable(); + sparseInitializer_.set(index, value); + onChanged(); + } else { + sparseInitializerBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public Builder setSparseInitializer( + int index, OnnxMl.SparseTensorProto.Builder builderForValue) { + if (sparseInitializerBuilder_ == null) { + ensureSparseInitializerIsMutable(); + sparseInitializer_.set(index, builderForValue.build()); + onChanged(); + } else { + sparseInitializerBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public Builder addSparseInitializer(OnnxMl.SparseTensorProto value) { + if (sparseInitializerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSparseInitializerIsMutable(); + sparseInitializer_.add(value); + onChanged(); + } else { + sparseInitializerBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public Builder addSparseInitializer( + int index, OnnxMl.SparseTensorProto value) { + if (sparseInitializerBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSparseInitializerIsMutable(); + sparseInitializer_.add(index, value); + onChanged(); + } else { + sparseInitializerBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public Builder addSparseInitializer( + OnnxMl.SparseTensorProto.Builder builderForValue) { + if (sparseInitializerBuilder_ == null) { + ensureSparseInitializerIsMutable(); + sparseInitializer_.add(builderForValue.build()); + onChanged(); + } else { + sparseInitializerBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public Builder addSparseInitializer( + int index, OnnxMl.SparseTensorProto.Builder builderForValue) { + if (sparseInitializerBuilder_ == null) { + ensureSparseInitializerIsMutable(); + sparseInitializer_.add(index, builderForValue.build()); + onChanged(); + } else { + sparseInitializerBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public Builder addAllSparseInitializer( + java.lang.Iterable values) { + if (sparseInitializerBuilder_ == null) { + ensureSparseInitializerIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, sparseInitializer_); + onChanged(); + } else { + sparseInitializerBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public Builder clearSparseInitializer() { + if (sparseInitializerBuilder_ == null) { + sparseInitializer_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + sparseInitializerBuilder_.clear(); + } + return this; + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public Builder removeSparseInitializer(int index) { + if (sparseInitializerBuilder_ == null) { + ensureSparseInitializerIsMutable(); + sparseInitializer_.remove(index); + onChanged(); + } else { + sparseInitializerBuilder_.remove(index); + } + return this; + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public OnnxMl.SparseTensorProto.Builder getSparseInitializerBuilder( + int index) { + return getSparseInitializerFieldBuilder().getBuilder(index); + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public OnnxMl.SparseTensorProtoOrBuilder getSparseInitializerOrBuilder( + int index) { + if (sparseInitializerBuilder_ == null) { + return sparseInitializer_.get(index); } else { + return sparseInitializerBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public java.util.List + getSparseInitializerOrBuilderList() { + if (sparseInitializerBuilder_ != null) { + return sparseInitializerBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sparseInitializer_); + } + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public OnnxMl.SparseTensorProto.Builder addSparseInitializerBuilder() { + return getSparseInitializerFieldBuilder().addBuilder( + OnnxMl.SparseTensorProto.getDefaultInstance()); + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public OnnxMl.SparseTensorProto.Builder addSparseInitializerBuilder( + int index) { + return getSparseInitializerFieldBuilder().addBuilder( + index, OnnxMl.SparseTensorProto.getDefaultInstance()); + } + /** + *
+       * Initializers (see above) stored in sparse format.
+       * 
+ * + * repeated .onnx.SparseTensorProto sparse_initializer = 15; + */ + public java.util.List + getSparseInitializerBuilderList() { + return getSparseInitializerFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.SparseTensorProto, OnnxMl.SparseTensorProto.Builder, OnnxMl.SparseTensorProtoOrBuilder> + getSparseInitializerFieldBuilder() { + if (sparseInitializerBuilder_ == null) { + sparseInitializerBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.SparseTensorProto, OnnxMl.SparseTensorProto.Builder, OnnxMl.SparseTensorProtoOrBuilder>( + sparseInitializer_, + ((bitField0_ & 0x00000008) == 0x00000008), + getParentForChildren(), + isClean()); + sparseInitializer_ = null; + } + return sparseInitializerBuilder_; + } + + private java.lang.Object docString_ = ""; + /** + *
+       * A human-readable documentation for this graph. Markdown is allowed.
+       * 
+ * + * string doc_string = 10; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * A human-readable documentation for this graph. Markdown is allowed.
+       * 
+ * + * string doc_string = 10; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * A human-readable documentation for this graph. Markdown is allowed.
+       * 
+ * + * string doc_string = 10; + */ + public Builder setDocString( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + docString_ = value; + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this graph. Markdown is allowed.
+       * 
+ * + * string doc_string = 10; + */ + public Builder clearDocString() { + + docString_ = getDefaultInstance().getDocString(); + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this graph. Markdown is allowed.
+       * 
+ * + * string doc_string = 10; + */ + public Builder setDocStringBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + docString_ = value; + onChanged(); + return this; + } + + private java.util.List input_ = + java.util.Collections.emptyList(); + private void ensureInputIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + input_ = new java.util.ArrayList(input_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.ValueInfoProto, OnnxMl.ValueInfoProto.Builder, OnnxMl.ValueInfoProtoOrBuilder> inputBuilder_; + + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public java.util.List getInputList() { + if (inputBuilder_ == null) { + return java.util.Collections.unmodifiableList(input_); + } else { + return inputBuilder_.getMessageList(); + } + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public int getInputCount() { + if (inputBuilder_ == null) { + return input_.size(); + } else { + return inputBuilder_.getCount(); + } + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public OnnxMl.ValueInfoProto getInput(int index) { + if (inputBuilder_ == null) { + return input_.get(index); + } else { + return inputBuilder_.getMessage(index); + } + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public Builder setInput( + int index, OnnxMl.ValueInfoProto value) { + if (inputBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputIsMutable(); + input_.set(index, value); + onChanged(); + } else { + inputBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public Builder setInput( + int index, OnnxMl.ValueInfoProto.Builder builderForValue) { + if (inputBuilder_ == null) { + ensureInputIsMutable(); + input_.set(index, builderForValue.build()); + onChanged(); + } else { + inputBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public Builder addInput(OnnxMl.ValueInfoProto value) { + if (inputBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputIsMutable(); + input_.add(value); + onChanged(); + } else { + inputBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public Builder addInput( + int index, OnnxMl.ValueInfoProto value) { + if (inputBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputIsMutable(); + input_.add(index, value); + onChanged(); + } else { + inputBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public Builder addInput( + OnnxMl.ValueInfoProto.Builder builderForValue) { + if (inputBuilder_ == null) { + ensureInputIsMutable(); + input_.add(builderForValue.build()); + onChanged(); + } else { + inputBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public Builder addInput( + int index, OnnxMl.ValueInfoProto.Builder builderForValue) { + if (inputBuilder_ == null) { + ensureInputIsMutable(); + input_.add(index, builderForValue.build()); + onChanged(); + } else { + inputBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public Builder addAllInput( + java.lang.Iterable values) { + if (inputBuilder_ == null) { + ensureInputIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, input_); + onChanged(); + } else { + inputBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public Builder clearInput() { + if (inputBuilder_ == null) { + input_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + inputBuilder_.clear(); + } + return this; + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public Builder removeInput(int index) { + if (inputBuilder_ == null) { + ensureInputIsMutable(); + input_.remove(index); + onChanged(); + } else { + inputBuilder_.remove(index); + } + return this; + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public OnnxMl.ValueInfoProto.Builder getInputBuilder( + int index) { + return getInputFieldBuilder().getBuilder(index); + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public OnnxMl.ValueInfoProtoOrBuilder getInputOrBuilder( + int index) { + if (inputBuilder_ == null) { + return input_.get(index); } else { + return inputBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public java.util.List + getInputOrBuilderList() { + if (inputBuilder_ != null) { + return inputBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(input_); + } + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public OnnxMl.ValueInfoProto.Builder addInputBuilder() { + return getInputFieldBuilder().addBuilder( + OnnxMl.ValueInfoProto.getDefaultInstance()); + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public OnnxMl.ValueInfoProto.Builder addInputBuilder( + int index) { + return getInputFieldBuilder().addBuilder( + index, OnnxMl.ValueInfoProto.getDefaultInstance()); + } + /** + *
+       * The inputs and outputs of the graph.
+       * 
+ * + * repeated .onnx.ValueInfoProto input = 11; + */ + public java.util.List + getInputBuilderList() { + return getInputFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.ValueInfoProto, OnnxMl.ValueInfoProto.Builder, OnnxMl.ValueInfoProtoOrBuilder> + getInputFieldBuilder() { + if (inputBuilder_ == null) { + inputBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.ValueInfoProto, OnnxMl.ValueInfoProto.Builder, OnnxMl.ValueInfoProtoOrBuilder>( + input_, + ((bitField0_ & 0x00000020) == 0x00000020), + getParentForChildren(), + isClean()); + input_ = null; + } + return inputBuilder_; + } + + private java.util.List output_ = + java.util.Collections.emptyList(); + private void ensureOutputIsMutable() { + if (!((bitField0_ & 0x00000040) == 0x00000040)) { + output_ = new java.util.ArrayList(output_); + bitField0_ |= 0x00000040; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.ValueInfoProto, OnnxMl.ValueInfoProto.Builder, OnnxMl.ValueInfoProtoOrBuilder> outputBuilder_; + + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public java.util.List getOutputList() { + if (outputBuilder_ == null) { + return java.util.Collections.unmodifiableList(output_); + } else { + return outputBuilder_.getMessageList(); + } + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public int getOutputCount() { + if (outputBuilder_ == null) { + return output_.size(); + } else { + return outputBuilder_.getCount(); + } + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public OnnxMl.ValueInfoProto getOutput(int index) { + if (outputBuilder_ == null) { + return output_.get(index); + } else { + return outputBuilder_.getMessage(index); + } + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public Builder setOutput( + int index, OnnxMl.ValueInfoProto value) { + if (outputBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputIsMutable(); + output_.set(index, value); + onChanged(); + } else { + outputBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public Builder setOutput( + int index, OnnxMl.ValueInfoProto.Builder builderForValue) { + if (outputBuilder_ == null) { + ensureOutputIsMutable(); + output_.set(index, builderForValue.build()); + onChanged(); + } else { + outputBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public Builder addOutput(OnnxMl.ValueInfoProto value) { + if (outputBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputIsMutable(); + output_.add(value); + onChanged(); + } else { + outputBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public Builder addOutput( + int index, OnnxMl.ValueInfoProto value) { + if (outputBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputIsMutable(); + output_.add(index, value); + onChanged(); + } else { + outputBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public Builder addOutput( + OnnxMl.ValueInfoProto.Builder builderForValue) { + if (outputBuilder_ == null) { + ensureOutputIsMutable(); + output_.add(builderForValue.build()); + onChanged(); + } else { + outputBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public Builder addOutput( + int index, OnnxMl.ValueInfoProto.Builder builderForValue) { + if (outputBuilder_ == null) { + ensureOutputIsMutable(); + output_.add(index, builderForValue.build()); + onChanged(); + } else { + outputBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public Builder addAllOutput( + java.lang.Iterable values) { + if (outputBuilder_ == null) { + ensureOutputIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, output_); + onChanged(); + } else { + outputBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public Builder clearOutput() { + if (outputBuilder_ == null) { + output_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + } else { + outputBuilder_.clear(); + } + return this; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public Builder removeOutput(int index) { + if (outputBuilder_ == null) { + ensureOutputIsMutable(); + output_.remove(index); + onChanged(); + } else { + outputBuilder_.remove(index); + } + return this; + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public OnnxMl.ValueInfoProto.Builder getOutputBuilder( + int index) { + return getOutputFieldBuilder().getBuilder(index); + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public OnnxMl.ValueInfoProtoOrBuilder getOutputOrBuilder( + int index) { + if (outputBuilder_ == null) { + return output_.get(index); } else { + return outputBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public java.util.List + getOutputOrBuilderList() { + if (outputBuilder_ != null) { + return outputBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(output_); + } + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public OnnxMl.ValueInfoProto.Builder addOutputBuilder() { + return getOutputFieldBuilder().addBuilder( + OnnxMl.ValueInfoProto.getDefaultInstance()); + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public OnnxMl.ValueInfoProto.Builder addOutputBuilder( + int index) { + return getOutputFieldBuilder().addBuilder( + index, OnnxMl.ValueInfoProto.getDefaultInstance()); + } + /** + * repeated .onnx.ValueInfoProto output = 12; + */ + public java.util.List + getOutputBuilderList() { + return getOutputFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.ValueInfoProto, OnnxMl.ValueInfoProto.Builder, OnnxMl.ValueInfoProtoOrBuilder> + getOutputFieldBuilder() { + if (outputBuilder_ == null) { + outputBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.ValueInfoProto, OnnxMl.ValueInfoProto.Builder, OnnxMl.ValueInfoProtoOrBuilder>( + output_, + ((bitField0_ & 0x00000040) == 0x00000040), + getParentForChildren(), + isClean()); + output_ = null; + } + return outputBuilder_; + } + + private java.util.List valueInfo_ = + java.util.Collections.emptyList(); + private void ensureValueInfoIsMutable() { + if (!((bitField0_ & 0x00000080) == 0x00000080)) { + valueInfo_ = new java.util.ArrayList(valueInfo_); + bitField0_ |= 0x00000080; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.ValueInfoProto, OnnxMl.ValueInfoProto.Builder, OnnxMl.ValueInfoProtoOrBuilder> valueInfoBuilder_; + + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public java.util.List getValueInfoList() { + if (valueInfoBuilder_ == null) { + return java.util.Collections.unmodifiableList(valueInfo_); + } else { + return valueInfoBuilder_.getMessageList(); + } + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public int getValueInfoCount() { + if (valueInfoBuilder_ == null) { + return valueInfo_.size(); + } else { + return valueInfoBuilder_.getCount(); + } + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public OnnxMl.ValueInfoProto getValueInfo(int index) { + if (valueInfoBuilder_ == null) { + return valueInfo_.get(index); + } else { + return valueInfoBuilder_.getMessage(index); + } + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public Builder setValueInfo( + int index, OnnxMl.ValueInfoProto value) { + if (valueInfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValueInfoIsMutable(); + valueInfo_.set(index, value); + onChanged(); + } else { + valueInfoBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public Builder setValueInfo( + int index, OnnxMl.ValueInfoProto.Builder builderForValue) { + if (valueInfoBuilder_ == null) { + ensureValueInfoIsMutable(); + valueInfo_.set(index, builderForValue.build()); + onChanged(); + } else { + valueInfoBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public Builder addValueInfo(OnnxMl.ValueInfoProto value) { + if (valueInfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValueInfoIsMutable(); + valueInfo_.add(value); + onChanged(); + } else { + valueInfoBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public Builder addValueInfo( + int index, OnnxMl.ValueInfoProto value) { + if (valueInfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValueInfoIsMutable(); + valueInfo_.add(index, value); + onChanged(); + } else { + valueInfoBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public Builder addValueInfo( + OnnxMl.ValueInfoProto.Builder builderForValue) { + if (valueInfoBuilder_ == null) { + ensureValueInfoIsMutable(); + valueInfo_.add(builderForValue.build()); + onChanged(); + } else { + valueInfoBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public Builder addValueInfo( + int index, OnnxMl.ValueInfoProto.Builder builderForValue) { + if (valueInfoBuilder_ == null) { + ensureValueInfoIsMutable(); + valueInfo_.add(index, builderForValue.build()); + onChanged(); + } else { + valueInfoBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public Builder addAllValueInfo( + java.lang.Iterable values) { + if (valueInfoBuilder_ == null) { + ensureValueInfoIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, valueInfo_); + onChanged(); + } else { + valueInfoBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public Builder clearValueInfo() { + if (valueInfoBuilder_ == null) { + valueInfo_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + onChanged(); + } else { + valueInfoBuilder_.clear(); + } + return this; + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public Builder removeValueInfo(int index) { + if (valueInfoBuilder_ == null) { + ensureValueInfoIsMutable(); + valueInfo_.remove(index); + onChanged(); + } else { + valueInfoBuilder_.remove(index); + } + return this; + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public OnnxMl.ValueInfoProto.Builder getValueInfoBuilder( + int index) { + return getValueInfoFieldBuilder().getBuilder(index); + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public OnnxMl.ValueInfoProtoOrBuilder getValueInfoOrBuilder( + int index) { + if (valueInfoBuilder_ == null) { + return valueInfo_.get(index); } else { + return valueInfoBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public java.util.List + getValueInfoOrBuilderList() { + if (valueInfoBuilder_ != null) { + return valueInfoBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(valueInfo_); + } + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public OnnxMl.ValueInfoProto.Builder addValueInfoBuilder() { + return getValueInfoFieldBuilder().addBuilder( + OnnxMl.ValueInfoProto.getDefaultInstance()); + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public OnnxMl.ValueInfoProto.Builder addValueInfoBuilder( + int index) { + return getValueInfoFieldBuilder().addBuilder( + index, OnnxMl.ValueInfoProto.getDefaultInstance()); + } + /** + *
+       * Information for the values in the graph. The ValueInfoProto.name's
+       * must be distinct. It is optional for a value to appear in value_info list.
+       * 
+ * + * repeated .onnx.ValueInfoProto value_info = 13; + */ + public java.util.List + getValueInfoBuilderList() { + return getValueInfoFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.ValueInfoProto, OnnxMl.ValueInfoProto.Builder, OnnxMl.ValueInfoProtoOrBuilder> + getValueInfoFieldBuilder() { + if (valueInfoBuilder_ == null) { + valueInfoBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.ValueInfoProto, OnnxMl.ValueInfoProto.Builder, OnnxMl.ValueInfoProtoOrBuilder>( + valueInfo_, + ((bitField0_ & 0x00000080) == 0x00000080), + getParentForChildren(), + isClean()); + valueInfo_ = null; + } + return valueInfoBuilder_; + } + + private java.util.List quantizationAnnotation_ = + java.util.Collections.emptyList(); + private void ensureQuantizationAnnotationIsMutable() { + if (!((bitField0_ & 0x00000100) == 0x00000100)) { + quantizationAnnotation_ = new java.util.ArrayList(quantizationAnnotation_); + bitField0_ |= 0x00000100; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorAnnotation, OnnxMl.TensorAnnotation.Builder, OnnxMl.TensorAnnotationOrBuilder> quantizationAnnotationBuilder_; + + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public java.util.List getQuantizationAnnotationList() { + if (quantizationAnnotationBuilder_ == null) { + return java.util.Collections.unmodifiableList(quantizationAnnotation_); + } else { + return quantizationAnnotationBuilder_.getMessageList(); + } + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public int getQuantizationAnnotationCount() { + if (quantizationAnnotationBuilder_ == null) { + return quantizationAnnotation_.size(); + } else { + return quantizationAnnotationBuilder_.getCount(); + } + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public OnnxMl.TensorAnnotation getQuantizationAnnotation(int index) { + if (quantizationAnnotationBuilder_ == null) { + return quantizationAnnotation_.get(index); + } else { + return quantizationAnnotationBuilder_.getMessage(index); + } + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public Builder setQuantizationAnnotation( + int index, OnnxMl.TensorAnnotation value) { + if (quantizationAnnotationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuantizationAnnotationIsMutable(); + quantizationAnnotation_.set(index, value); + onChanged(); + } else { + quantizationAnnotationBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public Builder setQuantizationAnnotation( + int index, OnnxMl.TensorAnnotation.Builder builderForValue) { + if (quantizationAnnotationBuilder_ == null) { + ensureQuantizationAnnotationIsMutable(); + quantizationAnnotation_.set(index, builderForValue.build()); + onChanged(); + } else { + quantizationAnnotationBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public Builder addQuantizationAnnotation(OnnxMl.TensorAnnotation value) { + if (quantizationAnnotationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuantizationAnnotationIsMutable(); + quantizationAnnotation_.add(value); + onChanged(); + } else { + quantizationAnnotationBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public Builder addQuantizationAnnotation( + int index, OnnxMl.TensorAnnotation value) { + if (quantizationAnnotationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureQuantizationAnnotationIsMutable(); + quantizationAnnotation_.add(index, value); + onChanged(); + } else { + quantizationAnnotationBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public Builder addQuantizationAnnotation( + OnnxMl.TensorAnnotation.Builder builderForValue) { + if (quantizationAnnotationBuilder_ == null) { + ensureQuantizationAnnotationIsMutable(); + quantizationAnnotation_.add(builderForValue.build()); + onChanged(); + } else { + quantizationAnnotationBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public Builder addQuantizationAnnotation( + int index, OnnxMl.TensorAnnotation.Builder builderForValue) { + if (quantizationAnnotationBuilder_ == null) { + ensureQuantizationAnnotationIsMutable(); + quantizationAnnotation_.add(index, builderForValue.build()); + onChanged(); + } else { + quantizationAnnotationBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public Builder addAllQuantizationAnnotation( + java.lang.Iterable values) { + if (quantizationAnnotationBuilder_ == null) { + ensureQuantizationAnnotationIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, quantizationAnnotation_); + onChanged(); + } else { + quantizationAnnotationBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public Builder clearQuantizationAnnotation() { + if (quantizationAnnotationBuilder_ == null) { + quantizationAnnotation_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000100); + onChanged(); + } else { + quantizationAnnotationBuilder_.clear(); + } + return this; + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public Builder removeQuantizationAnnotation(int index) { + if (quantizationAnnotationBuilder_ == null) { + ensureQuantizationAnnotationIsMutable(); + quantizationAnnotation_.remove(index); + onChanged(); + } else { + quantizationAnnotationBuilder_.remove(index); + } + return this; + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public OnnxMl.TensorAnnotation.Builder getQuantizationAnnotationBuilder( + int index) { + return getQuantizationAnnotationFieldBuilder().getBuilder(index); + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public OnnxMl.TensorAnnotationOrBuilder getQuantizationAnnotationOrBuilder( + int index) { + if (quantizationAnnotationBuilder_ == null) { + return quantizationAnnotation_.get(index); } else { + return quantizationAnnotationBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public java.util.List + getQuantizationAnnotationOrBuilderList() { + if (quantizationAnnotationBuilder_ != null) { + return quantizationAnnotationBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(quantizationAnnotation_); + } + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public OnnxMl.TensorAnnotation.Builder addQuantizationAnnotationBuilder() { + return getQuantizationAnnotationFieldBuilder().addBuilder( + OnnxMl.TensorAnnotation.getDefaultInstance()); + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public OnnxMl.TensorAnnotation.Builder addQuantizationAnnotationBuilder( + int index) { + return getQuantizationAnnotationFieldBuilder().addBuilder( + index, OnnxMl.TensorAnnotation.getDefaultInstance()); + } + /** + *
+       * This field carries information to indicate the mapping among a tensor and its
+       * quantization parameter tensors. For example:
+       * For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
+       * which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
+       * 
+ * + * repeated .onnx.TensorAnnotation quantization_annotation = 14; + */ + public java.util.List + getQuantizationAnnotationBuilderList() { + return getQuantizationAnnotationFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorAnnotation, OnnxMl.TensorAnnotation.Builder, OnnxMl.TensorAnnotationOrBuilder> + getQuantizationAnnotationFieldBuilder() { + if (quantizationAnnotationBuilder_ == null) { + quantizationAnnotationBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorAnnotation, OnnxMl.TensorAnnotation.Builder, OnnxMl.TensorAnnotationOrBuilder>( + quantizationAnnotation_, + ((bitField0_ & 0x00000100) == 0x00000100), + getParentForChildren(), + isClean()); + quantizationAnnotation_ = null; + } + return quantizationAnnotationBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.GraphProto) + } + + // @@protoc_insertion_point(class_scope:onnx.GraphProto) + private static final OnnxMl.GraphProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.GraphProto(); + } + + public static OnnxMl.GraphProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GraphProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new GraphProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.GraphProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TensorProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TensorProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * The shape of the tensor.
+     * 
+ * + * repeated int64 dims = 1; + */ + java.util.List getDimsList(); + /** + *
+     * The shape of the tensor.
+     * 
+ * + * repeated int64 dims = 1; + */ + int getDimsCount(); + /** + *
+     * The shape of the tensor.
+     * 
+ * + * repeated int64 dims = 1; + */ + long getDims(int index); + + /** + *
+     * The data type of the tensor.
+     * This field MUST have a valid TensorProto.DataType value
+     * 
+ * + * int32 data_type = 2; + */ + int getDataType(); + + /** + * .onnx.TensorProto.Segment segment = 3; + */ + boolean hasSegment(); + /** + * .onnx.TensorProto.Segment segment = 3; + */ + OnnxMl.TensorProto.Segment getSegment(); + /** + * .onnx.TensorProto.Segment segment = 3; + */ + OnnxMl.TensorProto.SegmentOrBuilder getSegmentOrBuilder(); + + /** + *
+     * For float and complex64 values
+     * Complex64 tensors are encoded as a single array of floats,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+     * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + java.util.List getFloatDataList(); + /** + *
+     * For float and complex64 values
+     * Complex64 tensors are encoded as a single array of floats,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+     * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + int getFloatDataCount(); + /** + *
+     * For float and complex64 values
+     * Complex64 tensors are encoded as a single array of floats,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+     * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + float getFloatData(int index); + + /** + *
+     * For int32, uint8, int8, uint16, int16, bool, and float16 values
+     * float16 values must be bit-wise converted to an uint16_t prior
+     * to writing to the buffer.
+     * When this field is present, the data_type field MUST be
+     * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+     * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + java.util.List getInt32DataList(); + /** + *
+     * For int32, uint8, int8, uint16, int16, bool, and float16 values
+     * float16 values must be bit-wise converted to an uint16_t prior
+     * to writing to the buffer.
+     * When this field is present, the data_type field MUST be
+     * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+     * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + int getInt32DataCount(); + /** + *
+     * For int32, uint8, int8, uint16, int16, bool, and float16 values
+     * float16 values must be bit-wise converted to an uint16_t prior
+     * to writing to the buffer.
+     * When this field is present, the data_type field MUST be
+     * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+     * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + int getInt32Data(int index); + + /** + *
+     * For strings.
+     * Each element of string_data is a UTF-8 encoded Unicode
+     * string. No trailing null, no leading BOM. The protobuf "string"
+     * scalar type is not used to match ML community conventions.
+     * When this field is present, the data_type field MUST be STRING
+     * 
+ * + * repeated bytes string_data = 6; + */ + java.util.List getStringDataList(); + /** + *
+     * For strings.
+     * Each element of string_data is a UTF-8 encoded Unicode
+     * string. No trailing null, no leading BOM. The protobuf "string"
+     * scalar type is not used to match ML community conventions.
+     * When this field is present, the data_type field MUST be STRING
+     * 
+ * + * repeated bytes string_data = 6; + */ + int getStringDataCount(); + /** + *
+     * For strings.
+     * Each element of string_data is a UTF-8 encoded Unicode
+     * string. No trailing null, no leading BOM. The protobuf "string"
+     * scalar type is not used to match ML community conventions.
+     * When this field is present, the data_type field MUST be STRING
+     * 
+ * + * repeated bytes string_data = 6; + */ + com.google.protobuf.ByteString getStringData(int index); + + /** + *
+     * For int64.
+     * When this field is present, the data_type field MUST be INT64
+     * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + java.util.List getInt64DataList(); + /** + *
+     * For int64.
+     * When this field is present, the data_type field MUST be INT64
+     * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + int getInt64DataCount(); + /** + *
+     * For int64.
+     * When this field is present, the data_type field MUST be INT64
+     * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + long getInt64Data(int index); + + /** + *
+     * Optionally, a name for the tensor.
+     * 
+ * + * string name = 8; + */ + java.lang.String getName(); + /** + *
+     * Optionally, a name for the tensor.
+     * 
+ * + * string name = 8; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     * A human-readable documentation for this tensor. Markdown is allowed.
+     * 
+ * + * string doc_string = 12; + */ + java.lang.String getDocString(); + /** + *
+     * A human-readable documentation for this tensor. Markdown is allowed.
+     * 
+ * + * string doc_string = 12; + */ + com.google.protobuf.ByteString + getDocStringBytes(); + + /** + *
+     * Serializations can either use one of the fields above, or use this
+     * raw bytes field. The only exception is the string case, where one is
+     * required to store the content in the repeated bytes string_data field.
+     * When this raw_data field is used to store tensor value, elements MUST
+     * be stored in as fixed-width, little-endian order.
+     * Floating-point data types MUST be stored in IEEE 754 format.
+     * Complex64 elements must be written as two consecutive FLOAT values, real component first.
+     * Complex128 elements must be written as two consecutive DOUBLE values, real component first.
+     * Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false).
+     * Note: the advantage of specific field rather than the raw_data field is
+     * that in some cases (e.g. int data), protobuf does a better packing via
+     * variable length storage, and may lead to smaller binary footprint.
+     * When this field is present, the data_type field MUST NOT be STRING or UNDEFINED
+     * 
+ * + * bytes raw_data = 9; + */ + com.google.protobuf.ByteString getRawData(); + + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + java.util.List + getExternalDataList(); + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + OnnxMl.StringStringEntryProto getExternalData(int index); + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + int getExternalDataCount(); + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + java.util.List + getExternalDataOrBuilderList(); + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + OnnxMl.StringStringEntryProtoOrBuilder getExternalDataOrBuilder( + int index); + + /** + *
+     * If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
+     * 
+ * + * .onnx.TensorProto.DataLocation data_location = 14; + */ + int getDataLocationValue(); + /** + *
+     * If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
+     * 
+ * + * .onnx.TensorProto.DataLocation data_location = 14; + */ + OnnxMl.TensorProto.DataLocation getDataLocation(); + + /** + *
+     * For double
+     * Complex128 tensors are encoded as a single array of doubles,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+     * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + java.util.List getDoubleDataList(); + /** + *
+     * For double
+     * Complex128 tensors are encoded as a single array of doubles,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+     * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + int getDoubleDataCount(); + /** + *
+     * For double
+     * Complex128 tensors are encoded as a single array of doubles,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+     * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + double getDoubleData(int index); + + /** + *
+     * For uint64 and uint32 values
+     * When this field is present, the data_type field MUST be
+     * UINT32 or UINT64
+     * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + java.util.List getUint64DataList(); + /** + *
+     * For uint64 and uint32 values
+     * When this field is present, the data_type field MUST be
+     * UINT32 or UINT64
+     * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + int getUint64DataCount(); + /** + *
+     * For uint64 and uint32 values
+     * When this field is present, the data_type field MUST be
+     * UINT32 or UINT64
+     * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + long getUint64Data(int index); + } + /** + *
+   * Tensors
+   * A serialized tensor value.
+   * 
+ * + * Protobuf type {@code onnx.TensorProto} + */ + public static final class TensorProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TensorProto) + TensorProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use TensorProto.newBuilder() to construct. + private TensorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TensorProto() { + dims_ = java.util.Collections.emptyList(); + dataType_ = 0; + floatData_ = java.util.Collections.emptyList(); + int32Data_ = java.util.Collections.emptyList(); + stringData_ = java.util.Collections.emptyList(); + int64Data_ = java.util.Collections.emptyList(); + name_ = ""; + docString_ = ""; + rawData_ = com.google.protobuf.ByteString.EMPTY; + externalData_ = java.util.Collections.emptyList(); + dataLocation_ = 0; + doubleData_ = java.util.Collections.emptyList(); + uint64Data_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TensorProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + dims_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + dims_.add(input.readInt64()); + break; + } + case 10: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001) && input.getBytesUntilLimit() > 0) { + dims_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + while (input.getBytesUntilLimit() > 0) { + dims_.add(input.readInt64()); + } + input.popLimit(limit); + break; + } + case 16: { + + dataType_ = input.readInt32(); + break; + } + case 26: { + OnnxMl.TensorProto.Segment.Builder subBuilder = null; + if (segment_ != null) { + subBuilder = segment_.toBuilder(); + } + segment_ = input.readMessage(OnnxMl.TensorProto.Segment.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(segment_); + segment_ = subBuilder.buildPartial(); + } + + break; + } + case 37: { + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + floatData_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + floatData_.add(input.readFloat()); + break; + } + case 34: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008) && input.getBytesUntilLimit() > 0) { + floatData_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + while (input.getBytesUntilLimit() > 0) { + floatData_.add(input.readFloat()); + } + input.popLimit(limit); + break; + } + case 40: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + int32Data_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + int32Data_.add(input.readInt32()); + break; + } + case 42: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010) && input.getBytesUntilLimit() > 0) { + int32Data_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + while (input.getBytesUntilLimit() > 0) { + int32Data_.add(input.readInt32()); + } + input.popLimit(limit); + break; + } + case 50: { + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + stringData_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000020; + } + stringData_.add(input.readBytes()); + break; + } + case 56: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + int64Data_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000040; + } + int64Data_.add(input.readInt64()); + break; + } + case 58: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040) && input.getBytesUntilLimit() > 0) { + int64Data_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000040; + } + while (input.getBytesUntilLimit() > 0) { + int64Data_.add(input.readInt64()); + } + input.popLimit(limit); + break; + } + case 66: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 74: { + + rawData_ = input.readBytes(); + break; + } + case 81: { + if (!((mutable_bitField0_ & 0x00001000) == 0x00001000)) { + doubleData_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00001000; + } + doubleData_.add(input.readDouble()); + break; + } + case 82: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00001000) == 0x00001000) && input.getBytesUntilLimit() > 0) { + doubleData_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00001000; + } + while (input.getBytesUntilLimit() > 0) { + doubleData_.add(input.readDouble()); + } + input.popLimit(limit); + break; + } + case 88: { + if (!((mutable_bitField0_ & 0x00002000) == 0x00002000)) { + uint64Data_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00002000; + } + uint64Data_.add(input.readUInt64()); + break; + } + case 90: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00002000) == 0x00002000) && input.getBytesUntilLimit() > 0) { + uint64Data_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00002000; + } + while (input.getBytesUntilLimit() > 0) { + uint64Data_.add(input.readUInt64()); + } + input.popLimit(limit); + break; + } + case 98: { + java.lang.String s = input.readStringRequireUtf8(); + + docString_ = s; + break; + } + case 106: { + if (!((mutable_bitField0_ & 0x00000400) == 0x00000400)) { + externalData_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000400; + } + externalData_.add( + input.readMessage(OnnxMl.StringStringEntryProto.parser(), extensionRegistry)); + break; + } + case 112: { + int rawValue = input.readEnum(); + + dataLocation_ = rawValue; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + dims_ = java.util.Collections.unmodifiableList(dims_); + } + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + floatData_ = java.util.Collections.unmodifiableList(floatData_); + } + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + int32Data_ = java.util.Collections.unmodifiableList(int32Data_); + } + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + stringData_ = java.util.Collections.unmodifiableList(stringData_); + } + if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + int64Data_ = java.util.Collections.unmodifiableList(int64Data_); + } + if (((mutable_bitField0_ & 0x00001000) == 0x00001000)) { + doubleData_ = java.util.Collections.unmodifiableList(doubleData_); + } + if (((mutable_bitField0_ & 0x00002000) == 0x00002000)) { + uint64Data_ = java.util.Collections.unmodifiableList(uint64Data_); + } + if (((mutable_bitField0_ & 0x00000400) == 0x00000400)) { + externalData_ = java.util.Collections.unmodifiableList(externalData_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorProto.class, OnnxMl.TensorProto.Builder.class); + } + + /** + * Protobuf enum {@code onnx.TensorProto.DataType} + */ + public enum DataType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * UNDEFINED = 0; + */ + UNDEFINED(0), + /** + *
+       * Basic types.
+       * 
+ * + * FLOAT = 1; + */ + FLOAT(1), + /** + *
+       * uint8_t
+       * 
+ * + * UINT8 = 2; + */ + UINT8(2), + /** + *
+       * int8_t
+       * 
+ * + * INT8 = 3; + */ + INT8(3), + /** + *
+       * uint16_t
+       * 
+ * + * UINT16 = 4; + */ + UINT16(4), + /** + *
+       * int16_t
+       * 
+ * + * INT16 = 5; + */ + INT16(5), + /** + *
+       * int32_t
+       * 
+ * + * INT32 = 6; + */ + INT32(6), + /** + *
+       * int64_t
+       * 
+ * + * INT64 = 7; + */ + INT64(7), + /** + *
+       * string
+       * 
+ * + * STRING = 8; + */ + STRING(8), + /** + *
+       * bool
+       * 
+ * + * BOOL = 9; + */ + BOOL(9), + /** + *
+       * IEEE754 half-precision floating-point format (16 bits wide).
+       * This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits.
+       * 
+ * + * FLOAT16 = 10; + */ + FLOAT16(10), + /** + * DOUBLE = 11; + */ + DOUBLE(11), + /** + * UINT32 = 12; + */ + UINT32(12), + /** + * UINT64 = 13; + */ + UINT64(13), + /** + *
+       * complex with float32 real and imaginary components
+       * 
+ * + * COMPLEX64 = 14; + */ + COMPLEX64(14), + /** + *
+       * complex with float64 real and imaginary components
+       * 
+ * + * COMPLEX128 = 15; + */ + COMPLEX128(15), + /** + *
+       * Non-IEEE floating-point format based on IEEE754 single-precision
+       * floating-point number truncated to 16 bits.
+       * This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits.
+       * 
+ * + * BFLOAT16 = 16; + */ + BFLOAT16(16), + UNRECOGNIZED(-1), + ; + + /** + * UNDEFINED = 0; + */ + public static final int UNDEFINED_VALUE = 0; + /** + *
+       * Basic types.
+       * 
+ * + * FLOAT = 1; + */ + public static final int FLOAT_VALUE = 1; + /** + *
+       * uint8_t
+       * 
+ * + * UINT8 = 2; + */ + public static final int UINT8_VALUE = 2; + /** + *
+       * int8_t
+       * 
+ * + * INT8 = 3; + */ + public static final int INT8_VALUE = 3; + /** + *
+       * uint16_t
+       * 
+ * + * UINT16 = 4; + */ + public static final int UINT16_VALUE = 4; + /** + *
+       * int16_t
+       * 
+ * + * INT16 = 5; + */ + public static final int INT16_VALUE = 5; + /** + *
+       * int32_t
+       * 
+ * + * INT32 = 6; + */ + public static final int INT32_VALUE = 6; + /** + *
+       * int64_t
+       * 
+ * + * INT64 = 7; + */ + public static final int INT64_VALUE = 7; + /** + *
+       * string
+       * 
+ * + * STRING = 8; + */ + public static final int STRING_VALUE = 8; + /** + *
+       * bool
+       * 
+ * + * BOOL = 9; + */ + public static final int BOOL_VALUE = 9; + /** + *
+       * IEEE754 half-precision floating-point format (16 bits wide).
+       * This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits.
+       * 
+ * + * FLOAT16 = 10; + */ + public static final int FLOAT16_VALUE = 10; + /** + * DOUBLE = 11; + */ + public static final int DOUBLE_VALUE = 11; + /** + * UINT32 = 12; + */ + public static final int UINT32_VALUE = 12; + /** + * UINT64 = 13; + */ + public static final int UINT64_VALUE = 13; + /** + *
+       * complex with float32 real and imaginary components
+       * 
+ * + * COMPLEX64 = 14; + */ + public static final int COMPLEX64_VALUE = 14; + /** + *
+       * complex with float64 real and imaginary components
+       * 
+ * + * COMPLEX128 = 15; + */ + public static final int COMPLEX128_VALUE = 15; + /** + *
+       * Non-IEEE floating-point format based on IEEE754 single-precision
+       * floating-point number truncated to 16 bits.
+       * This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits.
+       * 
+ * + * BFLOAT16 = 16; + */ + public static final int BFLOAT16_VALUE = 16; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static DataType valueOf(int value) { + return forNumber(value); + } + + public static DataType forNumber(int value) { + switch (value) { + case 0: return UNDEFINED; + case 1: return FLOAT; + case 2: return UINT8; + case 3: return INT8; + case 4: return UINT16; + case 5: return INT16; + case 6: return INT32; + case 7: return INT64; + case 8: return STRING; + case 9: return BOOL; + case 10: return FLOAT16; + case 11: return DOUBLE; + case 12: return UINT32; + case 13: return UINT64; + case 14: return COMPLEX64; + case 15: return COMPLEX128; + case 16: return BFLOAT16; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + DataType> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DataType findValueByNumber(int number) { + return DataType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return OnnxMl.TensorProto.getDescriptor().getEnumTypes().get(0); + } + + private static final DataType[] VALUES = values(); + + public static DataType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private DataType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:onnx.TensorProto.DataType) + } + + /** + *
+     * Location of the data for this tensor. MUST be one of:
+     * - DEFAULT - data stored inside the protobuf message. Data is stored in raw_data (if set) otherwise in type-specified field.
+     * - EXTERNAL - data stored in an external location as described by external_data field.
+     * 
+ * + * Protobuf enum {@code onnx.TensorProto.DataLocation} + */ + public enum DataLocation + implements com.google.protobuf.ProtocolMessageEnum { + /** + * DEFAULT = 0; + */ + DEFAULT(0), + /** + * EXTERNAL = 1; + */ + EXTERNAL(1), + UNRECOGNIZED(-1), + ; + + /** + * DEFAULT = 0; + */ + public static final int DEFAULT_VALUE = 0; + /** + * EXTERNAL = 1; + */ + public static final int EXTERNAL_VALUE = 1; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static DataLocation valueOf(int value) { + return forNumber(value); + } + + public static DataLocation forNumber(int value) { + switch (value) { + case 0: return DEFAULT; + case 1: return EXTERNAL; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + DataLocation> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DataLocation findValueByNumber(int number) { + return DataLocation.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return OnnxMl.TensorProto.getDescriptor().getEnumTypes().get(1); + } + + private static final DataLocation[] VALUES = values(); + + public static DataLocation valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private DataLocation(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:onnx.TensorProto.DataLocation) + } + + public interface SegmentOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TensorProto.Segment) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 begin = 1; + */ + long getBegin(); + + /** + * int64 end = 2; + */ + long getEnd(); + } + /** + *
+     * For very large tensors, we may want to store them in chunks, in which
+     * case the following fields will specify the segment that is stored in
+     * the current TensorProto.
+     * 
+ * + * Protobuf type {@code onnx.TensorProto.Segment} + */ + public static final class Segment extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TensorProto.Segment) + SegmentOrBuilder { + private static final long serialVersionUID = 0L; + // Use Segment.newBuilder() to construct. + private Segment(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Segment() { + begin_ = 0L; + end_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Segment( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + begin_ = input.readInt64(); + break; + } + case 16: { + + end_ = input.readInt64(); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorProto_Segment_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorProto_Segment_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorProto.Segment.class, OnnxMl.TensorProto.Segment.Builder.class); + } + + public static final int BEGIN_FIELD_NUMBER = 1; + private long begin_; + /** + * int64 begin = 1; + */ + public long getBegin() { + return begin_; + } + + public static final int END_FIELD_NUMBER = 2; + private long end_; + /** + * int64 end = 2; + */ + public long getEnd() { + return end_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (begin_ != 0L) { + output.writeInt64(1, begin_); + } + if (end_ != 0L) { + output.writeInt64(2, end_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (begin_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, begin_); + } + if (end_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, end_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TensorProto.Segment)) { + return super.equals(obj); + } + OnnxMl.TensorProto.Segment other = (OnnxMl.TensorProto.Segment) obj; + + boolean result = true; + result = result && (getBegin() + == other.getBegin()); + result = result && (getEnd() + == other.getEnd()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + BEGIN_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getBegin()); + hash = (37 * hash) + END_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getEnd()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TensorProto.Segment parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorProto.Segment parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorProto.Segment parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorProto.Segment parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorProto.Segment parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorProto.Segment parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorProto.Segment parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorProto.Segment parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorProto.Segment parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TensorProto.Segment parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorProto.Segment parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorProto.Segment parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TensorProto.Segment prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+       * For very large tensors, we may want to store them in chunks, in which
+       * case the following fields will specify the segment that is stored in
+       * the current TensorProto.
+       * 
+ * + * Protobuf type {@code onnx.TensorProto.Segment} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TensorProto.Segment) + OnnxMl.TensorProto.SegmentOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorProto_Segment_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorProto_Segment_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorProto.Segment.class, OnnxMl.TensorProto.Segment.Builder.class); + } + + // Construct using OnnxMlProto3.TensorProto.Segment.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + begin_ = 0L; + + end_ = 0L; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TensorProto_Segment_descriptor; + } + + @java.lang.Override + public OnnxMl.TensorProto.Segment getDefaultInstanceForType() { + return OnnxMl.TensorProto.Segment.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TensorProto.Segment build() { + OnnxMl.TensorProto.Segment result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TensorProto.Segment buildPartial() { + OnnxMl.TensorProto.Segment result = new OnnxMl.TensorProto.Segment(this); + result.begin_ = begin_; + result.end_ = end_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TensorProto.Segment) { + return mergeFrom((OnnxMl.TensorProto.Segment)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TensorProto.Segment other) { + if (other == OnnxMl.TensorProto.Segment.getDefaultInstance()) return this; + if (other.getBegin() != 0L) { + setBegin(other.getBegin()); + } + if (other.getEnd() != 0L) { + setEnd(other.getEnd()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TensorProto.Segment parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TensorProto.Segment) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long begin_ ; + /** + * int64 begin = 1; + */ + public long getBegin() { + return begin_; + } + /** + * int64 begin = 1; + */ + public Builder setBegin(long value) { + + begin_ = value; + onChanged(); + return this; + } + /** + * int64 begin = 1; + */ + public Builder clearBegin() { + + begin_ = 0L; + onChanged(); + return this; + } + + private long end_ ; + /** + * int64 end = 2; + */ + public long getEnd() { + return end_; + } + /** + * int64 end = 2; + */ + public Builder setEnd(long value) { + + end_ = value; + onChanged(); + return this; + } + /** + * int64 end = 2; + */ + public Builder clearEnd() { + + end_ = 0L; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TensorProto.Segment) + } + + // @@protoc_insertion_point(class_scope:onnx.TensorProto.Segment) + private static final OnnxMl.TensorProto.Segment DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TensorProto.Segment(); + } + + public static OnnxMl.TensorProto.Segment getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Segment parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Segment(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TensorProto.Segment getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int DIMS_FIELD_NUMBER = 1; + private java.util.List dims_; + /** + *
+     * The shape of the tensor.
+     * 
+ * + * repeated int64 dims = 1; + */ + public java.util.List + getDimsList() { + return dims_; + } + /** + *
+     * The shape of the tensor.
+     * 
+ * + * repeated int64 dims = 1; + */ + public int getDimsCount() { + return dims_.size(); + } + /** + *
+     * The shape of the tensor.
+     * 
+ * + * repeated int64 dims = 1; + */ + public long getDims(int index) { + return dims_.get(index); + } + private int dimsMemoizedSerializedSize = -1; + + public static final int DATA_TYPE_FIELD_NUMBER = 2; + private int dataType_; + /** + *
+     * The data type of the tensor.
+     * This field MUST have a valid TensorProto.DataType value
+     * 
+ * + * int32 data_type = 2; + */ + public int getDataType() { + return dataType_; + } + + public static final int SEGMENT_FIELD_NUMBER = 3; + private OnnxMl.TensorProto.Segment segment_; + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public boolean hasSegment() { + return segment_ != null; + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public OnnxMl.TensorProto.Segment getSegment() { + return segment_ == null ? OnnxMl.TensorProto.Segment.getDefaultInstance() : segment_; + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public OnnxMl.TensorProto.SegmentOrBuilder getSegmentOrBuilder() { + return getSegment(); + } + + public static final int FLOAT_DATA_FIELD_NUMBER = 4; + private java.util.List floatData_; + /** + *
+     * For float and complex64 values
+     * Complex64 tensors are encoded as a single array of floats,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+     * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public java.util.List + getFloatDataList() { + return floatData_; + } + /** + *
+     * For float and complex64 values
+     * Complex64 tensors are encoded as a single array of floats,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+     * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public int getFloatDataCount() { + return floatData_.size(); + } + /** + *
+     * For float and complex64 values
+     * Complex64 tensors are encoded as a single array of floats,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+     * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public float getFloatData(int index) { + return floatData_.get(index); + } + private int floatDataMemoizedSerializedSize = -1; + + public static final int INT32_DATA_FIELD_NUMBER = 5; + private java.util.List int32Data_; + /** + *
+     * For int32, uint8, int8, uint16, int16, bool, and float16 values
+     * float16 values must be bit-wise converted to an uint16_t prior
+     * to writing to the buffer.
+     * When this field is present, the data_type field MUST be
+     * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+     * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public java.util.List + getInt32DataList() { + return int32Data_; + } + /** + *
+     * For int32, uint8, int8, uint16, int16, bool, and float16 values
+     * float16 values must be bit-wise converted to an uint16_t prior
+     * to writing to the buffer.
+     * When this field is present, the data_type field MUST be
+     * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+     * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public int getInt32DataCount() { + return int32Data_.size(); + } + /** + *
+     * For int32, uint8, int8, uint16, int16, bool, and float16 values
+     * float16 values must be bit-wise converted to an uint16_t prior
+     * to writing to the buffer.
+     * When this field is present, the data_type field MUST be
+     * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+     * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public int getInt32Data(int index) { + return int32Data_.get(index); + } + private int int32DataMemoizedSerializedSize = -1; + + public static final int STRING_DATA_FIELD_NUMBER = 6; + private java.util.List stringData_; + /** + *
+     * For strings.
+     * Each element of string_data is a UTF-8 encoded Unicode
+     * string. No trailing null, no leading BOM. The protobuf "string"
+     * scalar type is not used to match ML community conventions.
+     * When this field is present, the data_type field MUST be STRING
+     * 
+ * + * repeated bytes string_data = 6; + */ + public java.util.List + getStringDataList() { + return stringData_; + } + /** + *
+     * For strings.
+     * Each element of string_data is a UTF-8 encoded Unicode
+     * string. No trailing null, no leading BOM. The protobuf "string"
+     * scalar type is not used to match ML community conventions.
+     * When this field is present, the data_type field MUST be STRING
+     * 
+ * + * repeated bytes string_data = 6; + */ + public int getStringDataCount() { + return stringData_.size(); + } + /** + *
+     * For strings.
+     * Each element of string_data is a UTF-8 encoded Unicode
+     * string. No trailing null, no leading BOM. The protobuf "string"
+     * scalar type is not used to match ML community conventions.
+     * When this field is present, the data_type field MUST be STRING
+     * 
+ * + * repeated bytes string_data = 6; + */ + public com.google.protobuf.ByteString getStringData(int index) { + return stringData_.get(index); + } + + public static final int INT64_DATA_FIELD_NUMBER = 7; + private java.util.List int64Data_; + /** + *
+     * For int64.
+     * When this field is present, the data_type field MUST be INT64
+     * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public java.util.List + getInt64DataList() { + return int64Data_; + } + /** + *
+     * For int64.
+     * When this field is present, the data_type field MUST be INT64
+     * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public int getInt64DataCount() { + return int64Data_.size(); + } + /** + *
+     * For int64.
+     * When this field is present, the data_type field MUST be INT64
+     * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public long getInt64Data(int index) { + return int64Data_.get(index); + } + private int int64DataMemoizedSerializedSize = -1; + + public static final int NAME_FIELD_NUMBER = 8; + private volatile java.lang.Object name_; + /** + *
+     * Optionally, a name for the tensor.
+     * 
+ * + * string name = 8; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     * Optionally, a name for the tensor.
+     * 
+ * + * string name = 8; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DOC_STRING_FIELD_NUMBER = 12; + private volatile java.lang.Object docString_; + /** + *
+     * A human-readable documentation for this tensor. Markdown is allowed.
+     * 
+ * + * string doc_string = 12; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } + } + /** + *
+     * A human-readable documentation for this tensor. Markdown is allowed.
+     * 
+ * + * string doc_string = 12; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RAW_DATA_FIELD_NUMBER = 9; + private com.google.protobuf.ByteString rawData_; + /** + *
+     * Serializations can either use one of the fields above, or use this
+     * raw bytes field. The only exception is the string case, where one is
+     * required to store the content in the repeated bytes string_data field.
+     * When this raw_data field is used to store tensor value, elements MUST
+     * be stored in as fixed-width, little-endian order.
+     * Floating-point data types MUST be stored in IEEE 754 format.
+     * Complex64 elements must be written as two consecutive FLOAT values, real component first.
+     * Complex128 elements must be written as two consecutive DOUBLE values, real component first.
+     * Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false).
+     * Note: the advantage of specific field rather than the raw_data field is
+     * that in some cases (e.g. int data), protobuf does a better packing via
+     * variable length storage, and may lead to smaller binary footprint.
+     * When this field is present, the data_type field MUST NOT be STRING or UNDEFINED
+     * 
+ * + * bytes raw_data = 9; + */ + public com.google.protobuf.ByteString getRawData() { + return rawData_; + } + + public static final int EXTERNAL_DATA_FIELD_NUMBER = 13; + private java.util.List externalData_; + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public java.util.List getExternalDataList() { + return externalData_; + } + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public java.util.List + getExternalDataOrBuilderList() { + return externalData_; + } + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public int getExternalDataCount() { + return externalData_.size(); + } + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public OnnxMl.StringStringEntryProto getExternalData(int index) { + return externalData_.get(index); + } + /** + *
+     * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+     * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+     * external_data stores key-value pairs describing data location. Recognized keys are:
+     * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+     *                           protobuf model was stored
+     * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+     *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+     * - "length" (optional) - number of bytes containing data. Integer stored as string.
+     * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+     * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public OnnxMl.StringStringEntryProtoOrBuilder getExternalDataOrBuilder( + int index) { + return externalData_.get(index); + } + + public static final int DATA_LOCATION_FIELD_NUMBER = 14; + private int dataLocation_; + /** + *
+     * If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
+     * 
+ * + * .onnx.TensorProto.DataLocation data_location = 14; + */ + public int getDataLocationValue() { + return dataLocation_; + } + /** + *
+     * If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
+     * 
+ * + * .onnx.TensorProto.DataLocation data_location = 14; + */ + public OnnxMl.TensorProto.DataLocation getDataLocation() { + @SuppressWarnings("deprecation") + OnnxMl.TensorProto.DataLocation result = OnnxMl.TensorProto.DataLocation.valueOf(dataLocation_); + return result == null ? OnnxMl.TensorProto.DataLocation.UNRECOGNIZED : result; + } + + public static final int DOUBLE_DATA_FIELD_NUMBER = 10; + private java.util.List doubleData_; + /** + *
+     * For double
+     * Complex128 tensors are encoded as a single array of doubles,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+     * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public java.util.List + getDoubleDataList() { + return doubleData_; + } + /** + *
+     * For double
+     * Complex128 tensors are encoded as a single array of doubles,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+     * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public int getDoubleDataCount() { + return doubleData_.size(); + } + /** + *
+     * For double
+     * Complex128 tensors are encoded as a single array of doubles,
+     * with the real components appearing in odd numbered positions,
+     * and the corresponding imaginary component apparing in the
+     * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+     * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+     * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+     * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public double getDoubleData(int index) { + return doubleData_.get(index); + } + private int doubleDataMemoizedSerializedSize = -1; + + public static final int UINT64_DATA_FIELD_NUMBER = 11; + private java.util.List uint64Data_; + /** + *
+     * For uint64 and uint32 values
+     * When this field is present, the data_type field MUST be
+     * UINT32 or UINT64
+     * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public java.util.List + getUint64DataList() { + return uint64Data_; + } + /** + *
+     * For uint64 and uint32 values
+     * When this field is present, the data_type field MUST be
+     * UINT32 or UINT64
+     * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public int getUint64DataCount() { + return uint64Data_.size(); + } + /** + *
+     * For uint64 and uint32 values
+     * When this field is present, the data_type field MUST be
+     * UINT32 or UINT64
+     * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public long getUint64Data(int index) { + return uint64Data_.get(index); + } + private int uint64DataMemoizedSerializedSize = -1; + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (getDimsList().size() > 0) { + output.writeUInt32NoTag(10); + output.writeUInt32NoTag(dimsMemoizedSerializedSize); + } + for (int i = 0; i < dims_.size(); i++) { + output.writeInt64NoTag(dims_.get(i)); + } + if (dataType_ != 0) { + output.writeInt32(2, dataType_); + } + if (segment_ != null) { + output.writeMessage(3, getSegment()); + } + if (getFloatDataList().size() > 0) { + output.writeUInt32NoTag(34); + output.writeUInt32NoTag(floatDataMemoizedSerializedSize); + } + for (int i = 0; i < floatData_.size(); i++) { + output.writeFloatNoTag(floatData_.get(i)); + } + if (getInt32DataList().size() > 0) { + output.writeUInt32NoTag(42); + output.writeUInt32NoTag(int32DataMemoizedSerializedSize); + } + for (int i = 0; i < int32Data_.size(); i++) { + output.writeInt32NoTag(int32Data_.get(i)); + } + for (int i = 0; i < stringData_.size(); i++) { + output.writeBytes(6, stringData_.get(i)); + } + if (getInt64DataList().size() > 0) { + output.writeUInt32NoTag(58); + output.writeUInt32NoTag(int64DataMemoizedSerializedSize); + } + for (int i = 0; i < int64Data_.size(); i++) { + output.writeInt64NoTag(int64Data_.get(i)); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, name_); + } + if (!rawData_.isEmpty()) { + output.writeBytes(9, rawData_); + } + if (getDoubleDataList().size() > 0) { + output.writeUInt32NoTag(82); + output.writeUInt32NoTag(doubleDataMemoizedSerializedSize); + } + for (int i = 0; i < doubleData_.size(); i++) { + output.writeDoubleNoTag(doubleData_.get(i)); + } + if (getUint64DataList().size() > 0) { + output.writeUInt32NoTag(90); + output.writeUInt32NoTag(uint64DataMemoizedSerializedSize); + } + for (int i = 0; i < uint64Data_.size(); i++) { + output.writeUInt64NoTag(uint64Data_.get(i)); + } + if (!getDocStringBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 12, docString_); + } + for (int i = 0; i < externalData_.size(); i++) { + output.writeMessage(13, externalData_.get(i)); + } + if (dataLocation_ != OnnxMl.TensorProto.DataLocation.DEFAULT.getNumber()) { + output.writeEnum(14, dataLocation_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < dims_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeInt64SizeNoTag(dims_.get(i)); + } + size += dataSize; + if (!getDimsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + dimsMemoizedSerializedSize = dataSize; + } + if (dataType_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, dataType_); + } + if (segment_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getSegment()); + } + { + int dataSize = 0; + dataSize = 4 * getFloatDataList().size(); + size += dataSize; + if (!getFloatDataList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + floatDataMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + for (int i = 0; i < int32Data_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(int32Data_.get(i)); + } + size += dataSize; + if (!getInt32DataList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + int32DataMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + for (int i = 0; i < stringData_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeBytesSizeNoTag(stringData_.get(i)); + } + size += dataSize; + size += 1 * getStringDataList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < int64Data_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeInt64SizeNoTag(int64Data_.get(i)); + } + size += dataSize; + if (!getInt64DataList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + int64DataMemoizedSerializedSize = dataSize; + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, name_); + } + if (!rawData_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(9, rawData_); + } + { + int dataSize = 0; + dataSize = 8 * getDoubleDataList().size(); + size += dataSize; + if (!getDoubleDataList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + doubleDataMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + for (int i = 0; i < uint64Data_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeUInt64SizeNoTag(uint64Data_.get(i)); + } + size += dataSize; + if (!getUint64DataList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + uint64DataMemoizedSerializedSize = dataSize; + } + if (!getDocStringBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(12, docString_); + } + for (int i = 0; i < externalData_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(13, externalData_.get(i)); + } + if (dataLocation_ != OnnxMl.TensorProto.DataLocation.DEFAULT.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(14, dataLocation_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TensorProto)) { + return super.equals(obj); + } + OnnxMl.TensorProto other = (OnnxMl.TensorProto) obj; + + boolean result = true; + result = result && getDimsList() + .equals(other.getDimsList()); + result = result && (getDataType() + == other.getDataType()); + result = result && (hasSegment() == other.hasSegment()); + if (hasSegment()) { + result = result && getSegment() + .equals(other.getSegment()); + } + result = result && getFloatDataList() + .equals(other.getFloatDataList()); + result = result && getInt32DataList() + .equals(other.getInt32DataList()); + result = result && getStringDataList() + .equals(other.getStringDataList()); + result = result && getInt64DataList() + .equals(other.getInt64DataList()); + result = result && getName() + .equals(other.getName()); + result = result && getDocString() + .equals(other.getDocString()); + result = result && getRawData() + .equals(other.getRawData()); + result = result && getExternalDataList() + .equals(other.getExternalDataList()); + result = result && dataLocation_ == other.dataLocation_; + result = result && getDoubleDataList() + .equals(other.getDoubleDataList()); + result = result && getUint64DataList() + .equals(other.getUint64DataList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDimsCount() > 0) { + hash = (37 * hash) + DIMS_FIELD_NUMBER; + hash = (53 * hash) + getDimsList().hashCode(); + } + hash = (37 * hash) + DATA_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getDataType(); + if (hasSegment()) { + hash = (37 * hash) + SEGMENT_FIELD_NUMBER; + hash = (53 * hash) + getSegment().hashCode(); + } + if (getFloatDataCount() > 0) { + hash = (37 * hash) + FLOAT_DATA_FIELD_NUMBER; + hash = (53 * hash) + getFloatDataList().hashCode(); + } + if (getInt32DataCount() > 0) { + hash = (37 * hash) + INT32_DATA_FIELD_NUMBER; + hash = (53 * hash) + getInt32DataList().hashCode(); + } + if (getStringDataCount() > 0) { + hash = (37 * hash) + STRING_DATA_FIELD_NUMBER; + hash = (53 * hash) + getStringDataList().hashCode(); + } + if (getInt64DataCount() > 0) { + hash = (37 * hash) + INT64_DATA_FIELD_NUMBER; + hash = (53 * hash) + getInt64DataList().hashCode(); + } + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + DOC_STRING_FIELD_NUMBER; + hash = (53 * hash) + getDocString().hashCode(); + hash = (37 * hash) + RAW_DATA_FIELD_NUMBER; + hash = (53 * hash) + getRawData().hashCode(); + if (getExternalDataCount() > 0) { + hash = (37 * hash) + EXTERNAL_DATA_FIELD_NUMBER; + hash = (53 * hash) + getExternalDataList().hashCode(); + } + hash = (37 * hash) + DATA_LOCATION_FIELD_NUMBER; + hash = (53 * hash) + dataLocation_; + if (getDoubleDataCount() > 0) { + hash = (37 * hash) + DOUBLE_DATA_FIELD_NUMBER; + hash = (53 * hash) + getDoubleDataList().hashCode(); + } + if (getUint64DataCount() > 0) { + hash = (37 * hash) + UINT64_DATA_FIELD_NUMBER; + hash = (53 * hash) + getUint64DataList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TensorProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TensorProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TensorProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Tensors
+     * A serialized tensor value.
+     * 
+ * + * Protobuf type {@code onnx.TensorProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TensorProto) + OnnxMl.TensorProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorProto.class, OnnxMl.TensorProto.Builder.class); + } + + // Construct using OnnxMlProto3.TensorProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getExternalDataFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + dims_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + dataType_ = 0; + + if (segmentBuilder_ == null) { + segment_ = null; + } else { + segment_ = null; + segmentBuilder_ = null; + } + floatData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + int32Data_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + stringData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + int64Data_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + name_ = ""; + + docString_ = ""; + + rawData_ = com.google.protobuf.ByteString.EMPTY; + + if (externalDataBuilder_ == null) { + externalData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000400); + } else { + externalDataBuilder_.clear(); + } + dataLocation_ = 0; + + doubleData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00001000); + uint64Data_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00002000); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TensorProto_descriptor; + } + + @java.lang.Override + public OnnxMl.TensorProto getDefaultInstanceForType() { + return OnnxMl.TensorProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TensorProto build() { + OnnxMl.TensorProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TensorProto buildPartial() { + OnnxMl.TensorProto result = new OnnxMl.TensorProto(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + dims_ = java.util.Collections.unmodifiableList(dims_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.dims_ = dims_; + result.dataType_ = dataType_; + if (segmentBuilder_ == null) { + result.segment_ = segment_; + } else { + result.segment_ = segmentBuilder_.build(); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + floatData_ = java.util.Collections.unmodifiableList(floatData_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.floatData_ = floatData_; + if (((bitField0_ & 0x00000010) == 0x00000010)) { + int32Data_ = java.util.Collections.unmodifiableList(int32Data_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.int32Data_ = int32Data_; + if (((bitField0_ & 0x00000020) == 0x00000020)) { + stringData_ = java.util.Collections.unmodifiableList(stringData_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.stringData_ = stringData_; + if (((bitField0_ & 0x00000040) == 0x00000040)) { + int64Data_ = java.util.Collections.unmodifiableList(int64Data_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.int64Data_ = int64Data_; + result.name_ = name_; + result.docString_ = docString_; + result.rawData_ = rawData_; + if (externalDataBuilder_ == null) { + if (((bitField0_ & 0x00000400) == 0x00000400)) { + externalData_ = java.util.Collections.unmodifiableList(externalData_); + bitField0_ = (bitField0_ & ~0x00000400); + } + result.externalData_ = externalData_; + } else { + result.externalData_ = externalDataBuilder_.build(); + } + result.dataLocation_ = dataLocation_; + if (((bitField0_ & 0x00001000) == 0x00001000)) { + doubleData_ = java.util.Collections.unmodifiableList(doubleData_); + bitField0_ = (bitField0_ & ~0x00001000); + } + result.doubleData_ = doubleData_; + if (((bitField0_ & 0x00002000) == 0x00002000)) { + uint64Data_ = java.util.Collections.unmodifiableList(uint64Data_); + bitField0_ = (bitField0_ & ~0x00002000); + } + result.uint64Data_ = uint64Data_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TensorProto) { + return mergeFrom((OnnxMl.TensorProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TensorProto other) { + if (other == OnnxMl.TensorProto.getDefaultInstance()) return this; + if (!other.dims_.isEmpty()) { + if (dims_.isEmpty()) { + dims_ = other.dims_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureDimsIsMutable(); + dims_.addAll(other.dims_); + } + onChanged(); + } + if (other.getDataType() != 0) { + setDataType(other.getDataType()); + } + if (other.hasSegment()) { + mergeSegment(other.getSegment()); + } + if (!other.floatData_.isEmpty()) { + if (floatData_.isEmpty()) { + floatData_ = other.floatData_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureFloatDataIsMutable(); + floatData_.addAll(other.floatData_); + } + onChanged(); + } + if (!other.int32Data_.isEmpty()) { + if (int32Data_.isEmpty()) { + int32Data_ = other.int32Data_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureInt32DataIsMutable(); + int32Data_.addAll(other.int32Data_); + } + onChanged(); + } + if (!other.stringData_.isEmpty()) { + if (stringData_.isEmpty()) { + stringData_ = other.stringData_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureStringDataIsMutable(); + stringData_.addAll(other.stringData_); + } + onChanged(); + } + if (!other.int64Data_.isEmpty()) { + if (int64Data_.isEmpty()) { + int64Data_ = other.int64Data_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensureInt64DataIsMutable(); + int64Data_.addAll(other.int64Data_); + } + onChanged(); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getDocString().isEmpty()) { + docString_ = other.docString_; + onChanged(); + } + if (other.getRawData() != com.google.protobuf.ByteString.EMPTY) { + setRawData(other.getRawData()); + } + if (externalDataBuilder_ == null) { + if (!other.externalData_.isEmpty()) { + if (externalData_.isEmpty()) { + externalData_ = other.externalData_; + bitField0_ = (bitField0_ & ~0x00000400); + } else { + ensureExternalDataIsMutable(); + externalData_.addAll(other.externalData_); + } + onChanged(); + } + } else { + if (!other.externalData_.isEmpty()) { + if (externalDataBuilder_.isEmpty()) { + externalDataBuilder_.dispose(); + externalDataBuilder_ = null; + externalData_ = other.externalData_; + bitField0_ = (bitField0_ & ~0x00000400); + externalDataBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getExternalDataFieldBuilder() : null; + } else { + externalDataBuilder_.addAllMessages(other.externalData_); + } + } + } + if (other.dataLocation_ != 0) { + setDataLocationValue(other.getDataLocationValue()); + } + if (!other.doubleData_.isEmpty()) { + if (doubleData_.isEmpty()) { + doubleData_ = other.doubleData_; + bitField0_ = (bitField0_ & ~0x00001000); + } else { + ensureDoubleDataIsMutable(); + doubleData_.addAll(other.doubleData_); + } + onChanged(); + } + if (!other.uint64Data_.isEmpty()) { + if (uint64Data_.isEmpty()) { + uint64Data_ = other.uint64Data_; + bitField0_ = (bitField0_ & ~0x00002000); + } else { + ensureUint64DataIsMutable(); + uint64Data_.addAll(other.uint64Data_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TensorProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TensorProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List dims_ = java.util.Collections.emptyList(); + private void ensureDimsIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + dims_ = new java.util.ArrayList(dims_); + bitField0_ |= 0x00000001; + } + } + /** + *
+       * The shape of the tensor.
+       * 
+ * + * repeated int64 dims = 1; + */ + public java.util.List + getDimsList() { + return java.util.Collections.unmodifiableList(dims_); + } + /** + *
+       * The shape of the tensor.
+       * 
+ * + * repeated int64 dims = 1; + */ + public int getDimsCount() { + return dims_.size(); + } + /** + *
+       * The shape of the tensor.
+       * 
+ * + * repeated int64 dims = 1; + */ + public long getDims(int index) { + return dims_.get(index); + } + /** + *
+       * The shape of the tensor.
+       * 
+ * + * repeated int64 dims = 1; + */ + public Builder setDims( + int index, long value) { + ensureDimsIsMutable(); + dims_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * The shape of the tensor.
+       * 
+ * + * repeated int64 dims = 1; + */ + public Builder addDims(long value) { + ensureDimsIsMutable(); + dims_.add(value); + onChanged(); + return this; + } + /** + *
+       * The shape of the tensor.
+       * 
+ * + * repeated int64 dims = 1; + */ + public Builder addAllDims( + java.lang.Iterable values) { + ensureDimsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, dims_); + onChanged(); + return this; + } + /** + *
+       * The shape of the tensor.
+       * 
+ * + * repeated int64 dims = 1; + */ + public Builder clearDims() { + dims_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + private int dataType_ ; + /** + *
+       * The data type of the tensor.
+       * This field MUST have a valid TensorProto.DataType value
+       * 
+ * + * int32 data_type = 2; + */ + public int getDataType() { + return dataType_; + } + /** + *
+       * The data type of the tensor.
+       * This field MUST have a valid TensorProto.DataType value
+       * 
+ * + * int32 data_type = 2; + */ + public Builder setDataType(int value) { + + dataType_ = value; + onChanged(); + return this; + } + /** + *
+       * The data type of the tensor.
+       * This field MUST have a valid TensorProto.DataType value
+       * 
+ * + * int32 data_type = 2; + */ + public Builder clearDataType() { + + dataType_ = 0; + onChanged(); + return this; + } + + private OnnxMl.TensorProto.Segment segment_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto.Segment, OnnxMl.TensorProto.Segment.Builder, OnnxMl.TensorProto.SegmentOrBuilder> segmentBuilder_; + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public boolean hasSegment() { + return segmentBuilder_ != null || segment_ != null; + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public OnnxMl.TensorProto.Segment getSegment() { + if (segmentBuilder_ == null) { + return segment_ == null ? OnnxMl.TensorProto.Segment.getDefaultInstance() : segment_; + } else { + return segmentBuilder_.getMessage(); + } + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public Builder setSegment(OnnxMl.TensorProto.Segment value) { + if (segmentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + segment_ = value; + onChanged(); + } else { + segmentBuilder_.setMessage(value); + } + + return this; + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public Builder setSegment( + OnnxMl.TensorProto.Segment.Builder builderForValue) { + if (segmentBuilder_ == null) { + segment_ = builderForValue.build(); + onChanged(); + } else { + segmentBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public Builder mergeSegment(OnnxMl.TensorProto.Segment value) { + if (segmentBuilder_ == null) { + if (segment_ != null) { + segment_ = + OnnxMl.TensorProto.Segment.newBuilder(segment_).mergeFrom(value).buildPartial(); + } else { + segment_ = value; + } + onChanged(); + } else { + segmentBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public Builder clearSegment() { + if (segmentBuilder_ == null) { + segment_ = null; + onChanged(); + } else { + segment_ = null; + segmentBuilder_ = null; + } + + return this; + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public OnnxMl.TensorProto.Segment.Builder getSegmentBuilder() { + + onChanged(); + return getSegmentFieldBuilder().getBuilder(); + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + public OnnxMl.TensorProto.SegmentOrBuilder getSegmentOrBuilder() { + if (segmentBuilder_ != null) { + return segmentBuilder_.getMessageOrBuilder(); + } else { + return segment_ == null ? + OnnxMl.TensorProto.Segment.getDefaultInstance() : segment_; + } + } + /** + * .onnx.TensorProto.Segment segment = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto.Segment, OnnxMl.TensorProto.Segment.Builder, OnnxMl.TensorProto.SegmentOrBuilder> + getSegmentFieldBuilder() { + if (segmentBuilder_ == null) { + segmentBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto.Segment, OnnxMl.TensorProto.Segment.Builder, OnnxMl.TensorProto.SegmentOrBuilder>( + getSegment(), + getParentForChildren(), + isClean()); + segment_ = null; + } + return segmentBuilder_; + } + + private java.util.List floatData_ = java.util.Collections.emptyList(); + private void ensureFloatDataIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + floatData_ = new java.util.ArrayList(floatData_); + bitField0_ |= 0x00000008; + } + } + /** + *
+       * For float and complex64 values
+       * Complex64 tensors are encoded as a single array of floats,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+       * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public java.util.List + getFloatDataList() { + return java.util.Collections.unmodifiableList(floatData_); + } + /** + *
+       * For float and complex64 values
+       * Complex64 tensors are encoded as a single array of floats,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+       * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public int getFloatDataCount() { + return floatData_.size(); + } + /** + *
+       * For float and complex64 values
+       * Complex64 tensors are encoded as a single array of floats,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+       * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public float getFloatData(int index) { + return floatData_.get(index); + } + /** + *
+       * For float and complex64 values
+       * Complex64 tensors are encoded as a single array of floats,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+       * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public Builder setFloatData( + int index, float value) { + ensureFloatDataIsMutable(); + floatData_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * For float and complex64 values
+       * Complex64 tensors are encoded as a single array of floats,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+       * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public Builder addFloatData(float value) { + ensureFloatDataIsMutable(); + floatData_.add(value); + onChanged(); + return this; + } + /** + *
+       * For float and complex64 values
+       * Complex64 tensors are encoded as a single array of floats,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+       * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public Builder addAllFloatData( + java.lang.Iterable values) { + ensureFloatDataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, floatData_); + onChanged(); + return this; + } + /** + *
+       * For float and complex64 values
+       * Complex64 tensors are encoded as a single array of floats,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
+       * 
+ * + * repeated float float_data = 4 [packed = true]; + */ + public Builder clearFloatData() { + floatData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + private java.util.List int32Data_ = java.util.Collections.emptyList(); + private void ensureInt32DataIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + int32Data_ = new java.util.ArrayList(int32Data_); + bitField0_ |= 0x00000010; + } + } + /** + *
+       * For int32, uint8, int8, uint16, int16, bool, and float16 values
+       * float16 values must be bit-wise converted to an uint16_t prior
+       * to writing to the buffer.
+       * When this field is present, the data_type field MUST be
+       * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+       * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public java.util.List + getInt32DataList() { + return java.util.Collections.unmodifiableList(int32Data_); + } + /** + *
+       * For int32, uint8, int8, uint16, int16, bool, and float16 values
+       * float16 values must be bit-wise converted to an uint16_t prior
+       * to writing to the buffer.
+       * When this field is present, the data_type field MUST be
+       * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+       * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public int getInt32DataCount() { + return int32Data_.size(); + } + /** + *
+       * For int32, uint8, int8, uint16, int16, bool, and float16 values
+       * float16 values must be bit-wise converted to an uint16_t prior
+       * to writing to the buffer.
+       * When this field is present, the data_type field MUST be
+       * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+       * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public int getInt32Data(int index) { + return int32Data_.get(index); + } + /** + *
+       * For int32, uint8, int8, uint16, int16, bool, and float16 values
+       * float16 values must be bit-wise converted to an uint16_t prior
+       * to writing to the buffer.
+       * When this field is present, the data_type field MUST be
+       * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+       * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public Builder setInt32Data( + int index, int value) { + ensureInt32DataIsMutable(); + int32Data_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * For int32, uint8, int8, uint16, int16, bool, and float16 values
+       * float16 values must be bit-wise converted to an uint16_t prior
+       * to writing to the buffer.
+       * When this field is present, the data_type field MUST be
+       * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+       * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public Builder addInt32Data(int value) { + ensureInt32DataIsMutable(); + int32Data_.add(value); + onChanged(); + return this; + } + /** + *
+       * For int32, uint8, int8, uint16, int16, bool, and float16 values
+       * float16 values must be bit-wise converted to an uint16_t prior
+       * to writing to the buffer.
+       * When this field is present, the data_type field MUST be
+       * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+       * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public Builder addAllInt32Data( + java.lang.Iterable values) { + ensureInt32DataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, int32Data_); + onChanged(); + return this; + } + /** + *
+       * For int32, uint8, int8, uint16, int16, bool, and float16 values
+       * float16 values must be bit-wise converted to an uint16_t prior
+       * to writing to the buffer.
+       * When this field is present, the data_type field MUST be
+       * INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
+       * 
+ * + * repeated int32 int32_data = 5 [packed = true]; + */ + public Builder clearInt32Data() { + int32Data_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + private java.util.List stringData_ = java.util.Collections.emptyList(); + private void ensureStringDataIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + stringData_ = new java.util.ArrayList(stringData_); + bitField0_ |= 0x00000020; + } + } + /** + *
+       * For strings.
+       * Each element of string_data is a UTF-8 encoded Unicode
+       * string. No trailing null, no leading BOM. The protobuf "string"
+       * scalar type is not used to match ML community conventions.
+       * When this field is present, the data_type field MUST be STRING
+       * 
+ * + * repeated bytes string_data = 6; + */ + public java.util.List + getStringDataList() { + return java.util.Collections.unmodifiableList(stringData_); + } + /** + *
+       * For strings.
+       * Each element of string_data is a UTF-8 encoded Unicode
+       * string. No trailing null, no leading BOM. The protobuf "string"
+       * scalar type is not used to match ML community conventions.
+       * When this field is present, the data_type field MUST be STRING
+       * 
+ * + * repeated bytes string_data = 6; + */ + public int getStringDataCount() { + return stringData_.size(); + } + /** + *
+       * For strings.
+       * Each element of string_data is a UTF-8 encoded Unicode
+       * string. No trailing null, no leading BOM. The protobuf "string"
+       * scalar type is not used to match ML community conventions.
+       * When this field is present, the data_type field MUST be STRING
+       * 
+ * + * repeated bytes string_data = 6; + */ + public com.google.protobuf.ByteString getStringData(int index) { + return stringData_.get(index); + } + /** + *
+       * For strings.
+       * Each element of string_data is a UTF-8 encoded Unicode
+       * string. No trailing null, no leading BOM. The protobuf "string"
+       * scalar type is not used to match ML community conventions.
+       * When this field is present, the data_type field MUST be STRING
+       * 
+ * + * repeated bytes string_data = 6; + */ + public Builder setStringData( + int index, com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureStringDataIsMutable(); + stringData_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * For strings.
+       * Each element of string_data is a UTF-8 encoded Unicode
+       * string. No trailing null, no leading BOM. The protobuf "string"
+       * scalar type is not used to match ML community conventions.
+       * When this field is present, the data_type field MUST be STRING
+       * 
+ * + * repeated bytes string_data = 6; + */ + public Builder addStringData(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + ensureStringDataIsMutable(); + stringData_.add(value); + onChanged(); + return this; + } + /** + *
+       * For strings.
+       * Each element of string_data is a UTF-8 encoded Unicode
+       * string. No trailing null, no leading BOM. The protobuf "string"
+       * scalar type is not used to match ML community conventions.
+       * When this field is present, the data_type field MUST be STRING
+       * 
+ * + * repeated bytes string_data = 6; + */ + public Builder addAllStringData( + java.lang.Iterable values) { + ensureStringDataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, stringData_); + onChanged(); + return this; + } + /** + *
+       * For strings.
+       * Each element of string_data is a UTF-8 encoded Unicode
+       * string. No trailing null, no leading BOM. The protobuf "string"
+       * scalar type is not used to match ML community conventions.
+       * When this field is present, the data_type field MUST be STRING
+       * 
+ * + * repeated bytes string_data = 6; + */ + public Builder clearStringData() { + stringData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + return this; + } + + private java.util.List int64Data_ = java.util.Collections.emptyList(); + private void ensureInt64DataIsMutable() { + if (!((bitField0_ & 0x00000040) == 0x00000040)) { + int64Data_ = new java.util.ArrayList(int64Data_); + bitField0_ |= 0x00000040; + } + } + /** + *
+       * For int64.
+       * When this field is present, the data_type field MUST be INT64
+       * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public java.util.List + getInt64DataList() { + return java.util.Collections.unmodifiableList(int64Data_); + } + /** + *
+       * For int64.
+       * When this field is present, the data_type field MUST be INT64
+       * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public int getInt64DataCount() { + return int64Data_.size(); + } + /** + *
+       * For int64.
+       * When this field is present, the data_type field MUST be INT64
+       * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public long getInt64Data(int index) { + return int64Data_.get(index); + } + /** + *
+       * For int64.
+       * When this field is present, the data_type field MUST be INT64
+       * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public Builder setInt64Data( + int index, long value) { + ensureInt64DataIsMutable(); + int64Data_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * For int64.
+       * When this field is present, the data_type field MUST be INT64
+       * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public Builder addInt64Data(long value) { + ensureInt64DataIsMutable(); + int64Data_.add(value); + onChanged(); + return this; + } + /** + *
+       * For int64.
+       * When this field is present, the data_type field MUST be INT64
+       * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public Builder addAllInt64Data( + java.lang.Iterable values) { + ensureInt64DataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, int64Data_); + onChanged(); + return this; + } + /** + *
+       * For int64.
+       * When this field is present, the data_type field MUST be INT64
+       * 
+ * + * repeated int64 int64_data = 7 [packed = true]; + */ + public Builder clearInt64Data() { + int64Data_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + /** + *
+       * Optionally, a name for the tensor.
+       * 
+ * + * string name = 8; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * Optionally, a name for the tensor.
+       * 
+ * + * string name = 8; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * Optionally, a name for the tensor.
+       * 
+ * + * string name = 8; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       * Optionally, a name for the tensor.
+       * 
+ * + * string name = 8; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       * Optionally, a name for the tensor.
+       * 
+ * + * string name = 8; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object docString_ = ""; + /** + *
+       * A human-readable documentation for this tensor. Markdown is allowed.
+       * 
+ * + * string doc_string = 12; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * A human-readable documentation for this tensor. Markdown is allowed.
+       * 
+ * + * string doc_string = 12; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * A human-readable documentation for this tensor. Markdown is allowed.
+       * 
+ * + * string doc_string = 12; + */ + public Builder setDocString( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + docString_ = value; + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this tensor. Markdown is allowed.
+       * 
+ * + * string doc_string = 12; + */ + public Builder clearDocString() { + + docString_ = getDefaultInstance().getDocString(); + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this tensor. Markdown is allowed.
+       * 
+ * + * string doc_string = 12; + */ + public Builder setDocStringBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + docString_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString rawData_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+       * Serializations can either use one of the fields above, or use this
+       * raw bytes field. The only exception is the string case, where one is
+       * required to store the content in the repeated bytes string_data field.
+       * When this raw_data field is used to store tensor value, elements MUST
+       * be stored in as fixed-width, little-endian order.
+       * Floating-point data types MUST be stored in IEEE 754 format.
+       * Complex64 elements must be written as two consecutive FLOAT values, real component first.
+       * Complex128 elements must be written as two consecutive DOUBLE values, real component first.
+       * Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false).
+       * Note: the advantage of specific field rather than the raw_data field is
+       * that in some cases (e.g. int data), protobuf does a better packing via
+       * variable length storage, and may lead to smaller binary footprint.
+       * When this field is present, the data_type field MUST NOT be STRING or UNDEFINED
+       * 
+ * + * bytes raw_data = 9; + */ + public com.google.protobuf.ByteString getRawData() { + return rawData_; + } + /** + *
+       * Serializations can either use one of the fields above, or use this
+       * raw bytes field. The only exception is the string case, where one is
+       * required to store the content in the repeated bytes string_data field.
+       * When this raw_data field is used to store tensor value, elements MUST
+       * be stored in as fixed-width, little-endian order.
+       * Floating-point data types MUST be stored in IEEE 754 format.
+       * Complex64 elements must be written as two consecutive FLOAT values, real component first.
+       * Complex128 elements must be written as two consecutive DOUBLE values, real component first.
+       * Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false).
+       * Note: the advantage of specific field rather than the raw_data field is
+       * that in some cases (e.g. int data), protobuf does a better packing via
+       * variable length storage, and may lead to smaller binary footprint.
+       * When this field is present, the data_type field MUST NOT be STRING or UNDEFINED
+       * 
+ * + * bytes raw_data = 9; + */ + public Builder setRawData(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + rawData_ = value; + onChanged(); + return this; + } + /** + *
+       * Serializations can either use one of the fields above, or use this
+       * raw bytes field. The only exception is the string case, where one is
+       * required to store the content in the repeated bytes string_data field.
+       * When this raw_data field is used to store tensor value, elements MUST
+       * be stored in as fixed-width, little-endian order.
+       * Floating-point data types MUST be stored in IEEE 754 format.
+       * Complex64 elements must be written as two consecutive FLOAT values, real component first.
+       * Complex128 elements must be written as two consecutive DOUBLE values, real component first.
+       * Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false).
+       * Note: the advantage of specific field rather than the raw_data field is
+       * that in some cases (e.g. int data), protobuf does a better packing via
+       * variable length storage, and may lead to smaller binary footprint.
+       * When this field is present, the data_type field MUST NOT be STRING or UNDEFINED
+       * 
+ * + * bytes raw_data = 9; + */ + public Builder clearRawData() { + + rawData_ = getDefaultInstance().getRawData(); + onChanged(); + return this; + } + + private java.util.List externalData_ = + java.util.Collections.emptyList(); + private void ensureExternalDataIsMutable() { + if (!((bitField0_ & 0x00000400) == 0x00000400)) { + externalData_ = new java.util.ArrayList(externalData_); + bitField0_ |= 0x00000400; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.StringStringEntryProto, OnnxMl.StringStringEntryProto.Builder, OnnxMl.StringStringEntryProtoOrBuilder> externalDataBuilder_; + + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public java.util.List getExternalDataList() { + if (externalDataBuilder_ == null) { + return java.util.Collections.unmodifiableList(externalData_); + } else { + return externalDataBuilder_.getMessageList(); + } + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public int getExternalDataCount() { + if (externalDataBuilder_ == null) { + return externalData_.size(); + } else { + return externalDataBuilder_.getCount(); + } + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public OnnxMl.StringStringEntryProto getExternalData(int index) { + if (externalDataBuilder_ == null) { + return externalData_.get(index); + } else { + return externalDataBuilder_.getMessage(index); + } + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public Builder setExternalData( + int index, OnnxMl.StringStringEntryProto value) { + if (externalDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureExternalDataIsMutable(); + externalData_.set(index, value); + onChanged(); + } else { + externalDataBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public Builder setExternalData( + int index, OnnxMl.StringStringEntryProto.Builder builderForValue) { + if (externalDataBuilder_ == null) { + ensureExternalDataIsMutable(); + externalData_.set(index, builderForValue.build()); + onChanged(); + } else { + externalDataBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public Builder addExternalData(OnnxMl.StringStringEntryProto value) { + if (externalDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureExternalDataIsMutable(); + externalData_.add(value); + onChanged(); + } else { + externalDataBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public Builder addExternalData( + int index, OnnxMl.StringStringEntryProto value) { + if (externalDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureExternalDataIsMutable(); + externalData_.add(index, value); + onChanged(); + } else { + externalDataBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public Builder addExternalData( + OnnxMl.StringStringEntryProto.Builder builderForValue) { + if (externalDataBuilder_ == null) { + ensureExternalDataIsMutable(); + externalData_.add(builderForValue.build()); + onChanged(); + } else { + externalDataBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public Builder addExternalData( + int index, OnnxMl.StringStringEntryProto.Builder builderForValue) { + if (externalDataBuilder_ == null) { + ensureExternalDataIsMutable(); + externalData_.add(index, builderForValue.build()); + onChanged(); + } else { + externalDataBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public Builder addAllExternalData( + java.lang.Iterable values) { + if (externalDataBuilder_ == null) { + ensureExternalDataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, externalData_); + onChanged(); + } else { + externalDataBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public Builder clearExternalData() { + if (externalDataBuilder_ == null) { + externalData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000400); + onChanged(); + } else { + externalDataBuilder_.clear(); + } + return this; + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public Builder removeExternalData(int index) { + if (externalDataBuilder_ == null) { + ensureExternalDataIsMutable(); + externalData_.remove(index); + onChanged(); + } else { + externalDataBuilder_.remove(index); + } + return this; + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public OnnxMl.StringStringEntryProto.Builder getExternalDataBuilder( + int index) { + return getExternalDataFieldBuilder().getBuilder(index); + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public OnnxMl.StringStringEntryProtoOrBuilder getExternalDataOrBuilder( + int index) { + if (externalDataBuilder_ == null) { + return externalData_.get(index); } else { + return externalDataBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public java.util.List + getExternalDataOrBuilderList() { + if (externalDataBuilder_ != null) { + return externalDataBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(externalData_); + } + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public OnnxMl.StringStringEntryProto.Builder addExternalDataBuilder() { + return getExternalDataFieldBuilder().addBuilder( + OnnxMl.StringStringEntryProto.getDefaultInstance()); + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public OnnxMl.StringStringEntryProto.Builder addExternalDataBuilder( + int index) { + return getExternalDataFieldBuilder().addBuilder( + index, OnnxMl.StringStringEntryProto.getDefaultInstance()); + } + /** + *
+       * Data can be stored inside the protobuf file using type-specific fields or raw_data.
+       * Alternatively, raw bytes data can be stored in an external file, using the external_data field.
+       * external_data stores key-value pairs describing data location. Recognized keys are:
+       * - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
+       *                           protobuf model was stored
+       * - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
+       *                         Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
+       * - "length" (optional) - number of bytes containing data. Integer stored as string.
+       * - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
+       * 
+ * + * repeated .onnx.StringStringEntryProto external_data = 13; + */ + public java.util.List + getExternalDataBuilderList() { + return getExternalDataFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.StringStringEntryProto, OnnxMl.StringStringEntryProto.Builder, OnnxMl.StringStringEntryProtoOrBuilder> + getExternalDataFieldBuilder() { + if (externalDataBuilder_ == null) { + externalDataBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.StringStringEntryProto, OnnxMl.StringStringEntryProto.Builder, OnnxMl.StringStringEntryProtoOrBuilder>( + externalData_, + ((bitField0_ & 0x00000400) == 0x00000400), + getParentForChildren(), + isClean()); + externalData_ = null; + } + return externalDataBuilder_; + } + + private int dataLocation_ = 0; + /** + *
+       * If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
+       * 
+ * + * .onnx.TensorProto.DataLocation data_location = 14; + */ + public int getDataLocationValue() { + return dataLocation_; + } + /** + *
+       * If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
+       * 
+ * + * .onnx.TensorProto.DataLocation data_location = 14; + */ + public Builder setDataLocationValue(int value) { + dataLocation_ = value; + onChanged(); + return this; + } + /** + *
+       * If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
+       * 
+ * + * .onnx.TensorProto.DataLocation data_location = 14; + */ + public OnnxMl.TensorProto.DataLocation getDataLocation() { + @SuppressWarnings("deprecation") + OnnxMl.TensorProto.DataLocation result = OnnxMl.TensorProto.DataLocation.valueOf(dataLocation_); + return result == null ? OnnxMl.TensorProto.DataLocation.UNRECOGNIZED : result; + } + /** + *
+       * If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
+       * 
+ * + * .onnx.TensorProto.DataLocation data_location = 14; + */ + public Builder setDataLocation(OnnxMl.TensorProto.DataLocation value) { + if (value == null) { + throw new NullPointerException(); + } + + dataLocation_ = value.getNumber(); + onChanged(); + return this; + } + /** + *
+       * If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
+       * 
+ * + * .onnx.TensorProto.DataLocation data_location = 14; + */ + public Builder clearDataLocation() { + + dataLocation_ = 0; + onChanged(); + return this; + } + + private java.util.List doubleData_ = java.util.Collections.emptyList(); + private void ensureDoubleDataIsMutable() { + if (!((bitField0_ & 0x00001000) == 0x00001000)) { + doubleData_ = new java.util.ArrayList(doubleData_); + bitField0_ |= 0x00001000; + } + } + /** + *
+       * For double
+       * Complex128 tensors are encoded as a single array of doubles,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+       * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public java.util.List + getDoubleDataList() { + return java.util.Collections.unmodifiableList(doubleData_); + } + /** + *
+       * For double
+       * Complex128 tensors are encoded as a single array of doubles,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+       * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public int getDoubleDataCount() { + return doubleData_.size(); + } + /** + *
+       * For double
+       * Complex128 tensors are encoded as a single array of doubles,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+       * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public double getDoubleData(int index) { + return doubleData_.get(index); + } + /** + *
+       * For double
+       * Complex128 tensors are encoded as a single array of doubles,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+       * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public Builder setDoubleData( + int index, double value) { + ensureDoubleDataIsMutable(); + doubleData_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * For double
+       * Complex128 tensors are encoded as a single array of doubles,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+       * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public Builder addDoubleData(double value) { + ensureDoubleDataIsMutable(); + doubleData_.add(value); + onChanged(); + return this; + } + /** + *
+       * For double
+       * Complex128 tensors are encoded as a single array of doubles,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+       * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public Builder addAllDoubleData( + java.lang.Iterable values) { + ensureDoubleDataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, doubleData_); + onChanged(); + return this; + } + /** + *
+       * For double
+       * Complex128 tensors are encoded as a single array of doubles,
+       * with the real components appearing in odd numbered positions,
+       * and the corresponding imaginary component apparing in the
+       * subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
+       * is encoded as [1.0, 2.0 ,3.0 ,4.0]
+       * When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
+       * 
+ * + * repeated double double_data = 10 [packed = true]; + */ + public Builder clearDoubleData() { + doubleData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00001000); + onChanged(); + return this; + } + + private java.util.List uint64Data_ = java.util.Collections.emptyList(); + private void ensureUint64DataIsMutable() { + if (!((bitField0_ & 0x00002000) == 0x00002000)) { + uint64Data_ = new java.util.ArrayList(uint64Data_); + bitField0_ |= 0x00002000; + } + } + /** + *
+       * For uint64 and uint32 values
+       * When this field is present, the data_type field MUST be
+       * UINT32 or UINT64
+       * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public java.util.List + getUint64DataList() { + return java.util.Collections.unmodifiableList(uint64Data_); + } + /** + *
+       * For uint64 and uint32 values
+       * When this field is present, the data_type field MUST be
+       * UINT32 or UINT64
+       * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public int getUint64DataCount() { + return uint64Data_.size(); + } + /** + *
+       * For uint64 and uint32 values
+       * When this field is present, the data_type field MUST be
+       * UINT32 or UINT64
+       * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public long getUint64Data(int index) { + return uint64Data_.get(index); + } + /** + *
+       * For uint64 and uint32 values
+       * When this field is present, the data_type field MUST be
+       * UINT32 or UINT64
+       * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public Builder setUint64Data( + int index, long value) { + ensureUint64DataIsMutable(); + uint64Data_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * For uint64 and uint32 values
+       * When this field is present, the data_type field MUST be
+       * UINT32 or UINT64
+       * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public Builder addUint64Data(long value) { + ensureUint64DataIsMutable(); + uint64Data_.add(value); + onChanged(); + return this; + } + /** + *
+       * For uint64 and uint32 values
+       * When this field is present, the data_type field MUST be
+       * UINT32 or UINT64
+       * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public Builder addAllUint64Data( + java.lang.Iterable values) { + ensureUint64DataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, uint64Data_); + onChanged(); + return this; + } + /** + *
+       * For uint64 and uint32 values
+       * When this field is present, the data_type field MUST be
+       * UINT32 or UINT64
+       * 
+ * + * repeated uint64 uint64_data = 11 [packed = true]; + */ + public Builder clearUint64Data() { + uint64Data_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00002000); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TensorProto) + } + + // @@protoc_insertion_point(class_scope:onnx.TensorProto) + private static final OnnxMl.TensorProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TensorProto(); + } + + public static OnnxMl.TensorProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TensorProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TensorProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TensorProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SparseTensorProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.SparseTensorProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+     * The default-value is zero for numeric tensors, and empty-string for string tensors.
+     * 
+ * + * .onnx.TensorProto values = 1; + */ + boolean hasValues(); + /** + *
+     * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+     * The default-value is zero for numeric tensors, and empty-string for string tensors.
+     * 
+ * + * .onnx.TensorProto values = 1; + */ + OnnxMl.TensorProto getValues(); + /** + *
+     * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+     * The default-value is zero for numeric tensors, and empty-string for string tensors.
+     * 
+ * + * .onnx.TensorProto values = 1; + */ + OnnxMl.TensorProtoOrBuilder getValuesOrBuilder(); + + /** + *
+     * The indices of the non-default values, which may be stored in one of two formats.
+     * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+     * corresponding to the j-th index of the i-th value (in the values tensor).
+     * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+     * must be the linearized-index of the i-th value (in the values tensor).
+     * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+     * using the shape provided below.
+     * The indices must appear in ascending order without duplication.
+     * In the first format, the ordering is lexicographic-ordering:
+     * e.g., index-value [1,4] must appear before [2,1]
+     * 
+ * + * .onnx.TensorProto indices = 2; + */ + boolean hasIndices(); + /** + *
+     * The indices of the non-default values, which may be stored in one of two formats.
+     * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+     * corresponding to the j-th index of the i-th value (in the values tensor).
+     * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+     * must be the linearized-index of the i-th value (in the values tensor).
+     * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+     * using the shape provided below.
+     * The indices must appear in ascending order without duplication.
+     * In the first format, the ordering is lexicographic-ordering:
+     * e.g., index-value [1,4] must appear before [2,1]
+     * 
+ * + * .onnx.TensorProto indices = 2; + */ + OnnxMl.TensorProto getIndices(); + /** + *
+     * The indices of the non-default values, which may be stored in one of two formats.
+     * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+     * corresponding to the j-th index of the i-th value (in the values tensor).
+     * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+     * must be the linearized-index of the i-th value (in the values tensor).
+     * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+     * using the shape provided below.
+     * The indices must appear in ascending order without duplication.
+     * In the first format, the ordering is lexicographic-ordering:
+     * e.g., index-value [1,4] must appear before [2,1]
+     * 
+ * + * .onnx.TensorProto indices = 2; + */ + OnnxMl.TensorProtoOrBuilder getIndicesOrBuilder(); + + /** + *
+     * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+     * 
+ * + * repeated int64 dims = 3; + */ + java.util.List getDimsList(); + /** + *
+     * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+     * 
+ * + * repeated int64 dims = 3; + */ + int getDimsCount(); + /** + *
+     * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+     * 
+ * + * repeated int64 dims = 3; + */ + long getDims(int index); + } + /** + *
+   * A serialized sparse-tensor value
+   * 
+ * + * Protobuf type {@code onnx.SparseTensorProto} + */ + public static final class SparseTensorProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.SparseTensorProto) + SparseTensorProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use SparseTensorProto.newBuilder() to construct. + private SparseTensorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SparseTensorProto() { + dims_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SparseTensorProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + OnnxMl.TensorProto.Builder subBuilder = null; + if (values_ != null) { + subBuilder = values_.toBuilder(); + } + values_ = input.readMessage(OnnxMl.TensorProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(values_); + values_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + OnnxMl.TensorProto.Builder subBuilder = null; + if (indices_ != null) { + subBuilder = indices_.toBuilder(); + } + indices_ = input.readMessage(OnnxMl.TensorProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(indices_); + indices_ = subBuilder.buildPartial(); + } + + break; + } + case 24: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + dims_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + dims_.add(input.readInt64()); + break; + } + case 26: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004) && input.getBytesUntilLimit() > 0) { + dims_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + while (input.getBytesUntilLimit() > 0) { + dims_.add(input.readInt64()); + } + input.popLimit(limit); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + dims_ = java.util.Collections.unmodifiableList(dims_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_SparseTensorProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_SparseTensorProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.SparseTensorProto.class, OnnxMl.SparseTensorProto.Builder.class); + } + + private int bitField0_; + public static final int VALUES_FIELD_NUMBER = 1; + private OnnxMl.TensorProto values_; + /** + *
+     * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+     * The default-value is zero for numeric tensors, and empty-string for string tensors.
+     * 
+ * + * .onnx.TensorProto values = 1; + */ + public boolean hasValues() { + return values_ != null; + } + /** + *
+     * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+     * The default-value is zero for numeric tensors, and empty-string for string tensors.
+     * 
+ * + * .onnx.TensorProto values = 1; + */ + public OnnxMl.TensorProto getValues() { + return values_ == null ? OnnxMl.TensorProto.getDefaultInstance() : values_; + } + /** + *
+     * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+     * The default-value is zero for numeric tensors, and empty-string for string tensors.
+     * 
+ * + * .onnx.TensorProto values = 1; + */ + public OnnxMl.TensorProtoOrBuilder getValuesOrBuilder() { + return getValues(); + } + + public static final int INDICES_FIELD_NUMBER = 2; + private OnnxMl.TensorProto indices_; + /** + *
+     * The indices of the non-default values, which may be stored in one of two formats.
+     * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+     * corresponding to the j-th index of the i-th value (in the values tensor).
+     * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+     * must be the linearized-index of the i-th value (in the values tensor).
+     * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+     * using the shape provided below.
+     * The indices must appear in ascending order without duplication.
+     * In the first format, the ordering is lexicographic-ordering:
+     * e.g., index-value [1,4] must appear before [2,1]
+     * 
+ * + * .onnx.TensorProto indices = 2; + */ + public boolean hasIndices() { + return indices_ != null; + } + /** + *
+     * The indices of the non-default values, which may be stored in one of two formats.
+     * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+     * corresponding to the j-th index of the i-th value (in the values tensor).
+     * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+     * must be the linearized-index of the i-th value (in the values tensor).
+     * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+     * using the shape provided below.
+     * The indices must appear in ascending order without duplication.
+     * In the first format, the ordering is lexicographic-ordering:
+     * e.g., index-value [1,4] must appear before [2,1]
+     * 
+ * + * .onnx.TensorProto indices = 2; + */ + public OnnxMl.TensorProto getIndices() { + return indices_ == null ? OnnxMl.TensorProto.getDefaultInstance() : indices_; + } + /** + *
+     * The indices of the non-default values, which may be stored in one of two formats.
+     * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+     * corresponding to the j-th index of the i-th value (in the values tensor).
+     * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+     * must be the linearized-index of the i-th value (in the values tensor).
+     * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+     * using the shape provided below.
+     * The indices must appear in ascending order without duplication.
+     * In the first format, the ordering is lexicographic-ordering:
+     * e.g., index-value [1,4] must appear before [2,1]
+     * 
+ * + * .onnx.TensorProto indices = 2; + */ + public OnnxMl.TensorProtoOrBuilder getIndicesOrBuilder() { + return getIndices(); + } + + public static final int DIMS_FIELD_NUMBER = 3; + private java.util.List dims_; + /** + *
+     * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+     * 
+ * + * repeated int64 dims = 3; + */ + public java.util.List + getDimsList() { + return dims_; + } + /** + *
+     * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+     * 
+ * + * repeated int64 dims = 3; + */ + public int getDimsCount() { + return dims_.size(); + } + /** + *
+     * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+     * 
+ * + * repeated int64 dims = 3; + */ + public long getDims(int index) { + return dims_.get(index); + } + private int dimsMemoizedSerializedSize = -1; + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (values_ != null) { + output.writeMessage(1, getValues()); + } + if (indices_ != null) { + output.writeMessage(2, getIndices()); + } + if (getDimsList().size() > 0) { + output.writeUInt32NoTag(26); + output.writeUInt32NoTag(dimsMemoizedSerializedSize); + } + for (int i = 0; i < dims_.size(); i++) { + output.writeInt64NoTag(dims_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (values_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getValues()); + } + if (indices_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getIndices()); + } + { + int dataSize = 0; + for (int i = 0; i < dims_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeInt64SizeNoTag(dims_.get(i)); + } + size += dataSize; + if (!getDimsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + dimsMemoizedSerializedSize = dataSize; + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.SparseTensorProto)) { + return super.equals(obj); + } + OnnxMl.SparseTensorProto other = (OnnxMl.SparseTensorProto) obj; + + boolean result = true; + result = result && (hasValues() == other.hasValues()); + if (hasValues()) { + result = result && getValues() + .equals(other.getValues()); + } + result = result && (hasIndices() == other.hasIndices()); + if (hasIndices()) { + result = result && getIndices() + .equals(other.getIndices()); + } + result = result && getDimsList() + .equals(other.getDimsList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasValues()) { + hash = (37 * hash) + VALUES_FIELD_NUMBER; + hash = (53 * hash) + getValues().hashCode(); + } + if (hasIndices()) { + hash = (37 * hash) + INDICES_FIELD_NUMBER; + hash = (53 * hash) + getIndices().hashCode(); + } + if (getDimsCount() > 0) { + hash = (37 * hash) + DIMS_FIELD_NUMBER; + hash = (53 * hash) + getDimsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.SparseTensorProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.SparseTensorProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.SparseTensorProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.SparseTensorProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.SparseTensorProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.SparseTensorProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.SparseTensorProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.SparseTensorProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.SparseTensorProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.SparseTensorProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.SparseTensorProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.SparseTensorProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.SparseTensorProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * A serialized sparse-tensor value
+     * 
+ * + * Protobuf type {@code onnx.SparseTensorProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.SparseTensorProto) + OnnxMl.SparseTensorProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_SparseTensorProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_SparseTensorProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.SparseTensorProto.class, OnnxMl.SparseTensorProto.Builder.class); + } + + // Construct using OnnxMlProto3.SparseTensorProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (valuesBuilder_ == null) { + values_ = null; + } else { + values_ = null; + valuesBuilder_ = null; + } + if (indicesBuilder_ == null) { + indices_ = null; + } else { + indices_ = null; + indicesBuilder_ = null; + } + dims_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_SparseTensorProto_descriptor; + } + + @java.lang.Override + public OnnxMl.SparseTensorProto getDefaultInstanceForType() { + return OnnxMl.SparseTensorProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.SparseTensorProto build() { + OnnxMl.SparseTensorProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.SparseTensorProto buildPartial() { + OnnxMl.SparseTensorProto result = new OnnxMl.SparseTensorProto(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (valuesBuilder_ == null) { + result.values_ = values_; + } else { + result.values_ = valuesBuilder_.build(); + } + if (indicesBuilder_ == null) { + result.indices_ = indices_; + } else { + result.indices_ = indicesBuilder_.build(); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + dims_ = java.util.Collections.unmodifiableList(dims_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.dims_ = dims_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.SparseTensorProto) { + return mergeFrom((OnnxMl.SparseTensorProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.SparseTensorProto other) { + if (other == OnnxMl.SparseTensorProto.getDefaultInstance()) return this; + if (other.hasValues()) { + mergeValues(other.getValues()); + } + if (other.hasIndices()) { + mergeIndices(other.getIndices()); + } + if (!other.dims_.isEmpty()) { + if (dims_.isEmpty()) { + dims_ = other.dims_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureDimsIsMutable(); + dims_.addAll(other.dims_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.SparseTensorProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.SparseTensorProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private OnnxMl.TensorProto values_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> valuesBuilder_; + /** + *
+       * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+       * The default-value is zero for numeric tensors, and empty-string for string tensors.
+       * 
+ * + * .onnx.TensorProto values = 1; + */ + public boolean hasValues() { + return valuesBuilder_ != null || values_ != null; + } + /** + *
+       * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+       * The default-value is zero for numeric tensors, and empty-string for string tensors.
+       * 
+ * + * .onnx.TensorProto values = 1; + */ + public OnnxMl.TensorProto getValues() { + if (valuesBuilder_ == null) { + return values_ == null ? OnnxMl.TensorProto.getDefaultInstance() : values_; + } else { + return valuesBuilder_.getMessage(); + } + } + /** + *
+       * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+       * The default-value is zero for numeric tensors, and empty-string for string tensors.
+       * 
+ * + * .onnx.TensorProto values = 1; + */ + public Builder setValues(OnnxMl.TensorProto value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + values_ = value; + onChanged(); + } else { + valuesBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+       * The default-value is zero for numeric tensors, and empty-string for string tensors.
+       * 
+ * + * .onnx.TensorProto values = 1; + */ + public Builder setValues( + OnnxMl.TensorProto.Builder builderForValue) { + if (valuesBuilder_ == null) { + values_ = builderForValue.build(); + onChanged(); + } else { + valuesBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+       * The default-value is zero for numeric tensors, and empty-string for string tensors.
+       * 
+ * + * .onnx.TensorProto values = 1; + */ + public Builder mergeValues(OnnxMl.TensorProto value) { + if (valuesBuilder_ == null) { + if (values_ != null) { + values_ = + OnnxMl.TensorProto.newBuilder(values_).mergeFrom(value).buildPartial(); + } else { + values_ = value; + } + onChanged(); + } else { + valuesBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+       * The default-value is zero for numeric tensors, and empty-string for string tensors.
+       * 
+ * + * .onnx.TensorProto values = 1; + */ + public Builder clearValues() { + if (valuesBuilder_ == null) { + values_ = null; + onChanged(); + } else { + values_ = null; + valuesBuilder_ = null; + } + + return this; + } + /** + *
+       * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+       * The default-value is zero for numeric tensors, and empty-string for string tensors.
+       * 
+ * + * .onnx.TensorProto values = 1; + */ + public OnnxMl.TensorProto.Builder getValuesBuilder() { + + onChanged(); + return getValuesFieldBuilder().getBuilder(); + } + /** + *
+       * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+       * The default-value is zero for numeric tensors, and empty-string for string tensors.
+       * 
+ * + * .onnx.TensorProto values = 1; + */ + public OnnxMl.TensorProtoOrBuilder getValuesOrBuilder() { + if (valuesBuilder_ != null) { + return valuesBuilder_.getMessageOrBuilder(); + } else { + return values_ == null ? + OnnxMl.TensorProto.getDefaultInstance() : values_; + } + } + /** + *
+       * The sequence of non-default values are encoded as a tensor of shape [NNZ].
+       * The default-value is zero for numeric tensors, and empty-string for string tensors.
+       * 
+ * + * .onnx.TensorProto values = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> + getValuesFieldBuilder() { + if (valuesBuilder_ == null) { + valuesBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder>( + getValues(), + getParentForChildren(), + isClean()); + values_ = null; + } + return valuesBuilder_; + } + + private OnnxMl.TensorProto indices_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> indicesBuilder_; + /** + *
+       * The indices of the non-default values, which may be stored in one of two formats.
+       * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+       * corresponding to the j-th index of the i-th value (in the values tensor).
+       * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+       * must be the linearized-index of the i-th value (in the values tensor).
+       * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+       * using the shape provided below.
+       * The indices must appear in ascending order without duplication.
+       * In the first format, the ordering is lexicographic-ordering:
+       * e.g., index-value [1,4] must appear before [2,1]
+       * 
+ * + * .onnx.TensorProto indices = 2; + */ + public boolean hasIndices() { + return indicesBuilder_ != null || indices_ != null; + } + /** + *
+       * The indices of the non-default values, which may be stored in one of two formats.
+       * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+       * corresponding to the j-th index of the i-th value (in the values tensor).
+       * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+       * must be the linearized-index of the i-th value (in the values tensor).
+       * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+       * using the shape provided below.
+       * The indices must appear in ascending order without duplication.
+       * In the first format, the ordering is lexicographic-ordering:
+       * e.g., index-value [1,4] must appear before [2,1]
+       * 
+ * + * .onnx.TensorProto indices = 2; + */ + public OnnxMl.TensorProto getIndices() { + if (indicesBuilder_ == null) { + return indices_ == null ? OnnxMl.TensorProto.getDefaultInstance() : indices_; + } else { + return indicesBuilder_.getMessage(); + } + } + /** + *
+       * The indices of the non-default values, which may be stored in one of two formats.
+       * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+       * corresponding to the j-th index of the i-th value (in the values tensor).
+       * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+       * must be the linearized-index of the i-th value (in the values tensor).
+       * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+       * using the shape provided below.
+       * The indices must appear in ascending order without duplication.
+       * In the first format, the ordering is lexicographic-ordering:
+       * e.g., index-value [1,4] must appear before [2,1]
+       * 
+ * + * .onnx.TensorProto indices = 2; + */ + public Builder setIndices(OnnxMl.TensorProto value) { + if (indicesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + indices_ = value; + onChanged(); + } else { + indicesBuilder_.setMessage(value); + } + + return this; + } + /** + *
+       * The indices of the non-default values, which may be stored in one of two formats.
+       * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+       * corresponding to the j-th index of the i-th value (in the values tensor).
+       * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+       * must be the linearized-index of the i-th value (in the values tensor).
+       * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+       * using the shape provided below.
+       * The indices must appear in ascending order without duplication.
+       * In the first format, the ordering is lexicographic-ordering:
+       * e.g., index-value [1,4] must appear before [2,1]
+       * 
+ * + * .onnx.TensorProto indices = 2; + */ + public Builder setIndices( + OnnxMl.TensorProto.Builder builderForValue) { + if (indicesBuilder_ == null) { + indices_ = builderForValue.build(); + onChanged(); + } else { + indicesBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+       * The indices of the non-default values, which may be stored in one of two formats.
+       * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+       * corresponding to the j-th index of the i-th value (in the values tensor).
+       * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+       * must be the linearized-index of the i-th value (in the values tensor).
+       * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+       * using the shape provided below.
+       * The indices must appear in ascending order without duplication.
+       * In the first format, the ordering is lexicographic-ordering:
+       * e.g., index-value [1,4] must appear before [2,1]
+       * 
+ * + * .onnx.TensorProto indices = 2; + */ + public Builder mergeIndices(OnnxMl.TensorProto value) { + if (indicesBuilder_ == null) { + if (indices_ != null) { + indices_ = + OnnxMl.TensorProto.newBuilder(indices_).mergeFrom(value).buildPartial(); + } else { + indices_ = value; + } + onChanged(); + } else { + indicesBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+       * The indices of the non-default values, which may be stored in one of two formats.
+       * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+       * corresponding to the j-th index of the i-th value (in the values tensor).
+       * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+       * must be the linearized-index of the i-th value (in the values tensor).
+       * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+       * using the shape provided below.
+       * The indices must appear in ascending order without duplication.
+       * In the first format, the ordering is lexicographic-ordering:
+       * e.g., index-value [1,4] must appear before [2,1]
+       * 
+ * + * .onnx.TensorProto indices = 2; + */ + public Builder clearIndices() { + if (indicesBuilder_ == null) { + indices_ = null; + onChanged(); + } else { + indices_ = null; + indicesBuilder_ = null; + } + + return this; + } + /** + *
+       * The indices of the non-default values, which may be stored in one of two formats.
+       * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+       * corresponding to the j-th index of the i-th value (in the values tensor).
+       * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+       * must be the linearized-index of the i-th value (in the values tensor).
+       * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+       * using the shape provided below.
+       * The indices must appear in ascending order without duplication.
+       * In the first format, the ordering is lexicographic-ordering:
+       * e.g., index-value [1,4] must appear before [2,1]
+       * 
+ * + * .onnx.TensorProto indices = 2; + */ + public OnnxMl.TensorProto.Builder getIndicesBuilder() { + + onChanged(); + return getIndicesFieldBuilder().getBuilder(); + } + /** + *
+       * The indices of the non-default values, which may be stored in one of two formats.
+       * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+       * corresponding to the j-th index of the i-th value (in the values tensor).
+       * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+       * must be the linearized-index of the i-th value (in the values tensor).
+       * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+       * using the shape provided below.
+       * The indices must appear in ascending order without duplication.
+       * In the first format, the ordering is lexicographic-ordering:
+       * e.g., index-value [1,4] must appear before [2,1]
+       * 
+ * + * .onnx.TensorProto indices = 2; + */ + public OnnxMl.TensorProtoOrBuilder getIndicesOrBuilder() { + if (indicesBuilder_ != null) { + return indicesBuilder_.getMessageOrBuilder(); + } else { + return indices_ == null ? + OnnxMl.TensorProto.getDefaultInstance() : indices_; + } + } + /** + *
+       * The indices of the non-default values, which may be stored in one of two formats.
+       * (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
+       * corresponding to the j-th index of the i-th value (in the values tensor).
+       * (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
+       * must be the linearized-index of the i-th value (in the values tensor).
+       * The linearized-index can be converted into an index tuple (k_1,...,k_rank)
+       * using the shape provided below.
+       * The indices must appear in ascending order without duplication.
+       * In the first format, the ordering is lexicographic-ordering:
+       * e.g., index-value [1,4] must appear before [2,1]
+       * 
+ * + * .onnx.TensorProto indices = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder> + getIndicesFieldBuilder() { + if (indicesBuilder_ == null) { + indicesBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorProto, OnnxMl.TensorProto.Builder, OnnxMl.TensorProtoOrBuilder>( + getIndices(), + getParentForChildren(), + isClean()); + indices_ = null; + } + return indicesBuilder_; + } + + private java.util.List dims_ = java.util.Collections.emptyList(); + private void ensureDimsIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + dims_ = new java.util.ArrayList(dims_); + bitField0_ |= 0x00000004; + } + } + /** + *
+       * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+       * 
+ * + * repeated int64 dims = 3; + */ + public java.util.List + getDimsList() { + return java.util.Collections.unmodifiableList(dims_); + } + /** + *
+       * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+       * 
+ * + * repeated int64 dims = 3; + */ + public int getDimsCount() { + return dims_.size(); + } + /** + *
+       * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+       * 
+ * + * repeated int64 dims = 3; + */ + public long getDims(int index) { + return dims_.get(index); + } + /** + *
+       * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+       * 
+ * + * repeated int64 dims = 3; + */ + public Builder setDims( + int index, long value) { + ensureDimsIsMutable(); + dims_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+       * 
+ * + * repeated int64 dims = 3; + */ + public Builder addDims(long value) { + ensureDimsIsMutable(); + dims_.add(value); + onChanged(); + return this; + } + /** + *
+       * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+       * 
+ * + * repeated int64 dims = 3; + */ + public Builder addAllDims( + java.lang.Iterable values) { + ensureDimsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, dims_); + onChanged(); + return this; + } + /** + *
+       * The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
+       * 
+ * + * repeated int64 dims = 3; + */ + public Builder clearDims() { + dims_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.SparseTensorProto) + } + + // @@protoc_insertion_point(class_scope:onnx.SparseTensorProto) + private static final OnnxMl.SparseTensorProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.SparseTensorProto(); + } + + public static OnnxMl.SparseTensorProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SparseTensorProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SparseTensorProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.SparseTensorProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TensorShapeProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TensorShapeProto) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + java.util.List + getDimList(); + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + OnnxMl.TensorShapeProto.Dimension getDim(int index); + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + int getDimCount(); + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + java.util.List + getDimOrBuilderList(); + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + OnnxMl.TensorShapeProto.DimensionOrBuilder getDimOrBuilder( + int index); + } + /** + *
+   * Defines a tensor shape. A dimension can be either an integer value
+   * or a symbolic variable. A symbolic variable represents an unknown
+   * dimension.
+   * 
+ * + * Protobuf type {@code onnx.TensorShapeProto} + */ + public static final class TensorShapeProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TensorShapeProto) + TensorShapeProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use TensorShapeProto.newBuilder() to construct. + private TensorShapeProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TensorShapeProto() { + dim_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TensorShapeProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + dim_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + dim_.add( + input.readMessage(OnnxMl.TensorShapeProto.Dimension.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + dim_ = java.util.Collections.unmodifiableList(dim_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorShapeProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorShapeProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorShapeProto.class, OnnxMl.TensorShapeProto.Builder.class); + } + + public interface DimensionOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TensorShapeProto.Dimension) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 dim_value = 1; + */ + long getDimValue(); + + /** + *
+       * namespace Shape
+       * 
+ * + * string dim_param = 2; + */ + java.lang.String getDimParam(); + /** + *
+       * namespace Shape
+       * 
+ * + * string dim_param = 2; + */ + com.google.protobuf.ByteString + getDimParamBytes(); + + /** + *
+       * Standard denotation can optionally be used to denote tensor
+       * dimensions with standard semantic descriptions to ensure
+       * that operations are applied to the correct axis of a tensor.
+       * Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
+       * for pre-defined dimension denotations.
+       * 
+ * + * string denotation = 3; + */ + java.lang.String getDenotation(); + /** + *
+       * Standard denotation can optionally be used to denote tensor
+       * dimensions with standard semantic descriptions to ensure
+       * that operations are applied to the correct axis of a tensor.
+       * Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
+       * for pre-defined dimension denotations.
+       * 
+ * + * string denotation = 3; + */ + com.google.protobuf.ByteString + getDenotationBytes(); + + public OnnxMl.TensorShapeProto.Dimension.ValueCase getValueCase(); + } + /** + * Protobuf type {@code onnx.TensorShapeProto.Dimension} + */ + public static final class Dimension extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TensorShapeProto.Dimension) + DimensionOrBuilder { + private static final long serialVersionUID = 0L; + // Use Dimension.newBuilder() to construct. + private Dimension(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Dimension() { + denotation_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Dimension( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + valueCase_ = 1; + value_ = input.readInt64(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + valueCase_ = 2; + value_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + denotation_ = s; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorShapeProto_Dimension_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorShapeProto_Dimension_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorShapeProto.Dimension.class, OnnxMl.TensorShapeProto.Dimension.Builder.class); + } + + private int valueCase_ = 0; + private java.lang.Object value_; + public enum ValueCase + implements com.google.protobuf.Internal.EnumLite { + DIM_VALUE(1), + DIM_PARAM(2), + VALUE_NOT_SET(0); + private final int value; + private ValueCase(int value) { + this.value = value; + } + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ValueCase valueOf(int value) { + return forNumber(value); + } + + public static ValueCase forNumber(int value) { + switch (value) { + case 1: return DIM_VALUE; + case 2: return DIM_PARAM; + case 0: return VALUE_NOT_SET; + default: return null; + } + } + public int getNumber() { + return this.value; + } + }; + + public ValueCase + getValueCase() { + return ValueCase.forNumber( + valueCase_); + } + + public static final int DIM_VALUE_FIELD_NUMBER = 1; + /** + * int64 dim_value = 1; + */ + public long getDimValue() { + if (valueCase_ == 1) { + return (java.lang.Long) value_; + } + return 0L; + } + + public static final int DIM_PARAM_FIELD_NUMBER = 2; + /** + *
+       * namespace Shape
+       * 
+ * + * string dim_param = 2; + */ + public java.lang.String getDimParam() { + java.lang.Object ref = ""; + if (valueCase_ == 2) { + ref = value_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueCase_ == 2) { + value_ = s; + } + return s; + } + } + /** + *
+       * namespace Shape
+       * 
+ * + * string dim_param = 2; + */ + public com.google.protobuf.ByteString + getDimParamBytes() { + java.lang.Object ref = ""; + if (valueCase_ == 2) { + ref = value_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (valueCase_ == 2) { + value_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DENOTATION_FIELD_NUMBER = 3; + private volatile java.lang.Object denotation_; + /** + *
+       * Standard denotation can optionally be used to denote tensor
+       * dimensions with standard semantic descriptions to ensure
+       * that operations are applied to the correct axis of a tensor.
+       * Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
+       * for pre-defined dimension denotations.
+       * 
+ * + * string denotation = 3; + */ + public java.lang.String getDenotation() { + java.lang.Object ref = denotation_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + denotation_ = s; + return s; + } + } + /** + *
+       * Standard denotation can optionally be used to denote tensor
+       * dimensions with standard semantic descriptions to ensure
+       * that operations are applied to the correct axis of a tensor.
+       * Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
+       * for pre-defined dimension denotations.
+       * 
+ * + * string denotation = 3; + */ + public com.google.protobuf.ByteString + getDenotationBytes() { + java.lang.Object ref = denotation_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + denotation_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (valueCase_ == 1) { + output.writeInt64( + 1, (long)((java.lang.Long) value_)); + } + if (valueCase_ == 2) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, value_); + } + if (!getDenotationBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, denotation_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (valueCase_ == 1) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size( + 1, (long)((java.lang.Long) value_)); + } + if (valueCase_ == 2) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, value_); + } + if (!getDenotationBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, denotation_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TensorShapeProto.Dimension)) { + return super.equals(obj); + } + OnnxMl.TensorShapeProto.Dimension other = (OnnxMl.TensorShapeProto.Dimension) obj; + + boolean result = true; + result = result && getDenotation() + .equals(other.getDenotation()); + result = result && getValueCase().equals( + other.getValueCase()); + if (!result) return false; + switch (valueCase_) { + case 1: + result = result && (getDimValue() + == other.getDimValue()); + break; + case 2: + result = result && getDimParam() + .equals(other.getDimParam()); + break; + case 0: + default: + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DENOTATION_FIELD_NUMBER; + hash = (53 * hash) + getDenotation().hashCode(); + switch (valueCase_) { + case 1: + hash = (37 * hash) + DIM_VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getDimValue()); + break; + case 2: + hash = (37 * hash) + DIM_PARAM_FIELD_NUMBER; + hash = (53 * hash) + getDimParam().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TensorShapeProto.Dimension parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorShapeProto.Dimension parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorShapeProto.Dimension parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorShapeProto.Dimension parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorShapeProto.Dimension parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorShapeProto.Dimension parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorShapeProto.Dimension parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorShapeProto.Dimension parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorShapeProto.Dimension parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TensorShapeProto.Dimension parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorShapeProto.Dimension parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorShapeProto.Dimension parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TensorShapeProto.Dimension prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code onnx.TensorShapeProto.Dimension} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TensorShapeProto.Dimension) + OnnxMl.TensorShapeProto.DimensionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorShapeProto_Dimension_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorShapeProto_Dimension_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorShapeProto.Dimension.class, OnnxMl.TensorShapeProto.Dimension.Builder.class); + } + + // Construct using OnnxMlProto3.TensorShapeProto.Dimension.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + denotation_ = ""; + + valueCase_ = 0; + value_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TensorShapeProto_Dimension_descriptor; + } + + @java.lang.Override + public OnnxMl.TensorShapeProto.Dimension getDefaultInstanceForType() { + return OnnxMl.TensorShapeProto.Dimension.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TensorShapeProto.Dimension build() { + OnnxMl.TensorShapeProto.Dimension result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TensorShapeProto.Dimension buildPartial() { + OnnxMl.TensorShapeProto.Dimension result = new OnnxMl.TensorShapeProto.Dimension(this); + if (valueCase_ == 1) { + result.value_ = value_; + } + if (valueCase_ == 2) { + result.value_ = value_; + } + result.denotation_ = denotation_; + result.valueCase_ = valueCase_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TensorShapeProto.Dimension) { + return mergeFrom((OnnxMl.TensorShapeProto.Dimension)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TensorShapeProto.Dimension other) { + if (other == OnnxMl.TensorShapeProto.Dimension.getDefaultInstance()) return this; + if (!other.getDenotation().isEmpty()) { + denotation_ = other.denotation_; + onChanged(); + } + switch (other.getValueCase()) { + case DIM_VALUE: { + setDimValue(other.getDimValue()); + break; + } + case DIM_PARAM: { + valueCase_ = 2; + value_ = other.value_; + onChanged(); + break; + } + case VALUE_NOT_SET: { + break; + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TensorShapeProto.Dimension parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TensorShapeProto.Dimension) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int valueCase_ = 0; + private java.lang.Object value_; + public ValueCase + getValueCase() { + return ValueCase.forNumber( + valueCase_); + } + + public Builder clearValue() { + valueCase_ = 0; + value_ = null; + onChanged(); + return this; + } + + + /** + * int64 dim_value = 1; + */ + public long getDimValue() { + if (valueCase_ == 1) { + return (java.lang.Long) value_; + } + return 0L; + } + /** + * int64 dim_value = 1; + */ + public Builder setDimValue(long value) { + valueCase_ = 1; + value_ = value; + onChanged(); + return this; + } + /** + * int64 dim_value = 1; + */ + public Builder clearDimValue() { + if (valueCase_ == 1) { + valueCase_ = 0; + value_ = null; + onChanged(); + } + return this; + } + + /** + *
+         * namespace Shape
+         * 
+ * + * string dim_param = 2; + */ + public java.lang.String getDimParam() { + java.lang.Object ref = ""; + if (valueCase_ == 2) { + ref = value_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueCase_ == 2) { + value_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+         * namespace Shape
+         * 
+ * + * string dim_param = 2; + */ + public com.google.protobuf.ByteString + getDimParamBytes() { + java.lang.Object ref = ""; + if (valueCase_ == 2) { + ref = value_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + if (valueCase_ == 2) { + value_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+         * namespace Shape
+         * 
+ * + * string dim_param = 2; + */ + public Builder setDimParam( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + valueCase_ = 2; + value_ = value; + onChanged(); + return this; + } + /** + *
+         * namespace Shape
+         * 
+ * + * string dim_param = 2; + */ + public Builder clearDimParam() { + if (valueCase_ == 2) { + valueCase_ = 0; + value_ = null; + onChanged(); + } + return this; + } + /** + *
+         * namespace Shape
+         * 
+ * + * string dim_param = 2; + */ + public Builder setDimParamBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + valueCase_ = 2; + value_ = value; + onChanged(); + return this; + } + + private java.lang.Object denotation_ = ""; + /** + *
+         * Standard denotation can optionally be used to denote tensor
+         * dimensions with standard semantic descriptions to ensure
+         * that operations are applied to the correct axis of a tensor.
+         * Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
+         * for pre-defined dimension denotations.
+         * 
+ * + * string denotation = 3; + */ + public java.lang.String getDenotation() { + java.lang.Object ref = denotation_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + denotation_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+         * Standard denotation can optionally be used to denote tensor
+         * dimensions with standard semantic descriptions to ensure
+         * that operations are applied to the correct axis of a tensor.
+         * Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
+         * for pre-defined dimension denotations.
+         * 
+ * + * string denotation = 3; + */ + public com.google.protobuf.ByteString + getDenotationBytes() { + java.lang.Object ref = denotation_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + denotation_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+         * Standard denotation can optionally be used to denote tensor
+         * dimensions with standard semantic descriptions to ensure
+         * that operations are applied to the correct axis of a tensor.
+         * Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
+         * for pre-defined dimension denotations.
+         * 
+ * + * string denotation = 3; + */ + public Builder setDenotation( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + denotation_ = value; + onChanged(); + return this; + } + /** + *
+         * Standard denotation can optionally be used to denote tensor
+         * dimensions with standard semantic descriptions to ensure
+         * that operations are applied to the correct axis of a tensor.
+         * Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
+         * for pre-defined dimension denotations.
+         * 
+ * + * string denotation = 3; + */ + public Builder clearDenotation() { + + denotation_ = getDefaultInstance().getDenotation(); + onChanged(); + return this; + } + /** + *
+         * Standard denotation can optionally be used to denote tensor
+         * dimensions with standard semantic descriptions to ensure
+         * that operations are applied to the correct axis of a tensor.
+         * Refer to https://github.com/onnx/onnx/blob/master/docs/DimensionDenotation.md#denotation-definition
+         * for pre-defined dimension denotations.
+         * 
+ * + * string denotation = 3; + */ + public Builder setDenotationBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + denotation_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TensorShapeProto.Dimension) + } + + // @@protoc_insertion_point(class_scope:onnx.TensorShapeProto.Dimension) + private static final OnnxMl.TensorShapeProto.Dimension DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TensorShapeProto.Dimension(); + } + + public static OnnxMl.TensorShapeProto.Dimension getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Dimension parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Dimension(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TensorShapeProto.Dimension getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int DIM_FIELD_NUMBER = 1; + private java.util.List dim_; + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public java.util.List getDimList() { + return dim_; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public java.util.List + getDimOrBuilderList() { + return dim_; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public int getDimCount() { + return dim_.size(); + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public OnnxMl.TensorShapeProto.Dimension getDim(int index) { + return dim_.get(index); + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public OnnxMl.TensorShapeProto.DimensionOrBuilder getDimOrBuilder( + int index) { + return dim_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < dim_.size(); i++) { + output.writeMessage(1, dim_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < dim_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, dim_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TensorShapeProto)) { + return super.equals(obj); + } + OnnxMl.TensorShapeProto other = (OnnxMl.TensorShapeProto) obj; + + boolean result = true; + result = result && getDimList() + .equals(other.getDimList()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDimCount() > 0) { + hash = (37 * hash) + DIM_FIELD_NUMBER; + hash = (53 * hash) + getDimList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TensorShapeProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorShapeProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorShapeProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorShapeProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorShapeProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TensorShapeProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TensorShapeProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorShapeProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorShapeProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TensorShapeProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TensorShapeProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TensorShapeProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TensorShapeProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Defines a tensor shape. A dimension can be either an integer value
+     * or a symbolic variable. A symbolic variable represents an unknown
+     * dimension.
+     * 
+ * + * Protobuf type {@code onnx.TensorShapeProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TensorShapeProto) + OnnxMl.TensorShapeProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TensorShapeProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TensorShapeProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TensorShapeProto.class, OnnxMl.TensorShapeProto.Builder.class); + } + + // Construct using OnnxMlProto3.TensorShapeProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getDimFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (dimBuilder_ == null) { + dim_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + dimBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TensorShapeProto_descriptor; + } + + @java.lang.Override + public OnnxMl.TensorShapeProto getDefaultInstanceForType() { + return OnnxMl.TensorShapeProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TensorShapeProto build() { + OnnxMl.TensorShapeProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TensorShapeProto buildPartial() { + OnnxMl.TensorShapeProto result = new OnnxMl.TensorShapeProto(this); + int from_bitField0_ = bitField0_; + if (dimBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + dim_ = java.util.Collections.unmodifiableList(dim_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.dim_ = dim_; + } else { + result.dim_ = dimBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TensorShapeProto) { + return mergeFrom((OnnxMl.TensorShapeProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TensorShapeProto other) { + if (other == OnnxMl.TensorShapeProto.getDefaultInstance()) return this; + if (dimBuilder_ == null) { + if (!other.dim_.isEmpty()) { + if (dim_.isEmpty()) { + dim_ = other.dim_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureDimIsMutable(); + dim_.addAll(other.dim_); + } + onChanged(); + } + } else { + if (!other.dim_.isEmpty()) { + if (dimBuilder_.isEmpty()) { + dimBuilder_.dispose(); + dimBuilder_ = null; + dim_ = other.dim_; + bitField0_ = (bitField0_ & ~0x00000001); + dimBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getDimFieldBuilder() : null; + } else { + dimBuilder_.addAllMessages(other.dim_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TensorShapeProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TensorShapeProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List dim_ = + java.util.Collections.emptyList(); + private void ensureDimIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + dim_ = new java.util.ArrayList(dim_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorShapeProto.Dimension, OnnxMl.TensorShapeProto.Dimension.Builder, OnnxMl.TensorShapeProto.DimensionOrBuilder> dimBuilder_; + + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public java.util.List getDimList() { + if (dimBuilder_ == null) { + return java.util.Collections.unmodifiableList(dim_); + } else { + return dimBuilder_.getMessageList(); + } + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public int getDimCount() { + if (dimBuilder_ == null) { + return dim_.size(); + } else { + return dimBuilder_.getCount(); + } + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public OnnxMl.TensorShapeProto.Dimension getDim(int index) { + if (dimBuilder_ == null) { + return dim_.get(index); + } else { + return dimBuilder_.getMessage(index); + } + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public Builder setDim( + int index, OnnxMl.TensorShapeProto.Dimension value) { + if (dimBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDimIsMutable(); + dim_.set(index, value); + onChanged(); + } else { + dimBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public Builder setDim( + int index, OnnxMl.TensorShapeProto.Dimension.Builder builderForValue) { + if (dimBuilder_ == null) { + ensureDimIsMutable(); + dim_.set(index, builderForValue.build()); + onChanged(); + } else { + dimBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public Builder addDim(OnnxMl.TensorShapeProto.Dimension value) { + if (dimBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDimIsMutable(); + dim_.add(value); + onChanged(); + } else { + dimBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public Builder addDim( + int index, OnnxMl.TensorShapeProto.Dimension value) { + if (dimBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDimIsMutable(); + dim_.add(index, value); + onChanged(); + } else { + dimBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public Builder addDim( + OnnxMl.TensorShapeProto.Dimension.Builder builderForValue) { + if (dimBuilder_ == null) { + ensureDimIsMutable(); + dim_.add(builderForValue.build()); + onChanged(); + } else { + dimBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public Builder addDim( + int index, OnnxMl.TensorShapeProto.Dimension.Builder builderForValue) { + if (dimBuilder_ == null) { + ensureDimIsMutable(); + dim_.add(index, builderForValue.build()); + onChanged(); + } else { + dimBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public Builder addAllDim( + java.lang.Iterable values) { + if (dimBuilder_ == null) { + ensureDimIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, dim_); + onChanged(); + } else { + dimBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public Builder clearDim() { + if (dimBuilder_ == null) { + dim_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + dimBuilder_.clear(); + } + return this; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public Builder removeDim(int index) { + if (dimBuilder_ == null) { + ensureDimIsMutable(); + dim_.remove(index); + onChanged(); + } else { + dimBuilder_.remove(index); + } + return this; + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public OnnxMl.TensorShapeProto.Dimension.Builder getDimBuilder( + int index) { + return getDimFieldBuilder().getBuilder(index); + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public OnnxMl.TensorShapeProto.DimensionOrBuilder getDimOrBuilder( + int index) { + if (dimBuilder_ == null) { + return dim_.get(index); } else { + return dimBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public java.util.List + getDimOrBuilderList() { + if (dimBuilder_ != null) { + return dimBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(dim_); + } + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public OnnxMl.TensorShapeProto.Dimension.Builder addDimBuilder() { + return getDimFieldBuilder().addBuilder( + OnnxMl.TensorShapeProto.Dimension.getDefaultInstance()); + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public OnnxMl.TensorShapeProto.Dimension.Builder addDimBuilder( + int index) { + return getDimFieldBuilder().addBuilder( + index, OnnxMl.TensorShapeProto.Dimension.getDefaultInstance()); + } + /** + * repeated .onnx.TensorShapeProto.Dimension dim = 1; + */ + public java.util.List + getDimBuilderList() { + return getDimFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorShapeProto.Dimension, OnnxMl.TensorShapeProto.Dimension.Builder, OnnxMl.TensorShapeProto.DimensionOrBuilder> + getDimFieldBuilder() { + if (dimBuilder_ == null) { + dimBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.TensorShapeProto.Dimension, OnnxMl.TensorShapeProto.Dimension.Builder, OnnxMl.TensorShapeProto.DimensionOrBuilder>( + dim_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + dim_ = null; + } + return dimBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TensorShapeProto) + } + + // @@protoc_insertion_point(class_scope:onnx.TensorShapeProto) + private static final OnnxMl.TensorShapeProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TensorShapeProto(); + } + + public static OnnxMl.TensorShapeProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TensorShapeProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TensorShapeProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TensorShapeProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface TypeProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TypeProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * The type of a tensor.
+     * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + boolean hasTensorType(); + /** + *
+     * The type of a tensor.
+     * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + OnnxMl.TypeProto.Tensor getTensorType(); + /** + *
+     * The type of a tensor.
+     * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + OnnxMl.TypeProto.TensorOrBuilder getTensorTypeOrBuilder(); + + /** + *
+     * The type of a sequence.
+     * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + boolean hasSequenceType(); + /** + *
+     * The type of a sequence.
+     * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + OnnxMl.TypeProto.Sequence getSequenceType(); + /** + *
+     * The type of a sequence.
+     * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + OnnxMl.TypeProto.SequenceOrBuilder getSequenceTypeOrBuilder(); + + /** + *
+     * The type of a map.
+     * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + boolean hasMapType(); + /** + *
+     * The type of a map.
+     * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + OnnxMl.TypeProto.Map getMapType(); + /** + *
+     * The type of a map.
+     * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + OnnxMl.TypeProto.MapOrBuilder getMapTypeOrBuilder(); + + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + boolean hasSparseTensorType(); + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + OnnxMl.TypeProto.SparseTensor getSparseTensorType(); + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + OnnxMl.TypeProto.SparseTensorOrBuilder getSparseTensorTypeOrBuilder(); + + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + boolean hasOpaqueType(); + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + OnnxMl.TypeProto.Opaque getOpaqueType(); + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + OnnxMl.TypeProto.OpaqueOrBuilder getOpaqueTypeOrBuilder(); + + /** + *
+     * An optional denotation can be used to denote the whole 
+     * type with a standard semantic description as to what is 
+     * stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
+     * for pre-defined type denotations.
+     * 
+ * + * string denotation = 6; + */ + java.lang.String getDenotation(); + /** + *
+     * An optional denotation can be used to denote the whole 
+     * type with a standard semantic description as to what is 
+     * stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
+     * for pre-defined type denotations.
+     * 
+ * + * string denotation = 6; + */ + com.google.protobuf.ByteString + getDenotationBytes(); + + public OnnxMl.TypeProto.ValueCase getValueCase(); + } + /** + *
+   * Types
+   * The standard ONNX data types.
+   * 
+ * + * Protobuf type {@code onnx.TypeProto} + */ + public static final class TypeProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TypeProto) + TypeProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use TypeProto.newBuilder() to construct. + private TypeProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private TypeProto() { + denotation_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private TypeProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + OnnxMl.TypeProto.Tensor.Builder subBuilder = null; + if (valueCase_ == 1) { + subBuilder = ((OnnxMl.TypeProto.Tensor) value_).toBuilder(); + } + value_ = + input.readMessage(OnnxMl.TypeProto.Tensor.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((OnnxMl.TypeProto.Tensor) value_); + value_ = subBuilder.buildPartial(); + } + valueCase_ = 1; + break; + } + case 34: { + OnnxMl.TypeProto.Sequence.Builder subBuilder = null; + if (valueCase_ == 4) { + subBuilder = ((OnnxMl.TypeProto.Sequence) value_).toBuilder(); + } + value_ = + input.readMessage(OnnxMl.TypeProto.Sequence.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((OnnxMl.TypeProto.Sequence) value_); + value_ = subBuilder.buildPartial(); + } + valueCase_ = 4; + break; + } + case 42: { + OnnxMl.TypeProto.Map.Builder subBuilder = null; + if (valueCase_ == 5) { + subBuilder = ((OnnxMl.TypeProto.Map) value_).toBuilder(); + } + value_ = + input.readMessage(OnnxMl.TypeProto.Map.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((OnnxMl.TypeProto.Map) value_); + value_ = subBuilder.buildPartial(); + } + valueCase_ = 5; + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + denotation_ = s; + break; + } + case 58: { + OnnxMl.TypeProto.Opaque.Builder subBuilder = null; + if (valueCase_ == 7) { + subBuilder = ((OnnxMl.TypeProto.Opaque) value_).toBuilder(); + } + value_ = + input.readMessage(OnnxMl.TypeProto.Opaque.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((OnnxMl.TypeProto.Opaque) value_); + value_ = subBuilder.buildPartial(); + } + valueCase_ = 7; + break; + } + case 66: { + OnnxMl.TypeProto.SparseTensor.Builder subBuilder = null; + if (valueCase_ == 8) { + subBuilder = ((OnnxMl.TypeProto.SparseTensor) value_).toBuilder(); + } + value_ = + input.readMessage(OnnxMl.TypeProto.SparseTensor.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom((OnnxMl.TypeProto.SparseTensor) value_); + value_ = subBuilder.buildPartial(); + } + valueCase_ = 8; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.class, OnnxMl.TypeProto.Builder.class); + } + + public interface TensorOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TypeProto.Tensor) + com.google.protobuf.MessageOrBuilder { + + /** + *
+       * This field MUST NOT have the value of UNDEFINED
+       * This field MUST have a valid TensorProto.DataType value
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * int32 elem_type = 1; + */ + int getElemType(); + + /** + * .onnx.TensorShapeProto shape = 2; + */ + boolean hasShape(); + /** + * .onnx.TensorShapeProto shape = 2; + */ + OnnxMl.TensorShapeProto getShape(); + /** + * .onnx.TensorShapeProto shape = 2; + */ + OnnxMl.TensorShapeProtoOrBuilder getShapeOrBuilder(); + } + /** + * Protobuf type {@code onnx.TypeProto.Tensor} + */ + public static final class Tensor extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TypeProto.Tensor) + TensorOrBuilder { + private static final long serialVersionUID = 0L; + // Use Tensor.newBuilder() to construct. + private Tensor(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Tensor() { + elemType_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Tensor( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + elemType_ = input.readInt32(); + break; + } + case 18: { + OnnxMl.TensorShapeProto.Builder subBuilder = null; + if (shape_ != null) { + subBuilder = shape_.toBuilder(); + } + shape_ = input.readMessage(OnnxMl.TensorShapeProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(shape_); + shape_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_Tensor_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_Tensor_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.Tensor.class, OnnxMl.TypeProto.Tensor.Builder.class); + } + + public static final int ELEM_TYPE_FIELD_NUMBER = 1; + private int elemType_; + /** + *
+       * This field MUST NOT have the value of UNDEFINED
+       * This field MUST have a valid TensorProto.DataType value
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * int32 elem_type = 1; + */ + public int getElemType() { + return elemType_; + } + + public static final int SHAPE_FIELD_NUMBER = 2; + private OnnxMl.TensorShapeProto shape_; + /** + * .onnx.TensorShapeProto shape = 2; + */ + public boolean hasShape() { + return shape_ != null; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProto getShape() { + return shape_ == null ? OnnxMl.TensorShapeProto.getDefaultInstance() : shape_; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProtoOrBuilder getShapeOrBuilder() { + return getShape(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (elemType_ != 0) { + output.writeInt32(1, elemType_); + } + if (shape_ != null) { + output.writeMessage(2, getShape()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (elemType_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, elemType_); + } + if (shape_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getShape()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TypeProto.Tensor)) { + return super.equals(obj); + } + OnnxMl.TypeProto.Tensor other = (OnnxMl.TypeProto.Tensor) obj; + + boolean result = true; + result = result && (getElemType() + == other.getElemType()); + result = result && (hasShape() == other.hasShape()); + if (hasShape()) { + result = result && getShape() + .equals(other.getShape()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ELEM_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getElemType(); + if (hasShape()) { + hash = (37 * hash) + SHAPE_FIELD_NUMBER; + hash = (53 * hash) + getShape().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TypeProto.Tensor parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Tensor parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Tensor parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Tensor parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Tensor parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Tensor parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Tensor parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Tensor parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.Tensor parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Tensor parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.Tensor parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Tensor parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TypeProto.Tensor prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code onnx.TypeProto.Tensor} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TypeProto.Tensor) + OnnxMl.TypeProto.TensorOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_Tensor_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_Tensor_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.Tensor.class, OnnxMl.TypeProto.Tensor.Builder.class); + } + + // Construct using OnnxMlProto3.TypeProto.Tensor.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + elemType_ = 0; + + if (shapeBuilder_ == null) { + shape_ = null; + } else { + shape_ = null; + shapeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TypeProto_Tensor_descriptor; + } + + @java.lang.Override + public OnnxMl.TypeProto.Tensor getDefaultInstanceForType() { + return OnnxMl.TypeProto.Tensor.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TypeProto.Tensor build() { + OnnxMl.TypeProto.Tensor result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TypeProto.Tensor buildPartial() { + OnnxMl.TypeProto.Tensor result = new OnnxMl.TypeProto.Tensor(this); + result.elemType_ = elemType_; + if (shapeBuilder_ == null) { + result.shape_ = shape_; + } else { + result.shape_ = shapeBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TypeProto.Tensor) { + return mergeFrom((OnnxMl.TypeProto.Tensor)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TypeProto.Tensor other) { + if (other == OnnxMl.TypeProto.Tensor.getDefaultInstance()) return this; + if (other.getElemType() != 0) { + setElemType(other.getElemType()); + } + if (other.hasShape()) { + mergeShape(other.getShape()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TypeProto.Tensor parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TypeProto.Tensor) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int elemType_ ; + /** + *
+         * This field MUST NOT have the value of UNDEFINED
+         * This field MUST have a valid TensorProto.DataType value
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * int32 elem_type = 1; + */ + public int getElemType() { + return elemType_; + } + /** + *
+         * This field MUST NOT have the value of UNDEFINED
+         * This field MUST have a valid TensorProto.DataType value
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * int32 elem_type = 1; + */ + public Builder setElemType(int value) { + + elemType_ = value; + onChanged(); + return this; + } + /** + *
+         * This field MUST NOT have the value of UNDEFINED
+         * This field MUST have a valid TensorProto.DataType value
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * int32 elem_type = 1; + */ + public Builder clearElemType() { + + elemType_ = 0; + onChanged(); + return this; + } + + private OnnxMl.TensorShapeProto shape_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorShapeProto, OnnxMl.TensorShapeProto.Builder, OnnxMl.TensorShapeProtoOrBuilder> shapeBuilder_; + /** + * .onnx.TensorShapeProto shape = 2; + */ + public boolean hasShape() { + return shapeBuilder_ != null || shape_ != null; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProto getShape() { + if (shapeBuilder_ == null) { + return shape_ == null ? OnnxMl.TensorShapeProto.getDefaultInstance() : shape_; + } else { + return shapeBuilder_.getMessage(); + } + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public Builder setShape(OnnxMl.TensorShapeProto value) { + if (shapeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + shape_ = value; + onChanged(); + } else { + shapeBuilder_.setMessage(value); + } + + return this; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public Builder setShape( + OnnxMl.TensorShapeProto.Builder builderForValue) { + if (shapeBuilder_ == null) { + shape_ = builderForValue.build(); + onChanged(); + } else { + shapeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public Builder mergeShape(OnnxMl.TensorShapeProto value) { + if (shapeBuilder_ == null) { + if (shape_ != null) { + shape_ = + OnnxMl.TensorShapeProto.newBuilder(shape_).mergeFrom(value).buildPartial(); + } else { + shape_ = value; + } + onChanged(); + } else { + shapeBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public Builder clearShape() { + if (shapeBuilder_ == null) { + shape_ = null; + onChanged(); + } else { + shape_ = null; + shapeBuilder_ = null; + } + + return this; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProto.Builder getShapeBuilder() { + + onChanged(); + return getShapeFieldBuilder().getBuilder(); + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProtoOrBuilder getShapeOrBuilder() { + if (shapeBuilder_ != null) { + return shapeBuilder_.getMessageOrBuilder(); + } else { + return shape_ == null ? + OnnxMl.TensorShapeProto.getDefaultInstance() : shape_; + } + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorShapeProto, OnnxMl.TensorShapeProto.Builder, OnnxMl.TensorShapeProtoOrBuilder> + getShapeFieldBuilder() { + if (shapeBuilder_ == null) { + shapeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorShapeProto, OnnxMl.TensorShapeProto.Builder, OnnxMl.TensorShapeProtoOrBuilder>( + getShape(), + getParentForChildren(), + isClean()); + shape_ = null; + } + return shapeBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TypeProto.Tensor) + } + + // @@protoc_insertion_point(class_scope:onnx.TypeProto.Tensor) + private static final OnnxMl.TypeProto.Tensor DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TypeProto.Tensor(); + } + + public static OnnxMl.TypeProto.Tensor getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Tensor parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Tensor(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TypeProto.Tensor getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SequenceOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TypeProto.Sequence) + com.google.protobuf.MessageOrBuilder { + + /** + *
+       * The type and optional shape of each element of the sequence.
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + boolean hasElemType(); + /** + *
+       * The type and optional shape of each element of the sequence.
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + OnnxMl.TypeProto getElemType(); + /** + *
+       * The type and optional shape of each element of the sequence.
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + OnnxMl.TypeProtoOrBuilder getElemTypeOrBuilder(); + } + /** + *
+     * repeated T
+     * 
+ * + * Protobuf type {@code onnx.TypeProto.Sequence} + */ + public static final class Sequence extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TypeProto.Sequence) + SequenceOrBuilder { + private static final long serialVersionUID = 0L; + // Use Sequence.newBuilder() to construct. + private Sequence(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Sequence() { + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Sequence( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + OnnxMl.TypeProto.Builder subBuilder = null; + if (elemType_ != null) { + subBuilder = elemType_.toBuilder(); + } + elemType_ = input.readMessage(OnnxMl.TypeProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(elemType_); + elemType_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_Sequence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_Sequence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.Sequence.class, OnnxMl.TypeProto.Sequence.Builder.class); + } + + public static final int ELEM_TYPE_FIELD_NUMBER = 1; + private OnnxMl.TypeProto elemType_; + /** + *
+       * The type and optional shape of each element of the sequence.
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public boolean hasElemType() { + return elemType_ != null; + } + /** + *
+       * The type and optional shape of each element of the sequence.
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public OnnxMl.TypeProto getElemType() { + return elemType_ == null ? OnnxMl.TypeProto.getDefaultInstance() : elemType_; + } + /** + *
+       * The type and optional shape of each element of the sequence.
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public OnnxMl.TypeProtoOrBuilder getElemTypeOrBuilder() { + return getElemType(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (elemType_ != null) { + output.writeMessage(1, getElemType()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (elemType_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getElemType()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TypeProto.Sequence)) { + return super.equals(obj); + } + OnnxMl.TypeProto.Sequence other = (OnnxMl.TypeProto.Sequence) obj; + + boolean result = true; + result = result && (hasElemType() == other.hasElemType()); + if (hasElemType()) { + result = result && getElemType() + .equals(other.getElemType()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasElemType()) { + hash = (37 * hash) + ELEM_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getElemType().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TypeProto.Sequence parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Sequence parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Sequence parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Sequence parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Sequence parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Sequence parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Sequence parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Sequence parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.Sequence parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Sequence parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.Sequence parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Sequence parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TypeProto.Sequence prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+       * repeated T
+       * 
+ * + * Protobuf type {@code onnx.TypeProto.Sequence} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TypeProto.Sequence) + OnnxMl.TypeProto.SequenceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_Sequence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_Sequence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.Sequence.class, OnnxMl.TypeProto.Sequence.Builder.class); + } + + // Construct using OnnxMlProto3.TypeProto.Sequence.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (elemTypeBuilder_ == null) { + elemType_ = null; + } else { + elemType_ = null; + elemTypeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TypeProto_Sequence_descriptor; + } + + @java.lang.Override + public OnnxMl.TypeProto.Sequence getDefaultInstanceForType() { + return OnnxMl.TypeProto.Sequence.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TypeProto.Sequence build() { + OnnxMl.TypeProto.Sequence result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TypeProto.Sequence buildPartial() { + OnnxMl.TypeProto.Sequence result = new OnnxMl.TypeProto.Sequence(this); + if (elemTypeBuilder_ == null) { + result.elemType_ = elemType_; + } else { + result.elemType_ = elemTypeBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TypeProto.Sequence) { + return mergeFrom((OnnxMl.TypeProto.Sequence)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TypeProto.Sequence other) { + if (other == OnnxMl.TypeProto.Sequence.getDefaultInstance()) return this; + if (other.hasElemType()) { + mergeElemType(other.getElemType()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TypeProto.Sequence parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TypeProto.Sequence) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private OnnxMl.TypeProto elemType_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto, OnnxMl.TypeProto.Builder, OnnxMl.TypeProtoOrBuilder> elemTypeBuilder_; + /** + *
+         * The type and optional shape of each element of the sequence.
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public boolean hasElemType() { + return elemTypeBuilder_ != null || elemType_ != null; + } + /** + *
+         * The type and optional shape of each element of the sequence.
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public OnnxMl.TypeProto getElemType() { + if (elemTypeBuilder_ == null) { + return elemType_ == null ? OnnxMl.TypeProto.getDefaultInstance() : elemType_; + } else { + return elemTypeBuilder_.getMessage(); + } + } + /** + *
+         * The type and optional shape of each element of the sequence.
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public Builder setElemType(OnnxMl.TypeProto value) { + if (elemTypeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + elemType_ = value; + onChanged(); + } else { + elemTypeBuilder_.setMessage(value); + } + + return this; + } + /** + *
+         * The type and optional shape of each element of the sequence.
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public Builder setElemType( + OnnxMl.TypeProto.Builder builderForValue) { + if (elemTypeBuilder_ == null) { + elemType_ = builderForValue.build(); + onChanged(); + } else { + elemTypeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+         * The type and optional shape of each element of the sequence.
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public Builder mergeElemType(OnnxMl.TypeProto value) { + if (elemTypeBuilder_ == null) { + if (elemType_ != null) { + elemType_ = + OnnxMl.TypeProto.newBuilder(elemType_).mergeFrom(value).buildPartial(); + } else { + elemType_ = value; + } + onChanged(); + } else { + elemTypeBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+         * The type and optional shape of each element of the sequence.
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public Builder clearElemType() { + if (elemTypeBuilder_ == null) { + elemType_ = null; + onChanged(); + } else { + elemType_ = null; + elemTypeBuilder_ = null; + } + + return this; + } + /** + *
+         * The type and optional shape of each element of the sequence.
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public OnnxMl.TypeProto.Builder getElemTypeBuilder() { + + onChanged(); + return getElemTypeFieldBuilder().getBuilder(); + } + /** + *
+         * The type and optional shape of each element of the sequence.
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + public OnnxMl.TypeProtoOrBuilder getElemTypeOrBuilder() { + if (elemTypeBuilder_ != null) { + return elemTypeBuilder_.getMessageOrBuilder(); + } else { + return elemType_ == null ? + OnnxMl.TypeProto.getDefaultInstance() : elemType_; + } + } + /** + *
+         * The type and optional shape of each element of the sequence.
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto elem_type = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto, OnnxMl.TypeProto.Builder, OnnxMl.TypeProtoOrBuilder> + getElemTypeFieldBuilder() { + if (elemTypeBuilder_ == null) { + elemTypeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto, OnnxMl.TypeProto.Builder, OnnxMl.TypeProtoOrBuilder>( + getElemType(), + getParentForChildren(), + isClean()); + elemType_ = null; + } + return elemTypeBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TypeProto.Sequence) + } + + // @@protoc_insertion_point(class_scope:onnx.TypeProto.Sequence) + private static final OnnxMl.TypeProto.Sequence DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TypeProto.Sequence(); + } + + public static OnnxMl.TypeProto.Sequence getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Sequence parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Sequence(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TypeProto.Sequence getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface MapOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TypeProto.Map) + com.google.protobuf.MessageOrBuilder { + + /** + *
+       * This field MUST have a valid TensorProto.DataType value
+       * This field MUST be present for this version of the IR.
+       * This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING
+       * 
+ * + * int32 key_type = 1; + */ + int getKeyType(); + + /** + *
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto value_type = 2; + */ + boolean hasValueType(); + /** + *
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto value_type = 2; + */ + OnnxMl.TypeProto getValueType(); + /** + *
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto value_type = 2; + */ + OnnxMl.TypeProtoOrBuilder getValueTypeOrBuilder(); + } + /** + *
+     * map<K,V>
+     * 
+ * + * Protobuf type {@code onnx.TypeProto.Map} + */ + public static final class Map extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TypeProto.Map) + MapOrBuilder { + private static final long serialVersionUID = 0L; + // Use Map.newBuilder() to construct. + private Map(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Map() { + keyType_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Map( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + keyType_ = input.readInt32(); + break; + } + case 18: { + OnnxMl.TypeProto.Builder subBuilder = null; + if (valueType_ != null) { + subBuilder = valueType_.toBuilder(); + } + valueType_ = input.readMessage(OnnxMl.TypeProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(valueType_); + valueType_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_Map_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_Map_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.Map.class, OnnxMl.TypeProto.Map.Builder.class); + } + + public static final int KEY_TYPE_FIELD_NUMBER = 1; + private int keyType_; + /** + *
+       * This field MUST have a valid TensorProto.DataType value
+       * This field MUST be present for this version of the IR.
+       * This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING
+       * 
+ * + * int32 key_type = 1; + */ + public int getKeyType() { + return keyType_; + } + + public static final int VALUE_TYPE_FIELD_NUMBER = 2; + private OnnxMl.TypeProto valueType_; + /** + *
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public boolean hasValueType() { + return valueType_ != null; + } + /** + *
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public OnnxMl.TypeProto getValueType() { + return valueType_ == null ? OnnxMl.TypeProto.getDefaultInstance() : valueType_; + } + /** + *
+       * This field MUST be present for this version of the IR.
+       * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public OnnxMl.TypeProtoOrBuilder getValueTypeOrBuilder() { + return getValueType(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (keyType_ != 0) { + output.writeInt32(1, keyType_); + } + if (valueType_ != null) { + output.writeMessage(2, getValueType()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (keyType_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, keyType_); + } + if (valueType_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getValueType()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TypeProto.Map)) { + return super.equals(obj); + } + OnnxMl.TypeProto.Map other = (OnnxMl.TypeProto.Map) obj; + + boolean result = true; + result = result && (getKeyType() + == other.getKeyType()); + result = result && (hasValueType() == other.hasValueType()); + if (hasValueType()) { + result = result && getValueType() + .equals(other.getValueType()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + KEY_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getKeyType(); + if (hasValueType()) { + hash = (37 * hash) + VALUE_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getValueType().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TypeProto.Map parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Map parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Map parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Map parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Map parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Map parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Map parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Map parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.Map parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Map parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.Map parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Map parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TypeProto.Map prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+       * map<K,V>
+       * 
+ * + * Protobuf type {@code onnx.TypeProto.Map} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TypeProto.Map) + OnnxMl.TypeProto.MapOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_Map_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_Map_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.Map.class, OnnxMl.TypeProto.Map.Builder.class); + } + + // Construct using OnnxMlProto3.TypeProto.Map.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + keyType_ = 0; + + if (valueTypeBuilder_ == null) { + valueType_ = null; + } else { + valueType_ = null; + valueTypeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TypeProto_Map_descriptor; + } + + @java.lang.Override + public OnnxMl.TypeProto.Map getDefaultInstanceForType() { + return OnnxMl.TypeProto.Map.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TypeProto.Map build() { + OnnxMl.TypeProto.Map result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TypeProto.Map buildPartial() { + OnnxMl.TypeProto.Map result = new OnnxMl.TypeProto.Map(this); + result.keyType_ = keyType_; + if (valueTypeBuilder_ == null) { + result.valueType_ = valueType_; + } else { + result.valueType_ = valueTypeBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TypeProto.Map) { + return mergeFrom((OnnxMl.TypeProto.Map)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TypeProto.Map other) { + if (other == OnnxMl.TypeProto.Map.getDefaultInstance()) return this; + if (other.getKeyType() != 0) { + setKeyType(other.getKeyType()); + } + if (other.hasValueType()) { + mergeValueType(other.getValueType()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TypeProto.Map parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TypeProto.Map) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int keyType_ ; + /** + *
+         * This field MUST have a valid TensorProto.DataType value
+         * This field MUST be present for this version of the IR.
+         * This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING
+         * 
+ * + * int32 key_type = 1; + */ + public int getKeyType() { + return keyType_; + } + /** + *
+         * This field MUST have a valid TensorProto.DataType value
+         * This field MUST be present for this version of the IR.
+         * This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING
+         * 
+ * + * int32 key_type = 1; + */ + public Builder setKeyType(int value) { + + keyType_ = value; + onChanged(); + return this; + } + /** + *
+         * This field MUST have a valid TensorProto.DataType value
+         * This field MUST be present for this version of the IR.
+         * This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING
+         * 
+ * + * int32 key_type = 1; + */ + public Builder clearKeyType() { + + keyType_ = 0; + onChanged(); + return this; + } + + private OnnxMl.TypeProto valueType_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto, OnnxMl.TypeProto.Builder, OnnxMl.TypeProtoOrBuilder> valueTypeBuilder_; + /** + *
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public boolean hasValueType() { + return valueTypeBuilder_ != null || valueType_ != null; + } + /** + *
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public OnnxMl.TypeProto getValueType() { + if (valueTypeBuilder_ == null) { + return valueType_ == null ? OnnxMl.TypeProto.getDefaultInstance() : valueType_; + } else { + return valueTypeBuilder_.getMessage(); + } + } + /** + *
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public Builder setValueType(OnnxMl.TypeProto value) { + if (valueTypeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + valueTypeBuilder_.setMessage(value); + } + + return this; + } + /** + *
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public Builder setValueType( + OnnxMl.TypeProto.Builder builderForValue) { + if (valueTypeBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + valueTypeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public Builder mergeValueType(OnnxMl.TypeProto value) { + if (valueTypeBuilder_ == null) { + if (valueType_ != null) { + valueType_ = + OnnxMl.TypeProto.newBuilder(valueType_).mergeFrom(value).buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + valueTypeBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public Builder clearValueType() { + if (valueTypeBuilder_ == null) { + valueType_ = null; + onChanged(); + } else { + valueType_ = null; + valueTypeBuilder_ = null; + } + + return this; + } + /** + *
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public OnnxMl.TypeProto.Builder getValueTypeBuilder() { + + onChanged(); + return getValueTypeFieldBuilder().getBuilder(); + } + /** + *
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto value_type = 2; + */ + public OnnxMl.TypeProtoOrBuilder getValueTypeOrBuilder() { + if (valueTypeBuilder_ != null) { + return valueTypeBuilder_.getMessageOrBuilder(); + } else { + return valueType_ == null ? + OnnxMl.TypeProto.getDefaultInstance() : valueType_; + } + } + /** + *
+         * This field MUST be present for this version of the IR.
+         * 
+ * + * .onnx.TypeProto value_type = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto, OnnxMl.TypeProto.Builder, OnnxMl.TypeProtoOrBuilder> + getValueTypeFieldBuilder() { + if (valueTypeBuilder_ == null) { + valueTypeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto, OnnxMl.TypeProto.Builder, OnnxMl.TypeProtoOrBuilder>( + getValueType(), + getParentForChildren(), + isClean()); + valueType_ = null; + } + return valueTypeBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TypeProto.Map) + } + + // @@protoc_insertion_point(class_scope:onnx.TypeProto.Map) + private static final OnnxMl.TypeProto.Map DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TypeProto.Map(); + } + + public static OnnxMl.TypeProto.Map getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Map parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Map(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TypeProto.Map getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SparseTensorOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TypeProto.SparseTensor) + com.google.protobuf.MessageOrBuilder { + + /** + *
+       * This field MUST NOT have the value of UNDEFINED 
+       * This field MUST have a valid TensorProto.DataType value
+       * This field MUST be present for this version of the IR. 
+       * 
+ * + * int32 elem_type = 1; + */ + int getElemType(); + + /** + * .onnx.TensorShapeProto shape = 2; + */ + boolean hasShape(); + /** + * .onnx.TensorShapeProto shape = 2; + */ + OnnxMl.TensorShapeProto getShape(); + /** + * .onnx.TensorShapeProto shape = 2; + */ + OnnxMl.TensorShapeProtoOrBuilder getShapeOrBuilder(); + } + /** + * Protobuf type {@code onnx.TypeProto.SparseTensor} + */ + public static final class SparseTensor extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TypeProto.SparseTensor) + SparseTensorOrBuilder { + private static final long serialVersionUID = 0L; + // Use SparseTensor.newBuilder() to construct. + private SparseTensor(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SparseTensor() { + elemType_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SparseTensor( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + elemType_ = input.readInt32(); + break; + } + case 18: { + OnnxMl.TensorShapeProto.Builder subBuilder = null; + if (shape_ != null) { + subBuilder = shape_.toBuilder(); + } + shape_ = input.readMessage(OnnxMl.TensorShapeProto.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(shape_); + shape_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_SparseTensor_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_SparseTensor_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.SparseTensor.class, OnnxMl.TypeProto.SparseTensor.Builder.class); + } + + public static final int ELEM_TYPE_FIELD_NUMBER = 1; + private int elemType_; + /** + *
+       * This field MUST NOT have the value of UNDEFINED 
+       * This field MUST have a valid TensorProto.DataType value
+       * This field MUST be present for this version of the IR. 
+       * 
+ * + * int32 elem_type = 1; + */ + public int getElemType() { + return elemType_; + } + + public static final int SHAPE_FIELD_NUMBER = 2; + private OnnxMl.TensorShapeProto shape_; + /** + * .onnx.TensorShapeProto shape = 2; + */ + public boolean hasShape() { + return shape_ != null; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProto getShape() { + return shape_ == null ? OnnxMl.TensorShapeProto.getDefaultInstance() : shape_; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProtoOrBuilder getShapeOrBuilder() { + return getShape(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (elemType_ != 0) { + output.writeInt32(1, elemType_); + } + if (shape_ != null) { + output.writeMessage(2, getShape()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (elemType_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, elemType_); + } + if (shape_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getShape()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TypeProto.SparseTensor)) { + return super.equals(obj); + } + OnnxMl.TypeProto.SparseTensor other = (OnnxMl.TypeProto.SparseTensor) obj; + + boolean result = true; + result = result && (getElemType() + == other.getElemType()); + result = result && (hasShape() == other.hasShape()); + if (hasShape()) { + result = result && getShape() + .equals(other.getShape()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ELEM_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getElemType(); + if (hasShape()) { + hash = (37 * hash) + SHAPE_FIELD_NUMBER; + hash = (53 * hash) + getShape().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TypeProto.SparseTensor parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.SparseTensor parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.SparseTensor parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.SparseTensor parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.SparseTensor parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.SparseTensor parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.SparseTensor parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.SparseTensor parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.SparseTensor parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.SparseTensor parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.SparseTensor parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.SparseTensor parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TypeProto.SparseTensor prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code onnx.TypeProto.SparseTensor} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TypeProto.SparseTensor) + OnnxMl.TypeProto.SparseTensorOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_SparseTensor_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_SparseTensor_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.SparseTensor.class, OnnxMl.TypeProto.SparseTensor.Builder.class); + } + + // Construct using OnnxMlProto3.TypeProto.SparseTensor.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + elemType_ = 0; + + if (shapeBuilder_ == null) { + shape_ = null; + } else { + shape_ = null; + shapeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TypeProto_SparseTensor_descriptor; + } + + @java.lang.Override + public OnnxMl.TypeProto.SparseTensor getDefaultInstanceForType() { + return OnnxMl.TypeProto.SparseTensor.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TypeProto.SparseTensor build() { + OnnxMl.TypeProto.SparseTensor result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TypeProto.SparseTensor buildPartial() { + OnnxMl.TypeProto.SparseTensor result = new OnnxMl.TypeProto.SparseTensor(this); + result.elemType_ = elemType_; + if (shapeBuilder_ == null) { + result.shape_ = shape_; + } else { + result.shape_ = shapeBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TypeProto.SparseTensor) { + return mergeFrom((OnnxMl.TypeProto.SparseTensor)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TypeProto.SparseTensor other) { + if (other == OnnxMl.TypeProto.SparseTensor.getDefaultInstance()) return this; + if (other.getElemType() != 0) { + setElemType(other.getElemType()); + } + if (other.hasShape()) { + mergeShape(other.getShape()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TypeProto.SparseTensor parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TypeProto.SparseTensor) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int elemType_ ; + /** + *
+         * This field MUST NOT have the value of UNDEFINED 
+         * This field MUST have a valid TensorProto.DataType value
+         * This field MUST be present for this version of the IR. 
+         * 
+ * + * int32 elem_type = 1; + */ + public int getElemType() { + return elemType_; + } + /** + *
+         * This field MUST NOT have the value of UNDEFINED 
+         * This field MUST have a valid TensorProto.DataType value
+         * This field MUST be present for this version of the IR. 
+         * 
+ * + * int32 elem_type = 1; + */ + public Builder setElemType(int value) { + + elemType_ = value; + onChanged(); + return this; + } + /** + *
+         * This field MUST NOT have the value of UNDEFINED 
+         * This field MUST have a valid TensorProto.DataType value
+         * This field MUST be present for this version of the IR. 
+         * 
+ * + * int32 elem_type = 1; + */ + public Builder clearElemType() { + + elemType_ = 0; + onChanged(); + return this; + } + + private OnnxMl.TensorShapeProto shape_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorShapeProto, OnnxMl.TensorShapeProto.Builder, OnnxMl.TensorShapeProtoOrBuilder> shapeBuilder_; + /** + * .onnx.TensorShapeProto shape = 2; + */ + public boolean hasShape() { + return shapeBuilder_ != null || shape_ != null; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProto getShape() { + if (shapeBuilder_ == null) { + return shape_ == null ? OnnxMl.TensorShapeProto.getDefaultInstance() : shape_; + } else { + return shapeBuilder_.getMessage(); + } + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public Builder setShape(OnnxMl.TensorShapeProto value) { + if (shapeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + shape_ = value; + onChanged(); + } else { + shapeBuilder_.setMessage(value); + } + + return this; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public Builder setShape( + OnnxMl.TensorShapeProto.Builder builderForValue) { + if (shapeBuilder_ == null) { + shape_ = builderForValue.build(); + onChanged(); + } else { + shapeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public Builder mergeShape(OnnxMl.TensorShapeProto value) { + if (shapeBuilder_ == null) { + if (shape_ != null) { + shape_ = + OnnxMl.TensorShapeProto.newBuilder(shape_).mergeFrom(value).buildPartial(); + } else { + shape_ = value; + } + onChanged(); + } else { + shapeBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public Builder clearShape() { + if (shapeBuilder_ == null) { + shape_ = null; + onChanged(); + } else { + shape_ = null; + shapeBuilder_ = null; + } + + return this; + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProto.Builder getShapeBuilder() { + + onChanged(); + return getShapeFieldBuilder().getBuilder(); + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + public OnnxMl.TensorShapeProtoOrBuilder getShapeOrBuilder() { + if (shapeBuilder_ != null) { + return shapeBuilder_.getMessageOrBuilder(); + } else { + return shape_ == null ? + OnnxMl.TensorShapeProto.getDefaultInstance() : shape_; + } + } + /** + * .onnx.TensorShapeProto shape = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorShapeProto, OnnxMl.TensorShapeProto.Builder, OnnxMl.TensorShapeProtoOrBuilder> + getShapeFieldBuilder() { + if (shapeBuilder_ == null) { + shapeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TensorShapeProto, OnnxMl.TensorShapeProto.Builder, OnnxMl.TensorShapeProtoOrBuilder>( + getShape(), + getParentForChildren(), + isClean()); + shape_ = null; + } + return shapeBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TypeProto.SparseTensor) + } + + // @@protoc_insertion_point(class_scope:onnx.TypeProto.SparseTensor) + private static final OnnxMl.TypeProto.SparseTensor DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TypeProto.SparseTensor(); + } + + public static OnnxMl.TypeProto.SparseTensor getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SparseTensor parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SparseTensor(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TypeProto.SparseTensor getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface OpaqueOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.TypeProto.Opaque) + com.google.protobuf.MessageOrBuilder { + + /** + *
+       * When missing, the domain is the same as the model's.
+       * 
+ * + * string domain = 1; + */ + java.lang.String getDomain(); + /** + *
+       * When missing, the domain is the same as the model's.
+       * 
+ * + * string domain = 1; + */ + com.google.protobuf.ByteString + getDomainBytes(); + + /** + *
+       * The name is optional but significant when provided.
+       * 
+ * + * string name = 2; + */ + java.lang.String getName(); + /** + *
+       * The name is optional but significant when provided.
+       * 
+ * + * string name = 2; + */ + com.google.protobuf.ByteString + getNameBytes(); + } + /** + * Protobuf type {@code onnx.TypeProto.Opaque} + */ + public static final class Opaque extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.TypeProto.Opaque) + OpaqueOrBuilder { + private static final long serialVersionUID = 0L; + // Use Opaque.newBuilder() to construct. + private Opaque(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Opaque() { + domain_ = ""; + name_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Opaque( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + domain_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_Opaque_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_Opaque_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.Opaque.class, OnnxMl.TypeProto.Opaque.Builder.class); + } + + public static final int DOMAIN_FIELD_NUMBER = 1; + private volatile java.lang.Object domain_; + /** + *
+       * When missing, the domain is the same as the model's.
+       * 
+ * + * string domain = 1; + */ + public java.lang.String getDomain() { + java.lang.Object ref = domain_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + domain_ = s; + return s; + } + } + /** + *
+       * When missing, the domain is the same as the model's.
+       * 
+ * + * string domain = 1; + */ + public com.google.protobuf.ByteString + getDomainBytes() { + java.lang.Object ref = domain_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + domain_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object name_; + /** + *
+       * The name is optional but significant when provided.
+       * 
+ * + * string name = 2; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+       * The name is optional but significant when provided.
+       * 
+ * + * string name = 2; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getDomainBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, domain_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getDomainBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, domain_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TypeProto.Opaque)) { + return super.equals(obj); + } + OnnxMl.TypeProto.Opaque other = (OnnxMl.TypeProto.Opaque) obj; + + boolean result = true; + result = result && getDomain() + .equals(other.getDomain()); + result = result && getName() + .equals(other.getName()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DOMAIN_FIELD_NUMBER; + hash = (53 * hash) + getDomain().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TypeProto.Opaque parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Opaque parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Opaque parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Opaque parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Opaque parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto.Opaque parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto.Opaque parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Opaque parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.Opaque parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Opaque parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto.Opaque parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto.Opaque parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TypeProto.Opaque prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code onnx.TypeProto.Opaque} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TypeProto.Opaque) + OnnxMl.TypeProto.OpaqueOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_Opaque_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_Opaque_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.Opaque.class, OnnxMl.TypeProto.Opaque.Builder.class); + } + + // Construct using OnnxMlProto3.TypeProto.Opaque.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + domain_ = ""; + + name_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TypeProto_Opaque_descriptor; + } + + @java.lang.Override + public OnnxMl.TypeProto.Opaque getDefaultInstanceForType() { + return OnnxMl.TypeProto.Opaque.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TypeProto.Opaque build() { + OnnxMl.TypeProto.Opaque result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TypeProto.Opaque buildPartial() { + OnnxMl.TypeProto.Opaque result = new OnnxMl.TypeProto.Opaque(this); + result.domain_ = domain_; + result.name_ = name_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TypeProto.Opaque) { + return mergeFrom((OnnxMl.TypeProto.Opaque)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TypeProto.Opaque other) { + if (other == OnnxMl.TypeProto.Opaque.getDefaultInstance()) return this; + if (!other.getDomain().isEmpty()) { + domain_ = other.domain_; + onChanged(); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TypeProto.Opaque parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TypeProto.Opaque) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object domain_ = ""; + /** + *
+         * When missing, the domain is the same as the model's.
+         * 
+ * + * string domain = 1; + */ + public java.lang.String getDomain() { + java.lang.Object ref = domain_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + domain_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+         * When missing, the domain is the same as the model's.
+         * 
+ * + * string domain = 1; + */ + public com.google.protobuf.ByteString + getDomainBytes() { + java.lang.Object ref = domain_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + domain_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+         * When missing, the domain is the same as the model's.
+         * 
+ * + * string domain = 1; + */ + public Builder setDomain( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + domain_ = value; + onChanged(); + return this; + } + /** + *
+         * When missing, the domain is the same as the model's.
+         * 
+ * + * string domain = 1; + */ + public Builder clearDomain() { + + domain_ = getDefaultInstance().getDomain(); + onChanged(); + return this; + } + /** + *
+         * When missing, the domain is the same as the model's.
+         * 
+ * + * string domain = 1; + */ + public Builder setDomainBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + domain_ = value; + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + /** + *
+         * The name is optional but significant when provided.
+         * 
+ * + * string name = 2; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+         * The name is optional but significant when provided.
+         * 
+ * + * string name = 2; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+         * The name is optional but significant when provided.
+         * 
+ * + * string name = 2; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+         * The name is optional but significant when provided.
+         * 
+ * + * string name = 2; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+         * The name is optional but significant when provided.
+         * 
+ * + * string name = 2; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TypeProto.Opaque) + } + + // @@protoc_insertion_point(class_scope:onnx.TypeProto.Opaque) + private static final OnnxMl.TypeProto.Opaque DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TypeProto.Opaque(); + } + + public static OnnxMl.TypeProto.Opaque getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Opaque parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Opaque(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TypeProto.Opaque getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int valueCase_ = 0; + private java.lang.Object value_; + public enum ValueCase + implements com.google.protobuf.Internal.EnumLite { + TENSOR_TYPE(1), + SEQUENCE_TYPE(4), + MAP_TYPE(5), + SPARSE_TENSOR_TYPE(8), + OPAQUE_TYPE(7), + VALUE_NOT_SET(0); + private final int value; + private ValueCase(int value) { + this.value = value; + } + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ValueCase valueOf(int value) { + return forNumber(value); + } + + public static ValueCase forNumber(int value) { + switch (value) { + case 1: return TENSOR_TYPE; + case 4: return SEQUENCE_TYPE; + case 5: return MAP_TYPE; + case 8: return SPARSE_TENSOR_TYPE; + case 7: return OPAQUE_TYPE; + case 0: return VALUE_NOT_SET; + default: return null; + } + } + public int getNumber() { + return this.value; + } + }; + + public ValueCase + getValueCase() { + return ValueCase.forNumber( + valueCase_); + } + + public static final int TENSOR_TYPE_FIELD_NUMBER = 1; + /** + *
+     * The type of a tensor.
+     * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public boolean hasTensorType() { + return valueCase_ == 1; + } + /** + *
+     * The type of a tensor.
+     * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public OnnxMl.TypeProto.Tensor getTensorType() { + if (valueCase_ == 1) { + return (OnnxMl.TypeProto.Tensor) value_; + } + return OnnxMl.TypeProto.Tensor.getDefaultInstance(); + } + /** + *
+     * The type of a tensor.
+     * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public OnnxMl.TypeProto.TensorOrBuilder getTensorTypeOrBuilder() { + if (valueCase_ == 1) { + return (OnnxMl.TypeProto.Tensor) value_; + } + return OnnxMl.TypeProto.Tensor.getDefaultInstance(); + } + + public static final int SEQUENCE_TYPE_FIELD_NUMBER = 4; + /** + *
+     * The type of a sequence.
+     * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public boolean hasSequenceType() { + return valueCase_ == 4; + } + /** + *
+     * The type of a sequence.
+     * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public OnnxMl.TypeProto.Sequence getSequenceType() { + if (valueCase_ == 4) { + return (OnnxMl.TypeProto.Sequence) value_; + } + return OnnxMl.TypeProto.Sequence.getDefaultInstance(); + } + /** + *
+     * The type of a sequence.
+     * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public OnnxMl.TypeProto.SequenceOrBuilder getSequenceTypeOrBuilder() { + if (valueCase_ == 4) { + return (OnnxMl.TypeProto.Sequence) value_; + } + return OnnxMl.TypeProto.Sequence.getDefaultInstance(); + } + + public static final int MAP_TYPE_FIELD_NUMBER = 5; + /** + *
+     * The type of a map.
+     * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public boolean hasMapType() { + return valueCase_ == 5; + } + /** + *
+     * The type of a map.
+     * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public OnnxMl.TypeProto.Map getMapType() { + if (valueCase_ == 5) { + return (OnnxMl.TypeProto.Map) value_; + } + return OnnxMl.TypeProto.Map.getDefaultInstance(); + } + /** + *
+     * The type of a map.
+     * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public OnnxMl.TypeProto.MapOrBuilder getMapTypeOrBuilder() { + if (valueCase_ == 5) { + return (OnnxMl.TypeProto.Map) value_; + } + return OnnxMl.TypeProto.Map.getDefaultInstance(); + } + + public static final int SPARSE_TENSOR_TYPE_FIELD_NUMBER = 8; + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public boolean hasSparseTensorType() { + return valueCase_ == 8; + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public OnnxMl.TypeProto.SparseTensor getSparseTensorType() { + if (valueCase_ == 8) { + return (OnnxMl.TypeProto.SparseTensor) value_; + } + return OnnxMl.TypeProto.SparseTensor.getDefaultInstance(); + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public OnnxMl.TypeProto.SparseTensorOrBuilder getSparseTensorTypeOrBuilder() { + if (valueCase_ == 8) { + return (OnnxMl.TypeProto.SparseTensor) value_; + } + return OnnxMl.TypeProto.SparseTensor.getDefaultInstance(); + } + + public static final int OPAQUE_TYPE_FIELD_NUMBER = 7; + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public boolean hasOpaqueType() { + return valueCase_ == 7; + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public OnnxMl.TypeProto.Opaque getOpaqueType() { + if (valueCase_ == 7) { + return (OnnxMl.TypeProto.Opaque) value_; + } + return OnnxMl.TypeProto.Opaque.getDefaultInstance(); + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public OnnxMl.TypeProto.OpaqueOrBuilder getOpaqueTypeOrBuilder() { + if (valueCase_ == 7) { + return (OnnxMl.TypeProto.Opaque) value_; + } + return OnnxMl.TypeProto.Opaque.getDefaultInstance(); + } + + public static final int DENOTATION_FIELD_NUMBER = 6; + private volatile java.lang.Object denotation_; + /** + *
+     * An optional denotation can be used to denote the whole 
+     * type with a standard semantic description as to what is 
+     * stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
+     * for pre-defined type denotations.
+     * 
+ * + * string denotation = 6; + */ + public java.lang.String getDenotation() { + java.lang.Object ref = denotation_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + denotation_ = s; + return s; + } + } + /** + *
+     * An optional denotation can be used to denote the whole 
+     * type with a standard semantic description as to what is 
+     * stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
+     * for pre-defined type denotations.
+     * 
+ * + * string denotation = 6; + */ + public com.google.protobuf.ByteString + getDenotationBytes() { + java.lang.Object ref = denotation_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + denotation_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (valueCase_ == 1) { + output.writeMessage(1, (OnnxMl.TypeProto.Tensor) value_); + } + if (valueCase_ == 4) { + output.writeMessage(4, (OnnxMl.TypeProto.Sequence) value_); + } + if (valueCase_ == 5) { + output.writeMessage(5, (OnnxMl.TypeProto.Map) value_); + } + if (!getDenotationBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, denotation_); + } + if (valueCase_ == 7) { + output.writeMessage(7, (OnnxMl.TypeProto.Opaque) value_); + } + if (valueCase_ == 8) { + output.writeMessage(8, (OnnxMl.TypeProto.SparseTensor) value_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (valueCase_ == 1) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, (OnnxMl.TypeProto.Tensor) value_); + } + if (valueCase_ == 4) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, (OnnxMl.TypeProto.Sequence) value_); + } + if (valueCase_ == 5) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, (OnnxMl.TypeProto.Map) value_); + } + if (!getDenotationBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, denotation_); + } + if (valueCase_ == 7) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, (OnnxMl.TypeProto.Opaque) value_); + } + if (valueCase_ == 8) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, (OnnxMl.TypeProto.SparseTensor) value_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.TypeProto)) { + return super.equals(obj); + } + OnnxMl.TypeProto other = (OnnxMl.TypeProto) obj; + + boolean result = true; + result = result && getDenotation() + .equals(other.getDenotation()); + result = result && getValueCase().equals( + other.getValueCase()); + if (!result) return false; + switch (valueCase_) { + case 1: + result = result && getTensorType() + .equals(other.getTensorType()); + break; + case 4: + result = result && getSequenceType() + .equals(other.getSequenceType()); + break; + case 5: + result = result && getMapType() + .equals(other.getMapType()); + break; + case 8: + result = result && getSparseTensorType() + .equals(other.getSparseTensorType()); + break; + case 7: + result = result && getOpaqueType() + .equals(other.getOpaqueType()); + break; + case 0: + default: + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DENOTATION_FIELD_NUMBER; + hash = (53 * hash) + getDenotation().hashCode(); + switch (valueCase_) { + case 1: + hash = (37 * hash) + TENSOR_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getTensorType().hashCode(); + break; + case 4: + hash = (37 * hash) + SEQUENCE_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getSequenceType().hashCode(); + break; + case 5: + hash = (37 * hash) + MAP_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getMapType().hashCode(); + break; + case 8: + hash = (37 * hash) + SPARSE_TENSOR_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getSparseTensorType().hashCode(); + break; + case 7: + hash = (37 * hash) + OPAQUE_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getOpaqueType().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.TypeProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.TypeProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.TypeProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.TypeProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.TypeProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.TypeProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Types
+     * The standard ONNX data types.
+     * 
+ * + * Protobuf type {@code onnx.TypeProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.TypeProto) + OnnxMl.TypeProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_TypeProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_TypeProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.TypeProto.class, OnnxMl.TypeProto.Builder.class); + } + + // Construct using OnnxMlProto3.TypeProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + denotation_ = ""; + + valueCase_ = 0; + value_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_TypeProto_descriptor; + } + + @java.lang.Override + public OnnxMl.TypeProto getDefaultInstanceForType() { + return OnnxMl.TypeProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.TypeProto build() { + OnnxMl.TypeProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.TypeProto buildPartial() { + OnnxMl.TypeProto result = new OnnxMl.TypeProto(this); + if (valueCase_ == 1) { + if (tensorTypeBuilder_ == null) { + result.value_ = value_; + } else { + result.value_ = tensorTypeBuilder_.build(); + } + } + if (valueCase_ == 4) { + if (sequenceTypeBuilder_ == null) { + result.value_ = value_; + } else { + result.value_ = sequenceTypeBuilder_.build(); + } + } + if (valueCase_ == 5) { + if (mapTypeBuilder_ == null) { + result.value_ = value_; + } else { + result.value_ = mapTypeBuilder_.build(); + } + } + if (valueCase_ == 8) { + if (sparseTensorTypeBuilder_ == null) { + result.value_ = value_; + } else { + result.value_ = sparseTensorTypeBuilder_.build(); + } + } + if (valueCase_ == 7) { + if (opaqueTypeBuilder_ == null) { + result.value_ = value_; + } else { + result.value_ = opaqueTypeBuilder_.build(); + } + } + result.denotation_ = denotation_; + result.valueCase_ = valueCase_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.TypeProto) { + return mergeFrom((OnnxMl.TypeProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.TypeProto other) { + if (other == OnnxMl.TypeProto.getDefaultInstance()) return this; + if (!other.getDenotation().isEmpty()) { + denotation_ = other.denotation_; + onChanged(); + } + switch (other.getValueCase()) { + case TENSOR_TYPE: { + mergeTensorType(other.getTensorType()); + break; + } + case SEQUENCE_TYPE: { + mergeSequenceType(other.getSequenceType()); + break; + } + case MAP_TYPE: { + mergeMapType(other.getMapType()); + break; + } + case SPARSE_TENSOR_TYPE: { + mergeSparseTensorType(other.getSparseTensorType()); + break; + } + case OPAQUE_TYPE: { + mergeOpaqueType(other.getOpaqueType()); + break; + } + case VALUE_NOT_SET: { + break; + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.TypeProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.TypeProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int valueCase_ = 0; + private java.lang.Object value_; + public ValueCase + getValueCase() { + return ValueCase.forNumber( + valueCase_); + } + + public Builder clearValue() { + valueCase_ = 0; + value_ = null; + onChanged(); + return this; + } + + + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Tensor, OnnxMl.TypeProto.Tensor.Builder, OnnxMl.TypeProto.TensorOrBuilder> tensorTypeBuilder_; + /** + *
+       * The type of a tensor.
+       * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public boolean hasTensorType() { + return valueCase_ == 1; + } + /** + *
+       * The type of a tensor.
+       * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public OnnxMl.TypeProto.Tensor getTensorType() { + if (tensorTypeBuilder_ == null) { + if (valueCase_ == 1) { + return (OnnxMl.TypeProto.Tensor) value_; + } + return OnnxMl.TypeProto.Tensor.getDefaultInstance(); + } else { + if (valueCase_ == 1) { + return tensorTypeBuilder_.getMessage(); + } + return OnnxMl.TypeProto.Tensor.getDefaultInstance(); + } + } + /** + *
+       * The type of a tensor.
+       * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public Builder setTensorType(OnnxMl.TypeProto.Tensor value) { + if (tensorTypeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + value_ = value; + onChanged(); + } else { + tensorTypeBuilder_.setMessage(value); + } + valueCase_ = 1; + return this; + } + /** + *
+       * The type of a tensor.
+       * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public Builder setTensorType( + OnnxMl.TypeProto.Tensor.Builder builderForValue) { + if (tensorTypeBuilder_ == null) { + value_ = builderForValue.build(); + onChanged(); + } else { + tensorTypeBuilder_.setMessage(builderForValue.build()); + } + valueCase_ = 1; + return this; + } + /** + *
+       * The type of a tensor.
+       * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public Builder mergeTensorType(OnnxMl.TypeProto.Tensor value) { + if (tensorTypeBuilder_ == null) { + if (valueCase_ == 1 && + value_ != OnnxMl.TypeProto.Tensor.getDefaultInstance()) { + value_ = OnnxMl.TypeProto.Tensor.newBuilder((OnnxMl.TypeProto.Tensor) value_) + .mergeFrom(value).buildPartial(); + } else { + value_ = value; + } + onChanged(); + } else { + if (valueCase_ == 1) { + tensorTypeBuilder_.mergeFrom(value); + } + tensorTypeBuilder_.setMessage(value); + } + valueCase_ = 1; + return this; + } + /** + *
+       * The type of a tensor.
+       * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public Builder clearTensorType() { + if (tensorTypeBuilder_ == null) { + if (valueCase_ == 1) { + valueCase_ = 0; + value_ = null; + onChanged(); + } + } else { + if (valueCase_ == 1) { + valueCase_ = 0; + value_ = null; + } + tensorTypeBuilder_.clear(); + } + return this; + } + /** + *
+       * The type of a tensor.
+       * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public OnnxMl.TypeProto.Tensor.Builder getTensorTypeBuilder() { + return getTensorTypeFieldBuilder().getBuilder(); + } + /** + *
+       * The type of a tensor.
+       * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + public OnnxMl.TypeProto.TensorOrBuilder getTensorTypeOrBuilder() { + if ((valueCase_ == 1) && (tensorTypeBuilder_ != null)) { + return tensorTypeBuilder_.getMessageOrBuilder(); + } else { + if (valueCase_ == 1) { + return (OnnxMl.TypeProto.Tensor) value_; + } + return OnnxMl.TypeProto.Tensor.getDefaultInstance(); + } + } + /** + *
+       * The type of a tensor.
+       * 
+ * + * .onnx.TypeProto.Tensor tensor_type = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Tensor, OnnxMl.TypeProto.Tensor.Builder, OnnxMl.TypeProto.TensorOrBuilder> + getTensorTypeFieldBuilder() { + if (tensorTypeBuilder_ == null) { + if (!(valueCase_ == 1)) { + value_ = OnnxMl.TypeProto.Tensor.getDefaultInstance(); + } + tensorTypeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Tensor, OnnxMl.TypeProto.Tensor.Builder, OnnxMl.TypeProto.TensorOrBuilder>( + (OnnxMl.TypeProto.Tensor) value_, + getParentForChildren(), + isClean()); + value_ = null; + } + valueCase_ = 1; + onChanged();; + return tensorTypeBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Sequence, OnnxMl.TypeProto.Sequence.Builder, OnnxMl.TypeProto.SequenceOrBuilder> sequenceTypeBuilder_; + /** + *
+       * The type of a sequence.
+       * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public boolean hasSequenceType() { + return valueCase_ == 4; + } + /** + *
+       * The type of a sequence.
+       * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public OnnxMl.TypeProto.Sequence getSequenceType() { + if (sequenceTypeBuilder_ == null) { + if (valueCase_ == 4) { + return (OnnxMl.TypeProto.Sequence) value_; + } + return OnnxMl.TypeProto.Sequence.getDefaultInstance(); + } else { + if (valueCase_ == 4) { + return sequenceTypeBuilder_.getMessage(); + } + return OnnxMl.TypeProto.Sequence.getDefaultInstance(); + } + } + /** + *
+       * The type of a sequence.
+       * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public Builder setSequenceType(OnnxMl.TypeProto.Sequence value) { + if (sequenceTypeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + value_ = value; + onChanged(); + } else { + sequenceTypeBuilder_.setMessage(value); + } + valueCase_ = 4; + return this; + } + /** + *
+       * The type of a sequence.
+       * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public Builder setSequenceType( + OnnxMl.TypeProto.Sequence.Builder builderForValue) { + if (sequenceTypeBuilder_ == null) { + value_ = builderForValue.build(); + onChanged(); + } else { + sequenceTypeBuilder_.setMessage(builderForValue.build()); + } + valueCase_ = 4; + return this; + } + /** + *
+       * The type of a sequence.
+       * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public Builder mergeSequenceType(OnnxMl.TypeProto.Sequence value) { + if (sequenceTypeBuilder_ == null) { + if (valueCase_ == 4 && + value_ != OnnxMl.TypeProto.Sequence.getDefaultInstance()) { + value_ = OnnxMl.TypeProto.Sequence.newBuilder((OnnxMl.TypeProto.Sequence) value_) + .mergeFrom(value).buildPartial(); + } else { + value_ = value; + } + onChanged(); + } else { + if (valueCase_ == 4) { + sequenceTypeBuilder_.mergeFrom(value); + } + sequenceTypeBuilder_.setMessage(value); + } + valueCase_ = 4; + return this; + } + /** + *
+       * The type of a sequence.
+       * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public Builder clearSequenceType() { + if (sequenceTypeBuilder_ == null) { + if (valueCase_ == 4) { + valueCase_ = 0; + value_ = null; + onChanged(); + } + } else { + if (valueCase_ == 4) { + valueCase_ = 0; + value_ = null; + } + sequenceTypeBuilder_.clear(); + } + return this; + } + /** + *
+       * The type of a sequence.
+       * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public OnnxMl.TypeProto.Sequence.Builder getSequenceTypeBuilder() { + return getSequenceTypeFieldBuilder().getBuilder(); + } + /** + *
+       * The type of a sequence.
+       * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + public OnnxMl.TypeProto.SequenceOrBuilder getSequenceTypeOrBuilder() { + if ((valueCase_ == 4) && (sequenceTypeBuilder_ != null)) { + return sequenceTypeBuilder_.getMessageOrBuilder(); + } else { + if (valueCase_ == 4) { + return (OnnxMl.TypeProto.Sequence) value_; + } + return OnnxMl.TypeProto.Sequence.getDefaultInstance(); + } + } + /** + *
+       * The type of a sequence.
+       * 
+ * + * .onnx.TypeProto.Sequence sequence_type = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Sequence, OnnxMl.TypeProto.Sequence.Builder, OnnxMl.TypeProto.SequenceOrBuilder> + getSequenceTypeFieldBuilder() { + if (sequenceTypeBuilder_ == null) { + if (!(valueCase_ == 4)) { + value_ = OnnxMl.TypeProto.Sequence.getDefaultInstance(); + } + sequenceTypeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Sequence, OnnxMl.TypeProto.Sequence.Builder, OnnxMl.TypeProto.SequenceOrBuilder>( + (OnnxMl.TypeProto.Sequence) value_, + getParentForChildren(), + isClean()); + value_ = null; + } + valueCase_ = 4; + onChanged();; + return sequenceTypeBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Map, OnnxMl.TypeProto.Map.Builder, OnnxMl.TypeProto.MapOrBuilder> mapTypeBuilder_; + /** + *
+       * The type of a map.
+       * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public boolean hasMapType() { + return valueCase_ == 5; + } + /** + *
+       * The type of a map.
+       * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public OnnxMl.TypeProto.Map getMapType() { + if (mapTypeBuilder_ == null) { + if (valueCase_ == 5) { + return (OnnxMl.TypeProto.Map) value_; + } + return OnnxMl.TypeProto.Map.getDefaultInstance(); + } else { + if (valueCase_ == 5) { + return mapTypeBuilder_.getMessage(); + } + return OnnxMl.TypeProto.Map.getDefaultInstance(); + } + } + /** + *
+       * The type of a map.
+       * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public Builder setMapType(OnnxMl.TypeProto.Map value) { + if (mapTypeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + value_ = value; + onChanged(); + } else { + mapTypeBuilder_.setMessage(value); + } + valueCase_ = 5; + return this; + } + /** + *
+       * The type of a map.
+       * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public Builder setMapType( + OnnxMl.TypeProto.Map.Builder builderForValue) { + if (mapTypeBuilder_ == null) { + value_ = builderForValue.build(); + onChanged(); + } else { + mapTypeBuilder_.setMessage(builderForValue.build()); + } + valueCase_ = 5; + return this; + } + /** + *
+       * The type of a map.
+       * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public Builder mergeMapType(OnnxMl.TypeProto.Map value) { + if (mapTypeBuilder_ == null) { + if (valueCase_ == 5 && + value_ != OnnxMl.TypeProto.Map.getDefaultInstance()) { + value_ = OnnxMl.TypeProto.Map.newBuilder((OnnxMl.TypeProto.Map) value_) + .mergeFrom(value).buildPartial(); + } else { + value_ = value; + } + onChanged(); + } else { + if (valueCase_ == 5) { + mapTypeBuilder_.mergeFrom(value); + } + mapTypeBuilder_.setMessage(value); + } + valueCase_ = 5; + return this; + } + /** + *
+       * The type of a map.
+       * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public Builder clearMapType() { + if (mapTypeBuilder_ == null) { + if (valueCase_ == 5) { + valueCase_ = 0; + value_ = null; + onChanged(); + } + } else { + if (valueCase_ == 5) { + valueCase_ = 0; + value_ = null; + } + mapTypeBuilder_.clear(); + } + return this; + } + /** + *
+       * The type of a map.
+       * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public OnnxMl.TypeProto.Map.Builder getMapTypeBuilder() { + return getMapTypeFieldBuilder().getBuilder(); + } + /** + *
+       * The type of a map.
+       * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + public OnnxMl.TypeProto.MapOrBuilder getMapTypeOrBuilder() { + if ((valueCase_ == 5) && (mapTypeBuilder_ != null)) { + return mapTypeBuilder_.getMessageOrBuilder(); + } else { + if (valueCase_ == 5) { + return (OnnxMl.TypeProto.Map) value_; + } + return OnnxMl.TypeProto.Map.getDefaultInstance(); + } + } + /** + *
+       * The type of a map.
+       * 
+ * + * .onnx.TypeProto.Map map_type = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Map, OnnxMl.TypeProto.Map.Builder, OnnxMl.TypeProto.MapOrBuilder> + getMapTypeFieldBuilder() { + if (mapTypeBuilder_ == null) { + if (!(valueCase_ == 5)) { + value_ = OnnxMl.TypeProto.Map.getDefaultInstance(); + } + mapTypeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Map, OnnxMl.TypeProto.Map.Builder, OnnxMl.TypeProto.MapOrBuilder>( + (OnnxMl.TypeProto.Map) value_, + getParentForChildren(), + isClean()); + value_ = null; + } + valueCase_ = 5; + onChanged();; + return mapTypeBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.SparseTensor, OnnxMl.TypeProto.SparseTensor.Builder, OnnxMl.TypeProto.SparseTensorOrBuilder> sparseTensorTypeBuilder_; + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public boolean hasSparseTensorType() { + return valueCase_ == 8; + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public OnnxMl.TypeProto.SparseTensor getSparseTensorType() { + if (sparseTensorTypeBuilder_ == null) { + if (valueCase_ == 8) { + return (OnnxMl.TypeProto.SparseTensor) value_; + } + return OnnxMl.TypeProto.SparseTensor.getDefaultInstance(); + } else { + if (valueCase_ == 8) { + return sparseTensorTypeBuilder_.getMessage(); + } + return OnnxMl.TypeProto.SparseTensor.getDefaultInstance(); + } + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public Builder setSparseTensorType(OnnxMl.TypeProto.SparseTensor value) { + if (sparseTensorTypeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + value_ = value; + onChanged(); + } else { + sparseTensorTypeBuilder_.setMessage(value); + } + valueCase_ = 8; + return this; + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public Builder setSparseTensorType( + OnnxMl.TypeProto.SparseTensor.Builder builderForValue) { + if (sparseTensorTypeBuilder_ == null) { + value_ = builderForValue.build(); + onChanged(); + } else { + sparseTensorTypeBuilder_.setMessage(builderForValue.build()); + } + valueCase_ = 8; + return this; + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public Builder mergeSparseTensorType(OnnxMl.TypeProto.SparseTensor value) { + if (sparseTensorTypeBuilder_ == null) { + if (valueCase_ == 8 && + value_ != OnnxMl.TypeProto.SparseTensor.getDefaultInstance()) { + value_ = OnnxMl.TypeProto.SparseTensor.newBuilder((OnnxMl.TypeProto.SparseTensor) value_) + .mergeFrom(value).buildPartial(); + } else { + value_ = value; + } + onChanged(); + } else { + if (valueCase_ == 8) { + sparseTensorTypeBuilder_.mergeFrom(value); + } + sparseTensorTypeBuilder_.setMessage(value); + } + valueCase_ = 8; + return this; + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public Builder clearSparseTensorType() { + if (sparseTensorTypeBuilder_ == null) { + if (valueCase_ == 8) { + valueCase_ = 0; + value_ = null; + onChanged(); + } + } else { + if (valueCase_ == 8) { + valueCase_ = 0; + value_ = null; + } + sparseTensorTypeBuilder_.clear(); + } + return this; + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public OnnxMl.TypeProto.SparseTensor.Builder getSparseTensorTypeBuilder() { + return getSparseTensorTypeFieldBuilder().getBuilder(); + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + public OnnxMl.TypeProto.SparseTensorOrBuilder getSparseTensorTypeOrBuilder() { + if ((valueCase_ == 8) && (sparseTensorTypeBuilder_ != null)) { + return sparseTensorTypeBuilder_.getMessageOrBuilder(); + } else { + if (valueCase_ == 8) { + return (OnnxMl.TypeProto.SparseTensor) value_; + } + return OnnxMl.TypeProto.SparseTensor.getDefaultInstance(); + } + } + /** + * .onnx.TypeProto.SparseTensor sparse_tensor_type = 8; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.SparseTensor, OnnxMl.TypeProto.SparseTensor.Builder, OnnxMl.TypeProto.SparseTensorOrBuilder> + getSparseTensorTypeFieldBuilder() { + if (sparseTensorTypeBuilder_ == null) { + if (!(valueCase_ == 8)) { + value_ = OnnxMl.TypeProto.SparseTensor.getDefaultInstance(); + } + sparseTensorTypeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.SparseTensor, OnnxMl.TypeProto.SparseTensor.Builder, OnnxMl.TypeProto.SparseTensorOrBuilder>( + (OnnxMl.TypeProto.SparseTensor) value_, + getParentForChildren(), + isClean()); + value_ = null; + } + valueCase_ = 8; + onChanged();; + return sparseTensorTypeBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Opaque, OnnxMl.TypeProto.Opaque.Builder, OnnxMl.TypeProto.OpaqueOrBuilder> opaqueTypeBuilder_; + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public boolean hasOpaqueType() { + return valueCase_ == 7; + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public OnnxMl.TypeProto.Opaque getOpaqueType() { + if (opaqueTypeBuilder_ == null) { + if (valueCase_ == 7) { + return (OnnxMl.TypeProto.Opaque) value_; + } + return OnnxMl.TypeProto.Opaque.getDefaultInstance(); + } else { + if (valueCase_ == 7) { + return opaqueTypeBuilder_.getMessage(); + } + return OnnxMl.TypeProto.Opaque.getDefaultInstance(); + } + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public Builder setOpaqueType(OnnxMl.TypeProto.Opaque value) { + if (opaqueTypeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + value_ = value; + onChanged(); + } else { + opaqueTypeBuilder_.setMessage(value); + } + valueCase_ = 7; + return this; + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public Builder setOpaqueType( + OnnxMl.TypeProto.Opaque.Builder builderForValue) { + if (opaqueTypeBuilder_ == null) { + value_ = builderForValue.build(); + onChanged(); + } else { + opaqueTypeBuilder_.setMessage(builderForValue.build()); + } + valueCase_ = 7; + return this; + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public Builder mergeOpaqueType(OnnxMl.TypeProto.Opaque value) { + if (opaqueTypeBuilder_ == null) { + if (valueCase_ == 7 && + value_ != OnnxMl.TypeProto.Opaque.getDefaultInstance()) { + value_ = OnnxMl.TypeProto.Opaque.newBuilder((OnnxMl.TypeProto.Opaque) value_) + .mergeFrom(value).buildPartial(); + } else { + value_ = value; + } + onChanged(); + } else { + if (valueCase_ == 7) { + opaqueTypeBuilder_.mergeFrom(value); + } + opaqueTypeBuilder_.setMessage(value); + } + valueCase_ = 7; + return this; + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public Builder clearOpaqueType() { + if (opaqueTypeBuilder_ == null) { + if (valueCase_ == 7) { + valueCase_ = 0; + value_ = null; + onChanged(); + } + } else { + if (valueCase_ == 7) { + valueCase_ = 0; + value_ = null; + } + opaqueTypeBuilder_.clear(); + } + return this; + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public OnnxMl.TypeProto.Opaque.Builder getOpaqueTypeBuilder() { + return getOpaqueTypeFieldBuilder().getBuilder(); + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + public OnnxMl.TypeProto.OpaqueOrBuilder getOpaqueTypeOrBuilder() { + if ((valueCase_ == 7) && (opaqueTypeBuilder_ != null)) { + return opaqueTypeBuilder_.getMessageOrBuilder(); + } else { + if (valueCase_ == 7) { + return (OnnxMl.TypeProto.Opaque) value_; + } + return OnnxMl.TypeProto.Opaque.getDefaultInstance(); + } + } + /** + * .onnx.TypeProto.Opaque opaque_type = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Opaque, OnnxMl.TypeProto.Opaque.Builder, OnnxMl.TypeProto.OpaqueOrBuilder> + getOpaqueTypeFieldBuilder() { + if (opaqueTypeBuilder_ == null) { + if (!(valueCase_ == 7)) { + value_ = OnnxMl.TypeProto.Opaque.getDefaultInstance(); + } + opaqueTypeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + OnnxMl.TypeProto.Opaque, OnnxMl.TypeProto.Opaque.Builder, OnnxMl.TypeProto.OpaqueOrBuilder>( + (OnnxMl.TypeProto.Opaque) value_, + getParentForChildren(), + isClean()); + value_ = null; + } + valueCase_ = 7; + onChanged();; + return opaqueTypeBuilder_; + } + + private java.lang.Object denotation_ = ""; + /** + *
+       * An optional denotation can be used to denote the whole 
+       * type with a standard semantic description as to what is 
+       * stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
+       * for pre-defined type denotations.
+       * 
+ * + * string denotation = 6; + */ + public java.lang.String getDenotation() { + java.lang.Object ref = denotation_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + denotation_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * An optional denotation can be used to denote the whole 
+       * type with a standard semantic description as to what is 
+       * stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
+       * for pre-defined type denotations.
+       * 
+ * + * string denotation = 6; + */ + public com.google.protobuf.ByteString + getDenotationBytes() { + java.lang.Object ref = denotation_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + denotation_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * An optional denotation can be used to denote the whole 
+       * type with a standard semantic description as to what is 
+       * stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
+       * for pre-defined type denotations.
+       * 
+ * + * string denotation = 6; + */ + public Builder setDenotation( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + denotation_ = value; + onChanged(); + return this; + } + /** + *
+       * An optional denotation can be used to denote the whole 
+       * type with a standard semantic description as to what is 
+       * stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
+       * for pre-defined type denotations.
+       * 
+ * + * string denotation = 6; + */ + public Builder clearDenotation() { + + denotation_ = getDefaultInstance().getDenotation(); + onChanged(); + return this; + } + /** + *
+       * An optional denotation can be used to denote the whole 
+       * type with a standard semantic description as to what is 
+       * stored inside. Refer to https://github.com/onnx/onnx/blob/master/docs/TypeDenotation.md#type-denotation-definition
+       * for pre-defined type denotations.
+       * 
+ * + * string denotation = 6; + */ + public Builder setDenotationBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + denotation_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.TypeProto) + } + + // @@protoc_insertion_point(class_scope:onnx.TypeProto) + private static final OnnxMl.TypeProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.TypeProto(); + } + + public static OnnxMl.TypeProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TypeProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new TypeProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.TypeProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface OperatorSetIdProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.OperatorSetIdProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * The domain of the operator set being identified.
+     * The empty string ("") or absence of this field implies the operator
+     * set that is defined as part of the ONNX specification.
+     * This field MUST be present in this version of the IR when referring to any other operator set.
+     * 
+ * + * string domain = 1; + */ + java.lang.String getDomain(); + /** + *
+     * The domain of the operator set being identified.
+     * The empty string ("") or absence of this field implies the operator
+     * set that is defined as part of the ONNX specification.
+     * This field MUST be present in this version of the IR when referring to any other operator set.
+     * 
+ * + * string domain = 1; + */ + com.google.protobuf.ByteString + getDomainBytes(); + + /** + *
+     * The version of the operator set being identified.
+     * This field MUST be present in this version of the IR.
+     * 
+ * + * int64 version = 2; + */ + long getVersion(); + } + /** + *
+   * Operator Sets
+   * OperatorSets are uniquely identified by a (domain, opset_version) pair.
+   * 
+ * + * Protobuf type {@code onnx.OperatorSetIdProto} + */ + public static final class OperatorSetIdProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.OperatorSetIdProto) + OperatorSetIdProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use OperatorSetIdProto.newBuilder() to construct. + private OperatorSetIdProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private OperatorSetIdProto() { + domain_ = ""; + version_ = 0L; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private OperatorSetIdProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + domain_ = s; + break; + } + case 16: { + + version_ = input.readInt64(); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_OperatorSetIdProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_OperatorSetIdProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.OperatorSetIdProto.class, OnnxMl.OperatorSetIdProto.Builder.class); + } + + public static final int DOMAIN_FIELD_NUMBER = 1; + private volatile java.lang.Object domain_; + /** + *
+     * The domain of the operator set being identified.
+     * The empty string ("") or absence of this field implies the operator
+     * set that is defined as part of the ONNX specification.
+     * This field MUST be present in this version of the IR when referring to any other operator set.
+     * 
+ * + * string domain = 1; + */ + public java.lang.String getDomain() { + java.lang.Object ref = domain_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + domain_ = s; + return s; + } + } + /** + *
+     * The domain of the operator set being identified.
+     * The empty string ("") or absence of this field implies the operator
+     * set that is defined as part of the ONNX specification.
+     * This field MUST be present in this version of the IR when referring to any other operator set.
+     * 
+ * + * string domain = 1; + */ + public com.google.protobuf.ByteString + getDomainBytes() { + java.lang.Object ref = domain_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + domain_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VERSION_FIELD_NUMBER = 2; + private long version_; + /** + *
+     * The version of the operator set being identified.
+     * This field MUST be present in this version of the IR.
+     * 
+ * + * int64 version = 2; + */ + public long getVersion() { + return version_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getDomainBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, domain_); + } + if (version_ != 0L) { + output.writeInt64(2, version_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getDomainBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, domain_); + } + if (version_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, version_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.OperatorSetIdProto)) { + return super.equals(obj); + } + OnnxMl.OperatorSetIdProto other = (OnnxMl.OperatorSetIdProto) obj; + + boolean result = true; + result = result && getDomain() + .equals(other.getDomain()); + result = result && (getVersion() + == other.getVersion()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DOMAIN_FIELD_NUMBER; + hash = (53 * hash) + getDomain().hashCode(); + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getVersion()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.OperatorSetIdProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.OperatorSetIdProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.OperatorSetIdProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.OperatorSetIdProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.OperatorSetIdProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.OperatorSetIdProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.OperatorSetIdProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.OperatorSetIdProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.OperatorSetIdProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.OperatorSetIdProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.OperatorSetIdProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.OperatorSetIdProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.OperatorSetIdProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Operator Sets
+     * OperatorSets are uniquely identified by a (domain, opset_version) pair.
+     * 
+ * + * Protobuf type {@code onnx.OperatorSetIdProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.OperatorSetIdProto) + OnnxMl.OperatorSetIdProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_OperatorSetIdProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_OperatorSetIdProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.OperatorSetIdProto.class, OnnxMl.OperatorSetIdProto.Builder.class); + } + + // Construct using OnnxMlProto3.OperatorSetIdProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + domain_ = ""; + + version_ = 0L; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_OperatorSetIdProto_descriptor; + } + + @java.lang.Override + public OnnxMl.OperatorSetIdProto getDefaultInstanceForType() { + return OnnxMl.OperatorSetIdProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.OperatorSetIdProto build() { + OnnxMl.OperatorSetIdProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.OperatorSetIdProto buildPartial() { + OnnxMl.OperatorSetIdProto result = new OnnxMl.OperatorSetIdProto(this); + result.domain_ = domain_; + result.version_ = version_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.OperatorSetIdProto) { + return mergeFrom((OnnxMl.OperatorSetIdProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.OperatorSetIdProto other) { + if (other == OnnxMl.OperatorSetIdProto.getDefaultInstance()) return this; + if (!other.getDomain().isEmpty()) { + domain_ = other.domain_; + onChanged(); + } + if (other.getVersion() != 0L) { + setVersion(other.getVersion()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.OperatorSetIdProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.OperatorSetIdProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object domain_ = ""; + /** + *
+       * The domain of the operator set being identified.
+       * The empty string ("") or absence of this field implies the operator
+       * set that is defined as part of the ONNX specification.
+       * This field MUST be present in this version of the IR when referring to any other operator set.
+       * 
+ * + * string domain = 1; + */ + public java.lang.String getDomain() { + java.lang.Object ref = domain_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + domain_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * The domain of the operator set being identified.
+       * The empty string ("") or absence of this field implies the operator
+       * set that is defined as part of the ONNX specification.
+       * This field MUST be present in this version of the IR when referring to any other operator set.
+       * 
+ * + * string domain = 1; + */ + public com.google.protobuf.ByteString + getDomainBytes() { + java.lang.Object ref = domain_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + domain_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * The domain of the operator set being identified.
+       * The empty string ("") or absence of this field implies the operator
+       * set that is defined as part of the ONNX specification.
+       * This field MUST be present in this version of the IR when referring to any other operator set.
+       * 
+ * + * string domain = 1; + */ + public Builder setDomain( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + domain_ = value; + onChanged(); + return this; + } + /** + *
+       * The domain of the operator set being identified.
+       * The empty string ("") or absence of this field implies the operator
+       * set that is defined as part of the ONNX specification.
+       * This field MUST be present in this version of the IR when referring to any other operator set.
+       * 
+ * + * string domain = 1; + */ + public Builder clearDomain() { + + domain_ = getDefaultInstance().getDomain(); + onChanged(); + return this; + } + /** + *
+       * The domain of the operator set being identified.
+       * The empty string ("") or absence of this field implies the operator
+       * set that is defined as part of the ONNX specification.
+       * This field MUST be present in this version of the IR when referring to any other operator set.
+       * 
+ * + * string domain = 1; + */ + public Builder setDomainBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + domain_ = value; + onChanged(); + return this; + } + + private long version_ ; + /** + *
+       * The version of the operator set being identified.
+       * This field MUST be present in this version of the IR.
+       * 
+ * + * int64 version = 2; + */ + public long getVersion() { + return version_; + } + /** + *
+       * The version of the operator set being identified.
+       * This field MUST be present in this version of the IR.
+       * 
+ * + * int64 version = 2; + */ + public Builder setVersion(long value) { + + version_ = value; + onChanged(); + return this; + } + /** + *
+       * The version of the operator set being identified.
+       * This field MUST be present in this version of the IR.
+       * 
+ * + * int64 version = 2; + */ + public Builder clearVersion() { + + version_ = 0L; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.OperatorSetIdProto) + } + + // @@protoc_insertion_point(class_scope:onnx.OperatorSetIdProto) + private static final OnnxMl.OperatorSetIdProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.OperatorSetIdProto(); + } + + public static OnnxMl.OperatorSetIdProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public OperatorSetIdProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new OperatorSetIdProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.OperatorSetIdProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface FunctionProtoOrBuilder extends + // @@protoc_insertion_point(interface_extends:onnx.FunctionProto) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     * The name of the function, similar usage of op_type in OperatorProto.
+     * 
+ * + * string name = 1; + */ + java.lang.String getName(); + /** + *
+     * The name of the function, similar usage of op_type in OperatorProto.
+     * 
+ * + * string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     * The first version of a function set which contains this function.
+     * When there's any breaking change for this function, the function set
+     * contains the function needs to bump its version, and since_version of
+     * the updated function will be changed to the updated function set version.  
+     * 
+ * + * int64 since_version = 2; + */ + long getSinceVersion(); + + /** + *
+     * This field indicates whether the syntax, semantics, or presence
+     * of this function is in an experimental or stable stage. Once an
+     * function is published as STABLE, its syntax and semantics MUST NOT
+     * change in subsequent versions of the operator set.
+     * When a function is published as EXPERIMENTAL, the syntax and semantics
+     * of the function MAY change across operator set versions.
+     * Functions "become" stable by deprecating the experimental version and
+     * introducing a new stable function with the same name.
+     * 
+ * + * .onnx.OperatorStatus status = 3; + */ + int getStatusValue(); + /** + *
+     * This field indicates whether the syntax, semantics, or presence
+     * of this function is in an experimental or stable stage. Once an
+     * function is published as STABLE, its syntax and semantics MUST NOT
+     * change in subsequent versions of the operator set.
+     * When a function is published as EXPERIMENTAL, the syntax and semantics
+     * of the function MAY change across operator set versions.
+     * Functions "become" stable by deprecating the experimental version and
+     * introducing a new stable function with the same name.
+     * 
+ * + * .onnx.OperatorStatus status = 3; + */ + OnnxMl.OperatorStatus getStatus(); + + /** + *
+     * The inputs and outputs of the function.
+     * 
+ * + * repeated string input = 4; + */ + java.util.List + getInputList(); + /** + *
+     * The inputs and outputs of the function.
+     * 
+ * + * repeated string input = 4; + */ + int getInputCount(); + /** + *
+     * The inputs and outputs of the function.
+     * 
+ * + * repeated string input = 4; + */ + java.lang.String getInput(int index); + /** + *
+     * The inputs and outputs of the function.
+     * 
+ * + * repeated string input = 4; + */ + com.google.protobuf.ByteString + getInputBytes(int index); + + /** + * repeated string output = 5; + */ + java.util.List + getOutputList(); + /** + * repeated string output = 5; + */ + int getOutputCount(); + /** + * repeated string output = 5; + */ + java.lang.String getOutput(int index); + /** + * repeated string output = 5; + */ + com.google.protobuf.ByteString + getOutputBytes(int index); + + /** + *
+     * The attributes of the function.
+     * 
+ * + * repeated string attribute = 6; + */ + java.util.List + getAttributeList(); + /** + *
+     * The attributes of the function.
+     * 
+ * + * repeated string attribute = 6; + */ + int getAttributeCount(); + /** + *
+     * The attributes of the function.
+     * 
+ * + * repeated string attribute = 6; + */ + java.lang.String getAttribute(int index); + /** + *
+     * The attributes of the function.
+     * 
+ * + * repeated string attribute = 6; + */ + com.google.protobuf.ByteString + getAttributeBytes(int index); + + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + java.util.List + getNodeList(); + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + OnnxMl.NodeProto getNode(int index); + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + int getNodeCount(); + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + java.util.List + getNodeOrBuilderList(); + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + OnnxMl.NodeProtoOrBuilder getNodeOrBuilder( + int index); + + /** + *
+     * A human-readable documentation for this function. Markdown is allowed.
+     * 
+ * + * string doc_string = 8; + */ + java.lang.String getDocString(); + /** + *
+     * A human-readable documentation for this function. Markdown is allowed.
+     * 
+ * + * string doc_string = 8; + */ + com.google.protobuf.ByteString + getDocStringBytes(); + } + /** + * Protobuf type {@code onnx.FunctionProto} + */ + public static final class FunctionProto extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:onnx.FunctionProto) + FunctionProtoOrBuilder { + private static final long serialVersionUID = 0L; + // Use FunctionProto.newBuilder() to construct. + private FunctionProto(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private FunctionProto() { + name_ = ""; + sinceVersion_ = 0L; + status_ = 0; + input_ = com.google.protobuf.LazyStringArrayList.EMPTY; + output_ = com.google.protobuf.LazyStringArrayList.EMPTY; + attribute_ = com.google.protobuf.LazyStringArrayList.EMPTY; + node_ = java.util.Collections.emptyList(); + docString_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private FunctionProto( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 16: { + + sinceVersion_ = input.readInt64(); + break; + } + case 24: { + int rawValue = input.readEnum(); + + status_ = rawValue; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + input_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000008; + } + input_.add(s); + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + output_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000010; + } + output_.add(s); + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + attribute_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000020; + } + attribute_.add(s); + break; + } + case 58: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + node_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000040; + } + node_.add( + input.readMessage(OnnxMl.NodeProto.parser(), extensionRegistry)); + break; + } + case 66: { + java.lang.String s = input.readStringRequireUtf8(); + + docString_ = s; + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { + input_ = input_.getUnmodifiableView(); + } + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + output_ = output_.getUnmodifiableView(); + } + if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { + attribute_ = attribute_.getUnmodifiableView(); + } + if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + node_ = java.util.Collections.unmodifiableList(node_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_FunctionProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_FunctionProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.FunctionProto.class, OnnxMl.FunctionProto.Builder.class); + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + *
+     * The name of the function, similar usage of op_type in OperatorProto.
+     * 
+ * + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     * The name of the function, similar usage of op_type in OperatorProto.
+     * 
+ * + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SINCE_VERSION_FIELD_NUMBER = 2; + private long sinceVersion_; + /** + *
+     * The first version of a function set which contains this function.
+     * When there's any breaking change for this function, the function set
+     * contains the function needs to bump its version, and since_version of
+     * the updated function will be changed to the updated function set version.  
+     * 
+ * + * int64 since_version = 2; + */ + public long getSinceVersion() { + return sinceVersion_; + } + + public static final int STATUS_FIELD_NUMBER = 3; + private int status_; + /** + *
+     * This field indicates whether the syntax, semantics, or presence
+     * of this function is in an experimental or stable stage. Once an
+     * function is published as STABLE, its syntax and semantics MUST NOT
+     * change in subsequent versions of the operator set.
+     * When a function is published as EXPERIMENTAL, the syntax and semantics
+     * of the function MAY change across operator set versions.
+     * Functions "become" stable by deprecating the experimental version and
+     * introducing a new stable function with the same name.
+     * 
+ * + * .onnx.OperatorStatus status = 3; + */ + public int getStatusValue() { + return status_; + } + /** + *
+     * This field indicates whether the syntax, semantics, or presence
+     * of this function is in an experimental or stable stage. Once an
+     * function is published as STABLE, its syntax and semantics MUST NOT
+     * change in subsequent versions of the operator set.
+     * When a function is published as EXPERIMENTAL, the syntax and semantics
+     * of the function MAY change across operator set versions.
+     * Functions "become" stable by deprecating the experimental version and
+     * introducing a new stable function with the same name.
+     * 
+ * + * .onnx.OperatorStatus status = 3; + */ + public OnnxMl.OperatorStatus getStatus() { + @SuppressWarnings("deprecation") + OnnxMl.OperatorStatus result = OnnxMl.OperatorStatus.valueOf(status_); + return result == null ? OnnxMl.OperatorStatus.UNRECOGNIZED : result; + } + + public static final int INPUT_FIELD_NUMBER = 4; + private com.google.protobuf.LazyStringList input_; + /** + *
+     * The inputs and outputs of the function.
+     * 
+ * + * repeated string input = 4; + */ + public com.google.protobuf.ProtocolStringList + getInputList() { + return input_; + } + /** + *
+     * The inputs and outputs of the function.
+     * 
+ * + * repeated string input = 4; + */ + public int getInputCount() { + return input_.size(); + } + /** + *
+     * The inputs and outputs of the function.
+     * 
+ * + * repeated string input = 4; + */ + public java.lang.String getInput(int index) { + return input_.get(index); + } + /** + *
+     * The inputs and outputs of the function.
+     * 
+ * + * repeated string input = 4; + */ + public com.google.protobuf.ByteString + getInputBytes(int index) { + return input_.getByteString(index); + } + + public static final int OUTPUT_FIELD_NUMBER = 5; + private com.google.protobuf.LazyStringList output_; + /** + * repeated string output = 5; + */ + public com.google.protobuf.ProtocolStringList + getOutputList() { + return output_; + } + /** + * repeated string output = 5; + */ + public int getOutputCount() { + return output_.size(); + } + /** + * repeated string output = 5; + */ + public java.lang.String getOutput(int index) { + return output_.get(index); + } + /** + * repeated string output = 5; + */ + public com.google.protobuf.ByteString + getOutputBytes(int index) { + return output_.getByteString(index); + } + + public static final int ATTRIBUTE_FIELD_NUMBER = 6; + private com.google.protobuf.LazyStringList attribute_; + /** + *
+     * The attributes of the function.
+     * 
+ * + * repeated string attribute = 6; + */ + public com.google.protobuf.ProtocolStringList + getAttributeList() { + return attribute_; + } + /** + *
+     * The attributes of the function.
+     * 
+ * + * repeated string attribute = 6; + */ + public int getAttributeCount() { + return attribute_.size(); + } + /** + *
+     * The attributes of the function.
+     * 
+ * + * repeated string attribute = 6; + */ + public java.lang.String getAttribute(int index) { + return attribute_.get(index); + } + /** + *
+     * The attributes of the function.
+     * 
+ * + * repeated string attribute = 6; + */ + public com.google.protobuf.ByteString + getAttributeBytes(int index) { + return attribute_.getByteString(index); + } + + public static final int NODE_FIELD_NUMBER = 7; + private java.util.List node_; + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public java.util.List getNodeList() { + return node_; + } + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public java.util.List + getNodeOrBuilderList() { + return node_; + } + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public int getNodeCount() { + return node_.size(); + } + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public OnnxMl.NodeProto getNode(int index) { + return node_.get(index); + } + /** + *
+     * The nodes in the function.
+     * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public OnnxMl.NodeProtoOrBuilder getNodeOrBuilder( + int index) { + return node_.get(index); + } + + public static final int DOC_STRING_FIELD_NUMBER = 8; + private volatile java.lang.Object docString_; + /** + *
+     * A human-readable documentation for this function. Markdown is allowed.
+     * 
+ * + * string doc_string = 8; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } + } + /** + *
+     * A human-readable documentation for this function. Markdown is allowed.
+     * 
+ * + * string doc_string = 8; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (sinceVersion_ != 0L) { + output.writeInt64(2, sinceVersion_); + } + if (status_ != OnnxMl.OperatorStatus.EXPERIMENTAL.getNumber()) { + output.writeEnum(3, status_); + } + for (int i = 0; i < input_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, input_.getRaw(i)); + } + for (int i = 0; i < output_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, output_.getRaw(i)); + } + for (int i = 0; i < attribute_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, attribute_.getRaw(i)); + } + for (int i = 0; i < node_.size(); i++) { + output.writeMessage(7, node_.get(i)); + } + if (!getDocStringBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, docString_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (sinceVersion_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, sinceVersion_); + } + if (status_ != OnnxMl.OperatorStatus.EXPERIMENTAL.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(3, status_); + } + { + int dataSize = 0; + for (int i = 0; i < input_.size(); i++) { + dataSize += computeStringSizeNoTag(input_.getRaw(i)); + } + size += dataSize; + size += 1 * getInputList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < output_.size(); i++) { + dataSize += computeStringSizeNoTag(output_.getRaw(i)); + } + size += dataSize; + size += 1 * getOutputList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < attribute_.size(); i++) { + dataSize += computeStringSizeNoTag(attribute_.getRaw(i)); + } + size += dataSize; + size += 1 * getAttributeList().size(); + } + for (int i = 0; i < node_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, node_.get(i)); + } + if (!getDocStringBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, docString_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OnnxMl.FunctionProto)) { + return super.equals(obj); + } + OnnxMl.FunctionProto other = (OnnxMl.FunctionProto) obj; + + boolean result = true; + result = result && getName() + .equals(other.getName()); + result = result && (getSinceVersion() + == other.getSinceVersion()); + result = result && status_ == other.status_; + result = result && getInputList() + .equals(other.getInputList()); + result = result && getOutputList() + .equals(other.getOutputList()); + result = result && getAttributeList() + .equals(other.getAttributeList()); + result = result && getNodeList() + .equals(other.getNodeList()); + result = result && getDocString() + .equals(other.getDocString()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + SINCE_VERSION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSinceVersion()); + hash = (37 * hash) + STATUS_FIELD_NUMBER; + hash = (53 * hash) + status_; + if (getInputCount() > 0) { + hash = (37 * hash) + INPUT_FIELD_NUMBER; + hash = (53 * hash) + getInputList().hashCode(); + } + if (getOutputCount() > 0) { + hash = (37 * hash) + OUTPUT_FIELD_NUMBER; + hash = (53 * hash) + getOutputList().hashCode(); + } + if (getAttributeCount() > 0) { + hash = (37 * hash) + ATTRIBUTE_FIELD_NUMBER; + hash = (53 * hash) + getAttributeList().hashCode(); + } + if (getNodeCount() > 0) { + hash = (37 * hash) + NODE_FIELD_NUMBER; + hash = (53 * hash) + getNodeList().hashCode(); + } + hash = (37 * hash) + DOC_STRING_FIELD_NUMBER; + hash = (53 * hash) + getDocString().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static OnnxMl.FunctionProto parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.FunctionProto parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.FunctionProto parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.FunctionProto parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.FunctionProto parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static OnnxMl.FunctionProto parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static OnnxMl.FunctionProto parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.FunctionProto parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.FunctionProto parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static OnnxMl.FunctionProto parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static OnnxMl.FunctionProto parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static OnnxMl.FunctionProto parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(OnnxMl.FunctionProto prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code onnx.FunctionProto} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:onnx.FunctionProto) + OnnxMl.FunctionProtoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return OnnxMl.internal_static_onnx_FunctionProto_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return OnnxMl.internal_static_onnx_FunctionProto_fieldAccessorTable + .ensureFieldAccessorsInitialized( + OnnxMl.FunctionProto.class, OnnxMl.FunctionProto.Builder.class); + } + + // Construct using OnnxMlProto3.FunctionProto.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getNodeFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + sinceVersion_ = 0L; + + status_ = 0; + + input_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000008); + output_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000010); + attribute_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000020); + if (nodeBuilder_ == null) { + node_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + } else { + nodeBuilder_.clear(); + } + docString_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return OnnxMl.internal_static_onnx_FunctionProto_descriptor; + } + + @java.lang.Override + public OnnxMl.FunctionProto getDefaultInstanceForType() { + return OnnxMl.FunctionProto.getDefaultInstance(); + } + + @java.lang.Override + public OnnxMl.FunctionProto build() { + OnnxMl.FunctionProto result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public OnnxMl.FunctionProto buildPartial() { + OnnxMl.FunctionProto result = new OnnxMl.FunctionProto(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.name_ = name_; + result.sinceVersion_ = sinceVersion_; + result.status_ = status_; + if (((bitField0_ & 0x00000008) == 0x00000008)) { + input_ = input_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.input_ = input_; + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output_ = output_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.output_ = output_; + if (((bitField0_ & 0x00000020) == 0x00000020)) { + attribute_ = attribute_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.attribute_ = attribute_; + if (nodeBuilder_ == null) { + if (((bitField0_ & 0x00000040) == 0x00000040)) { + node_ = java.util.Collections.unmodifiableList(node_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.node_ = node_; + } else { + result.node_ = nodeBuilder_.build(); + } + result.docString_ = docString_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof OnnxMl.FunctionProto) { + return mergeFrom((OnnxMl.FunctionProto)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(OnnxMl.FunctionProto other) { + if (other == OnnxMl.FunctionProto.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.getSinceVersion() != 0L) { + setSinceVersion(other.getSinceVersion()); + } + if (other.status_ != 0) { + setStatusValue(other.getStatusValue()); + } + if (!other.input_.isEmpty()) { + if (input_.isEmpty()) { + input_ = other.input_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureInputIsMutable(); + input_.addAll(other.input_); + } + onChanged(); + } + if (!other.output_.isEmpty()) { + if (output_.isEmpty()) { + output_ = other.output_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureOutputIsMutable(); + output_.addAll(other.output_); + } + onChanged(); + } + if (!other.attribute_.isEmpty()) { + if (attribute_.isEmpty()) { + attribute_ = other.attribute_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureAttributeIsMutable(); + attribute_.addAll(other.attribute_); + } + onChanged(); + } + if (nodeBuilder_ == null) { + if (!other.node_.isEmpty()) { + if (node_.isEmpty()) { + node_ = other.node_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensureNodeIsMutable(); + node_.addAll(other.node_); + } + onChanged(); + } + } else { + if (!other.node_.isEmpty()) { + if (nodeBuilder_.isEmpty()) { + nodeBuilder_.dispose(); + nodeBuilder_ = null; + node_ = other.node_; + bitField0_ = (bitField0_ & ~0x00000040); + nodeBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getNodeFieldBuilder() : null; + } else { + nodeBuilder_.addAllMessages(other.node_); + } + } + } + if (!other.getDocString().isEmpty()) { + docString_ = other.docString_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + OnnxMl.FunctionProto parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (OnnxMl.FunctionProto) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + *
+       * The name of the function, similar usage of op_type in OperatorProto.
+       * 
+ * + * string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * The name of the function, similar usage of op_type in OperatorProto.
+       * 
+ * + * string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * The name of the function, similar usage of op_type in OperatorProto.
+       * 
+ * + * string name = 1; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       * The name of the function, similar usage of op_type in OperatorProto.
+       * 
+ * + * string name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       * The name of the function, similar usage of op_type in OperatorProto.
+       * 
+ * + * string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private long sinceVersion_ ; + /** + *
+       * The first version of a function set which contains this function.
+       * When there's any breaking change for this function, the function set
+       * contains the function needs to bump its version, and since_version of
+       * the updated function will be changed to the updated function set version.  
+       * 
+ * + * int64 since_version = 2; + */ + public long getSinceVersion() { + return sinceVersion_; + } + /** + *
+       * The first version of a function set which contains this function.
+       * When there's any breaking change for this function, the function set
+       * contains the function needs to bump its version, and since_version of
+       * the updated function will be changed to the updated function set version.  
+       * 
+ * + * int64 since_version = 2; + */ + public Builder setSinceVersion(long value) { + + sinceVersion_ = value; + onChanged(); + return this; + } + /** + *
+       * The first version of a function set which contains this function.
+       * When there's any breaking change for this function, the function set
+       * contains the function needs to bump its version, and since_version of
+       * the updated function will be changed to the updated function set version.  
+       * 
+ * + * int64 since_version = 2; + */ + public Builder clearSinceVersion() { + + sinceVersion_ = 0L; + onChanged(); + return this; + } + + private int status_ = 0; + /** + *
+       * This field indicates whether the syntax, semantics, or presence
+       * of this function is in an experimental or stable stage. Once an
+       * function is published as STABLE, its syntax and semantics MUST NOT
+       * change in subsequent versions of the operator set.
+       * When a function is published as EXPERIMENTAL, the syntax and semantics
+       * of the function MAY change across operator set versions.
+       * Functions "become" stable by deprecating the experimental version and
+       * introducing a new stable function with the same name.
+       * 
+ * + * .onnx.OperatorStatus status = 3; + */ + public int getStatusValue() { + return status_; + } + /** + *
+       * This field indicates whether the syntax, semantics, or presence
+       * of this function is in an experimental or stable stage. Once an
+       * function is published as STABLE, its syntax and semantics MUST NOT
+       * change in subsequent versions of the operator set.
+       * When a function is published as EXPERIMENTAL, the syntax and semantics
+       * of the function MAY change across operator set versions.
+       * Functions "become" stable by deprecating the experimental version and
+       * introducing a new stable function with the same name.
+       * 
+ * + * .onnx.OperatorStatus status = 3; + */ + public Builder setStatusValue(int value) { + status_ = value; + onChanged(); + return this; + } + /** + *
+       * This field indicates whether the syntax, semantics, or presence
+       * of this function is in an experimental or stable stage. Once an
+       * function is published as STABLE, its syntax and semantics MUST NOT
+       * change in subsequent versions of the operator set.
+       * When a function is published as EXPERIMENTAL, the syntax and semantics
+       * of the function MAY change across operator set versions.
+       * Functions "become" stable by deprecating the experimental version and
+       * introducing a new stable function with the same name.
+       * 
+ * + * .onnx.OperatorStatus status = 3; + */ + public OnnxMl.OperatorStatus getStatus() { + @SuppressWarnings("deprecation") + OnnxMl.OperatorStatus result = OnnxMl.OperatorStatus.valueOf(status_); + return result == null ? OnnxMl.OperatorStatus.UNRECOGNIZED : result; + } + /** + *
+       * This field indicates whether the syntax, semantics, or presence
+       * of this function is in an experimental or stable stage. Once an
+       * function is published as STABLE, its syntax and semantics MUST NOT
+       * change in subsequent versions of the operator set.
+       * When a function is published as EXPERIMENTAL, the syntax and semantics
+       * of the function MAY change across operator set versions.
+       * Functions "become" stable by deprecating the experimental version and
+       * introducing a new stable function with the same name.
+       * 
+ * + * .onnx.OperatorStatus status = 3; + */ + public Builder setStatus(OnnxMl.OperatorStatus value) { + if (value == null) { + throw new NullPointerException(); + } + + status_ = value.getNumber(); + onChanged(); + return this; + } + /** + *
+       * This field indicates whether the syntax, semantics, or presence
+       * of this function is in an experimental or stable stage. Once an
+       * function is published as STABLE, its syntax and semantics MUST NOT
+       * change in subsequent versions of the operator set.
+       * When a function is published as EXPERIMENTAL, the syntax and semantics
+       * of the function MAY change across operator set versions.
+       * Functions "become" stable by deprecating the experimental version and
+       * introducing a new stable function with the same name.
+       * 
+ * + * .onnx.OperatorStatus status = 3; + */ + public Builder clearStatus() { + + status_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList input_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureInputIsMutable() { + if (!((bitField0_ & 0x00000008) == 0x00000008)) { + input_ = new com.google.protobuf.LazyStringArrayList(input_); + bitField0_ |= 0x00000008; + } + } + /** + *
+       * The inputs and outputs of the function.
+       * 
+ * + * repeated string input = 4; + */ + public com.google.protobuf.ProtocolStringList + getInputList() { + return input_.getUnmodifiableView(); + } + /** + *
+       * The inputs and outputs of the function.
+       * 
+ * + * repeated string input = 4; + */ + public int getInputCount() { + return input_.size(); + } + /** + *
+       * The inputs and outputs of the function.
+       * 
+ * + * repeated string input = 4; + */ + public java.lang.String getInput(int index) { + return input_.get(index); + } + /** + *
+       * The inputs and outputs of the function.
+       * 
+ * + * repeated string input = 4; + */ + public com.google.protobuf.ByteString + getInputBytes(int index) { + return input_.getByteString(index); + } + /** + *
+       * The inputs and outputs of the function.
+       * 
+ * + * repeated string input = 4; + */ + public Builder setInput( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputIsMutable(); + input_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * The inputs and outputs of the function.
+       * 
+ * + * repeated string input = 4; + */ + public Builder addInput( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureInputIsMutable(); + input_.add(value); + onChanged(); + return this; + } + /** + *
+       * The inputs and outputs of the function.
+       * 
+ * + * repeated string input = 4; + */ + public Builder addAllInput( + java.lang.Iterable values) { + ensureInputIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, input_); + onChanged(); + return this; + } + /** + *
+       * The inputs and outputs of the function.
+       * 
+ * + * repeated string input = 4; + */ + public Builder clearInput() { + input_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + /** + *
+       * The inputs and outputs of the function.
+       * 
+ * + * repeated string input = 4; + */ + public Builder addInputBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureInputIsMutable(); + input_.add(value); + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList output_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureOutputIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + output_ = new com.google.protobuf.LazyStringArrayList(output_); + bitField0_ |= 0x00000010; + } + } + /** + * repeated string output = 5; + */ + public com.google.protobuf.ProtocolStringList + getOutputList() { + return output_.getUnmodifiableView(); + } + /** + * repeated string output = 5; + */ + public int getOutputCount() { + return output_.size(); + } + /** + * repeated string output = 5; + */ + public java.lang.String getOutput(int index) { + return output_.get(index); + } + /** + * repeated string output = 5; + */ + public com.google.protobuf.ByteString + getOutputBytes(int index) { + return output_.getByteString(index); + } + /** + * repeated string output = 5; + */ + public Builder setOutput( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputIsMutable(); + output_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string output = 5; + */ + public Builder addOutput( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureOutputIsMutable(); + output_.add(value); + onChanged(); + return this; + } + /** + * repeated string output = 5; + */ + public Builder addAllOutput( + java.lang.Iterable values) { + ensureOutputIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, output_); + onChanged(); + return this; + } + /** + * repeated string output = 5; + */ + public Builder clearOutput() { + output_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + /** + * repeated string output = 5; + */ + public Builder addOutputBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureOutputIsMutable(); + output_.add(value); + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList attribute_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureAttributeIsMutable() { + if (!((bitField0_ & 0x00000020) == 0x00000020)) { + attribute_ = new com.google.protobuf.LazyStringArrayList(attribute_); + bitField0_ |= 0x00000020; + } + } + /** + *
+       * The attributes of the function.
+       * 
+ * + * repeated string attribute = 6; + */ + public com.google.protobuf.ProtocolStringList + getAttributeList() { + return attribute_.getUnmodifiableView(); + } + /** + *
+       * The attributes of the function.
+       * 
+ * + * repeated string attribute = 6; + */ + public int getAttributeCount() { + return attribute_.size(); + } + /** + *
+       * The attributes of the function.
+       * 
+ * + * repeated string attribute = 6; + */ + public java.lang.String getAttribute(int index) { + return attribute_.get(index); + } + /** + *
+       * The attributes of the function.
+       * 
+ * + * repeated string attribute = 6; + */ + public com.google.protobuf.ByteString + getAttributeBytes(int index) { + return attribute_.getByteString(index); + } + /** + *
+       * The attributes of the function.
+       * 
+ * + * repeated string attribute = 6; + */ + public Builder setAttribute( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributeIsMutable(); + attribute_.set(index, value); + onChanged(); + return this; + } + /** + *
+       * The attributes of the function.
+       * 
+ * + * repeated string attribute = 6; + */ + public Builder addAttribute( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAttributeIsMutable(); + attribute_.add(value); + onChanged(); + return this; + } + /** + *
+       * The attributes of the function.
+       * 
+ * + * repeated string attribute = 6; + */ + public Builder addAllAttribute( + java.lang.Iterable values) { + ensureAttributeIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, attribute_); + onChanged(); + return this; + } + /** + *
+       * The attributes of the function.
+       * 
+ * + * repeated string attribute = 6; + */ + public Builder clearAttribute() { + attribute_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + return this; + } + /** + *
+       * The attributes of the function.
+       * 
+ * + * repeated string attribute = 6; + */ + public Builder addAttributeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureAttributeIsMutable(); + attribute_.add(value); + onChanged(); + return this; + } + + private java.util.List node_ = + java.util.Collections.emptyList(); + private void ensureNodeIsMutable() { + if (!((bitField0_ & 0x00000040) == 0x00000040)) { + node_ = new java.util.ArrayList(node_); + bitField0_ |= 0x00000040; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.NodeProto, OnnxMl.NodeProto.Builder, OnnxMl.NodeProtoOrBuilder> nodeBuilder_; + + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public java.util.List getNodeList() { + if (nodeBuilder_ == null) { + return java.util.Collections.unmodifiableList(node_); + } else { + return nodeBuilder_.getMessageList(); + } + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public int getNodeCount() { + if (nodeBuilder_ == null) { + return node_.size(); + } else { + return nodeBuilder_.getCount(); + } + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public OnnxMl.NodeProto getNode(int index) { + if (nodeBuilder_ == null) { + return node_.get(index); + } else { + return nodeBuilder_.getMessage(index); + } + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public Builder setNode( + int index, OnnxMl.NodeProto value) { + if (nodeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNodeIsMutable(); + node_.set(index, value); + onChanged(); + } else { + nodeBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public Builder setNode( + int index, OnnxMl.NodeProto.Builder builderForValue) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + node_.set(index, builderForValue.build()); + onChanged(); + } else { + nodeBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public Builder addNode(OnnxMl.NodeProto value) { + if (nodeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNodeIsMutable(); + node_.add(value); + onChanged(); + } else { + nodeBuilder_.addMessage(value); + } + return this; + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public Builder addNode( + int index, OnnxMl.NodeProto value) { + if (nodeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNodeIsMutable(); + node_.add(index, value); + onChanged(); + } else { + nodeBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public Builder addNode( + OnnxMl.NodeProto.Builder builderForValue) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + node_.add(builderForValue.build()); + onChanged(); + } else { + nodeBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public Builder addNode( + int index, OnnxMl.NodeProto.Builder builderForValue) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + node_.add(index, builderForValue.build()); + onChanged(); + } else { + nodeBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public Builder addAllNode( + java.lang.Iterable values) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, node_); + onChanged(); + } else { + nodeBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public Builder clearNode() { + if (nodeBuilder_ == null) { + node_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + } else { + nodeBuilder_.clear(); + } + return this; + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public Builder removeNode(int index) { + if (nodeBuilder_ == null) { + ensureNodeIsMutable(); + node_.remove(index); + onChanged(); + } else { + nodeBuilder_.remove(index); + } + return this; + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public OnnxMl.NodeProto.Builder getNodeBuilder( + int index) { + return getNodeFieldBuilder().getBuilder(index); + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public OnnxMl.NodeProtoOrBuilder getNodeOrBuilder( + int index) { + if (nodeBuilder_ == null) { + return node_.get(index); } else { + return nodeBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public java.util.List + getNodeOrBuilderList() { + if (nodeBuilder_ != null) { + return nodeBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(node_); + } + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public OnnxMl.NodeProto.Builder addNodeBuilder() { + return getNodeFieldBuilder().addBuilder( + OnnxMl.NodeProto.getDefaultInstance()); + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public OnnxMl.NodeProto.Builder addNodeBuilder( + int index) { + return getNodeFieldBuilder().addBuilder( + index, OnnxMl.NodeProto.getDefaultInstance()); + } + /** + *
+       * The nodes in the function.
+       * 
+ * + * repeated .onnx.NodeProto node = 7; + */ + public java.util.List + getNodeBuilderList() { + return getNodeFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.NodeProto, OnnxMl.NodeProto.Builder, OnnxMl.NodeProtoOrBuilder> + getNodeFieldBuilder() { + if (nodeBuilder_ == null) { + nodeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + OnnxMl.NodeProto, OnnxMl.NodeProto.Builder, OnnxMl.NodeProtoOrBuilder>( + node_, + ((bitField0_ & 0x00000040) == 0x00000040), + getParentForChildren(), + isClean()); + node_ = null; + } + return nodeBuilder_; + } + + private java.lang.Object docString_ = ""; + /** + *
+       * A human-readable documentation for this function. Markdown is allowed.
+       * 
+ * + * string doc_string = 8; + */ + public java.lang.String getDocString() { + java.lang.Object ref = docString_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + docString_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+       * A human-readable documentation for this function. Markdown is allowed.
+       * 
+ * + * string doc_string = 8; + */ + public com.google.protobuf.ByteString + getDocStringBytes() { + java.lang.Object ref = docString_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + docString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       * A human-readable documentation for this function. Markdown is allowed.
+       * 
+ * + * string doc_string = 8; + */ + public Builder setDocString( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + docString_ = value; + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this function. Markdown is allowed.
+       * 
+ * + * string doc_string = 8; + */ + public Builder clearDocString() { + + docString_ = getDefaultInstance().getDocString(); + onChanged(); + return this; + } + /** + *
+       * A human-readable documentation for this function. Markdown is allowed.
+       * 
+ * + * string doc_string = 8; + */ + public Builder setDocStringBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + docString_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:onnx.FunctionProto) + } + + // @@protoc_insertion_point(class_scope:onnx.FunctionProto) + private static final OnnxMl.FunctionProto DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new OnnxMl.FunctionProto(); + } + + public static OnnxMl.FunctionProto getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FunctionProto parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new FunctionProto(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public OnnxMl.FunctionProto getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_AttributeProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_AttributeProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_ValueInfoProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_ValueInfoProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_NodeProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_NodeProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_ModelProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_ModelProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_StringStringEntryProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_StringStringEntryProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TensorAnnotation_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TensorAnnotation_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_GraphProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_GraphProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TensorProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TensorProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TensorProto_Segment_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TensorProto_Segment_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_SparseTensorProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_SparseTensorProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TensorShapeProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TensorShapeProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TensorShapeProto_Dimension_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TensorShapeProto_Dimension_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TypeProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TypeProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TypeProto_Tensor_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TypeProto_Tensor_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TypeProto_Sequence_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TypeProto_Sequence_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TypeProto_Map_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TypeProto_Map_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TypeProto_SparseTensor_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TypeProto_SparseTensor_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_TypeProto_Opaque_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_TypeProto_Opaque_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_OperatorSetIdProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_OperatorSetIdProto_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_onnx_FunctionProto_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_onnx_FunctionProto_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\016onnx-ml.proto3\022\004onnx\"\350\004\n\016AttributeProt" + + "o\022\014\n\004name\030\001 \001(\t\022\025\n\rref_attr_name\030\025 \001(\t\022\022" + + "\n\ndoc_string\030\r \001(\t\0220\n\004type\030\024 \001(\0162\".onnx." + + "AttributeProto.AttributeType\022\t\n\001f\030\002 \001(\002\022" + + "\t\n\001i\030\003 \001(\003\022\t\n\001s\030\004 \001(\014\022\034\n\001t\030\005 \001(\0132\021.onnx." + + "TensorProto\022\033\n\001g\030\006 \001(\0132\020.onnx.GraphProto" + + "\022.\n\rsparse_tensor\030\026 \001(\0132\027.onnx.SparseTen" + + "sorProto\022\016\n\006floats\030\007 \003(\002\022\014\n\004ints\030\010 \003(\003\022\017" + + "\n\007strings\030\t \003(\014\022\"\n\007tensors\030\n \003(\0132\021.onnx." + + "TensorProto\022 \n\006graphs\030\013 \003(\0132\020.onnx.Graph" + + "Proto\022/\n\016sparse_tensors\030\027 \003(\0132\027.onnx.Spa" + + "rseTensorProto\"\270\001\n\rAttributeType\022\r\n\tUNDE" + + "FINED\020\000\022\t\n\005FLOAT\020\001\022\007\n\003INT\020\002\022\n\n\006STRING\020\003\022" + + "\n\n\006TENSOR\020\004\022\t\n\005GRAPH\020\005\022\021\n\rSPARSE_TENSOR\020" + + "\013\022\n\n\006FLOATS\020\006\022\010\n\004INTS\020\007\022\013\n\007STRINGS\020\010\022\013\n\007" + + "TENSORS\020\t\022\n\n\006GRAPHS\020\n\022\022\n\016SPARSE_TENSORS\020" + + "\014\"Q\n\016ValueInfoProto\022\014\n\004name\030\001 \001(\t\022\035\n\004typ" + + "e\030\002 \001(\0132\017.onnx.TypeProto\022\022\n\ndoc_string\030\003" + + " \001(\t\"\226\001\n\tNodeProto\022\r\n\005input\030\001 \003(\t\022\016\n\006out" + + "put\030\002 \003(\t\022\014\n\004name\030\003 \001(\t\022\017\n\007op_type\030\004 \001(\t" + + "\022\016\n\006domain\030\007 \001(\t\022\'\n\tattribute\030\005 \003(\0132\024.on" + + "nx.AttributeProto\022\022\n\ndoc_string\030\006 \001(\t\"\273\002" + + "\n\nModelProto\022\022\n\nir_version\030\001 \001(\003\022.\n\014opse" + + "t_import\030\010 \003(\0132\030.onnx.OperatorSetIdProto" + + "\022\025\n\rproducer_name\030\002 \001(\t\022\030\n\020producer_vers" + + "ion\030\003 \001(\t\022\016\n\006domain\030\004 \001(\t\022\025\n\rmodel_versi" + + "on\030\005 \001(\003\022\022\n\ndoc_string\030\006 \001(\t\022\037\n\005graph\030\007 " + + "\001(\0132\020.onnx.GraphProto\022&\n\tfunctions\030d \003(\013" + + "2\023.onnx.FunctionProto\0224\n\016metadata_props\030" + + "\016 \003(\0132\034.onnx.StringStringEntryProto\"4\n\026S" + + "tringStringEntryProto\022\013\n\003key\030\001 \001(\t\022\r\n\005va" + + "lue\030\002 \001(\t\"k\n\020TensorAnnotation\022\023\n\013tensor_" + + "name\030\001 \001(\t\022B\n\034quant_parameter_tensor_nam" + + "es\030\002 \003(\0132\034.onnx.StringStringEntryProto\"\330" + + "\002\n\nGraphProto\022\035\n\004node\030\001 \003(\0132\017.onnx.NodeP" + + "roto\022\014\n\004name\030\002 \001(\t\022&\n\013initializer\030\005 \003(\0132" + + "\021.onnx.TensorProto\0223\n\022sparse_initializer" + + "\030\017 \003(\0132\027.onnx.SparseTensorProto\022\022\n\ndoc_s" + + "tring\030\n \001(\t\022#\n\005input\030\013 \003(\0132\024.onnx.ValueI" + + "nfoProto\022$\n\006output\030\014 \003(\0132\024.onnx.ValueInf" + + "oProto\022(\n\nvalue_info\030\r \003(\0132\024.onnx.ValueI" + + "nfoProto\0227\n\027quantization_annotation\030\016 \003(" + + "\0132\026.onnx.TensorAnnotation\"\270\005\n\013TensorProt" + + "o\022\014\n\004dims\030\001 \003(\003\022\021\n\tdata_type\030\002 \001(\005\022*\n\007se" + + "gment\030\003 \001(\0132\031.onnx.TensorProto.Segment\022\026" + + "\n\nfloat_data\030\004 \003(\002B\002\020\001\022\026\n\nint32_data\030\005 \003" + + "(\005B\002\020\001\022\023\n\013string_data\030\006 \003(\014\022\026\n\nint64_dat" + + "a\030\007 \003(\003B\002\020\001\022\014\n\004name\030\010 \001(\t\022\022\n\ndoc_string\030" + + "\014 \001(\t\022\020\n\010raw_data\030\t \001(\014\0223\n\rexternal_data" + + "\030\r \003(\0132\034.onnx.StringStringEntryProto\0225\n\r" + + "data_location\030\016 \001(\0162\036.onnx.TensorProto.D" + + "ataLocation\022\027\n\013double_data\030\n \003(\001B\002\020\001\022\027\n\013" + + "uint64_data\030\013 \003(\004B\002\020\001\032%\n\007Segment\022\r\n\005begi" + + "n\030\001 \001(\003\022\013\n\003end\030\002 \001(\003\"\332\001\n\010DataType\022\r\n\tUND" + + "EFINED\020\000\022\t\n\005FLOAT\020\001\022\t\n\005UINT8\020\002\022\010\n\004INT8\020\003" + + "\022\n\n\006UINT16\020\004\022\t\n\005INT16\020\005\022\t\n\005INT32\020\006\022\t\n\005IN" + + "T64\020\007\022\n\n\006STRING\020\010\022\010\n\004BOOL\020\t\022\013\n\007FLOAT16\020\n" + + "\022\n\n\006DOUBLE\020\013\022\n\n\006UINT32\020\014\022\n\n\006UINT64\020\r\022\r\n\t" + + "COMPLEX64\020\016\022\016\n\nCOMPLEX128\020\017\022\014\n\010BFLOAT16\020" + + "\020\")\n\014DataLocation\022\013\n\007DEFAULT\020\000\022\014\n\010EXTERN" + + "AL\020\001\"h\n\021SparseTensorProto\022!\n\006values\030\001 \001(" + + "\0132\021.onnx.TensorProto\022\"\n\007indices\030\002 \001(\0132\021." + + "onnx.TensorProto\022\014\n\004dims\030\003 \003(\003\"\225\001\n\020Tenso" + + "rShapeProto\022-\n\003dim\030\001 \003(\0132 .onnx.TensorSh" + + "apeProto.Dimension\032R\n\tDimension\022\023\n\tdim_v" + + "alue\030\001 \001(\003H\000\022\023\n\tdim_param\030\002 \001(\tH\000\022\022\n\nden" + + "otation\030\003 \001(\tB\007\n\005value\"\302\004\n\tTypeProto\022-\n\013" + + "tensor_type\030\001 \001(\0132\026.onnx.TypeProto.Tenso" + + "rH\000\0221\n\rsequence_type\030\004 \001(\0132\030.onnx.TypePr" + + "oto.SequenceH\000\022\'\n\010map_type\030\005 \001(\0132\023.onnx." + + "TypeProto.MapH\000\022:\n\022sparse_tensor_type\030\010 " + + "\001(\0132\034.onnx.TypeProto.SparseTensorH\000\022-\n\013o" + + "paque_type\030\007 \001(\0132\026.onnx.TypeProto.Opaque" + + "H\000\022\022\n\ndenotation\030\006 \001(\t\032B\n\006Tensor\022\021\n\telem" + + "_type\030\001 \001(\005\022%\n\005shape\030\002 \001(\0132\026.onnx.Tensor" + + "ShapeProto\032.\n\010Sequence\022\"\n\telem_type\030\001 \001(" + + "\0132\017.onnx.TypeProto\032<\n\003Map\022\020\n\010key_type\030\001 " + + "\001(\005\022#\n\nvalue_type\030\002 \001(\0132\017.onnx.TypeProto" + + "\032H\n\014SparseTensor\022\021\n\telem_type\030\001 \001(\005\022%\n\005s" + + "hape\030\002 \001(\0132\026.onnx.TensorShapeProto\032&\n\006Op" + + "aque\022\016\n\006domain\030\001 \001(\t\022\014\n\004name\030\002 \001(\tB\007\n\005va" + + "lue\"5\n\022OperatorSetIdProto\022\016\n\006domain\030\001 \001(" + + "\t\022\017\n\007version\030\002 \001(\003\"\277\001\n\rFunctionProto\022\014\n\004" + + "name\030\001 \001(\t\022\025\n\rsince_version\030\002 \001(\003\022$\n\006sta" + + "tus\030\003 \001(\0162\024.onnx.OperatorStatus\022\r\n\005input" + + "\030\004 \003(\t\022\016\n\006output\030\005 \003(\t\022\021\n\tattribute\030\006 \003(" + + "\t\022\035\n\004node\030\007 \003(\0132\017.onnx.NodeProto\022\022\n\ndoc_" + + "string\030\010 \001(\t*\261\001\n\007Version\022\022\n\016_START_VERSI" + + "ON\020\000\022\031\n\025IR_VERSION_2017_10_10\020\001\022\031\n\025IR_VE" + + "RSION_2017_10_30\020\002\022\030\n\024IR_VERSION_2017_11" + + "_3\020\003\022\030\n\024IR_VERSION_2019_1_22\020\004\022\030\n\024IR_VER" + + "SION_2019_3_18\020\005\022\016\n\nIR_VERSION\020\006*.\n\016Oper" + + "atorStatus\022\020\n\014EXPERIMENTAL\020\000\022\n\n\006STABLE\020\001" + + "b\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_onnx_AttributeProto_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_onnx_AttributeProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_AttributeProto_descriptor, + new java.lang.String[] { "Name", "RefAttrName", "DocString", "Type", "F", "I", "S", "T", "G", "SparseTensor", "Floats", "Ints", "Strings", "Tensors", "Graphs", "SparseTensors", }); + internal_static_onnx_ValueInfoProto_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_onnx_ValueInfoProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_ValueInfoProto_descriptor, + new java.lang.String[] { "Name", "Type", "DocString", }); + internal_static_onnx_NodeProto_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_onnx_NodeProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_NodeProto_descriptor, + new java.lang.String[] { "Input", "Output", "Name", "OpType", "Domain", "Attribute", "DocString", }); + internal_static_onnx_ModelProto_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_onnx_ModelProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_ModelProto_descriptor, + new java.lang.String[] { "IrVersion", "OpsetImport", "ProducerName", "ProducerVersion", "Domain", "ModelVersion", "DocString", "Graph", "Functions", "MetadataProps", }); + internal_static_onnx_StringStringEntryProto_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_onnx_StringStringEntryProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_StringStringEntryProto_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_onnx_TensorAnnotation_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_onnx_TensorAnnotation_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TensorAnnotation_descriptor, + new java.lang.String[] { "TensorName", "QuantParameterTensorNames", }); + internal_static_onnx_GraphProto_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_onnx_GraphProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_GraphProto_descriptor, + new java.lang.String[] { "Node", "Name", "Initializer", "SparseInitializer", "DocString", "Input", "Output", "ValueInfo", "QuantizationAnnotation", }); + internal_static_onnx_TensorProto_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_onnx_TensorProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TensorProto_descriptor, + new java.lang.String[] { "Dims", "DataType", "Segment", "FloatData", "Int32Data", "StringData", "Int64Data", "Name", "DocString", "RawData", "ExternalData", "DataLocation", "DoubleData", "Uint64Data", }); + internal_static_onnx_TensorProto_Segment_descriptor = + internal_static_onnx_TensorProto_descriptor.getNestedTypes().get(0); + internal_static_onnx_TensorProto_Segment_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TensorProto_Segment_descriptor, + new java.lang.String[] { "Begin", "End", }); + internal_static_onnx_SparseTensorProto_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_onnx_SparseTensorProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_SparseTensorProto_descriptor, + new java.lang.String[] { "Values", "Indices", "Dims", }); + internal_static_onnx_TensorShapeProto_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_onnx_TensorShapeProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TensorShapeProto_descriptor, + new java.lang.String[] { "Dim", }); + internal_static_onnx_TensorShapeProto_Dimension_descriptor = + internal_static_onnx_TensorShapeProto_descriptor.getNestedTypes().get(0); + internal_static_onnx_TensorShapeProto_Dimension_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TensorShapeProto_Dimension_descriptor, + new java.lang.String[] { "DimValue", "DimParam", "Denotation", "Value", }); + internal_static_onnx_TypeProto_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_onnx_TypeProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TypeProto_descriptor, + new java.lang.String[] { "TensorType", "SequenceType", "MapType", "SparseTensorType", "OpaqueType", "Denotation", "Value", }); + internal_static_onnx_TypeProto_Tensor_descriptor = + internal_static_onnx_TypeProto_descriptor.getNestedTypes().get(0); + internal_static_onnx_TypeProto_Tensor_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TypeProto_Tensor_descriptor, + new java.lang.String[] { "ElemType", "Shape", }); + internal_static_onnx_TypeProto_Sequence_descriptor = + internal_static_onnx_TypeProto_descriptor.getNestedTypes().get(1); + internal_static_onnx_TypeProto_Sequence_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TypeProto_Sequence_descriptor, + new java.lang.String[] { "ElemType", }); + internal_static_onnx_TypeProto_Map_descriptor = + internal_static_onnx_TypeProto_descriptor.getNestedTypes().get(2); + internal_static_onnx_TypeProto_Map_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TypeProto_Map_descriptor, + new java.lang.String[] { "KeyType", "ValueType", }); + internal_static_onnx_TypeProto_SparseTensor_descriptor = + internal_static_onnx_TypeProto_descriptor.getNestedTypes().get(3); + internal_static_onnx_TypeProto_SparseTensor_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TypeProto_SparseTensor_descriptor, + new java.lang.String[] { "ElemType", "Shape", }); + internal_static_onnx_TypeProto_Opaque_descriptor = + internal_static_onnx_TypeProto_descriptor.getNestedTypes().get(4); + internal_static_onnx_TypeProto_Opaque_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_TypeProto_Opaque_descriptor, + new java.lang.String[] { "Domain", "Name", }); + internal_static_onnx_OperatorSetIdProto_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_onnx_OperatorSetIdProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_OperatorSetIdProto_descriptor, + new java.lang.String[] { "Domain", "Version", }); + internal_static_onnx_FunctionProto_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_onnx_FunctionProto_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_onnx_FunctionProto_descriptor, + new java.lang.String[] { "Name", "SinceVersion", "Status", "Input", "Output", "Attribute", "Node", "DocString", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java/src/test/java/ai/onnxruntime/TestHelpers.java b/java/src/test/java/ai/onnxruntime/TestHelpers.java new file mode 100644 index 0000000000000..f4d3bded2098a --- /dev/null +++ b/java/src/test/java/ai/onnxruntime/TestHelpers.java @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Test helpers for manipulating primitive arrays. + */ +class TestHelpers { + + static boolean[] toPrimitiveBoolean(List input) { + boolean[] output = new boolean[input.size()]; + + for (int i = 0; i < output.length; i++) { + output[i] = input.get(i); + } + + return output; + } + + static byte[] toPrimitiveByte(List input) { + byte[] output = new byte[input.size()]; + + for (int i = 0; i < output.length; i++) { + output[i] = input.get(i); + } + + return output; + } + + static short[] toPrimitiveShort(List input) { + short[] output = new short[input.size()]; + + for (int i = 0; i < output.length; i++) { + output[i] = input.get(i); + } + + return output; + } + + static int[] toPrimitiveInteger(List input) { + int[] output = new int[input.size()]; + + for (int i = 0; i < output.length; i++) { + output[i] = input.get(i); + } + + return output; + } + + static long[] toPrimitiveLong(List input) { + long[] output = new long[input.size()]; + + for (int i = 0; i < output.length; i++) { + output[i] = input.get(i); + } + + return output; + } + + static float[] toPrimitiveFloat(List input) { + float[] output = new float[input.size()]; + + for (int i = 0; i < output.length; i++) { + output[i] = input.get(i); + } + + return output; + } + + static double[] toPrimitiveDouble(List input) { + double[] output = new double[input.size()]; + + for (int i = 0; i < output.length; i++) { + output[i] = input.get(i); + } + + return output; + } + + static boolean[] flattenBoolean(Object o) { + List output = new ArrayList<>(); + + flatten((Object[]) o,output, boolean.class); + + return toPrimitiveBoolean(output); + } + + static byte[] flattenByte(Object o) { + List output = new ArrayList<>(); + + flatten((Object[]) o,output, byte.class); + + return toPrimitiveByte(output); + } + + static short[] flattenShort(Object o) { + List output = new ArrayList<>(); + + flatten((Object[]) o,output, short.class); + + return toPrimitiveShort(output); + } + + static int[] flattenInteger(Object o) { + List output = new ArrayList<>(); + + flatten((Object[]) o,output, int.class); + + return toPrimitiveInteger(output); + } + + static long[] flattenLong(Object o) { + List output = new ArrayList<>(); + + flatten((Object[]) o,output, long.class); + + return toPrimitiveLong(output); + } + + static float[] flattenFloat(Object o) { + List output = new ArrayList<>(); + + flatten((Object[]) o,output, float.class); + + return toPrimitiveFloat(output); + } + + static double[] flattenDouble(Object o) { + List output = new ArrayList<>(); + + flatten((Object[]) o,output, double.class); + + return toPrimitiveDouble(output); + } + + static String[] flattenString(Object o) { + List output = new ArrayList<>(); + + flatten((Object[]) o,output, String.class); + + return output.toArray(new String[0]); + } + + static void flatten(Object[] input, List output, Class primitiveClazz) { + for (Object i : input) { + Class iClazz = i.getClass(); + if (iClazz.isArray()) { + if (iClazz.getComponentType().isArray()) { + flatten((Object[]) i, output, primitiveClazz); + } else if ((iClazz.getComponentType().isPrimitive() || iClazz.getComponentType().equals(String.class)) && iClazz.getComponentType().equals(primitiveClazz)){ + flattenBase(i,output,primitiveClazz); + } else { + throw new IllegalStateException("Found a non-primitive, non-array element type, " + iClazz); + } + } else { + throw new IllegalStateException("Found an element type where there should have been an array. Class = " + iClazz); + } + } + } + + static void flattenBase(Object input, List output, Class primitiveClass) { + if (primitiveClass.equals(boolean.class)) { + flattenBooleanBase((boolean[])input,output); + } else if (primitiveClass.equals(byte.class)) { + flattenByteBase((byte[])input,output); + } else if (primitiveClass.equals(short.class)) { + flattenShortBase((short[])input,output); + } else if (primitiveClass.equals(int.class)) { + flattenIntBase((int[])input,output); + } else if (primitiveClass.equals(long.class)) { + flattenLongBase((long[])input,output); + } else if (primitiveClass.equals(float.class)) { + flattenFloatBase((float[])input,output); + } else if (primitiveClass.equals(double.class)) { + flattenDoubleBase((double[]) input, output); + } else if (primitiveClass.equals(String.class)) { + flattenStringBase((String[]) input, output); + } else { + throw new IllegalStateException("Flattening a non-primitive class"); + } + } + + static void flattenBooleanBase(boolean[] input, List output) { + for (int i = 0; i < input.length; i++) { + output.add(input[i]); + } + } + + static void flattenByteBase(byte[] input, List output) { + for (int i = 0; i < input.length; i++) { + output.add(input[i]); + } + } + + static void flattenShortBase(short[] input, List output) { + for (int i = 0; i < input.length; i++) { + output.add(input[i]); + } + } + + static void flattenIntBase(int[] input, List output) { + for (int i = 0; i < input.length; i++) { + output.add(input[i]); + } + } + + static void flattenLongBase(long[] input, List output) { + for (int i = 0; i < input.length; i++) { + output.add(input[i]); + } + } + + static void flattenFloatBase(float[] input, List output) { + for (int i = 0; i < input.length; i++) { + output.add(input[i]); + } + } + + static void flattenDoubleBase(double[] input, List output) { + for (int i = 0; i < input.length; i++) { + output.add(input[i]); + } + } + + static void flattenStringBase(String[] input, List output) { + output.addAll(Arrays.asList(input)); + } + +} diff --git a/java/src/test/java/ai/onnxruntime/UtilTest.java b/java/src/test/java/ai/onnxruntime/UtilTest.java new file mode 100644 index 0000000000000..c3e116aca0b96 --- /dev/null +++ b/java/src/test/java/ai/onnxruntime/UtilTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Licensed under the MIT License. + */ +package ai.onnxruntime; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * + */ +public class UtilTest { + + @Test + public void reshapeTest() { + float[] input = new float[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29}; + + long[] candidateShape = new long[]{1,3,2,5}; + + float[][][][] reshapedArray = (float[][][][]) OrtUtil.reshape(input,candidateShape); + + float[] firstTestArray = new float[]{0,1,2,3,4}; + float[] secondTestArray = new float[]{5,6,7,8,9}; + float[] thirdTestArray = new float[]{10,11,12,13,14}; + float[] fourthTestArray = new float[]{15,16,17,18,19}; + float[] fifthTestArray = new float[]{20,21,22,23,24}; + float[] sixthTestArray = new float[]{25,26,27,28,29}; + + Assertions.assertArrayEquals(firstTestArray,reshapedArray[0][0][0]); + Assertions.assertArrayEquals(secondTestArray,reshapedArray[0][0][1]); + Assertions.assertArrayEquals(thirdTestArray,reshapedArray[0][1][0]); + Assertions.assertArrayEquals(fourthTestArray,reshapedArray[0][1][1]); + Assertions.assertArrayEquals(fifthTestArray,reshapedArray[0][2][0]); + Assertions.assertArrayEquals(sixthTestArray,reshapedArray[0][2][1]); + } + + @Test + public void reshape4DTest() { + float[] input = new float[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35}; + + long[] candidateShape = new long[]{3,3,2,2}; + + float[][][][] reshapedArray = (float[][][][]) OrtUtil.reshape(input,candidateShape); + + float[] oneTestArray = new float[]{0,1}; + float[] twoTestArray = new float[]{2,3}; + float[] threeTestArray = new float[]{4,5}; + float[] fourTestArray = new float[]{6,7}; + float[] fiveTestArray = new float[]{8,9}; + float[] sixTestArray = new float[]{10,11}; + float[] sevenTestArray = new float[]{12,13}; + float[] eightTestArray = new float[]{14,15}; + float[] nineTestArray = new float[]{16,17}; + float[] tenTestArray = new float[]{18,19}; + float[] elevenTestArray = new float[]{20,21}; + float[] twelveTestArray = new float[]{22,23}; + float[] thirteenTestArray = new float[]{24,25}; + float[] fourteenTestArray = new float[]{26,27}; + float[] fifteenTestArray = new float[]{28,29}; + float[] sixteenTestArray = new float[]{30,31}; + float[] seventeenTestArray = new float[]{32,33}; + float[] eighteenTestArray = new float[]{34,35}; + + Assertions.assertArrayEquals(oneTestArray,reshapedArray[0][0][0]); + Assertions.assertArrayEquals(twoTestArray,reshapedArray[0][0][1]); + Assertions.assertArrayEquals(threeTestArray,reshapedArray[0][1][0]); + Assertions.assertArrayEquals(fourTestArray,reshapedArray[0][1][1]); + Assertions.assertArrayEquals(fiveTestArray,reshapedArray[0][2][0]); + Assertions.assertArrayEquals(sixTestArray,reshapedArray[0][2][1]); + Assertions.assertArrayEquals(sevenTestArray,reshapedArray[1][0][0]); + Assertions.assertArrayEquals(eightTestArray,reshapedArray[1][0][1]); + Assertions.assertArrayEquals(nineTestArray,reshapedArray[1][1][0]); + Assertions.assertArrayEquals(tenTestArray,reshapedArray[1][1][1]); + Assertions.assertArrayEquals(elevenTestArray,reshapedArray[1][2][0]); + Assertions.assertArrayEquals(twelveTestArray,reshapedArray[1][2][1]); + Assertions.assertArrayEquals(thirteenTestArray,reshapedArray[2][0][0]); + Assertions.assertArrayEquals(fourteenTestArray,reshapedArray[2][0][1]); + Assertions.assertArrayEquals(fifteenTestArray,reshapedArray[2][1][0]); + Assertions.assertArrayEquals(sixteenTestArray,reshapedArray[2][1][1]); + Assertions.assertArrayEquals(seventeenTestArray,reshapedArray[2][2][0]); + Assertions.assertArrayEquals(eighteenTestArray,reshapedArray[2][2][1]); + } + +} diff --git a/onnxruntime/core/framework/allocation_planner.cc b/onnxruntime/core/framework/allocation_planner.cc index 2b287c89f2393..3348f46fd43cc 100644 --- a/onnxruntime/core/framework/allocation_planner.cc +++ b/onnxruntime/core/framework/allocation_planner.cc @@ -325,6 +325,7 @@ class PlannerImpl { auto p_required_buffer_shape = context_.GetShape(output_arg); if (nullptr == p_required_buffer_shape) return false; auto& required_memory_info = AllocPlan(output_arg.Name()).location; + if (HasFence(&output_arg)) return false; for (auto it = freelist_.begin(); it != freelist_.end(); ++it) { size_t reusable = static_cast(it->ml_value); diff --git a/onnxruntime/core/optimizer/embed_layer_norm_fusion.cc b/onnxruntime/core/optimizer/embed_layer_norm_fusion.cc index 970de353f5392..f7d9440a51d87 100644 --- a/onnxruntime/core/optimizer/embed_layer_norm_fusion.cc +++ b/onnxruntime/core/optimizer/embed_layer_norm_fusion.cc @@ -65,17 +65,428 @@ static bool CheckInput(NodeArg* input, const logging::Logger& logger) { return true; } +static void AddNodes(std::vector& node_indices, + const std::vector& edges) { + for (size_t i = 0; i < edges.size(); i++) { + auto item = edges[i]->GetNode().Index(); + // Avoid duplication. + if (std::find(node_indices.begin(), node_indices.end(), item) != node_indices.end()) { + continue; + } + node_indices.push_back(item); + } +} + +/** Match subgraph like the following: + (input_ids) + / \ + Shape Shape + | | + Gather (indice=0) Gather (indice=1)--+ + | | | + Unsqueeze Unsqueeze | + \ / | + \ / [other subgraph] + \ / | + Concat | + | | + +----------------------------+--+ + | | + [Expand] + | + [Gather] (for position embedding) + + Note that expand_node is the Expand node in the graph, and + expected_gather_node_1_index is node index of the gather with indices=1. + + The Expand and Gather on the bottom will not be added to subgraph_node_indices. + It is because they are matched as part of other subgraph. +*/ + +static bool MatchPositionSubgraph( + Graph& graph, + const Node& expand_node, + const NodeArg* input_ids, + const logging::Logger& logger, + std::vector& subgraph_node_indices, + const NodeIndex expected_gather_node_1_index) { + subgraph_node_indices.clear(); + + std::vector expand_parent_path1{ + {0, 1, "Concat", {4, 11}, kOnnxDomain}, + {0, 0, "Unsqueeze", {1, 11}, kOnnxDomain}, + {0, 0, "Gather", {1, 11}, kOnnxDomain}, + {0, 0, "Shape", {1}, kOnnxDomain}, + }; + + std::vector edges; + if (!graph_utils::FindPath(expand_node, true, expand_parent_path1, edges, logger)) { + DEBUG_LOG("Failed to find path 1 of position shape."); + return false; + } + for (size_t i = 0; i < edges.size(); i++) { + if (edges[i]->GetNode().GetOutputEdgesCount() != 1) { + DEBUG_LOG("Output edge count not expected for nodes in path 1 of position shape."); + return false; + } + } + + Node& concat_node = *graph.GetNode(edges[0]->GetNode().Index()); + Node& gather_node_0 = *graph.GetNode(edges[2]->GetNode().Index()); + Node& shape_node_0 = *graph.GetNode(edges[3]->GetNode().Index()); + if (!optimizer_utils::IsInitializerWithExpectedValue(graph, *(gather_node_0.InputDefs()[1]), int64_t(0), true)) { + DEBUG_LOG("Second input of Gather in path 1 of position shape should be a constant with value 0."); + return false; + } + + AddNodes(subgraph_node_indices, edges); + + std::vector concat_parent_path{ + {0, 1, "Unsqueeze", {1, 11}, kOnnxDomain}, + {0, 0, "Gather", {1, 11}, kOnnxDomain}, + {0, 0, "Shape", {1}, kOnnxDomain}}; + + if (!graph_utils::FindPath(concat_node, true, concat_parent_path, edges, logger)) { + DEBUG_LOG("Failed to find path 2 of position shape."); + return false; + } + + if (edges[0]->GetNode().GetOutputEdgesCount() != 1 || + edges[1]->GetNode().GetOutputEdgesCount() != 2 || + edges[2]->GetNode().GetOutputEdgesCount() != 1) { + DEBUG_LOG("Output edge count not expected for nodes in path 2 of position shape."); + return false; + } + + Node& gather_node_1 = *graph.GetNode(edges[1]->GetNode().Index()); + Node& shape_node_1 = *graph.GetNode(edges[2]->GetNode().Index()); + + // The gather node (with second input indices==1) is also shared by other subgraph + if (expected_gather_node_1_index != gather_node_1.Index()) { + DEBUG_LOG("Gather node in path 2 is not linked to another subgraph."); + return false; + } + + if (!optimizer_utils::IsInitializerWithExpectedValue(graph, *(gather_node_1.InputDefs()[1]), int64_t(1), true)) { + DEBUG_LOG("Second input of Gather in path 2 of position shape should be a constant with value 1."); + return false; + } + + // Check if the two paths of position gather lead to the same input. + if (shape_node_0.MutableInputDefs()[0] != input_ids || + shape_node_1.MutableInputDefs()[0] != input_ids) { + DEBUG_LOG("The parent of two shape nodes are expected to be input_ids."); + return false; + } + + AddNodes(subgraph_node_indices, edges); + return true; +} + +/** Match subgraph like the following: + (input_ids) + / \ + Shape Shape + | | + ^Gather (indice=0)^ Gather (indice=1)--+ + ^|^ ^|^ | + ^Unsqueeze^ ^Unsqueeze^ Unsqueeze + ^\^ ^/^ | + ^\^ ^/^ ConstantOfShape + ^\^ ^/^ | + ^Concat^ NonZero + | | + | Transpose + | | + | Squeeze + | | + | Cast + | | + | Unsqueeze + +--|----------------------------+ + | | + Expand + | + Gather + + Note that position gather node is the node in the bottom of above sub-graph. + Paths in ^^ are alternative path to be matched if path input_ids -> Shape -> Expand -> Gather is not found. +*/ +static bool MatchPositionEmbeddingSubgraph1( + Graph& graph, + const Node& position_gather_node, + const NodeArg* input_ids, + const logging::Logger& logger, + std::vector& subgraph_node_indices) { + subgraph_node_indices.clear(); + + std::vector pg_edges; + // Look for Path 1: + // Shape --> Gather --> Unsqueeze --> ConstantOfShape --> NonZero --> Transpose --> Squeeze --> Cast --> Unsqueeze --> Expand --> Gather + if (!graph_utils::FindPath(position_gather_node, true, + {{0, 1, "Expand", {8}, kOnnxDomain}, + {0, 0, "Unsqueeze", {1, 11}, kOnnxDomain}, + {0, 0, "Cast", {9}, kOnnxDomain}, + {0, 0, "Squeeze", {1, 11}, kOnnxDomain}, + {0, 0, "Transpose", {1}, kOnnxDomain}, + {0, 0, "NonZero", {9}, kOnnxDomain}, + {0, 0, "ConstantOfShape", {9}, kOnnxDomain}, + {0, 0, "Unsqueeze", {1, 11}, kOnnxDomain}, + {0, 0, "Gather", {1, 11}, kOnnxDomain}, + {0, 0, "Shape", {1}, kOnnxDomain}}, + pg_edges, logger)) { + return false; + } + const size_t gather_index = 8; + auto gather_output_edges_count = pg_edges[gather_index]->GetNode().GetOutputEdgesCount(); + // All nodes in Path 1 must have only 1 output edge, except the gather node allowed 1 or 2 output edges + for (size_t i = 0; i < pg_edges.size(); i++) { + if (pg_edges[i]->GetNode().GetOutputEdgesCount() != 1) { + if (i == gather_index && gather_output_edges_count == 2) { + continue; + } + DEBUG_LOG("Output edge count not expected for nodes in path1."); + return false; + } + } + + Node& expand_node = *graph.GetNode(pg_edges[0]->GetNode().Index()); + Node& gather_node = *graph.GetNode(pg_edges[gather_index]->GetNode().Index()); + + if (gather_output_edges_count == 1) { + // Check if the second input of the Gather node in the path has a constant input of 1 + // For gather_output_edges_count == 2, such checks are in MatchPositionSubgraph function. + if (!optimizer_utils::IsInitializerWithExpectedValue(graph, *(gather_node.InputDefs()[1]), int64_t(1), true)) { + DEBUG_LOG("Second input of Gather should be a constant with value 1. "); + return false; + } + + // Match Shape --> Expand path. + std::vector pg_edges_2; + if (!graph_utils::FindPath(expand_node, true, {{0, 1, "Shape", {1}, kOnnxDomain}}, pg_edges_2, logger)) { + DEBUG_LOG("Failed to match Shape node. "); + return false; + } + auto shape_node_index = pg_edges_2[0]->GetNode().Index(); + + // Check if the two paths of position gather lead to the same input. + Node& shape_node_1 = *graph.GetNode(pg_edges[pg_edges.size() - 1]->GetNode().Index()); + Node& shape_node_2 = *graph.GetNode(shape_node_index); + if (shape_node_1.MutableInputDefs()[0] != input_ids || + shape_node_2.MutableInputDefs()[0] != input_ids) { + DEBUG_LOG("The parent of shape nodes are expected to be input_ids."); + return false; + } + + subgraph_node_indices.push_back(shape_node_index); + } else { // gather_output_edges_count == 2 + if (!MatchPositionSubgraph(graph, expand_node, input_ids, logger, subgraph_node_indices, gather_node.Index())) { + DEBUG_LOG("Failed to match position subgraph."); + return false; + } + } + + AddNodes(subgraph_node_indices, pg_edges); + + return true; +} + +/** Match subgraph like the following: + (input_ids) + / \ + Shape Shape + | | + Gather (indice=0) Gather (indice=1)--+ + | | | + Unsqueeze Unsqueeze Cast + \ / | + \ / Range(start=0, delta=1) + \ / | + Concat Unsqueeze + | | + +--|----------------------------+ + | | + Expand + | + Gather + + Note that position gather node is the node in the bottom of above sub-graph. +*/ + +static bool MatchPositionEmbeddingSubgraph2( + Graph& graph, + const Node& position_gather_node, + const NodeArg* input_ids, + const logging::Logger& logger, + std::vector& subgraph_node_indices) { + subgraph_node_indices.clear(); + + // Match Gather <-- Expand <-- Unsqueeze <-- Range <-- Cast <-- Gather + // Since Range is from opset 11, we only match opset 11 here. + std::vector position_parent_nodes; + std::vector position_embedding_path_symbolic{ + {0, 1, "Expand", {8}, kOnnxDomain}, + {0, 0, "Unsqueeze", {11}, kOnnxDomain}, + {0, 0, "Range", {11}, kOnnxDomain}, + {0, 1, "Cast", {9}, kOnnxDomain}, + {0, 0, "Gather", {11}, kOnnxDomain}}; + std::vector edges; + if (!graph_utils::FindPath(position_gather_node, true, position_embedding_path_symbolic, edges, logger)) { + DEBUG_LOG("Failed to find path 1."); + return false; + } + for (size_t i = 0; i < edges.size(); i++) { + if (edges[i]->GetNode().GetOutputEdgesCount() != (i == 4 ? 2 : 1)) { + DEBUG_LOG("Output edge count not expected for nodes in path 1."); + return false; + } + } + + Node& expand_node = *graph.GetNode(edges[0]->GetNode().Index()); + Node& range_node = *graph.GetNode(edges[2]->GetNode().Index()); + Node& gather_node_1 = *graph.GetNode(edges[4]->GetNode().Index()); + if (!optimizer_utils::IsInitializerWithExpectedValue(graph, *(range_node.InputDefs()[0]), int64_t(0), true)) { + DEBUG_LOG("The first input of Range should be a constant with value 0."); + return false; + } + if (!optimizer_utils::IsInitializerWithExpectedValue(graph, *(range_node.InputDefs()[2]), int64_t(1), true)) { + DEBUG_LOG("The third input of Range should be a constant with value 1."); + return false; + } + + if (!MatchPositionSubgraph(graph, expand_node, input_ids, logger, subgraph_node_indices, gather_node_1.Index())) { + DEBUG_LOG("Failed to match position subgraph."); + return false; + } + + AddNodes(subgraph_node_indices, edges); + + return true; +} + +static bool MatchPositionEmbeddingSubgraph( + Graph& graph, + const Node& add_node, + const NodeArg* input_ids, + const logging::Logger& logger, + std::vector& subgraph_node_indices, + NodeArg*& position_embedding) { + // Traceback the Add node to find (Shape --> Expand -->) Gather --> Add. + // Constant folding removes Shape and Expand nodes when input has static shape. + // In that case just look for Gather --> Add. + std::vector edges; + if (!graph_utils::FindPath(add_node, true, {{0, 1, "Gather", {1, 11}, kOnnxDomain}}, edges, logger)) { + return false; + } + Node& position_gather_node = *graph.GetNode(edges[0]->GetNode().Index()); + if (position_gather_node.GetOutputEdgesCount() != 1) { + return false; + } + + // The first input of position_gather_node must be 2d. + position_embedding = position_gather_node.MutableInputDefs()[0]; + + // Check the second input of position gather. There are the following cases: + // (1) it is initializer. + // (2) it is not initializer and matches subgraph 1 (for opset 10) or 2 (for opset 11). + if (graph_utils::IsConstantInitializer(graph, position_gather_node.MutableInputDefs()[1]->Name())) { + // Check that the tensor has shape (batch_size, sequence_length) + std::vector data; + auto expected_shape = input_ids->Shape(); + if (!optimizer_utils::AppendTensorFromInitializer(graph, *(position_gather_node.MutableInputDefs()[1]), data) || + !utils::HasDimValue(expected_shape->dim()[0]) || + !utils::HasDimValue(expected_shape->dim()[1]) || + static_cast(data.size()) != expected_shape->dim()[0].dim_value() * expected_shape->dim()[1].dim_value()) { + return false; + } + + // Check the tensor value is like [0, 1, ..., sequence_length -1] for each batch. + int64_t expected_value = 0; + for (size_t i = 0; i < data.size(); i++) { + if (data[i] != expected_value) { + return false; + } + expected_value++; + if (expected_value >= static_cast(expected_shape->dim()[1].dim_value())) { + expected_value = 0; + } + } + } else { + if (!MatchPositionEmbeddingSubgraph1(graph, position_gather_node, input_ids, logger, subgraph_node_indices)) { + if (!MatchPositionEmbeddingSubgraph2(graph, position_gather_node, input_ids, logger, subgraph_node_indices)) { + return false; + } + } + } + + subgraph_node_indices.push_back(position_gather_node.Index()); + return true; +} + +template +bool CheckEmbeddingData(const T* data, int64_t batch_size, int64_t element_count) { + // check that all batches has same data. + size_t data_length = batch_size * element_count; + for (size_t i = element_count; i < data_length; i++) { + if (data[i] != data[i % element_count]) { + return false; + } + } + return true; +} + +static NodeArg* ExtractEmbedding(Graph& graph, + int64_t batch_size, + int64_t sequence_length, + int64_t hidden_size, + const ONNX_NAMESPACE::TensorProto* tensor) { + assert(nullptr != tensor); + assert(batch_size > 0); + assert(sequence_length > 0); + assert(hidden_size > 0); + + auto old_initializer = onnxruntime::make_unique(*tensor); + auto data_type = tensor->data_type(); + + ONNX_NAMESPACE::TensorProto initializer; + initializer.set_name(graph.GenerateNodeArgName("position_embeddings")); + initializer.add_dims(sequence_length); + initializer.add_dims(hidden_size); + initializer.set_data_type(data_type); + const int64_t element_count = sequence_length * hidden_size; + + if (data_type == ONNX_NAMESPACE::TensorProto_DataType_FLOAT) { + const float* data = old_initializer->data(); + if (!CheckEmbeddingData(data, batch_size, element_count)) { + return nullptr; + } + + initializer.set_raw_data(data, element_count * sizeof(float)); + } else { // data_type == ONNX_NAMESPACE::TensorProto_DataType_FLOAT16 + const MLFloat16* data = old_initializer->data(); + if (!CheckEmbeddingData(data, batch_size, element_count)) { + return nullptr; + } + + initializer.set_raw_data(data, element_count * sizeof(MLFloat16)); + } + + NodeArg& node_arg = graph_utils::AddInitializer(graph, initializer); + return &node_arg; +} + /** Embed Layer Normalization will fuse embeddings and mask processing into one node : The embeddings before conversion: - (input_ids) --------> Gather ----------+ (segment_ids) - | | | - | v v - +--> Shape --> Expand -> Gather---->Add Gather - | ^ | | - | | v v - +---(optional graph) SkipLayerNormalization - + (input_ids) --------> Gather ---------+ (segment_ids) + | | | + | v v + +--> Shape --> Expand -> Gather---->Add Gather + | ^ \ / + | | \ / + +---(optional graph) Add + | + LayerNormalization */ Status EmbedLayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_level, const logging::Logger& logger) const { GraphViewer graph_viewer(graph); @@ -91,7 +502,7 @@ Status EmbedLayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_l !graph_utils::IsSupportedProvider(layer_norm_node, GetCompatibleExecutionProviders())) { continue; } - // Find Attention after SkipLayerNormalization + // Find Attention after LayerNormalization const Node* p_attention = graph_utils::FirstChildByType(layer_norm_node, "Attention"); // Stop EmbedLayerNormalization fusion if Attention is not found. if (p_attention == nullptr) { @@ -115,7 +526,7 @@ Status EmbedLayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_l } Node& layer_norm_add_node = *graph.GetNode(edges[0]->GetNode().Index()); - // Traceback the SkipLayerNormalization node to find Gather --> SkipLayerNormalization + // Trace back to find the Gather for segment embedding. std::vector segment_embedding_path{ {0, 1, "Gather", {1, 11}, kOnnxDomain}}; if (!graph_utils::FindPath(layer_norm_add_node, true, segment_embedding_path, edges, logger)) { @@ -133,8 +544,9 @@ Status EmbedLayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_l sg_shape->dim()[1].dim_value() <= 0) { continue; } + auto hidden_size = sg_shape->dim()[1].dim_value(); - // Traceback the SkipLayerNormalization node to find Gather --> Add --> SkipLayerNormalization + // Trace back to find Gather --> Add --> LayerNormalization std::vector word_embedding_path{ {0, 0, "Add", {7}, kOnnxDomain}, {0, 0, "Gather", {1, 11}, kOnnxDomain}}; @@ -151,119 +563,79 @@ Status EmbedLayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_l auto wg_shape = word_embedding->Shape(); if (wg_shape == nullptr || wg_shape->dim_size() != 2 || !utils::HasDimValue(wg_shape->dim()[1]) || - wg_shape->dim()[1].dim_value() != sg_shape->dim()[1].dim_value()) { + wg_shape->dim()[1].dim_value() != hidden_size) { + DEBUG_LOG("Word embedding shape not expected."); continue; } - // Traceback the Add node to find (Shape --> Expand -->) Gather --> Add. - // Constant folding removes Shape and Expand nodes when input does not have symbolic shape. In that - // case just look for Gather --> Add. - std::vector position_embedding_path{ - {0, 1, "Gather", {1, 11}, kOnnxDomain}}; - if (!graph_utils::FindPath(add_node, true, position_embedding_path, edges, logger)) { - continue; - } - Node& position_gather_node = *graph.GetNode(edges[0]->GetNode().Index()); - if (position_gather_node.GetOutputEdgesCount() != 1) { - continue; - } - // The first input of position_gather_node must be 2d. - NodeArg* position_embedding = position_gather_node.MutableInputDefs()[0]; - auto pg_shape = position_embedding->Shape(); - if (pg_shape == nullptr || pg_shape->dim_size() != 2 || - !utils::HasDimValue(pg_shape->dim()[1]) || - pg_shape->dim()[1].dim_value() != sg_shape->dim()[1].dim_value()) { - continue; - } + NodeArg* input_ids = word_gather_node.MutableInputDefs()[1]; + NodeArg* position_embedding = nullptr; + std::vector nodes_to_remove; - // Check the second input of position gather. If it's not initializer, check for two paths. - Node* p_expand_node = nullptr; - Node* p_shape_node = nullptr; - std::vector pg_edges; - bool isValidEmbedSubNode = true; - if (graph_utils::IsConstantInitializer(graph, position_gather_node.MutableInputDefs()[1]->Name())) { - // Check if the second input of position gather is a tensor with values evenly spaced by 1 starting from 0. - std::vector data; - auto expected_shape = word_gather_node.MutableInputDefs()[1]->Shape(); - if (!optimizer_utils::AppendTensorFromInitializer(graph, *(position_gather_node.MutableInputDefs()[1]), data) - || !utils::HasDimValue(expected_shape->dim()[0]) - || !utils::HasDimValue(expected_shape->dim()[1]) - || static_cast(data.size()) != expected_shape->dim()[0].dim_value() * expected_shape->dim()[1].dim_value()) { + // ORT constant folding might be applied to position embedding subgraph when input has static shape. + // Here we handle such special case that the input of add node is constant initializer. + auto add_input_name = add_node.MutableInputDefs()[1]->Name(); + if (graph_utils::IsConstantInitializer(graph, add_input_name)) { + // Check that input has static shape. + auto input_shape = input_ids->Shape(); + if (input_shape->dim_size() != 2 || + !utils::HasDimValue(input_shape->dim()[0]) || + !utils::HasDimValue(input_shape->dim()[1])) { + DEBUG_LOG("Input is expected to have dim value in all dimensions."); continue; } - int64_t expected_value = 0; - for (size_t i = 0; i < data.size(); i++) { - if (data[i] != expected_value) { - isValidEmbedSubNode = false; - break; - } - expected_value++; - if (expected_value >= static_cast(expected_shape->dim()[1].dim_value())) { - expected_value = 0; - } - } - } else { - // Match two paths. - // Match Shape --> Expand path if needed. - std::vector position_parent_nodes; - std::vector position_embedding_path_symbolic{ - {0, 1, "Expand", {8}, kOnnxDomain}, - {0, 1, "Shape", {1}, kOnnxDomain}}; - if (!graph_utils::FindPath(position_gather_node, true, position_embedding_path_symbolic, edges, logger)) { + + int64_t batch_size = input_shape->dim()[0].dim_value(); + int64_t sequence_length = input_shape->dim()[1].dim_value(); + if (batch_size <= 0 || sequence_length <= 0) { continue; } - if (edges[0]->GetNode().GetOutputEdgesCount() != 1 && edges[1]->GetNode().GetOutputEdgesCount() != 1) { - continue; - } - p_expand_node = graph.GetNode(edges[0]->GetNode().Index()); - p_shape_node = graph.GetNode(edges[1]->GetNode().Index()); - // Match Shape --> Gather --> Unsqueeze --> ConstantOfShape --> NonZero --> Transpose --> Squeeze --> Cast --> Unsqueeze --> Expand - Node& expand_node = *graph.GetNode(edges[0]->GetNode().Index()); - Node& shape_node_1 = *graph.GetNode(edges[1]->GetNode().Index()); - std::vector pg_parent_path{ - {0, 0, "Unsqueeze", {1, 11}, kOnnxDomain}, - {0, 0, "Cast", {9}, kOnnxDomain}, - {0, 0, "Squeeze", {1}, kOnnxDomain}, - {0, 0, "Transpose", {1}, kOnnxDomain}, - {0, 0, "NonZero", {9}, kOnnxDomain}, - {0, 0, "ConstantOfShape", {9}, kOnnxDomain}, - {0, 0, "Unsqueeze", {1, 11}, kOnnxDomain}, - {0, 0, "Gather", {1, 11}, kOnnxDomain}, - {0, 0, "Shape", {1}, kOnnxDomain}, - }; - if (!graph_utils::FindPath(expand_node, true, pg_parent_path, pg_edges, logger)) { + + const ONNX_NAMESPACE::TensorProto* position_embed_tensor; + if (!graph.GetInitializedTensor(add_input_name, position_embed_tensor)) { + DEBUG_LOG("Failed to get initializer tensor."); continue; } - for (size_t i = 0; i < pg_edges.size(); i++) { - if (pg_edges[i]->GetNode().GetOutputEdgesCount() != 1) { - isValidEmbedSubNode = false; - break; - } - } - // Check if the second input of the Gather node in the path has a constant input of 1 - Node& gather_node = *graph.GetNode(pg_edges[pg_edges.size() - 2]->GetNode().Index()); - if (!optimizer_utils::IsInitializerWithExpectedValue(graph, *(gather_node.InputDefs()[1]), int64_t(1), true)) { - DEBUG_LOG("Second input of Gather should be a constant with value 1. "); - + // Tensor shape shall be [batch_size, sequence_length, hidden_size]. + if (position_embed_tensor->dims_size() != 3 || + position_embed_tensor->dims(0) != batch_size || + position_embed_tensor->dims(1) != sequence_length || + position_embed_tensor->dims(2) != hidden_size) { + DEBUG_LOG("Position embedding shape not matched."); continue; } - // Check if the two paths of position gather lead to the same input. - Node& shape_node_2 = *graph.GetNode(pg_edges[pg_edges.size() - 1]->GetNode().Index()); - if (shape_node_1.MutableInputDefs()[0] != shape_node_2.MutableInputDefs()[0]) { + + // Tensor data type should be float or float16. + const auto data_type = position_embed_tensor->data_type(); + if (data_type != ONNX_NAMESPACE::TensorProto_DataType_FLOAT && + data_type != ONNX_NAMESPACE::TensorProto_DataType_FLOAT16) { + DEBUG_LOG("Position embedding data type shall be float or float16."); continue; } - // Check if the parent of "shape" is the parent of "word gather" - if (shape_node_1.MutableInputDefs()[0] != word_gather_node.MutableInputDefs()[1]) { + + // The tensor has same data for all batches, and we extract only one batch data as position embedding. + position_embedding = ExtractEmbedding(graph, batch_size, sequence_length, hidden_size, position_embed_tensor); + } else { + if (!MatchPositionEmbeddingSubgraph(graph, add_node, input_ids, logger, nodes_to_remove, position_embedding)) { + DEBUG_LOG("Failed to match position embedding subgraph."); continue; } + } + if (position_embedding == nullptr) { + DEBUG_LOG("Failed to get position embedding weights."); + continue; } - if (!isValidEmbedSubNode) { + + auto pg_shape = position_embedding->Shape(); + if (pg_shape == nullptr || pg_shape->dim_size() != 2 || + !utils::HasDimValue(pg_shape->dim()[1]) || + pg_shape->dim()[1].dim_value() != hidden_size) { + DEBUG_LOG("Position embedding shape is not expected."); continue; } // Get input "input_ids" from node. - NodeArg* input_ids = word_gather_node.MutableInputDefs()[1]; if (!CheckInput(input_ids, logger)) { DEBUG_LOG("Input id is not valid. "); continue; @@ -283,32 +655,30 @@ Status EmbedLayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_l continue; } - if (utils::GetTensorShapeFromTensorShapeProto(*(input_ids->Shape())) != - utils::GetTensorShapeFromTensorShapeProto(*(segment_ids->Shape()))) { + if (utils::GetTensorShapeFromTensorShapeProto(*(input_ids->Shape())) != + utils::GetTensorShapeFromTensorShapeProto(*(segment_ids->Shape()))) { DEBUG_LOG("Input_ids and segment id should have the same shape. "); continue; } - if (utils::GetTensorShapeFromTensorShapeProto(*(input_ids->Shape())) != - utils::GetTensorShapeFromTensorShapeProto(*(mask->Shape()))) { + if (utils::GetTensorShapeFromTensorShapeProto(*(input_ids->Shape())) != + utils::GetTensorShapeFromTensorShapeProto(*(mask->Shape()))) { DEBUG_LOG("Input_ids and mask should have the same shape. "); continue; } NodeArg* gamma = layer_norm_node.MutableInputDefs()[1]; NodeArg* beta = layer_norm_node.MutableInputDefs()[2]; - if (gamma->Shape() == nullptr - || gamma->Shape()->dim()[0].dim_value() != word_embedding->Shape()->dim()[1].dim_value()) { + if (gamma->Shape() == nullptr || gamma->Shape()->dim()[0].dim_value() != hidden_size) { DEBUG_LOG("Gamma should be of shape (hidden_size). "); continue; } - if (beta->Shape() == nullptr - || beta->Shape()->dim()[0].dim_value() != word_embedding->Shape()->dim()[1].dim_value()) { + if (beta->Shape() == nullptr || beta->Shape()->dim()[0].dim_value() != hidden_size) { DEBUG_LOG("Beta should be of shape (hidden_size). "); continue; } - // Cast input_ids, segment_ids, and mask to int32 if needed. + // Cast input_ids, segment_ids, and mask to int32 if needed. input_ids = CastToInt32(graph, input_ids, layer_norm_node.GetExecutionProviderType()); segment_ids = CastToInt32(graph, segment_ids, layer_norm_node.GetExecutionProviderType()); mask = CastToInt32(graph, mask, layer_norm_node.GetExecutionProviderType()); @@ -332,19 +702,7 @@ Status EmbedLayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_l // Assign provider to this new node. Provider should be same as the provider for old node. embed_layer_norm_node.SetExecutionProviderType(layer_norm_node.GetExecutionProviderType()); - // move input edges to gather (first in list) across to the embed_layer_norm_node. - // move output definitions and output edges to embed_layer_norm_node. - // remove all the other nodes. - std::vector nodes_to_remove; - for (size_t i = 0; i < pg_edges.size(); i++) { - nodes_to_remove.push_back(pg_edges[i]->GetNode().Index()); - } - if (p_shape_node != nullptr && p_expand_node != nullptr) { - nodes_to_remove.push_back(p_shape_node->Index()); - nodes_to_remove.push_back(p_expand_node->Index()); - } nodes_to_remove.push_back(word_gather_node.Index()); - nodes_to_remove.push_back(position_gather_node.Index()); nodes_to_remove.push_back(segment_gather_node.Index()); nodes_to_remove.push_back(add_node.Index()); nodes_to_remove.push_back(reduce_sum_node.Index()); @@ -358,6 +716,7 @@ Status EmbedLayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_l } modified = true; } + return Status::OK(); } -} // namespace onnxruntime \ No newline at end of file +} // namespace onnxruntime diff --git a/onnxruntime/core/optimizer/layer_norm_fusion.cc b/onnxruntime/core/optimizer/layer_norm_fusion.cc index e57ada81f53e7..7d9b6fc9e32ff 100644 --- a/onnxruntime/core/optimizer/layer_norm_fusion.cc +++ b/onnxruntime/core/optimizer/layer_norm_fusion.cc @@ -153,7 +153,6 @@ Status LayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_level, continue; } nodes_to_remove.push_back(add2_node); - // Traceback the add node to find reduceMean --> add const Node* p_reduce_mean2 = nullptr; @@ -255,6 +254,15 @@ Status LayerNormFusion::ApplyImpl(Graph& graph, bool& modified, int graph_level, layer_norm_input_defs, {}, {}, kOnnxDomain); + // Get constant "epsilon" from "Add2" node if available. Else, default value will be used. + const ONNX_NAMESPACE::TensorProto* tensor_proto = graph_utils::GetConstantInitializer(graph, add2_node.MutableInputDefs()[1]->Name()); + if (tensor_proto != nullptr) { + if (tensor_proto->data_type() == ONNX_NAMESPACE::TensorProto_DataType_FLOAT) { + auto initializer = onnxruntime::make_unique(*tensor_proto); + layer_norm_node.AddAttribute("epsilon", initializer->data()[0]); + } + } + // Assign provider to this new node. Provider should be same as the provider for old node. layer_norm_node.SetExecutionProviderType(reduce_mean_node.GetExecutionProviderType()); diff --git a/onnxruntime/core/optimizer/reshape_fusion.cc b/onnxruntime/core/optimizer/reshape_fusion.cc index 0b54e46745073..0b0172792cd17 100644 --- a/onnxruntime/core/optimizer/reshape_fusion.cc +++ b/onnxruntime/core/optimizer/reshape_fusion.cc @@ -72,7 +72,7 @@ bool ReshapeFusion::Fuse_Subgraph1(Node& reshape, Graph& graph, const logging::L } const Node& concat = *p_concat; - if (!graph_utils::IsSupportedOptypeVersionAndDomain(concat, "Concat", {1, 4})) { + if (!graph_utils::IsSupportedOptypeVersionAndDomain(concat, "Concat", {1, 4, 11})) { return false; } @@ -83,8 +83,8 @@ bool ReshapeFusion::Fuse_Subgraph1(Node& reshape, Graph& graph, const logging::L // path 1: [Root] --> Shape --> Gather(indices=0) --> Unsqueeze (axes=0) --> Concat [input 0] std::vector parent_path{ - {0, 0, "Unsqueeze", {1}, kOnnxDomain}, - {0, 0, "Gather", {1}, kOnnxDomain}, + {0, 0, "Unsqueeze", {1, 11}, kOnnxDomain}, + {0, 0, "Gather", {1, 11}, kOnnxDomain}, {0, 0, "Shape", {1}, kOnnxDomain}}; std::vector edges; @@ -114,8 +114,8 @@ bool ReshapeFusion::Fuse_Subgraph1(Node& reshape, Graph& graph, const logging::L // path 2: [Root] --> Shape --> Gather(indices=1) --> Unsqueeze (axes=0) --> Concat [input 1] std::vector parent_path2 { - {0, 1, "Unsqueeze", {1}, kOnnxDomain}, - {0, 0, "Gather", {1}, kOnnxDomain}, + {0, 1, "Unsqueeze", {1, 11}, kOnnxDomain}, + {0, 0, "Gather", {1, 11}, kOnnxDomain}, {0, 0, "Shape", {1}, kOnnxDomain}}; if (!graph_utils::FindPath(concat, true, parent_path2, edges, logger)) { diff --git a/onnxruntime/core/optimizer/utils.cc b/onnxruntime/core/optimizer/utils.cc index 3b3ad343ad713..c58bac0498f92 100644 --- a/onnxruntime/core/optimizer/utils.cc +++ b/onnxruntime/core/optimizer/utils.cc @@ -63,7 +63,7 @@ bool IsInitializerWithExpectedValue(const Graph& graph, const NodeArg& input_arg } } else if (data_type == ONNX_NAMESPACE::TensorProto_DataType_FLOAT16) { const MLFloat16* val = init_const->data(); - float diff = std::abs(math::halfToFloat(val[0].val) - static_cast(expected_value)); + float diff = std::abs(math::halfToFloat(val[0].val) - math::halfToFloat(math::floatToHalf(expected_value))); if (diff > FLT_EPSILON) { return false; } diff --git a/onnxruntime/core/providers/cuda/tensor/expand.cc b/onnxruntime/core/providers/cuda/tensor/expand.cc index 72ae71cec46a6..347c36529b5fa 100644 --- a/onnxruntime/core/providers/cuda/tensor/expand.cc +++ b/onnxruntime/core/providers/cuda/tensor/expand.cc @@ -5,69 +5,105 @@ #include "expand_impl.h" #include "core/providers/cpu/tensor/utils.h" +using std::vector; + namespace onnxruntime { namespace cuda { +// Logically expanded y could just be a view of x. +static void CalcEffectiveDims(vector& x_dims, vector& y_dims) { + vector x_reverse; + vector y_reverse; + + int xi = gsl::narrow_cast(x_dims.size()) - 1; + for (int yi = gsl::narrow_cast(y_dims.size()) - 1; yi >= 0; --yi, --xi) { + int64_t xdim = (xi >= 0) ? x_dims[xi] : 1; + int64_t ydim = y_dims[yi]; + if (xdim == ydim || xdim == 1) { + x_reverse.push_back(xdim); + y_reverse.push_back(ydim); + } + else { // xdim < ydim && xdim > 1, split + ydim /= xdim; + x_reverse.push_back(xdim); + y_reverse.push_back(xdim); + x_reverse.push_back(1); + y_reverse.push_back(ydim); + } + } + + x_dims.clear(); + y_dims.clear(); + x_dims.push_back(1); + y_dims.push_back(1); + // compact the dims, remove (x=1, y=1), merge (x=1, y1*y2...) + for (int i = gsl::narrow_cast(y_reverse.size()) - 1; i >= 0; --i) { + if (x_reverse[i] == 1) { + if (y_reverse[i] == 1) { + continue; + } + if (x_dims.back() == 1) { + y_dims.back() *= y_reverse[i]; + } + else { + x_dims.push_back(1); + y_dims.push_back(y_reverse[i]); + } + } + else { // x_reverse[i] == y_reverse[i] + if (x_dims.back() == y_dims.back()) { + x_dims.back() *= x_reverse[i]; + y_dims.back() *= y_reverse[i]; + } + else { + x_dims.push_back(x_reverse[i]); + y_dims.push_back(y_reverse[i]); + } + } + } +} + Status Expand::ComputeInternal(OpKernelContext* ctx) const { - const auto& input0 = *ctx->Input(0); - const auto& input1 = *ctx->Input(1); + const auto& input_data_tensor = *ctx->Input(0); + const auto& input_shape_tensor = *ctx->Input(1); // new shape to be expanded to - const auto* p_shape = input1.template Data(); - std::vector output_dims{p_shape, p_shape + input1.Shape().Size()}; + const auto* p_shape = input_shape_tensor.template Data(); + std::vector output_dims{p_shape, p_shape + input_shape_tensor.Shape().Size()}; TensorShape output_shape(output_dims); - ORT_RETURN_IF_ERROR(ComputeOutputShape(Node().Name(), input0.Shape(), output_dims, output_shape)); - auto rank = output_shape.NumDimensions(); + ORT_RETURN_IF_ERROR(ComputeOutputShape(Node().Name(), input_data_tensor.Shape(), output_dims, output_shape)); auto& output_tensor = *ctx->Output(0, output_shape); - if (0 == output_shape.Size()) { return Status::OK(); } - auto input_shape = input0.Shape().GetDims(); + output_dims = output_shape.GetDims(); + auto input_dims = input_data_tensor.Shape().GetDims(); - // pad input_dims with 1 to make ranks match - for (size_t i = 0; i < rank - input_shape.size(); i++) { - input_shape.insert(input_shape.begin(), 1); - } + CalcEffectiveDims(input_dims, output_dims); + int rank = gsl::narrow_cast(output_dims.size()); - // create fast_divmod using dimension values - CudaAsyncBuffer fdm_input_dims(this, rank); - CudaAsyncBuffer fdm_output_dims(this, rank); - CudaAsyncBuffer fdm_output_subdim_size(this, rank); - { - auto in_span = fdm_input_dims.CpuSpan(); - auto out_span = fdm_output_dims.CpuSpan(); - auto sdm_span = fdm_output_subdim_size.CpuSpan(); - auto subdim_size = output_shape.Size(); - for (size_t i = 0; i < rank; i++) { - in_span[i] = fast_divmod(static_cast(input_shape[i])); - out_span[i] = fast_divmod(static_cast(output_shape[i])); - // output_shape[i] won't be 0 here, it's covered in (0 == output_shape.Size()) - // a null output will be returned for that case - subdim_size /= output_shape[i]; - sdm_span[i] = static_cast(subdim_size); - } + CudaAsyncBuffer fdm_output_strides(this, rank); + ORT_ENFORCE(CalculateFdmStrides(fdm_output_strides.CpuSpan(), output_dims)); + + CudaAsyncBuffer input_view_strides(this, rank); + TensorPitches::Calculate(input_view_strides.CpuSpan(), input_dims); + for (int i = 0; i < rank; ++i) { + if (input_dims[i] == 1) input_view_strides.CpuSpan()[i] = 0; } - ORT_RETURN_IF_ERROR(fdm_input_dims.CopyToGpu()); - ORT_RETURN_IF_ERROR(fdm_output_dims.CopyToGpu()); - ORT_RETURN_IF_ERROR(fdm_output_subdim_size.CopyToGpu()); - - ExpandImpl( - input0.DataType()->Size(), - output_shape.NumDimensions(), - output_shape.Size(), - input0.Shape().Size(), - input0.DataRaw(), - output_tensor.MutableDataRaw(), - fdm_input_dims.GpuPtr(), - fdm_output_dims.GpuPtr(), - fdm_output_subdim_size.GpuPtr()); - return Status::OK(); + return ExpandImpl( + input_data_tensor.DataType()->Size(), + gsl::narrow_cast(output_shape.Size()), + gsl::narrow_cast(input_data_tensor.Shape().Size()), + input_data_tensor.DataRaw(), + output_tensor.MutableDataRaw(), + fdm_output_strides, + input_view_strides); } + ONNX_OPERATOR_KERNEL_EX( Expand, kOnnxDomain, diff --git a/onnxruntime/core/providers/cuda/tensor/expand_impl.cu b/onnxruntime/core/providers/cuda/tensor/expand_impl.cu index bbad602ec0cbf..38e71052a5525 100644 --- a/onnxruntime/core/providers/cuda/tensor/expand_impl.cu +++ b/onnxruntime/core/providers/cuda/tensor/expand_impl.cu @@ -8,84 +8,144 @@ namespace onnxruntime { namespace cuda { +template +__global__ void _FillFromDataPtrKernel(T* output_data, const T* input_data, CUDA_LONG N) { + CUDA_LONG id = NumElementsPerThread * blockDim.x * blockIdx.x + threadIdx.x; + T val = *input_data; +#pragma unroll + for (int i = 0; i < NumElementsPerThread; i++) { + if (id < N) { + output_data[id] = val; + id += NumThreadsPerBlock; + } + } +} + +template +void FillFromDataPtr(T* output_data, const T* input_data, int64_t count) { + int blocksPerGrid = gsl::narrow_cast(CeilDiv(count, GridDim::maxThreadsPerBlock * GridDim::maxElementsPerThread)); + CUDA_LONG N = static_cast(count); + _FillFromDataPtrKernel + <<>>(output_data, input_data, N); +} + +template +__global__ void ExpandKernel2D( + const int N, + const T* input_data, + T* output_data, + const fast_divmod fdm_output_stride0, + const int input_view_stride0, + const int input_view_stride1) { + CALCULATE_ELEMENTWISE_INDEX_OR_EXIT(id, N); + + int dim0, dim1; + fdm_output_stride0.divmod(id, dim0, dim1); + output_data[id] = input_data[dim0 * input_view_stride0 + dim1 * input_view_stride1]; +} + template __global__ void ExpandKernel( - const size_t rank, - const size_t N, - const size_t N_input, + const int rank, + const int N, const T* input_data, T* output_data, - const fast_divmod* fdm_input_dims, - const fast_divmod* fdm_output_dims, - const fast_divmod* fdm_output_subdim_size) { + const fast_divmod* fdm_output_strides, + const int64_t* input_view_strides) { CALCULATE_ELEMENTWISE_INDEX_OR_EXIT(id, N); - // initialize - auto output_index = id; - auto input_index = 0; - auto input_subdim_size = N_input; - auto out_coord = output_index; - // use striding when tensor is larger than grid - int stride = blockDim.x * gridDim.x; - - // translate indices to coordinates. copy expanded dims from source - while (output_index < N) { - for (int64_t i = 0; i < rank; i++) { - input_subdim_size = fdm_input_dims[i].div(input_subdim_size); - auto new_out_coord = fdm_output_subdim_size[i].div(out_coord); - auto in_coord = (new_out_coord > (fdm_input_dims[i].d_ - 1)) ? fdm_input_dims[i].d_ - 1 : new_out_coord; - input_index += input_subdim_size * in_coord; - out_coord -= new_out_coord * fdm_output_subdim_size[i].d_; - } - output_data[output_index] = input_data[input_index]; - output_index += stride; - out_coord = output_index; - input_subdim_size = N_input; - input_index = 0; + int dim, r = id, input_index = 0; + for (int i = 0; i < rank; ++i) { + fdm_output_strides[i].divmod(r, dim, r); + input_index += dim * input_view_strides[i]; + } + output_data[id] = input_data[input_index]; +} + +Status ExpandByFill(const size_t element_size, const int N, const void* input_data, void* output_data) { +#define EXPAND_FILL_ON(TYPE) \ + case sizeof(TYPE): \ + FillFromDataPtr(reinterpret_cast(output_data), \ + reinterpret_cast(input_data), \ + static_cast(N)); \ + break + + switch (element_size) { + EXPAND_FILL_ON(int8_t); + EXPAND_FILL_ON(int16_t); + EXPAND_FILL_ON(int32_t); + EXPAND_FILL_ON(int64_t); + default: + return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Type not supported for Expand operator"); } + return Status::OK(); +} + +Status Expand2D( + const size_t element_size, + const int N, + const void* input_data, + void* output_data, + const fast_divmod fdm_output_stride0, + const int input_view_stride0, + const int input_view_stride1) { +#define EXPAND2D_ON(TYPE) \ + case sizeof(TYPE): \ + ExpandKernel2D<<>>( \ + N, reinterpret_cast(input_data), reinterpret_cast(output_data), \ + fdm_output_stride0, input_view_stride0, input_view_stride1); \ + break + + int blocksPerGrid = gsl::narrow_cast(CeilDiv(N, GridDim::maxThreadsPerBlock)); + switch (element_size) { + EXPAND2D_ON(int8_t); + EXPAND2D_ON(int16_t); + EXPAND2D_ON(int32_t); + EXPAND2D_ON(int64_t); + default: + return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Type not supported for Expand operator"); + } + return Status::OK(); } Status ExpandImpl( const size_t element_size, - const size_t rank, - const size_t N, - const size_t N_input, + const int N_output, + const int N_input, const void* input_data, void* output_data, - const fast_divmod* fdm_input_dims, - const fast_divmod* fdm_output_dims, - const fast_divmod* fdm_output_subdim_size) { - int blocksPerGrid = (int)(ceil(static_cast(N) / GridDim::maxThreadsPerBlock)); + CudaKernel::CudaAsyncBuffer& fdm_output_strides, + CudaKernel::CudaAsyncBuffer& input_view_strides) { + const int rank = static_cast(fdm_output_strides.count()); + if (rank == 1) { + if (N_input == N_output) { + CUDA_RETURN_IF_ERROR(cudaMemcpyAsync(output_data, input_data, N_output * element_size, cudaMemcpyDeviceToDevice)); + } else { // N_input == 1 + return ExpandByFill(element_size, N_output, input_data, output_data); + } + } else if (rank == 2) { + return Expand2D(element_size, N_output, input_data, output_data, + fdm_output_strides.CpuSpan()[0], + static_cast(input_view_strides.CpuSpan()[0]), + static_cast(input_view_strides.CpuSpan()[1])); + } + + int blocksPerGrid = gsl::narrow_cast(CeilDiv(N_output, GridDim::maxThreadsPerBlock)); + fdm_output_strides.CopyToGpu(); + input_view_strides.CopyToGpu(); + +#define EXPAND_ON(TYPE) \ + case sizeof(TYPE): \ + ExpandKernel<<>>( \ + rank, N_output, reinterpret_cast(input_data), reinterpret_cast(output_data), \ + fdm_output_strides.GpuPtr(), input_view_strides.GpuPtr()); \ + break switch (element_size) { - case sizeof(uint8_t): - ExpandKernel<<>>( - rank, N, N_input, - reinterpret_cast::MappedType*>(input_data), - reinterpret_cast::MappedType*>(output_data), - fdm_input_dims, fdm_output_dims, fdm_output_subdim_size); - break; - case sizeof(uint16_t): - ExpandKernel<<>>( - rank, N, N_input, - reinterpret_cast::MappedType*>(input_data), - reinterpret_cast::MappedType*>(output_data), - fdm_input_dims, fdm_output_dims, fdm_output_subdim_size); - break; - case sizeof(uint32_t): - ExpandKernel<<>>( - rank, N, N_input, - reinterpret_cast::MappedType*>(input_data), - reinterpret_cast::MappedType*>(output_data), - fdm_input_dims, fdm_output_dims, fdm_output_subdim_size); - break; - case sizeof(uint64_t): - ExpandKernel<<>>( - rank, N, N_input, - reinterpret_cast::MappedType*>(input_data), - reinterpret_cast::MappedType*>(output_data), - fdm_input_dims, fdm_output_dims, fdm_output_subdim_size); - break; + EXPAND_ON(uint8_t); + EXPAND_ON(uint16_t); + EXPAND_ON(uint32_t); + EXPAND_ON(uint64_t); default: return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Type not supported for Expand operator"); } diff --git a/onnxruntime/core/providers/cuda/tensor/expand_impl.h b/onnxruntime/core/providers/cuda/tensor/expand_impl.h index c127d72477f23..543dedaa4fdd7 100644 --- a/onnxruntime/core/providers/cuda/tensor/expand_impl.h +++ b/onnxruntime/core/providers/cuda/tensor/expand_impl.h @@ -6,20 +6,20 @@ #include "core/providers/cuda/shared_inc/cuda_utils.h" #include "core/framework/data_types.h" #include "core/common/common.h" +#include "core/providers/cuda/cuda_common.h" namespace onnxruntime { namespace cuda { Status ExpandImpl( const size_t element_size, - const size_t shape_rank, - const size_t N, - const size_t N_input, + const int N_output, + const int N_input, const void* input_data, void* output_data, - const fast_divmod* fdm_input_dims, - const fast_divmod* fdm_output_dims, - const fast_divmod* fdm_output_subdim_size); + CudaKernel::CudaAsyncBuffer& fdm_output_strides, + CudaKernel::CudaAsyncBuffer& input_view_strides); + } // namespace cuda } // namespace onnxruntime diff --git a/onnxruntime/core/providers/cuda/tensor/pad.cc b/onnxruntime/core/providers/cuda/tensor/pad.cc index ac22a8c57eb76..8dfb8202b98a6 100644 --- a/onnxruntime/core/providers/cuda/tensor/pad.cc +++ b/onnxruntime/core/providers/cuda/tensor/pad.cc @@ -36,9 +36,9 @@ typename ToCudaType::MappedType ToCudaValue(const T& value) { return value; } -template<> +template <> typename ToCudaType::MappedType ToCudaValue(const MLFloat16& value) { - return *reinterpret_cast::MappedType *>(&value.val); + return *reinterpret_cast::MappedType*>(&value.val); } template @@ -120,6 +120,16 @@ Status Pad::ComputeInternal(OpKernelContext* ctx) const { } auto& output_tensor = *ctx->Output(0, output_shape); + if (std::all_of(p_pads->begin(), p_pads->end(), [](const int64_t v) { return v == 0; }) && + std::all_of(p_slices->begin(), p_slices->end(), [](const int64_t v) { return v == 0; }) && + output_shape.Size() > 0) { + CUDA_RETURN_IF_ERROR(cudaMemcpyAsync( + output_tensor.template MutableData(), input_tensor.template Data(), + sizeof(typename ToCudaType::MappedType) * output_shape.Size(), + cudaMemcpyDeviceToDevice, 0)); + return Status::OK(); + } + ORT_ENFORCE(CalculateFdmStrides(fdm_output_strides.CpuSpan(), output_dims)); ORT_RETURN_IF_ERROR(input_dims.CopyToGpu()); ORT_RETURN_IF_ERROR(input_strides.CopyToGpu()); diff --git a/onnxruntime/core/providers/cuda/tensor/resize_impl.cu b/onnxruntime/core/providers/cuda/tensor/resize_impl.cu index 1442363110781..7d00813d441ba 100644 --- a/onnxruntime/core/providers/cuda/tensor/resize_impl.cu +++ b/onnxruntime/core/providers/cuda/tensor/resize_impl.cu @@ -130,42 +130,127 @@ CudaFunctionOriginalCoordinate GetDeviceOriginalCoordinateFunc(ResizeCoordinateT return s_coordinate_tranforms[coordinate_transform_mode]; } +struct NearestMappingInfo { + int origin_; + int extrapolate_; +}; + template -__global__ void _ResizeNearestKernel( +__global__ void _ResizeNearestMappingKernel2D( + const int input_height, const int input_width, + const int output_height, const int output_width, + const float scales_height, const float scales_width, + const float roi_start_height, const float roi_end_height, + const float roi_start_width, const float roi_end_width, + const bool extrapolation_enabled, + CudaFunctionOriginalCoordinate transform_coordinate, + CudaFunctionNearestPixel calc_nearest_pixel, + NearestMappingInfo* dims_mapping) { + CALCULATE_ELEMENTWISE_INDEX_OR_EXIT(id, output_height + output_width); + if (id >= 0 && id < output_height) { // for Height + int dim = id; + float orig_coord = transform_coordinate(static_cast(dim), scales_height, static_cast(output_height), + static_cast(input_height), roi_start_height, roi_end_height); + dims_mapping[id].extrapolate_ = (int)(extrapolation_enabled && (orig_coord < 0.f || orig_coord > static_cast(input_height - 1))); + dim = calc_nearest_pixel(orig_coord, scales_height < 1); + if (dim >= input_height) dim = input_height - 1; + if (dim < 0) dim = 0; + dims_mapping[id].origin_ = dim; + } else { + int dim = id - output_height; + float orig_coord = transform_coordinate(static_cast(dim), scales_width, static_cast(output_width), + static_cast(input_width), roi_start_width, roi_end_width); + dims_mapping[id].extrapolate_ = (int)(extrapolation_enabled && (orig_coord < 0.f || orig_coord > static_cast(input_width - 1))); + dim = calc_nearest_pixel(orig_coord, scales_width < 1); + if (dim >= input_width) dim = input_width - 1; + if (dim < 0) dim = 0; + dims_mapping[id].origin_ = dim; + return; + } +} + +template +__global__ void _ResizeNearestMappingKernel( const size_t rank, const int64_t* input_shape, const int64_t* output_shape, - const int64_t* input_pitches, - const fast_divmod* output_div_pitches, const float* scales, const float* roi, - const T* input_data, - T* output_data, - const size_t N, + const size_t total_dim_sum, bool extrapolation_enabled, - float extrapolation_value, CudaFunctionOriginalCoordinate transform_coordinate, - CudaFunctionNearestPixel calc_nearest_pixel) { + CudaFunctionNearestPixel calc_nearest_pixel, + int64_t* prefix_dim_sum, + NearestMappingInfo* dims_mapping) { + CALCULATE_ELEMENTWISE_INDEX_OR_EXIT(id, total_dim_sum); + int64_t dim_sum = 0; + for (int axis = 0; axis < rank; ++axis) { + if (id == dim_sum) { + prefix_dim_sum[axis] = dim_sum; + } + if (id >= dim_sum && id < dim_sum + output_shape[axis]) { + int dim = id - dim_sum; + float orig_coord = transform_coordinate(static_cast(dim), scales[axis], static_cast(output_shape[axis]), + static_cast(input_shape[axis]), roi[axis], roi[axis + rank]); + dims_mapping[id].extrapolate_ = (int)(extrapolation_enabled && (orig_coord < 0.f || orig_coord > static_cast(input_shape[axis] - 1))); + dim = calc_nearest_pixel(orig_coord, scales[axis] < 1); + if (dim >= input_shape[axis]) dim = input_shape[axis] - 1; + if (dim < 0) dim = 0; + dims_mapping[id].origin_ = dim; + return; + } + dim_sum += output_shape[axis]; + } +} + +template +__global__ void _ResizeNearestKernel2D( + const int64_t output_height, const int64_t output_width, + const int64_t input_stride_image, const int input_stride_row, + const fast_divmod output_stride_image, const fast_divmod output_stride_row, + const T* input_data, T* output_data, const size_t N, + const T extrapolation_value, const NearestMappingInfo* dims_mapping) { CALCULATE_ELEMENTWISE_INDEX_OR_EXIT(id, N); - CUDA_LONG input_index = 0; - CUDA_LONG output_index = id; - - int div, mod; - bool extrapolation_occured = false; - for (int dim = 0; dim < rank; ++dim) { - output_div_pitches[dim].divmod(output_index, div, mod); - output_index = mod; - float orig_coord = transform_coordinate(static_cast(div), scales[dim], static_cast(output_shape[dim]), - static_cast(input_shape[dim]), roi[dim], roi[dim + rank]); - if (extrapolation_enabled && !extrapolation_occured) { - extrapolation_occured = (orig_coord < 0.f || orig_coord > static_cast(input_shape[dim] - 1)); + + int imageid, h, w, output_index; + output_stride_image.divmod(static_cast(id), imageid, output_index); + output_stride_row.divmod(output_index, h, w); + if (UseExtrapolation) { + if (dims_mapping[h].extrapolate_ + dims_mapping[output_height + w].extrapolate_) { + output_data[id] = extrapolation_value; + return; } - div = calc_nearest_pixel(orig_coord, scales[dim] < 1); - if (div >= input_shape[dim]) div = input_shape[dim] - 1; - if (div < 0) div = 0; - input_index += input_pitches[dim] * div; } - output_data[id] = extrapolation_occured ? static_cast(extrapolation_value) : input_data[input_index]; + int input_index = input_stride_image * imageid + + input_stride_row * dims_mapping[h].origin_ + + dims_mapping[output_height + w].origin_; + output_data[id] = input_data[input_index]; +} + +template +__global__ void _ResizeNearestKernel( + const int rank, + const int64_t* input_strides, + const fast_divmod* output_div_pitches, + const T* input_data, + T* output_data, + const size_t N, + const T extrapolation_value, + const int64_t* prefix_dim_sum, + const NearestMappingInfo* dims_mapping) { + CALCULATE_ELEMENTWISE_INDEX_OR_EXIT(id, N); + + int output_index = static_cast(id); + int input_index = 0; + int extrapolation_occured = 0; + for (int axis = 0; axis < rank; ++axis) { + int dim = 0; + output_div_pitches[axis].divmod(output_index, dim, output_index); + const NearestMappingInfo& mi = dims_mapping[prefix_dim_sum[axis] + dim]; + extrapolation_occured += mi.extrapolate_; + input_index += input_strides[axis] * mi.origin_; + } + output_data[id] = extrapolation_occured ? extrapolation_value : input_data[input_index]; } struct BilinearMappingInfo { @@ -214,7 +299,7 @@ __global__ void _ResizeBilinearKernel( int64_t output_height, int64_t output_width, fast_divmod div_output_width, fast_divmod div_output_image, const T* input_data, T* output_data, const size_t N, - float extrapolation_value, + const T extrapolation_value, BilinearMappingInfo* dims_mapping) { CALCULATE_ELEMENTWISE_INDEX_OR_EXIT(id, N); int bxc, output_image_index; @@ -254,10 +339,10 @@ __device__ __forceinline__ float CubicInterpolationRowwise( const T* image, int x, int y, int input_height, int input_width, float coeff0, float coeff1, float coeff2, float coeff3) { int row_index = max(0, min(y, input_height - 1)) * input_width; - return coeff0 * static_cast(image[row_index + max(0, min(x - 1, input_width - 1))]) - + coeff1 * static_cast(image[row_index + max(0, min(x, input_width - 1))]) - + coeff2 * static_cast(image[row_index + max(0, min(x + 1, input_width - 1))]) - + coeff3 * static_cast(image[row_index + max(0, min(x + 2, input_width - 1))]); + return coeff0 * static_cast(image[row_index + max(0, min(x - 1, input_width - 1))]) + + coeff1 * static_cast(image[row_index + max(0, min(x, input_width - 1))]) + + coeff2 * static_cast(image[row_index + max(0, min(x + 1, input_width - 1))]) + + coeff3 * static_cast(image[row_index + max(0, min(x + 2, input_width - 1))]); } struct CubicMappingInfo { @@ -318,7 +403,7 @@ template __global__ void _ResizeBiCubicKernel( int64_t input_height, int64_t input_width, int64_t output_height, int64_t output_width, fast_divmod div_output_width, fast_divmod div_output_image, - const T* input_data, T* output_data, const size_t N, float extrapolation_value, + const T* input_data, T* output_data, const size_t N, const T extrapolation_value, CubicMappingInfo* dims_mapping) { CALCULATE_ELEMENTWISE_INDEX_OR_EXIT(id, N); int bxc, output_image_index, output_x, output_y; @@ -340,17 +425,17 @@ __global__ void _ResizeBiCubicKernel( int x_int = x_info.origin_; int y_int = y_info.origin_; const T* image = input_data + input_index; - output_data[id] = y_info.coeff0_ * CubicInterpolationRowwise(image, x_int, y_int - 1, input_height, input_width, w0, w1, w2, w3) - + y_info.coeff1_ * CubicInterpolationRowwise(image, x_int, y_int, input_height, input_width, w0, w1, w2, w3) - + y_info.coeff2_ * CubicInterpolationRowwise(image, x_int, y_int + 1, input_height, input_width, w0, w1, w2, w3) - + y_info.coeff3_ * CubicInterpolationRowwise(image, x_int, y_int + 2, input_height, input_width, w0, w1, w2, w3); + output_data[id] = y_info.coeff0_ * CubicInterpolationRowwise(image, x_int, y_int - 1, input_height, input_width, w0, w1, w2, w3) + + y_info.coeff1_ * CubicInterpolationRowwise(image, x_int, y_int, input_height, input_width, w0, w1, w2, w3) + + y_info.coeff2_ * CubicInterpolationRowwise(image, x_int, y_int + 1, input_height, input_width, w0, w1, w2, w3) + + y_info.coeff3_ * CubicInterpolationRowwise(image, x_int, y_int + 2, input_height, input_width, w0, w1, w2, w3); } size_t CalcResizeBufferSize(const onnxruntime::UpsampleMode upsample_mode, const std::vector& output_dims) { switch (upsample_mode) { case UpsampleMode::NN: - return 0; + return sizeof(int64_t) * output_dims.size() + sizeof(NearestMappingInfo) * std::accumulate(output_dims.begin(), output_dims.end(), 0); case UpsampleMode::LINEAR: return sizeof(BilinearMappingInfo) * std::accumulate(output_dims.rbegin(), output_dims.rbegin() + 2, 0); case UpsampleMode::CUBIC: @@ -359,6 +444,88 @@ size_t CalcResizeBufferSize(const onnxruntime::UpsampleMode upsample_mode, return 0; } +template +void ResizeNearestImpl( + const int rank, + CudaKernel::CudaAsyncBuffer& input_shape, + CudaKernel::CudaAsyncBuffer& output_shape, + CudaKernel::CudaAsyncBuffer& input_strides, + CudaKernel::CudaAsyncBuffer& output_div_pitches, + CudaKernel::CudaAsyncBuffer& scales_vals, + CudaKernel::CudaAsyncBuffer& roi_vals, + const T* input_data, + T* output_data, + const size_t N, + bool extrapolation_enabled, + const T extrapolation_value, + float cubic_coeff_a, + CudaFunctionOriginalCoordinate transform_coordinate, + CudaFunctionNearestPixel calc_nearest_pixel, + int64_t* prefix_dim_sum, + NearestMappingInfo* dims_mapping) { + int blocksPerGrid = (int)(ceil(static_cast(N) / GridDim::maxThreadsPerBlock)); + + bool could2d = rank >= 2 && + transform_coordinate != GetDeviceOriginalCoordinateFunc(ResizeCoordinateTransformationMode::TF_CROP_AND_RESIZE) && + std::all_of(scales_vals.CpuPtr(), scales_vals.CpuPtr() + (rank - 2), [](float v) { return v == 1.0; }); + if (could2d) { + int64_t output_height = output_shape.CpuPtr()[rank - 2]; + int64_t output_width = output_shape.CpuPtr()[rank - 1]; + fast_divmod div_output_image = (rank > 2) ? output_div_pitches.CpuPtr()[rank - 3] : fast_divmod(output_height * output_width); + int blocksPerDimsMappingGrid = (int)(ceil((output_height + output_width) / 32.0)); + + _ResizeNearestMappingKernel2D<<>>( + input_shape.CpuPtr()[rank - 2], input_shape.CpuPtr()[rank - 1], + output_height, output_width, + scales_vals.CpuPtr()[rank - 2], scales_vals.CpuPtr()[rank - 1], + roi_vals.CpuPtr()[rank - 2], roi_vals.CpuPtr()[rank - 2 + rank], + roi_vals.CpuPtr()[rank - 1], roi_vals.CpuPtr()[rank - 1 + rank], + extrapolation_enabled, transform_coordinate, calc_nearest_pixel, + dims_mapping); + if (extrapolation_enabled) { + _ResizeNearestKernel2D<<>>( + output_height, output_width, + input_shape.CpuPtr()[rank - 2] * input_shape.CpuPtr()[rank - 1], input_shape.CpuPtr()[rank - 1], + div_output_image, output_div_pitches.CpuPtr()[rank - 2], + input_data, output_data, N, + extrapolation_value, + dims_mapping); + } else { + _ResizeNearestKernel2D<<>>( + output_height, output_width, + input_shape.CpuPtr()[rank - 2] * input_shape.CpuPtr()[rank - 1], input_shape.CpuPtr()[rank - 1], + div_output_image, output_div_pitches.CpuPtr()[rank - 2], + input_data, output_data, N, + extrapolation_value, + dims_mapping); + } + return; + } + + int64_t total_dim_sum = std::accumulate(output_shape.CpuPtr(), output_shape.CpuPtr() + rank, 0); + int blocksPerDimsMappingGrid = (int)(ceil(static_cast(total_dim_sum) / 32)); + input_shape.CopyToGpu(); + output_shape.CopyToGpu(); + roi_vals.CopyToGpu(); + scales_vals.CopyToGpu(); + input_strides.CopyToGpu(); + output_div_pitches.CopyToGpu(); + _ResizeNearestMappingKernel<<>>( + rank, input_shape.GpuPtr(), output_shape.GpuPtr(), + scales_vals.GpuPtr(), roi_vals.GpuPtr(), + total_dim_sum, extrapolation_enabled, + transform_coordinate, calc_nearest_pixel, + reinterpret_cast(dims_mapping), + reinterpret_cast(reinterpret_cast(dims_mapping) + rank)); + _ResizeNearestKernel<<>>( + rank, input_strides.GpuPtr(), output_div_pitches.GpuPtr(), + input_data, output_data, N, + extrapolation_value, + reinterpret_cast(dims_mapping), + reinterpret_cast(reinterpret_cast(dims_mapping) + rank)); + return; +} + template void ResizeImpl( const UpsampleMode upsample_mode, @@ -373,36 +540,38 @@ void ResizeImpl( T* output_data, const size_t N, bool extrapolation_enabled, - float extrapolation_value, + const T extrapolation_value, float cubic_coeff_a, bool exclude_outside, ResizeCoordinateTransformationMode coordinate_transform_mode, ResizeNearestMode nearest_mode, void* dims_mapping) { - int blocksPerGrid = (int)(ceil(static_cast(N) / GridDim::maxThreadsPerBlock)); + bool isSame = std::all_of(scales_vals.CpuPtr(), scales_vals.CpuPtr() + rank, [](float v) { return v == 1.0f; }) && + (coordinate_transform_mode != ResizeCoordinateTransformationMode::TF_CROP_AND_RESIZE); + if (isSame) { + cudaMemcpyAsync(output_data, input_data, N * sizeof(T), cudaMemcpyDeviceToDevice); + return; + } + CudaFunctionOriginalCoordinate transform_coordinate = GetDeviceOriginalCoordinateFunc(coordinate_transform_mode); CudaFunctionNearestPixel calc_nearest_pixel = GetDeviceNearstPixelFunction(nearest_mode); + if (upsample_mode == UpsampleMode::NN) { + ResizeNearestImpl( + rank, input_shape, output_shape, input_strides, output_div_pitches, + scales_vals, roi_vals, input_data, output_data, N, + extrapolation_enabled, extrapolation_value, cubic_coeff_a, + transform_coordinate, calc_nearest_pixel, + reinterpret_cast(dims_mapping), + reinterpret_cast(reinterpret_cast(dims_mapping) + rank)); + return; + } + + int blocksPerGrid = (int)(ceil(static_cast(N) / GridDim::maxThreadsPerBlock)); fast_divmod div_output_image = (rank > 2) ? output_div_pitches.CpuPtr()[rank - 3] : fast_divmod(gsl::narrow_cast(N)); int64_t output_height = output_shape.CpuPtr()[rank - 2]; int64_t output_width = output_shape.CpuPtr()[rank - 1]; - int blocksPerDimsMappingGrid = (int)(ceil(static_cast(output_height + output_width) / 32)); - + int blocksPerDimsMappingGrid = (int)(ceil((output_height + output_width) / 32.0)); switch (upsample_mode) { - case UpsampleMode::NN: - input_shape.CopyToGpu(); - output_shape.CopyToGpu(); - roi_vals.CopyToGpu(); - scales_vals.CopyToGpu(); - input_strides.CopyToGpu(); - output_div_pitches.CopyToGpu(); - _ResizeNearestKernel<<>>( - rank, input_shape.GpuPtr(), output_shape.GpuPtr(), - input_strides.GpuPtr(), output_div_pitches.GpuPtr(), - scales_vals.GpuPtr(), roi_vals.GpuPtr(), - input_data, output_data, N, - extrapolation_enabled, extrapolation_value, - transform_coordinate, calc_nearest_pixel); - return; case UpsampleMode::LINEAR: _ResizeBilinearCoordinateMapping<<>>( input_shape.CpuPtr()[rank - 2], input_shape.CpuPtr()[rank - 1], @@ -435,7 +604,6 @@ void ResizeImpl( output_div_pitches.CpuPtr()[rank - 2], div_output_image, input_data, output_data, N, extrapolation_value, reinterpret_cast(dims_mapping)); - // CUDA_CALL(cudaGetLastError()); return; } } @@ -454,7 +622,7 @@ void ResizeImpl( T* output_data, \ const size_t N, \ bool extrapolation_enabled, \ - float extrapolation_value, \ + const T extrapolation_value, \ float cubic_coeff_a, \ bool exclude_outside, \ ResizeCoordinateTransformationMode coordinate_transform_mode, \ diff --git a/onnxruntime/core/providers/cuda/tensor/resize_impl.h b/onnxruntime/core/providers/cuda/tensor/resize_impl.h index 9248713d4df7a..e991e36f234e3 100644 --- a/onnxruntime/core/providers/cuda/tensor/resize_impl.h +++ b/onnxruntime/core/providers/cuda/tensor/resize_impl.h @@ -28,7 +28,7 @@ void ResizeImpl( T* output_data, const size_t N, bool extrapolation_enabled, - float extrapolation_value, + const T extrapolation_value, float cubic_coeff_a, bool exclude_outside, onnxruntime::ResizeCoordinateTransformationMode coordinate_transform_mode, diff --git a/onnxruntime/core/providers/cuda/tensor/scatter_elements.cc b/onnxruntime/core/providers/cuda/tensor/scatter_elements.cc index 92466ec124e7f..0032f148f863c 100755 --- a/onnxruntime/core/providers/cuda/tensor/scatter_elements.cc +++ b/onnxruntime/core/providers/cuda/tensor/scatter_elements.cc @@ -41,37 +41,35 @@ ONNX_OPERATOR_KERNEL_EX( const T* update_data = updates_tensor->template Data(); \ if (utils::IsPrimitiveDataType(Tin_type)) { \ const int32_t* indices_data = indices_tensor->template Data(); \ - ScatterElementsImpl( \ + return ScatterElementsImpl( \ rank, \ reinterpret_cast::MappedType*>(input_data), \ input_data_size, \ - gpu_input_dims.GpuPtr(), \ - gpu_input_strides.GpuPtr(), \ + buffer_input_dims, \ + buffer_input_strides, \ indices_data, \ indices_size, \ - gpu_indices_dims.GpuPtr(), \ - fdm_indices_strides.GpuPtr(), \ + buffer_indices_dims, \ + fdm_indices_strides, \ reinterpret_cast::MappedType*>(update_data), \ axis, \ reinterpret_cast::MappedType*>(output_data)); \ - return Status::OK(); \ } \ if (utils::IsPrimitiveDataType(Tin_type)) { \ const int64_t* indices_data = indices_tensor->template Data(); \ - ScatterElementsImpl( \ + return ScatterElementsImpl( \ rank, \ reinterpret_cast::MappedType*>(input_data), \ input_data_size, \ - gpu_input_dims.GpuPtr(), \ - gpu_input_strides.GpuPtr(), \ + buffer_input_dims, \ + buffer_input_strides, \ indices_data, \ indices_size, \ - gpu_indices_dims.GpuPtr(), \ - fdm_indices_strides.GpuPtr(), \ + buffer_indices_dims, \ + fdm_indices_strides, \ reinterpret_cast::MappedType*>(update_data), \ axis, \ reinterpret_cast::MappedType*>(output_data)); \ - return Status::OK(); \ } \ } @@ -122,19 +120,14 @@ Status ScatterElements::ComputeInternal(OpKernelContext* context) const { int rank = (int)input_dims.size(); auto* output_tensor = context->Output(0, input_data_shape); - CudaAsyncBuffer gpu_input_dims(this, input_dims); + CudaAsyncBuffer buffer_input_dims(this, input_dims); TensorPitches input_strides(input_dims); - CudaAsyncBuffer gpu_input_strides(this, input_strides); + CudaAsyncBuffer buffer_input_strides(this, input_strides); - CudaAsyncBuffer gpu_indices_dims(this, indices_dims); + CudaAsyncBuffer buffer_indices_dims(this, indices_dims); CudaAsyncBuffer fdm_indices_strides(this, rank); ORT_ENFORCE(CalculateFdmStrides(fdm_indices_strides.CpuSpan(), indices_dims)); - ORT_RETURN_IF_ERROR(gpu_input_dims.CopyToGpu()); - ORT_RETURN_IF_ERROR(gpu_input_strides.CopyToGpu()); - ORT_RETURN_IF_ERROR(gpu_indices_dims.CopyToGpu()); - ORT_RETURN_IF_ERROR(fdm_indices_strides.CopyToGpu()); - MLDataType Tin_type = indices_tensor->DataType(); MLDataType T_type = data_tensor->DataType(); diff --git a/onnxruntime/core/providers/cuda/tensor/scatter_elements_impl.cu b/onnxruntime/core/providers/cuda/tensor/scatter_elements_impl.cu index 5220493c7d15f..9041ffc5c7f46 100755 --- a/onnxruntime/core/providers/cuda/tensor/scatter_elements_impl.cu +++ b/onnxruntime/core/providers/cuda/tensor/scatter_elements_impl.cu @@ -7,6 +7,33 @@ namespace onnxruntime { namespace cuda { +template +__global__ void _ScatterElementsKernel2D( + const int max_dim, // max dim on the scattered axis + const T* input_data, + const Tin* indices_data, + const int64_t indices_size, + const fast_divmod indices_stride_row, + const T* updates, + const int64_t output_row_size, + T* output_data) { + CALCULATE_ELEMENTWISE_INDEX_OR_EXIT(indices_index, indices_size); + + int row, col, data_idx; + indices_stride_row.divmod(indices_index, row, col); + int dim = (int)(indices_data[indices_index]); + if (dim >= -max_dim && dim < max_dim) { + if (dim < 0) dim += max_dim; + if (OUTERAXIS) { + data_idx = dim * output_row_size + col; + } else { + data_idx = row * output_row_size + dim; + } + output_data[data_idx] = updates[indices_index]; + } + // else invalid index +} + template __global__ void _ScatterElementsKernel( const int rank, @@ -28,7 +55,7 @@ __global__ void _ScatterElementsKernel( if (i == axis) { dim = (int)(indices_data[indices_index]); if (dim < -input_dims[i] || dim >= input_dims[i]) { - return; // Invalid index + return; // Invalid index } if (dim < 0) dim += input_dims[i]; } @@ -37,61 +64,162 @@ __global__ void _ScatterElementsKernel( output_data[data_idx] = updates[indices_index]; } +// From the innermost axis (largest) check equality of dim value of input and indices. +// If same, merge it and continue. Otherwise, copy remaining. The scatter axis need +// to be keep. +static int CompactInputIndicesDims( + int rank, int axis, int64_t* input_dims, int64_t* indices_dims, + std::vector& eff_input_dims, + std::vector& eff_indices_dims) { + eff_input_dims.clear(); + eff_indices_dims.clear(); + + bool could_continue_merge = true; + if (axis < rank - 1) { + eff_input_dims.push_back(1); + eff_indices_dims.push_back(1); + int i = rank - 1; + for (; i > axis; --i) { + if (input_dims[i] == indices_dims[i]) { + eff_input_dims.back() *= input_dims[i]; + eff_indices_dims.back() *= indices_dims[i]; + } else { + could_continue_merge = false; + break; + } + } + if (eff_input_dims.back() == 1) { + eff_input_dims.pop_back(); + eff_indices_dims.pop_back(); + } + if (!could_continue_merge) { + for (; i > axis; --i) { + eff_input_dims.push_back(input_dims[i]); + eff_indices_dims.push_back(indices_dims[i]); + } + } + } + could_continue_merge = could_continue_merge && (input_dims[axis] == indices_dims[axis]); + eff_input_dims.push_back(input_dims[axis]); + eff_indices_dims.push_back(indices_dims[axis]); + int new_axis = (int)(eff_input_dims.size()); + if (axis > 0) { + if (could_continue_merge) { + eff_input_dims.push_back(1); + eff_indices_dims.push_back(1); + } + int i = axis - 1; + for (; i >= 0 && could_continue_merge; --i) { + if (input_dims[i] == indices_dims[i]) { + eff_input_dims.back() *= input_dims[i]; + eff_indices_dims.back() *= indices_dims[i]; + } else { + could_continue_merge = false; + break; + } + } + if (new_axis < (int)eff_indices_dims.size() && eff_input_dims.back() == 1) { + eff_input_dims.pop_back(); + eff_indices_dims.pop_back(); + } + if (!could_continue_merge) { + for (; i >= 0 && could_continue_merge; --i) { + eff_input_dims.push_back(input_dims[i]); + eff_indices_dims.push_back(indices_dims[i]); + } + } + } + new_axis = eff_input_dims.size() - new_axis; + std::reverse(eff_input_dims.begin(), eff_input_dims.end()); + std::reverse(eff_indices_dims.begin(), eff_indices_dims.end()); + return new_axis; +} + template -void ScatterElementsImpl( +Status ScatterElementsImpl2D( + const T* input_data, + const std::vector& input_dims, + const Tin* indices_data, + const int64_t indices_size, + const std::vector& indices_dims, + const T* updates, + const int axis, + T* output_data) { + int blocksPerGrid = gsl::narrow_cast(CeilDiv(indices_size, GridDim::maxThreadsPerBlock)); + fast_divmod indices_stride_row(indices_dims[1]); + if (axis == 0) { + _ScatterElementsKernel2D<<>>( + gsl::narrow_cast(input_dims[0]), input_data, + indices_data, indices_size, indices_stride_row, + updates, input_dims[1], output_data); + } else { + _ScatterElementsKernel2D<<>>( + gsl::narrow_cast(input_dims[1]), input_data, + indices_data, indices_size, indices_stride_row, + updates, input_dims[1], output_data); + } + return Status::OK(); +} + +template +Status ScatterElementsImpl( const int rank, const T* input_data, const int64_t input_size, - const int64_t* input_dims, - const int64_t* input_strides, + CudaKernel::CudaAsyncBuffer& buffer_input_dims, + CudaKernel::CudaAsyncBuffer& buffer_input_strides, const Tin* indices_data, const int64_t indices_size, - const int64_t* indices_dims, - const fast_divmod* indices_strides, + CudaKernel::CudaAsyncBuffer& buffer_indices_dims, + CudaKernel::CudaAsyncBuffer& fdm_indices_strides, const T* updates, const int axis, T* output_data) { - if (input_data != output_data) { - cudaMemcpyAsync(output_data, input_data, input_size * sizeof(T), cudaMemcpyDeviceToDevice, 0); + CUDA_RETURN_IF_ERROR(cudaMemcpyAsync(output_data, input_data, input_size * sizeof(T), cudaMemcpyDeviceToDevice, 0)); } if (indices_size > 0) { - int blocksPerGrid = (int)((indices_size + GridDim::maxThreadsPerBlock - 1) / GridDim::maxThreadsPerBlock); + std::vector eff_input_dims; + std::vector eff_indices_dims; + int new_axis = CompactInputIndicesDims( + rank, axis, buffer_input_dims.CpuPtr(), buffer_indices_dims.CpuPtr(), eff_input_dims, eff_indices_dims); + if (eff_input_dims.size() == 2) { + return ScatterElementsImpl2D( + input_data, eff_input_dims, indices_data, indices_size, eff_indices_dims, updates, new_axis, output_data); + } + + ORT_RETURN_IF_ERROR(buffer_input_dims.CopyToGpu()); + ORT_RETURN_IF_ERROR(buffer_input_strides.CopyToGpu()); + ORT_RETURN_IF_ERROR(buffer_indices_dims.CopyToGpu()); + ORT_RETURN_IF_ERROR(fdm_indices_strides.CopyToGpu()); + int blocksPerGrid = gsl::narrow_cast(CeilDiv(indices_size, GridDim::maxThreadsPerBlock)); _ScatterElementsKernel<<>>( - rank, input_data, input_dims, input_strides, - indices_data, indices_size, indices_dims, indices_strides, + rank, input_data, buffer_input_dims.GpuPtr(), buffer_input_strides.GpuPtr(), + indices_data, indices_size, buffer_indices_dims.GpuPtr(), fdm_indices_strides.GpuPtr(), updates, axis, output_data); } + return Status::OK(); } -#define SPECIALIZED_IMPL(T) \ - template void ScatterElementsImpl( \ - const int rank, \ - const T* input_data, \ - const int64_t input_size, \ - const int64_t* input_dims, \ - const int64_t* input_strides, \ - const int32_t* indices_data, \ - const int64_t indices_size, \ - const int64_t* indices_dims, \ - const fast_divmod* indices_strides, \ - const T* updates, \ - const int axis, \ - T* output_data); \ - template void ScatterElementsImpl( \ - const int rank, \ - const T* input_data, \ - const int64_t input_size, \ - const int64_t* input_dims, \ - const int64_t* input_strides, \ - const int64_t* indices_data, \ - const int64_t indices_size, \ - const int64_t* indices_dims, \ - const fast_divmod* indices_strides, \ - const T* updates, \ - const int axis, \ - T* output_data); \ +#define SPECIALIZED_TINDEX_IMPL(T, TIndex) \ + template Status ScatterElementsImpl( \ + const int rank, \ + const T* input_data, \ + const int64_t input_size, \ + CudaKernel::CudaAsyncBuffer& buffer_input_dims, \ + CudaKernel::CudaAsyncBuffer& buffer_input_strides, \ + const TIndex* indices_data, \ + const int64_t indices_size, \ + CudaKernel::CudaAsyncBuffer& buffer_indices_dims, \ + CudaKernel::CudaAsyncBuffer& indices_strides, \ + const T* updates, \ + const int axis, \ + T* output_data) + +#define SPECIALIZED_IMPL(T) \ + SPECIALIZED_TINDEX_IMPL(T, int32_t); \ + SPECIALIZED_TINDEX_IMPL(T, int64_t); SPECIALIZED_IMPL(int8_t) SPECIALIZED_IMPL(int16_t) @@ -108,4 +236,3 @@ SPECIALIZED_IMPL(bool) } // namespace cuda } // namespace onnxruntime - diff --git a/onnxruntime/core/providers/cuda/tensor/scatter_elements_impl.h b/onnxruntime/core/providers/cuda/tensor/scatter_elements_impl.h index 7b1a89d3345bf..f4fb1968e00f4 100755 --- a/onnxruntime/core/providers/cuda/tensor/scatter_elements_impl.h +++ b/onnxruntime/core/providers/cuda/tensor/scatter_elements_impl.h @@ -10,16 +10,16 @@ namespace onnxruntime { namespace cuda { template -void ScatterElementsImpl( +Status ScatterElementsImpl( const int rank, const T* input_data, const int64_t input_size, - const int64_t* input_dims, - const int64_t* input_strides, + CudaKernel::CudaAsyncBuffer& buffer_input_dims, + CudaKernel::CudaAsyncBuffer& buffer_input_strides, const Tin* indices_data, const int64_t indices_size, - const int64_t* indices_dims, - const fast_divmod* indices_strides, + CudaKernel::CudaAsyncBuffer& buffer_indices_dims, + CudaKernel::CudaAsyncBuffer& indices_strides, const T* updates, const int axis, T* output_data); diff --git a/onnxruntime/core/providers/cuda/tensor/upsample.cc b/onnxruntime/core/providers/cuda/tensor/upsample.cc index 68ab2cebde4a4..a39ece5b37cdb 100644 --- a/onnxruntime/core/providers/cuda/tensor/upsample.cc +++ b/onnxruntime/core/providers/cuda/tensor/upsample.cc @@ -81,7 +81,7 @@ Status Upsample::BaseCompute(OpKernelContext* context, input_strides, output_div_pitches, scales_vals, roi_vals, reinterpret_cast(X->template Data()), reinterpret_cast(Y->template MutableData()), - output_count, use_extrapolation_, extrapolation_value_, + output_count, use_extrapolation_, ToCudaType::FromFloat(extrapolation_value_), cubic_coeff_a_, exclude_outside_, coordinate_transform_mode_, nearest_mode_, dims_mapping); @@ -152,7 +152,7 @@ Status Upsample::ComputeInternal(OpKernelContext* context) const { // When sizes input is available directly populate it into the output_dims array. ORT_ENFORCE(sizes != nullptr && sizes->Shape().Size() != 0, "Either scales or sizes MUST be provided as input."); - ORT_ENFORCE(sizes->Shape().Size() == output_dims.size(), + ORT_ENFORCE(sizes->Shape().Size() == static_cast(output_dims.size()), "Resize: input tensor's rank does not match the output tensor's rank."); memcpy(output_dims.data(), sizes->template Data(), sizes->Shape().Size() * sizeof(int64_t)); ParseScalesDataFromOutputSize(output_dims, X->Shape().GetDims(), scales_array); diff --git a/onnxruntime/python/session.py b/onnxruntime/python/session.py index bcd146ff27254..bdeb5061c6627 100644 --- a/onnxruntime/python/session.py +++ b/onnxruntime/python/session.py @@ -13,14 +13,16 @@ class InferenceSession: """ This is the main class used to run a model. """ - def __init__(self, path_or_bytes, sess_options=None): + def __init__(self, path_or_bytes, sess_options=None, providers=[]): """ :param path_or_bytes: filename or serialized model in a byte string :param sess_options: session options + :param providers: providers to use for session. If empty, will use + all available providers. """ self._path_or_bytes = path_or_bytes self._sess_options = sess_options - self._load_model() + self._load_model(providers) self._enable_fallback = True def _load_model(self, providers=[]): diff --git a/onnxruntime/python/tools/automl/README.md b/onnxruntime/python/tools/featurizer_ops/README.md similarity index 100% rename from onnxruntime/python/tools/automl/README.md rename to onnxruntime/python/tools/featurizer_ops/README.md diff --git a/onnxruntime/python/tools/automl/create_test_model.py b/onnxruntime/python/tools/featurizer_ops/create_test_model.py similarity index 100% rename from onnxruntime/python/tools/automl/create_test_model.py rename to onnxruntime/python/tools/featurizer_ops/create_test_model.py diff --git a/onnxruntime/python/tools/automl/data_frame_tool.py b/onnxruntime/python/tools/featurizer_ops/data_frame_tool.py similarity index 100% rename from onnxruntime/python/tools/automl/data_frame_tool.py rename to onnxruntime/python/tools/featurizer_ops/data_frame_tool.py diff --git a/onnxruntime/python/tools/automl/data_frame_tool_test.py b/onnxruntime/python/tools/featurizer_ops/data_frame_tool_test.py similarity index 100% rename from onnxruntime/python/tools/automl/data_frame_tool_test.py rename to onnxruntime/python/tools/featurizer_ops/data_frame_tool_test.py diff --git a/onnxruntime/test/optimizer/graph_transform_test.cc b/onnxruntime/test/optimizer/graph_transform_test.cc index bd7665fdede74..bbfc1fcc0dd68 100644 --- a/onnxruntime/test/optimizer/graph_transform_test.cc +++ b/onnxruntime/test/optimizer/graph_transform_test.cc @@ -1328,6 +1328,103 @@ TEST(GraphTransformationTests, EmbedLayerNormFusionFormat2) { ASSERT_TRUE(op_to_count["SkipLayerNormalization"] == 0); ASSERT_TRUE(op_to_count["EmbedLayerNormalization"] == 1); } + +TEST(GraphTransformationTests, EmbedLayerNormFusionFormat3) { + auto model_uri = MODEL_FOLDER "fusion/embed_layer_norm_format3.onnx"; + std::shared_ptr p_model; + ASSERT_TRUE(Model::Load(model_uri, p_model, nullptr, DefaultLoggingManager().DefaultLogger()).IsOK()); + Graph& graph = p_model->MainGraph(); + + onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; + graph_transformation_mgr.Register(onnxruntime::make_unique(), TransformerLevel::Level2); + auto ret = graph_transformation_mgr.ApplyTransformers(graph, TransformerLevel::Level2, DefaultLoggingManager().DefaultLogger()); + ASSERT_TRUE(ret.IsOK()); + + std::map op_to_count = CountOpsInGraph(graph); + EXPECT_EQ(op_to_count["Shape"], 0); + EXPECT_EQ(op_to_count["Expand"], 0); + EXPECT_EQ(op_to_count["Gather"], 0); + EXPECT_EQ(op_to_count["Unsqueeze"], 0); + EXPECT_EQ(op_to_count["LayerNormalization"], 0); + EXPECT_EQ(op_to_count["SkipLayerNormalization"], 0); + EXPECT_EQ(op_to_count["ReduceSum"], 0); + EXPECT_EQ(op_to_count["MatMul"], 1); + EXPECT_EQ(op_to_count["Add"], 2); + EXPECT_EQ(op_to_count["Cast"], 3); + EXPECT_EQ(op_to_count["Attention"], 1); + EXPECT_EQ(op_to_count["EmbedLayerNormalization"], 1); +} + +TEST(GraphTransformationTests, EmbedLayerNormFusionFormat4) { + auto model_uri = MODEL_FOLDER "fusion/embed_layer_norm_format4.onnx"; + std::shared_ptr p_model; + ASSERT_TRUE(Model::Load(model_uri, p_model, nullptr, DefaultLoggingManager().DefaultLogger()).IsOK()); + Graph& graph = p_model->MainGraph(); + + onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; + graph_transformation_mgr.Register(onnxruntime::make_unique(), TransformerLevel::Level2); + auto ret = graph_transformation_mgr.ApplyTransformers(graph, TransformerLevel::Level2, DefaultLoggingManager().DefaultLogger()); + ASSERT_TRUE(ret.IsOK()); + + std::map op_to_count = CountOpsInGraph(graph); + ASSERT_TRUE(op_to_count["Shape"] == 0); + ASSERT_TRUE(op_to_count["Expand"] == 0); + ASSERT_TRUE(op_to_count["Gather"] == 0); + ASSERT_TRUE(op_to_count["Concat"] == 0); + ASSERT_TRUE(op_to_count["Unsqueeze"] == 0); + ASSERT_TRUE(op_to_count["ConstantOfShape"] == 0); + ASSERT_TRUE(op_to_count["NonZero"] == 0); + ASSERT_TRUE(op_to_count["Transpose"] == 0); + ASSERT_TRUE(op_to_count["Squeeze"] == 0); + ASSERT_TRUE(op_to_count["Add"] == 0); + ASSERT_TRUE(op_to_count["ReduceSum"] == 0); + ASSERT_TRUE(op_to_count["Attention"] == 1); + ASSERT_TRUE(op_to_count["SkipLayerNormalization"] == 0); + ASSERT_TRUE(op_to_count["EmbedLayerNormalization"] == 1); +} + +TEST(GraphTransformationTests, EmbedLayerNormFusionFormat5) { + auto model_uri = MODEL_FOLDER "fusion/embed_layer_norm_format5.onnx"; + std::shared_ptr p_model; + ASSERT_TRUE(Model::Load(model_uri, p_model, nullptr, DefaultLoggingManager().DefaultLogger()).IsOK()); + Graph& graph = p_model->MainGraph(); + + onnxruntime::GraphTransformerManager graph_transformation_mgr{5}; + graph_transformation_mgr.Register(onnxruntime::make_unique(), TransformerLevel::Level2); + auto ret = graph_transformation_mgr.ApplyTransformers(graph, TransformerLevel::Level2, DefaultLoggingManager().DefaultLogger()); + ASSERT_TRUE(ret.IsOK()); + + std::map op_to_count = CountOpsInGraph(graph); + EXPECT_EQ(op_to_count["Gather"], 0); + EXPECT_EQ(op_to_count["LayerNormalization"], 0); + EXPECT_EQ(op_to_count["SkipLayerNormalization"], 0); + EXPECT_EQ(op_to_count["ReduceSum"], 0); + EXPECT_EQ(op_to_count["MatMul"], 1); + EXPECT_EQ(op_to_count["Add"], 2); + EXPECT_EQ(op_to_count["Cast"], 3); + EXPECT_EQ(op_to_count["Attention"], 1); + EXPECT_EQ(op_to_count["EmbedLayerNormalization"], 1); + + // Validate the position embedding input. + for (const Node& node : graph.Nodes()) { + if (node.OpType() == "EmbedLayerNormalization") { + const ONNX_NAMESPACE::TensorProto* tensor_proto = graph_utils::GetConstantInitializer(graph, node.InputDefs()[3]->Name()); + ASSERT_TRUE(tensor_proto != nullptr); + EXPECT_EQ(tensor_proto->data_type(), ONNX_NAMESPACE::TensorProto_DataType_FLOAT); + + auto initializer = onnxruntime::make_unique(*tensor_proto); + EXPECT_EQ(initializer->size(), 12); + + std::vector expected_value = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 8.0, 7.0, 6.0}; + + const float* data = initializer->data(); + for (size_t i = 0; i < expected_value.size(); i++) { + EXPECT_EQ(data[i], static_cast(expected_value[i])); + } + } + } +} + #endif } // namespace test diff --git a/onnxruntime/test/python/onnxruntime_test_python.py b/onnxruntime/test/python/onnxruntime_test_python.py index e3ca816a65b8a..0a0060767ebea 100644 --- a/onnxruntime/test/python/onnxruntime_test_python.py +++ b/onnxruntime/test/python/onnxruntime_test_python.py @@ -66,6 +66,13 @@ def testInvalidSetProviders(self): self.assertTrue('[\'InvalidProvider\'] does not contain a subset of available providers' in str( context.exception)) + def testSessionProviders(self): + if 'CUDAExecutionProvider' in onnxrt.get_available_providers(): + # create session from scratch, but constrain it to only use the CPU. + sess = onnxrt.InferenceSession( + self.get_name("mul_1.onnx"), providers=['CPUExecutionProvider']) + self.assertEqual(['CPUExecutionProvider'], sess.get_providers()) + def testRunModel(self): sess = onnxrt.InferenceSession(self.get_name("mul_1.onnx")) x = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]], dtype=np.float32) diff --git a/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_format3.onnx b/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_format3.onnx new file mode 100644 index 0000000000000..e58ffa62a142f Binary files /dev/null and b/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_format3.onnx differ diff --git a/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_format4.onnx b/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_format4.onnx new file mode 100644 index 0000000000000..eddbf40b5bd5e Binary files /dev/null and b/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_format4.onnx differ diff --git a/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_format5.onnx b/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_format5.onnx new file mode 100644 index 0000000000000..074806243552d Binary files /dev/null and b/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_format5.onnx differ diff --git a/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_gen.py b/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_gen.py new file mode 100644 index 0000000000000..e911e28a12017 --- /dev/null +++ b/onnxruntime/test/testdata/transform/fusion/embed_layer_norm_gen.py @@ -0,0 +1,129 @@ +import onnx +from onnx import helper +from onnx import TensorProto +from enum import Enum + +def GenerateModel3(model_name): + nodes = [ # LayerNorm subgraph + helper.make_node("Shape", ["input_ids"], ["shape1_out"], "shape1"), + helper.make_node("Gather", ["shape1_out", "indices_0"], ["gather0_out"], "gather0"), + helper.make_node("Unsqueeze", ["gather0_out"], ["unsqueeze0_out"], "unsqueeze0", axes=[0]), + helper.make_node("Shape", ["input_ids"], ["shape2_out"], "shape2"), + helper.make_node("Gather", ["shape2_out", "indices_1"], ["gather1_out"], "gather1"), + helper.make_node("Unsqueeze", ["gather1_out"], ["unsqueeze1_out"], "unsqueeze1", axes=[0]), + helper.make_node("Concat", ["unsqueeze0_out", "unsqueeze1_out"], ["concat_out"], "concat", axis=0), + helper.make_node("Cast", ["gather1_out"], ["cast_out"], "cast", to=7), + helper.make_node("Range", ["start_0", "cast_out", "delta_1"], ["range_out"], "range"), + helper.make_node("Unsqueeze", ["range_out"], ["unsqueeze2_out"], "unsqueeze2", axes=[0]), + helper.make_node("Expand", ["unsqueeze2_out", "concat_out"], ["expand_out"], "expand"), + helper.make_node("Gather", ["pos_embed", "expand_out"], ["pos_gather_out"], "pos_gather"), + helper.make_node("Gather", ["word_embed", "input_ids"], ["word_gather_out"], "word_gather"), + helper.make_node("Add", ["word_gather_out", "pos_gather_out"], ["word_add_pos_out"], "word_add_pos"), + helper.make_node("Gather", ["seg_embed", "segment_ids"], ["seg_gather_out"], "seg_gather"), + helper.make_node("Add", ["word_add_pos_out", "seg_gather_out"], ["add3_out"], "add3"), + helper.make_node("LayerNormalization", ["add3_out", "layer_norm_weight", "layer_norm_bias"], ["layernorm_out"], "layernorm", axis=-1, epsion=0.000009999999747378752), + helper.make_node("Cast", ["input_mask"], ["mask_cast_out"], "mask_cast", to=6), + helper.make_node("ReduceSum", ["mask_cast_out"], ["mask_index_out"], "mask_index", axes=[1], keepdims=0), + helper.make_node("Attention", ["layernorm_out", "qkv_weights", "qkv_bias", "mask_index_out"], ["att_out"], "att", domain="com.microsoft", num_heads=2), + helper.make_node("MatMul", ["att_out", "matmul_weight"], ["matmul_out"], "matmul"), + helper.make_node("Add", ["matmul_out", "add_bias"], ["add_out"], "add"), + helper.make_node("Add", ["add_out", "layernorm_out"], ["add2_out"], "add2") + + ] + + # hidden_size=4, num_heads=2, max_seq_length=3 + initializers = [ # initializers + helper.make_tensor('indices_0', TensorProto.INT64, [], [0]), + helper.make_tensor('indices_1', TensorProto.INT64, [], [1]), + helper.make_tensor('start_0', TensorProto.INT64, [], [0]), + helper.make_tensor('delta_1', TensorProto.INT64, [], [1]), + helper.make_tensor('word_embed', TensorProto.FLOAT, [2, 4], [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('pos_embed', TensorProto.FLOAT, [4, 4], [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('seg_embed', TensorProto.FLOAT, [2, 4], [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('layer_norm_weight', TensorProto.FLOAT, [4], [1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('layer_norm_bias', TensorProto.FLOAT, [4], [0.1, 0.2, 0.3, 0.4]), + + helper.make_tensor('qkv_weights', TensorProto.FLOAT, [4, 4], [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('qkv_bias', TensorProto.FLOAT, [4], [0.1, 0.2, 0.3, 0.4]), + + helper.make_tensor('matmul_weight', TensorProto.FLOAT, [4, 4], [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('add_bias', TensorProto.FLOAT, [4], [0.1, 0.2, 0.3, 0.4]), + ] + + graph = helper.make_graph( + nodes, + "EmbedLayerNorm_format3", #name + [ # inputs + helper.make_tensor_value_info('input_ids', TensorProto.INT64, ['batch', 3]), + helper.make_tensor_value_info('segment_ids', TensorProto.INT64, ['batch', 3]), + helper.make_tensor_value_info('input_mask', TensorProto.INT64, ['batch', 3]), + ], + [ # outputs + helper.make_tensor_value_info('add2_out', TensorProto.FLOAT, ['batch', 3, 4]), + ], + initializers + ) + + model = helper.make_model(graph) + onnx.save(model, model_name) + +def GenerateModel5(model_name): + batch_size = 2 + hidden_size = 4 + attention_heads = 2 + sequence_length = 3 + + nodes = [ + helper.make_node("Gather", ["word_embed", "input_ids"], ["word_gather_out"], "word_gather", axis=0), + helper.make_node("Add", ["word_gather_out", "pos_gather_out"], ["word_add_pos_out"], "word_add_pos"), + helper.make_node("Gather", ["seg_embed", "segment_ids"], ["seg_gather_out"], "seg_gather", axis=0), + helper.make_node("Add", ["word_add_pos_out", "seg_gather_out"], ["add3_out"], "add3"), + helper.make_node("LayerNormalization", ["add3_out", "layer_norm_weight", "layer_norm_bias"], ["layernorm_out"], "layernorm", axis=-1, epsion=0.000009999999747378752), + helper.make_node("Cast", ["input_mask"], ["mask_cast_out"], "mask_cast", to=6), + helper.make_node("ReduceSum", ["mask_cast_out"], ["mask_index_out"], "mask_index", axes=[1], keepdims=0), + helper.make_node("Attention", ["layernorm_out", "qkv_weights", "qkv_bias", "mask_index_out"], ["att_out"], "att", domain="com.microsoft", num_heads=attention_heads), + helper.make_node("MatMul", ["att_out", "matmul_weight"], ["matmul_out"], "matmul"), + helper.make_node("Add", ["matmul_out", "add_bias"], ["add_out"], "add"), + helper.make_node("Add", ["add_out", "layernorm_out"], ["add2_out"], "add2") + ] + + qkv_weights = [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0] + + initializers = [# initializers + helper.make_tensor('word_embed', TensorProto.FLOAT, [2, hidden_size], [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('pos_gather_out', TensorProto.FLOAT, [batch_size, sequence_length, hidden_size], + [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 8.0, 7.0, 6.0, + 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 8.0, 7.0, 6.0]), + helper.make_tensor('seg_embed', TensorProto.FLOAT, [2, hidden_size], [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('layer_norm_weight', TensorProto.FLOAT, [hidden_size], [1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('layer_norm_bias', TensorProto.FLOAT, [hidden_size], [0.1, 0.2, 0.3, 0.4]), + helper.make_tensor('qkv_weights', TensorProto.FLOAT, [hidden_size, 3 * hidden_size], qkv_weights), + + helper.make_tensor('qkv_bias', TensorProto.FLOAT, [3 * hidden_size], [0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4, 0.1, 0.2, 0.3, 0.4]), + + helper.make_tensor('matmul_weight', TensorProto.FLOAT, [hidden_size, hidden_size], + [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]), + helper.make_tensor('add_bias', TensorProto.FLOAT, [hidden_size], [0.1, 0.2, 0.3, 0.4]),] + + graph = helper.make_graph( + nodes, + "EmbedLayerNorm_format5", #name + [ # inputs + helper.make_tensor_value_info('input_ids', TensorProto.INT64, [batch_size, sequence_length]), + helper.make_tensor_value_info('segment_ids', TensorProto.INT64, [batch_size, sequence_length]), + helper.make_tensor_value_info('input_mask', TensorProto.INT64, [batch_size, sequence_length]), + ], + [ # outputs + helper.make_tensor_value_info('add2_out', TensorProto.FLOAT, [batch_size, sequence_length, hidden_size]), + ], + initializers + ) + + model = helper.make_model(graph) + onnx.save(model, model_name) + +#GenerateModel3('embed_layer_norm_format3.onnx') +GenerateModel5('embed_layer_norm_format5.onnx') \ No newline at end of file diff --git a/samples/README.md b/samples/README.md index 69e75a6dd73bc..7b399953ff83e 100644 --- a/samples/README.md +++ b/samples/README.md @@ -6,6 +6,7 @@ For a list of available dockerfiles and published images to help with getting st * [Python](#Python) * [C#](#C) * [C/C++](#CC) +* [Java](#Java) *** ## Python @@ -51,3 +52,7 @@ For a list of available dockerfiles and published images to help with getting st * [C - Inferencing (SqueezeNet)](../csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp) * [C++ - Inferencing (SqueezeNet)](../csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/CXX_Api_Sample.cpp) * [C++ - Inferencing (MNIST)](../samples/c_cxx/MNIST) + +## Java +* [Inference Tutorial](../docs/Java_API.md#getting-started) +* [MNIST inference](../java/sample/ScoreMNIST.java) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 84703c7c89b7b..10939a0bdbd83 100755 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -296,6 +296,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home "-Donnxruntime_USE_MIMALLOC=" + ("ON" if args.use_mimalloc else "OFF"), "-Donnxruntime_ENABLE_PYTHON=" + ("ON" if args.enable_pybind else "OFF"), "-Donnxruntime_BUILD_CSHARP=" + ("ON" if args.build_csharp else "OFF"), + "-Donnxruntime_BUILD_JAVA=" + ("ON" if args.build_java else "OFF"), "-Donnxruntime_BUILD_SHARED_LIB=" + ("ON" if args.build_shared_lib or args.build_server else "OFF"), "-Donnxruntime_USE_EIGEN_FOR_BLAS=" + ("OFF" if args.use_openblas else "ON"), "-Donnxruntime_USE_OPENBLAS=" + ("ON" if args.use_openblas else "OFF"), @@ -889,7 +890,7 @@ def main(): if args.build_wheel or args.enable_server_model_tests: args.enable_pybind = True - if args.build_csharp: + if args.build_csharp or args.build_java: args.build_shared_lib = True # Disabling unit tests for VAD-F as FPGA only supports models with NCHW layout diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/test_macos.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/test_macos.yml index 25695dbfe7722..920a2e52d8948 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/test_macos.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/test_macos.yml @@ -47,6 +47,10 @@ jobs: exit 1 fi displayName: 'Run Test' + env: + OnnxRuntimeBuildDirectory: $(Build.BinariesDirectory) + DisableContribOps: $(DisableContribOps) + IsReleaseBuild: $(IsReleaseBuild) - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 displayName: 'Component Detection' diff --git a/tools/ci_build/github/azure-pipelines/win-ci-pipeline.yml b/tools/ci_build/github/azure-pipelines/win-ci-pipeline.yml index 3489ede0c4e71..9a06d031510d3 100644 --- a/tools/ci_build/github/azure-pipelines/win-ci-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/win-ci-pipeline.yml @@ -30,7 +30,7 @@ jobs: displayName: 'Generate cmake config' inputs: scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py' - arguments: '--config $(BuildConfig) --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --update --cmake_generator "Visual Studio 16 2019" --build_wheel --use_automl --use_dnnl --use_openmp --build_shared_lib --enable_onnx_tests' + arguments: '--config $(BuildConfig) --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --update --cmake_generator "Visual Studio 16 2019" --build_wheel --use_automl --use_dnnl --use_openmp --build_shared_lib --enable_onnx_tests --build_java' workingDirectory: '$(Build.BinariesDirectory)' - task: VSBuild@1 @@ -112,8 +112,9 @@ jobs: set /p WHEEL_FILENAME=