diff --git a/CHANGELOG.md b/CHANGELOG.md index 08c27c9f69e..eeef235b785 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ + * Map the C++ API of ONNX Runtime and refine support for DNNL ([pull #841](https://github.com/bytedeco/javacpp-presets/pull/841)) * Add convenient `Py_AddPath()` helper method to presets for CPython * Include `OrcBindings.h` and other missing header files for LLVM ([issue #833](https://github.com/bytedeco/javacpp-presets/issues/833)) * Fix `-platform` artifacts on JPMS by commenting out requires to Android modules ([issue #814](https://github.com/bytedeco/javacpp-presets/issues/814) and [pull #831](https://github.com/bytedeco/javacpp-presets/pull/831)) diff --git a/dnnl/cppbuild.sh b/dnnl/cppbuild.sh index 10e8b2a7208..395c9cc96df 100755 --- a/dnnl/cppbuild.sh +++ b/dnnl/cppbuild.sh @@ -28,19 +28,14 @@ case $PLATFORM in make install/strip ;; macosx-x86_64) - export CC="$(ls -1 /usr/local/bin/gcc-? | head -n 1)" - export CXX="$(ls -1 /usr/local/bin/g++-? | head -n 1)" sedinplace 's/__thread/thread_local/g' src/common/utils.hpp "$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" -DARCH_OPT_FLAGS='' -DMKLDNN_BUILD_EXAMPLES=OFF -DMKLDNN_BUILD_TESTS=OFF . make -j $MAKEJ make install/strip - unset CC - unset CXX ;; windows-x86_64) - "$CMAKE" -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" -DARCH_OPT_FLAGS='' -DMKLDNN_BUILD_EXAMPLES=OFF -DMKLDNN_BUILD_TESTS=OFF . - make -j $MAKEJ - make install/strip + "$CMAKE" -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" -DARCH_OPT_FLAGS='' -DMKLDNN_BUILD_EXAMPLES=OFF -DMKLDNN_BUILD_TESTS=OFF . + MSBuild.exe INSTALL.vcxproj //p:Configuration=Release //p:CL_MPCount=$MAKEJ ;; *) echo "Error: Platform \"$PLATFORM\" is not supported" diff --git a/dnnl/pom.xml b/dnnl/pom.xml index 35640fcf543..6862dd81715 100644 --- a/dnnl/pom.xml +++ b/dnnl/pom.xml @@ -86,68 +86,4 @@ - - - macosx-gcc8 - - - /usr/local/bin/g++-8 - - - - /usr/local/bin/g++-8 - - - - macosx-gcc7 - - - /usr/local/bin/g++-7 - - - - /usr/local/bin/g++-7 - - - - macosx-gcc6 - - - /usr/local/bin/g++-6 - - - - /usr/local/bin/g++-6 - - - - macosx-gcc5 - - - /usr/local/bin/g++-5 - - - - /usr/local/bin/g++-5 - - - - mingw - - windows - - - - - org.bytedeco - javacpp - - ${javacpp.platform}-mingw - - - - - - - diff --git a/dnnl/src/gen/java/org/bytedeco/dnnl/concat.java b/dnnl/src/gen/java/org/bytedeco/dnnl/concat.java index 760ab586b5d..265424cf9ee 100644 --- a/dnnl/src/gen/java/org/bytedeco/dnnl/concat.java +++ b/dnnl/src/gen/java/org/bytedeco/dnnl/concat.java @@ -28,8 +28,17 @@ public static class primitive_desc extends primitive_desc_base { static { Loader.load(); } - public primitive_desc() { super((Pointer)null); allocate(); } - private native void allocate(); + + public primitive_desc() { super((Pointer)null); allocate(); } + private native void allocate(); + public primitive_desc(@Const @ByRef primitive_desc arg0) { super((Pointer)null); allocate(arg0); } + private native void allocate(@Const @ByRef primitive_desc arg0); + + /// + public primitive_desc(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/) { super((Pointer)null); allocate(t, weak); } + private native void allocate(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/); + public primitive_desc(dnnl_primitive_desc t) { super((Pointer)null); allocate(t); } + private native void allocate(dnnl_primitive_desc t); /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ public primitive_desc(Pointer p) { super(p); } /** Native array allocator. Access with {@link Pointer#position(long)}. */ diff --git a/dnnl/src/gen/java/org/bytedeco/dnnl/post_ops.java b/dnnl/src/gen/java/org/bytedeco/dnnl/post_ops.java index 8c70ab06c4f..6dd4c9e18ab 100644 --- a/dnnl/src/gen/java/org/bytedeco/dnnl/post_ops.java +++ b/dnnl/src/gen/java/org/bytedeco/dnnl/post_ops.java @@ -20,6 +20,18 @@ @Namespace("dnnl") @Properties(inherit = org.bytedeco.dnnl.presets.dnnl.class) public class post_ops extends dnnl_post_ops_handle { static { Loader.load(); } + + + public post_ops() { super((Pointer)null); allocate(); } + private native void allocate(); + public post_ops(@Const @ByRef post_ops arg0) { super((Pointer)null); allocate(arg0); } + private native void allocate(@Const @ByRef post_ops arg0); + + /// + public post_ops(dnnl_post_ops t, @Cast("bool") boolean weak/*=false*/) { super((Pointer)null); allocate(t, weak); } + private native void allocate(dnnl_post_ops t, @Cast("bool") boolean weak/*=false*/); + public post_ops(dnnl_post_ops t) { super((Pointer)null); allocate(t); } + private native void allocate(dnnl_post_ops t); /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ public post_ops(Pointer p) { super(p); } /** Native array allocator. Access with {@link Pointer#position(long)}. */ @@ -31,8 +43,6 @@ public class post_ops extends dnnl_post_ops_handle { /** Constructs an empty sequence of post-ops. */ - public post_ops() { super((Pointer)null); allocate(); } - private native void allocate(); /** Returns the number of post-ops entries. */ public native int len(); diff --git a/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_attr.java b/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_attr.java index 089acd5a349..1f9c0c38f9c 100644 --- a/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_attr.java +++ b/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_attr.java @@ -16,6 +16,18 @@ @Namespace("dnnl") @Properties(inherit = org.bytedeco.dnnl.presets.dnnl.class) public class primitive_attr extends dnnl_primitive_attr_handle { static { Loader.load(); } + + + public primitive_attr() { super((Pointer)null); allocate(); } + private native void allocate(); + public primitive_attr(@Const @ByRef primitive_attr arg0) { super((Pointer)null); allocate(arg0); } + private native void allocate(@Const @ByRef primitive_attr arg0); + + /// + public primitive_attr(dnnl_primitive_attr t, @Cast("bool") boolean weak/*=false*/) { super((Pointer)null); allocate(t, weak); } + private native void allocate(dnnl_primitive_attr t, @Cast("bool") boolean weak/*=false*/); + public primitive_attr(dnnl_primitive_attr t) { super((Pointer)null); allocate(t); } + private native void allocate(dnnl_primitive_attr t); /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ public primitive_attr(Pointer p) { super(p); } /** Native array allocator. Access with {@link Pointer#position(long)}. */ @@ -27,10 +39,6 @@ public class primitive_attr extends dnnl_primitive_attr_handle { /** Constructs default (empty) primitive attributes. */ - - /// - public primitive_attr() { super((Pointer)null); allocate(); } - private native void allocate(); /** Creates primitive attributes from a C API ::dnnl_primitive_attr_t * handle. The resulting handle is not weak and the C handle will be diff --git a/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_desc.java b/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_desc.java index a00e76e6f25..8468fd34708 100644 --- a/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_desc.java +++ b/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_desc.java @@ -21,8 +21,17 @@ public class primitive_desc extends primitive_desc_base { static { Loader.load(); } - public primitive_desc() { super((Pointer)null); allocate(); } - private native void allocate(); + + public primitive_desc() { super((Pointer)null); allocate(); } + private native void allocate(); + public primitive_desc(@Const @ByRef primitive_desc arg0) { super((Pointer)null); allocate(arg0); } + private native void allocate(@Const @ByRef primitive_desc arg0); + + /// + public primitive_desc(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/) { super((Pointer)null); allocate(t, weak); } + private native void allocate(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/); + public primitive_desc(dnnl_primitive_desc t) { super((Pointer)null); allocate(t); } + private native void allocate(dnnl_primitive_desc t); /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ public primitive_desc(Pointer p) { super(p); } /** Native array allocator. Access with {@link Pointer#position(long)}. */ diff --git a/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_desc_base.java b/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_desc_base.java index c8e4d09ebbf..239ddad6f05 100644 --- a/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_desc_base.java +++ b/dnnl/src/gen/java/org/bytedeco/dnnl/primitive_desc_base.java @@ -21,6 +21,18 @@ @Namespace("dnnl") @Properties(inherit = org.bytedeco.dnnl.presets.dnnl.class) public class primitive_desc_base extends dnnl_primitive_desc_handle { static { Loader.load(); } + + + public primitive_desc_base() { super((Pointer)null); allocate(); } + private native void allocate(); + public primitive_desc_base(@Const @ByRef primitive_desc_base arg0) { super((Pointer)null); allocate(arg0); } + private native void allocate(@Const @ByRef primitive_desc_base arg0); + + /// + public primitive_desc_base(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/) { super((Pointer)null); allocate(t, weak); } + private native void allocate(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/); + public primitive_desc_base(dnnl_primitive_desc t) { super((Pointer)null); allocate(t); } + private native void allocate(dnnl_primitive_desc t); /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ public primitive_desc_base(Pointer p) { super(p); } /** Native array allocator. Access with {@link Pointer#position(long)}. */ @@ -32,8 +44,6 @@ public class primitive_desc_base extends dnnl_primitive_desc_handle { /** Default constructor. Produces an empty object. */ - public primitive_desc_base() { super((Pointer)null); allocate(); } - private native void allocate(); /** Returns the engine of the primitive descriptor. */ public native @ByVal engine get_engine(); diff --git a/dnnl/src/gen/java/org/bytedeco/dnnl/reorder.java b/dnnl/src/gen/java/org/bytedeco/dnnl/reorder.java index d1b9991aec6..879243dae64 100644 --- a/dnnl/src/gen/java/org/bytedeco/dnnl/reorder.java +++ b/dnnl/src/gen/java/org/bytedeco/dnnl/reorder.java @@ -38,8 +38,17 @@ public static class primitive_desc extends primitive_desc_base { static { Loader.load(); } - public primitive_desc() { super((Pointer)null); allocate(); } - private native void allocate(); + + public primitive_desc() { super((Pointer)null); allocate(); } + private native void allocate(); + public primitive_desc(@Const @ByRef primitive_desc arg0) { super((Pointer)null); allocate(arg0); } + private native void allocate(@Const @ByRef primitive_desc arg0); + + /// + public primitive_desc(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/) { super((Pointer)null); allocate(t, weak); } + private native void allocate(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/); + public primitive_desc(dnnl_primitive_desc t) { super((Pointer)null); allocate(t); } + private native void allocate(dnnl_primitive_desc t); /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ public primitive_desc(Pointer p) { super(p); } /** Native array allocator. Access with {@link Pointer#position(long)}. */ diff --git a/dnnl/src/gen/java/org/bytedeco/dnnl/rnn_primitive_desc_base.java b/dnnl/src/gen/java/org/bytedeco/dnnl/rnn_primitive_desc_base.java index 3fe66625d26..cd6c8512a94 100644 --- a/dnnl/src/gen/java/org/bytedeco/dnnl/rnn_primitive_desc_base.java +++ b/dnnl/src/gen/java/org/bytedeco/dnnl/rnn_primitive_desc_base.java @@ -26,8 +26,17 @@ public class rnn_primitive_desc_base extends org.bytedeco.dnnl.primitive_desc { - public rnn_primitive_desc_base() { super((Pointer)null); allocate(); } - private native void allocate(); + + public rnn_primitive_desc_base() { super((Pointer)null); allocate(); } + private native void allocate(); + public rnn_primitive_desc_base(@Const @ByRef rnn_primitive_desc_base arg0) { super((Pointer)null); allocate(arg0); } + private native void allocate(@Const @ByRef rnn_primitive_desc_base arg0); + + /// + public rnn_primitive_desc_base(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/) { super((Pointer)null); allocate(t, weak); } + private native void allocate(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/); + public rnn_primitive_desc_base(dnnl_primitive_desc t) { super((Pointer)null); allocate(t); } + private native void allocate(dnnl_primitive_desc t); /// diff --git a/dnnl/src/gen/java/org/bytedeco/dnnl/sum.java b/dnnl/src/gen/java/org/bytedeco/dnnl/sum.java index b88e38405f7..a1d35d4d550 100644 --- a/dnnl/src/gen/java/org/bytedeco/dnnl/sum.java +++ b/dnnl/src/gen/java/org/bytedeco/dnnl/sum.java @@ -37,8 +37,17 @@ public static class primitive_desc extends primitive_desc_base { static { Loader.load(); } - public primitive_desc() { super((Pointer)null); allocate(); } - private native void allocate(); + + public primitive_desc() { super((Pointer)null); allocate(); } + private native void allocate(); + public primitive_desc(@Const @ByRef primitive_desc arg0) { super((Pointer)null); allocate(arg0); } + private native void allocate(@Const @ByRef primitive_desc arg0); + + /// + public primitive_desc(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/) { super((Pointer)null); allocate(t, weak); } + private native void allocate(dnnl_primitive_desc t, @Cast("bool") boolean weak/*=false*/); + public primitive_desc(dnnl_primitive_desc t) { super((Pointer)null); allocate(t); } + private native void allocate(dnnl_primitive_desc t); /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ public primitive_desc(Pointer p) { super(p); } /** Native array allocator. Access with {@link Pointer#position(long)}. */ diff --git a/dnnl/src/main/java/org/bytedeco/dnnl/presets/dnnl.java b/dnnl/src/main/java/org/bytedeco/dnnl/presets/dnnl.java index f12adfdfc89..c0283d3e570 100644 --- a/dnnl/src/main/java/org/bytedeco/dnnl/presets/dnnl.java +++ b/dnnl/src/main/java/org/bytedeco/dnnl/presets/dnnl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 Samuel Audet, Alexander Merritt + * Copyright (C) 2018-2020 Samuel Audet, Alexander Merritt * * Licensed either under the Apache License, Version 2.0, or (at your option) * under the terms of the GNU General Public License as published by @@ -22,6 +22,9 @@ package org.bytedeco.dnnl.presets; +import java.util.List; +import org.bytedeco.javacpp.ClassProperties; +import org.bytedeco.javacpp.LoadEnabled; import org.bytedeco.javacpp.annotation.Platform; import org.bytedeco.javacpp.annotation.Properties; import org.bytedeco.javacpp.tools.Info; @@ -39,16 +42,61 @@ compiler = "cpp11", define = {"GENERIC_EXCEPTION_CLASS dnnl::error", "GENERIC_EXCEPTION_TOSTRING toStdString().c_str()"}, include = {"dnnl_types.h", "dnnl_config.h", /*"dnnl_debug.h",*/ "dnnl_version.h", "dnnl.h", "dnnl.hpp"}, - link = "dnnl@.1", preload = {"gomp@.1", "iomp5"}), + link = "dnnl@.1", preload = {"gomp@.1", "iomp5"} + ), @Platform( - value = "macosx-x86_64", - preload = {"gcc_s@.1", "gomp@.1", "stdc++@.6", "iomp5"}, - preloadpath = {"/usr/local/lib/gcc/8/", "/usr/local/lib/gcc/7/", "/usr/local/lib/gcc/6/", "/usr/local/lib/gcc/5/"}), + value = "windows", + preload = {"api-ms-win-crt-locale-l1-1-0", "api-ms-win-crt-string-l1-1-0", "api-ms-win-crt-stdio-l1-1-0", "api-ms-win-crt-math-l1-1-0", + "api-ms-win-crt-heap-l1-1-0", "api-ms-win-crt-runtime-l1-1-0", "api-ms-win-crt-convert-l1-1-0", "api-ms-win-crt-environment-l1-1-0", + "api-ms-win-crt-time-l1-1-0", "api-ms-win-crt-filesystem-l1-1-0", "api-ms-win-crt-utility-l1-1-0", "api-ms-win-crt-multibyte-l1-1-0", + "api-ms-win-core-string-l1-1-0", "api-ms-win-core-errorhandling-l1-1-0", "api-ms-win-core-timezone-l1-1-0", "api-ms-win-core-file-l1-1-0", + "api-ms-win-core-namedpipe-l1-1-0", "api-ms-win-core-handle-l1-1-0", "api-ms-win-core-file-l2-1-0", "api-ms-win-core-heap-l1-1-0", + "api-ms-win-core-libraryloader-l1-1-0", "api-ms-win-core-synch-l1-1-0", "api-ms-win-core-processthreads-l1-1-0", + "api-ms-win-core-processenvironment-l1-1-0", "api-ms-win-core-datetime-l1-1-0", "api-ms-win-core-localization-l1-2-0", + "api-ms-win-core-sysinfo-l1-1-0", "api-ms-win-core-synch-l1-2-0", "api-ms-win-core-console-l1-1-0", "api-ms-win-core-debug-l1-1-0", + "api-ms-win-core-rtlsupport-l1-1-0", "api-ms-win-core-processthreads-l1-1-1", "api-ms-win-core-file-l1-2-0", "api-ms-win-core-profile-l1-1-0", + "api-ms-win-core-memory-l1-1-0", "api-ms-win-core-util-l1-1-0", "api-ms-win-core-interlocked-l1-1-0", "ucrtbase", + "vcruntime140", "msvcp140", "concrt140", "vcomp140"} + ), + @Platform( + value = "windows-x86", + preloadpath = {"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/redist/x86/Microsoft.VC140.CRT/", + "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/redist/x86/Microsoft.VC140.OpenMP/", + "C:/Program Files (x86)/Windows Kits/10/Redist/ucrt/DLLs/x86/"} + ), @Platform( value = "windows-x86_64", - preload = {"libwinpthread-1", "libgcc_s_seh-1", "libgomp-1", "libstdc++-6", "libiomp5md", "libdnnl"})}, - target = "org.bytedeco.dnnl", global = "org.bytedeco.dnnl.global.dnnl") -public class dnnl implements InfoMapper { + preloadpath = {"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/redist/x64/Microsoft.VC140.CRT/", + "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/redist/x64/Microsoft.VC140.OpenMP/", + "C:/Program Files (x86)/Windows Kits/10/Redist/ucrt/DLLs/x64/"} + ), + }, + target = "org.bytedeco.dnnl", + global = "org.bytedeco.dnnl.global.dnnl" +) +public class dnnl implements LoadEnabled, InfoMapper { + + @Override public void init(ClassProperties properties) { + String platform = properties.getProperty("platform"); + List preloadpaths = properties.get("platform.preloadpath"); + + String vcredistdir = System.getenv("VCToolsRedistDir"); + if (vcredistdir != null && vcredistdir.length() > 0) { + switch (platform) { + case "windows-x86": + preloadpaths.add(0, vcredistdir + "\\x86\\Microsoft.VC141.CRT"); + preloadpaths.add(1, vcredistdir + "\\x86\\Microsoft.VC141.OpenMP"); + break; + case "windows-x86_64": + preloadpaths.add(0, vcredistdir + "\\x64\\Microsoft.VC141.CRT"); + preloadpaths.add(1, vcredistdir + "\\x64\\Microsoft.VC141.OpenMP"); + break; + default: + // not Windows + } + } + } + public void map(InfoMap infoMap) { infoMap.put(new Info().enumerate()) .put(new Info("DNNL_HELPER_DLL_IMPORT", "DNNL_HELPER_DLL_EXPORT", "DNNL_API", diff --git a/onnxruntime/README.md b/onnxruntime/README.md index 00b5402736a..465649e056c 100644 --- a/onnxruntime/README.md +++ b/onnxruntime/README.md @@ -16,16 +16,14 @@ Java API documentation is available here: * http://bytedeco.org/javacpp-presets/onnxruntime/apidocs/ -∗ Bindings are currently available only for the C API of ONNX Runtime. - Sample Usage ------------ -Here is a simple example of ONNX ported to Java from this C source file: +Here is a simple example of ONNX Runtime ported to Java from this C++ source file: - * https://github.com/microsoft/onnxruntime/blob/v1.0.0/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp + * https://github.com/microsoft/onnxruntime/blob/v1.0.0/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/CXX_Api_Sample.cpp -We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `CApiSample.java` source files below, simply execute on the command line: +We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `CXXApiSample.java` source files below, simply execute on the command line: ```bash $ mvn compile exec:java ``` @@ -35,10 +33,10 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic 4.0.0 org.bytedeco.onnxruntime - capisample + cxxapisample 1.5.3-SNAPSHOT - CApiSample + CXXApiSample @@ -53,111 +51,83 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic ``` -### The `CApiSample.java` source file +### The `CXXApiSample.java` source file ```java // Copyright(c) Microsoft Corporation.All rights reserved. // Licensed under the MIT License. // -import java.nio.file.*; import org.bytedeco.javacpp.*; import org.bytedeco.javacpp.indexer.*; import org.bytedeco.onnxruntime.*; import static org.bytedeco.onnxruntime.global.onnxruntime.*; -public class CApiSample { - - static final OrtApi g_ort = OrtGetApiBase().GetApi().call(ORT_API_VERSION); - - //***************************************************************************** - // helper function to check for status - static void CheckStatus(OrtStatus status) { - if (status != null && !status.isNull()) { - String msg = g_ort.GetErrorMessage().call(status).getString(); - System.err.println(msg); - g_ort.ReleaseStatus().call(status); - System.exit(1); - } - } +public class CXXApiSample { public static void main(String[] args) throws Exception { //************************************************************************* // initialize enviroment...one enviroment per process // enviroment maintains thread pools and other state info - PointerPointer envs = new PointerPointer(1); - CheckStatus(g_ort.CreateEnv().call(ORT_LOGGING_LEVEL_WARNING, new BytePointer("test"), envs)); - OrtEnv env = envs.get(OrtEnv.class); + Env env = new Env(ORT_LOGGING_LEVEL_WARNING, "test"); // initialize session options if needed - PointerPointer sessions_options = new PointerPointer(1); - CheckStatus(g_ort.CreateSessionOptions().call(sessions_options)); - OrtSessionOptions session_options = sessions_options.get(OrtSessionOptions.class); - g_ort.SetIntraOpNumThreads().call(session_options, 1); + SessionOptions session_options = new SessionOptions(); + session_options.SetIntraOpNumThreads(1); - // Sets graph optimization level - g_ort.SetSessionGraphOptimizationLevel().call(session_options, ORT_ENABLE_BASIC); + // If onnxruntime.dll is built with CUDA enabled, we can uncomment out this line to use CUDA for this + // session (we also need to include cuda_provider_factory.h above which defines it) + // #include "cuda_provider_factory.h" + // OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, 1); + OrtSessionOptionsAppendExecutionProvider_Dnnl(session_options.asOrtSessionOptions(), 1); - // Optionally add more execution providers via session_options - // E.g. for CUDA include cuda_provider_factory.h and uncomment the following line: - // OrtSessionOptionsAppendExecutionProvider_CUDA(sessionOptions, 0); + // Sets graph optimization level + // Available levels are + // ORT_DISABLE_ALL -> To disable all optimizations + // ORT_ENABLE_BASIC -> To enable basic optimizations (Such as redundant node removals) + // ORT_ENABLE_EXTENDED -> To enable extended optimizations (Includes level 1 + more complex optimizations like node fusions) + // ORT_ENABLE_ALL -> To Enable All possible opitmizations + session_options.SetGraphOptimizationLevel(ORT_ENABLE_EXTENDED); //************************************************************************* // create session and load model into memory // using squeezenet version 1.3 // URL = https://github.com/onnx/models/tree/master/squeezenet - PointerPointer sessions = new PointerPointer(1); String model_path = args.length > 0 ? args[0] : "squeezenet.onnx"; - System.out.println("Using Onnxruntime C API"); - CheckStatus(g_ort.CreateSession().call(env, new BytePointer(model_path), session_options, sessions)); - OrtSession session = sessions.get(OrtSession.class); + System.out.println("Using Onnxruntime C++ API"); + Session session = new Session(env, model_path, session_options); //************************************************************************* // print model input layer (node names, types, shape etc.) - SizeTPointer num_input_nodes = new SizeTPointer(1); - OrtStatus status; - PointerPointer allocators = new PointerPointer(1); - CheckStatus(g_ort.GetAllocatorWithDefaultOptions().call(allocators)); - OrtAllocator allocator = allocators.get(OrtAllocator.class); + AllocatorWithDefaultOptions allocator = new AllocatorWithDefaultOptions(); // print number of model input nodes - status = g_ort.SessionGetInputCount().call(session, num_input_nodes); - PointerPointer input_node_names = new PointerPointer(num_input_nodes.get()); + long num_input_nodes = session.GetInputCount(); + PointerPointer input_node_names = new PointerPointer(num_input_nodes); LongPointer input_node_dims = null; // simplify... this model has only 1 input node {1, 3, 224, 224}. // Otherwise need vector> - System.out.println("Number of inputs = " + num_input_nodes.get()); + System.out.println("Number of inputs = " + num_input_nodes); // iterate over all input nodes - for (long i = 0; i < num_input_nodes.get(); i++) { + for (long i = 0; i < num_input_nodes; i++) { // print input node names - PointerPointer input_names = new PointerPointer(1); - status = g_ort.SessionGetInputName().call(session, i, allocator, input_names); - BytePointer input_name = input_names.get(BytePointer.class); + BytePointer input_name = session.GetInputName(i, allocator.asOrtAllocator()); System.out.println("Input " + i + " : name=" + input_name.getString()); input_node_names.put(i, input_name); // print input node types - PointerPointer typeinfos = new PointerPointer(1); - status = g_ort.SessionGetInputTypeInfo().call(session, i, typeinfos); - OrtTypeInfo typeinfo = typeinfos.get(OrtTypeInfo.class); - PointerPointer tensor_infos = new PointerPointer(1); - CheckStatus(g_ort.CastTypeInfoToTensorInfo().call(typeinfo, tensor_infos)); - OrtTensorTypeAndShapeInfo tensor_info = tensor_infos.get(OrtTensorTypeAndShapeInfo.class); - IntPointer type = new IntPointer(1); - CheckStatus(g_ort.GetTensorElementType().call(tensor_info, type)); - System.out.println("Input " + i + " : type=" + type.get()); + TypeInfo type_info = session.GetInputTypeInfo(i); + TensorTypeAndShapeInfo tensor_info = type_info.GetTensorTypeAndShapeInfo(); + + int type = tensor_info.GetElementType(); + System.out.println("Input " + i + " : type=" + type); // print input shapes/dims - SizeTPointer num_dims = new SizeTPointer(1); - CheckStatus(g_ort.GetDimensionsCount().call(tensor_info, num_dims)); - System.out.println("Input " + i + " : num_dims=" + num_dims.get()); - input_node_dims = new LongPointer(num_dims.get()); - g_ort.GetDimensions().call(tensor_info, input_node_dims, num_dims.get()); - for (long j = 0; j < num_dims.get(); j++) + input_node_dims = tensor_info.GetShape(); + System.out.println("Input " + i + " : num_dims=" + input_node_dims.capacity()); + for (long j = 0; j < input_node_dims.capacity(); j++) System.out.println("Input " + i + " : dim " + j + "=" + input_node_dims.get(j)); - - g_ort.ReleaseTypeInfo().call(typeinfo); } // Results should be... @@ -178,6 +148,7 @@ public class CApiSample { //************************************************************************* // Score the model using sample data, and inspect values + long input_tensor_size = 224 * 224 * 3; // simplify ... using known dim values to calculate size // use OrtGetTensorShapeElementCount() to get official size! @@ -190,27 +161,16 @@ public class CApiSample { idx.put(i, (float)i / (input_tensor_size + 1)); // create input tensor object from data values - PointerPointer memory_infos = new PointerPointer(1); - CheckStatus(g_ort.CreateCpuMemoryInfo().call(OrtArenaAllocator, OrtMemTypeDefault, memory_infos)); - OrtMemoryInfo memory_info = memory_infos.get(OrtMemoryInfo.class); - PointerPointer input_tensors = new PointerPointer(1).put(0, null); - CheckStatus(g_ort.CreateTensorWithDataAsOrtValue().call(memory_info, input_tensor_values, input_tensor_size * Float.SIZE / 8, input_node_dims, 4, ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, input_tensors)); - OrtValue input_tensor = input_tensors.get(OrtValue.class); - IntPointer is_tensor = new IntPointer(1); - CheckStatus(g_ort.IsTensor().call(input_tensor, is_tensor)); - assert is_tensor.get() != 0; + MemoryInfo memory_info = MemoryInfo.CreateCpu(OrtArenaAllocator, OrtMemTypeDefault); + Value input_tensor = Value.CreateTensorFloat(memory_info.asOrtMemoryInfo(), input_tensor_values, input_tensor_size, input_node_dims, 4); + assert input_tensor.IsTensor(); // score model & input tensor, get back output tensor - PointerPointer output_tensors = new PointerPointer(1).put(0, null); - CheckStatus(g_ort.Run().call(session, null, input_node_names, input_tensors, 1, output_node_names, 1, output_tensors)); - OrtValue output_tensor = output_tensors.get(OrtValue.class); - CheckStatus(g_ort.IsTensor().call(output_tensor, is_tensor)); - assert is_tensor.get() != 0; + ValueVector output_tensor = session.Run(new RunOptions(), input_node_names, input_tensor, 1, output_node_names, 1); + assert output_tensor.size() == 1 && output_tensor.get(0).IsTensor(); // Get pointer to output tensor float values - PointerPointer floatarrs = new PointerPointer(1); - CheckStatus(g_ort.GetTensorMutableData().call(output_tensor, floatarrs)); - FloatPointer floatarr = floatarrs.get(FloatPointer.class); + FloatPointer floatarr = output_tensor.get(0).GetTensorMutableDataFloat(); assert Math.abs(floatarr.get(0) - 0.000045) < 1e-6; // score the model, and print scores for first 5 classes @@ -223,13 +183,6 @@ public class CApiSample { // Score for class[2] = 0.000125 // Score for class[3] = 0.001180 // Score for class[4] = 0.001317 - - g_ort.ReleaseMemoryInfo().call(memory_info); - g_ort.ReleaseValue().call(output_tensor); - g_ort.ReleaseValue().call(input_tensor); - g_ort.ReleaseSession().call(session); - g_ort.ReleaseSessionOptions().call(session_options); - g_ort.ReleaseEnv().call(env); System.out.println("Done!"); System.exit(0); } diff --git a/onnxruntime/cppbuild.sh b/onnxruntime/cppbuild.sh index 5d1a328f508..ee613c8d572 100755 --- a/onnxruntime/cppbuild.sh +++ b/onnxruntime/cppbuild.sh @@ -30,9 +30,9 @@ git submodule update --init --recursive --jobs $MAKEJ git submodule foreach --recursive git reset --hard patch -p1 < ../../../onnxruntime.patch which ctest3 &> /dev/null && CTEST="ctest3" || CTEST="ctest" -MAKEFLAGS="-j $MAKEJ" bash build.sh --cmake_path "$CMAKE" --ctest_path "$CTEST" --config Release --use_dnnl --use_mklml --build_shared_lib +MAKEFLAGS="-j $MAKEJ" bash build.sh --cmake_path "$CMAKE" --ctest_path "$CTEST" --config Release --use_dnnl --build_shared_lib cp -r include/* ../include -cp -r build/Linux/Release/lib* build/Linux/Release/dnnl/install/lib*/libdnnl* ../lib +cp -r build/Linux/Release/lib* ../lib cd ../.. diff --git a/onnxruntime/platform/pom.xml b/onnxruntime/platform/pom.xml index f3a5df45d48..dca6d56911a 100644 --- a/onnxruntime/platform/pom.xml +++ b/onnxruntime/platform/pom.xml @@ -22,8 +22,8 @@ org.bytedeco - mkl-dnn-platform - 0.21.3-${project.parent.version} + dnnl-platform + 1.2.0-${project.parent.version} ${project.groupId} diff --git a/onnxruntime/pom.xml b/onnxruntime/pom.xml index 94b888e0c5d..4855413ec1f 100644 --- a/onnxruntime/pom.xml +++ b/onnxruntime/pom.xml @@ -16,15 +16,15 @@ - requires org.bytedeco.mkldnn.${javacpp.platform.module}; + requires org.bytedeco.dnnl.${javacpp.platform.module}; org.bytedeco - mkl-dnn - 0.21.3-${project.parent.version} + dnnl + 1.2.0-${project.parent.version} org.bytedeco @@ -43,6 +43,13 @@ org.bytedeco javacpp + + + ${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/include/onnxruntime/core/session/ + ${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/include/ + ${basedir}/target/classes/org/bytedeco/${javacpp.packageName}/include/ + + maven-jar-plugin @@ -55,7 +62,6 @@ org/bytedeco/ngraph/${javacpp.platform}${javacpp.platform.extension}/*.exp org/bytedeco/ngraph/${javacpp.platform}${javacpp.platform.extension}/*.lib org/bytedeco/ngraph/${javacpp.platform}${javacpp.platform.extension}/*.obj - org/bytedeco/ngraph/${javacpp.platform}${javacpp.platform.extension}/*mklml* org/bytedeco/ngraph/${javacpp.platform}${javacpp.platform.extension}/*omp* diff --git a/onnxruntime/samples/CApiSample.java b/onnxruntime/samples/CApiSample.java index 561cf745994..ba5985d0281 100644 --- a/onnxruntime/samples/CApiSample.java +++ b/onnxruntime/samples/CApiSample.java @@ -2,7 +2,6 @@ // Licensed under the MIT License. // -import java.nio.file.*; import org.bytedeco.javacpp.*; import org.bytedeco.javacpp.indexer.*; import org.bytedeco.onnxruntime.*; @@ -43,6 +42,7 @@ public static void main(String[] args) throws Exception { // Optionally add more execution providers via session_options // E.g. for CUDA include cuda_provider_factory.h and uncomment the following line: // OrtSessionOptionsAppendExecutionProvider_CUDA(sessionOptions, 0); + OrtSessionOptionsAppendExecutionProvider_Dnnl(session_options, 1); //************************************************************************* // create session and load model into memory diff --git a/onnxruntime/samples/CXXApiSample.java b/onnxruntime/samples/CXXApiSample.java new file mode 100644 index 00000000000..86fee74eced --- /dev/null +++ b/onnxruntime/samples/CXXApiSample.java @@ -0,0 +1,134 @@ +// Copyright(c) Microsoft Corporation.All rights reserved. +// Licensed under the MIT License. +// + +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.indexer.*; +import org.bytedeco.onnxruntime.*; +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +public class CXXApiSample { + + public static void main(String[] args) throws Exception { + //************************************************************************* + // initialize enviroment...one enviroment per process + // enviroment maintains thread pools and other state info + Env env = new Env(ORT_LOGGING_LEVEL_WARNING, "test"); + + // initialize session options if needed + SessionOptions session_options = new SessionOptions(); + session_options.SetIntraOpNumThreads(1); + + // If onnxruntime.dll is built with CUDA enabled, we can uncomment out this line to use CUDA for this + // session (we also need to include cuda_provider_factory.h above which defines it) + // #include "cuda_provider_factory.h" + // OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, 1); + OrtSessionOptionsAppendExecutionProvider_Dnnl(session_options.asOrtSessionOptions(), 1); + + // Sets graph optimization level + // Available levels are + // ORT_DISABLE_ALL -> To disable all optimizations + // ORT_ENABLE_BASIC -> To enable basic optimizations (Such as redundant node removals) + // ORT_ENABLE_EXTENDED -> To enable extended optimizations (Includes level 1 + more complex optimizations like node fusions) + // ORT_ENABLE_ALL -> To Enable All possible opitmizations + session_options.SetGraphOptimizationLevel(ORT_ENABLE_EXTENDED); + + //************************************************************************* + // create session and load model into memory + // using squeezenet version 1.3 + // URL = https://github.com/onnx/models/tree/master/squeezenet + String model_path = args.length > 0 ? args[0] : "squeezenet.onnx"; + + System.out.println("Using Onnxruntime C++ API"); + Session session = new Session(env, model_path, session_options); + + //************************************************************************* + // print model input layer (node names, types, shape etc.) + AllocatorWithDefaultOptions allocator = new AllocatorWithDefaultOptions(); + + // print number of model input nodes + long num_input_nodes = session.GetInputCount(); + PointerPointer input_node_names = new PointerPointer(num_input_nodes); + LongPointer input_node_dims = null; // simplify... this model has only 1 input node {1, 3, 224, 224}. + // Otherwise need vector> + + System.out.println("Number of inputs = " + num_input_nodes); + + // iterate over all input nodes + for (long i = 0; i < num_input_nodes; i++) { + // print input node names + BytePointer input_name = session.GetInputName(i, allocator.asOrtAllocator()); + System.out.println("Input " + i + " : name=" + input_name.getString()); + input_node_names.put(i, input_name); + + // print input node types + TypeInfo type_info = session.GetInputTypeInfo(i); + TensorTypeAndShapeInfo tensor_info = type_info.GetTensorTypeAndShapeInfo(); + + int type = tensor_info.GetElementType(); + System.out.println("Input " + i + " : type=" + type); + + // print input shapes/dims + input_node_dims = tensor_info.GetShape(); + System.out.println("Input " + i + " : num_dims=" + input_node_dims.capacity()); + for (long j = 0; j < input_node_dims.capacity(); j++) + System.out.println("Input " + i + " : dim " + j + "=" + input_node_dims.get(j)); + } + + // Results should be... + // Number of inputs = 1 + // Input 0 : name = data_0 + // Input 0 : type = 1 + // Input 0 : num_dims = 4 + // Input 0 : dim 0 = 1 + // Input 0 : dim 1 = 3 + // Input 0 : dim 2 = 224 + // Input 0 : dim 3 = 224 + + //************************************************************************* + // Similar operations to get output node information. + // Use OrtSessionGetOutputCount(), OrtSessionGetOutputName() + // OrtSessionGetOutputTypeInfo() as shown above. + + //************************************************************************* + // Score the model using sample data, and inspect values + + + long input_tensor_size = 224 * 224 * 3; // simplify ... using known dim values to calculate size + // use OrtGetTensorShapeElementCount() to get official size! + + FloatPointer input_tensor_values = new FloatPointer(input_tensor_size); + PointerPointer output_node_names = new PointerPointer("softmaxout_1"); + + // initialize input data with values in [0.0, 1.0] + FloatIndexer idx = FloatIndexer.create(input_tensor_values); + for (long i = 0; i < input_tensor_size; i++) + idx.put(i, (float)i / (input_tensor_size + 1)); + + // create input tensor object from data values + MemoryInfo memory_info = MemoryInfo.CreateCpu(OrtArenaAllocator, OrtMemTypeDefault); + Value input_tensor = Value.CreateTensorFloat(memory_info.asOrtMemoryInfo(), input_tensor_values, input_tensor_size, input_node_dims, 4); + assert input_tensor.IsTensor(); + + // score model & input tensor, get back output tensor + ValueVector output_tensor = session.Run(new RunOptions(), input_node_names, input_tensor, 1, output_node_names, 1); + assert output_tensor.size() == 1 && output_tensor.get(0).IsTensor(); + + // Get pointer to output tensor float values + FloatPointer floatarr = output_tensor.get(0).GetTensorMutableDataFloat(); + assert Math.abs(floatarr.get(0) - 0.000045) < 1e-6; + + // score the model, and print scores for first 5 classes + for (int i = 0; i < 5; i++) + System.out.println("Score for class [" + i + "] = " + floatarr.get(i)); + + // Results should be as below... + // Score for class[0] = 0.000045 + // Score for class[1] = 0.003846 + // Score for class[2] = 0.000125 + // Score for class[3] = 0.001180 + // Score for class[4] = 0.001317 + System.out.println("Done!"); + System.exit(0); + } +} diff --git a/onnxruntime/samples/pom.xml b/onnxruntime/samples/pom.xml index 19714bd29b5..d2ddf13e6bd 100644 --- a/onnxruntime/samples/pom.xml +++ b/onnxruntime/samples/pom.xml @@ -1,10 +1,10 @@ 4.0.0 org.bytedeco.onnxruntime - capisample + cxxapisample 1.5.3-SNAPSHOT - CApiSample + CXXApiSample diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/AllocatorWithDefaultOptions.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/AllocatorWithDefaultOptions.java new file mode 100644 index 00000000000..c6202ed8d8c --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/AllocatorWithDefaultOptions.java @@ -0,0 +1,33 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class AllocatorWithDefaultOptions extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public AllocatorWithDefaultOptions(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public AllocatorWithDefaultOptions(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public AllocatorWithDefaultOptions position(long position) { + return (AllocatorWithDefaultOptions)super.position(position); + } + + public AllocatorWithDefaultOptions() { super((Pointer)null); allocate(); } + private native void allocate(); + + public native @Name("operator OrtAllocator*") OrtAllocator asOrtAllocator(); + + public native Pointer Alloc(@Cast("size_t") long size); + public native void Free(Pointer p); + + public native @Const OrtMemoryInfo GetInfo(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseCustomOpDomain.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseCustomOpDomain.java new file mode 100644 index 00000000000..fd63cf24943 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseCustomOpDomain.java @@ -0,0 +1,31 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +@Name("Ort::Base") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class BaseCustomOpDomain extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BaseCustomOpDomain(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BaseCustomOpDomain(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public BaseCustomOpDomain position(long position) { + return (BaseCustomOpDomain)super.position(position); + } + + public BaseCustomOpDomain() { super((Pointer)null); allocate(); } + private native void allocate(); + public BaseCustomOpDomain(OrtCustomOpDomain p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtCustomOpDomain p); + + public native @Name("operator OrtCustomOpDomain*") OrtCustomOpDomain asOrtCustomOpDomain(); + + public native OrtCustomOpDomain release(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseEnv.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseEnv.java new file mode 100644 index 00000000000..9e290d009e3 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseEnv.java @@ -0,0 +1,31 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +@Name("Ort::Base") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class BaseEnv extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BaseEnv(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BaseEnv(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public BaseEnv position(long position) { + return (BaseEnv)super.position(position); + } + + public BaseEnv() { super((Pointer)null); allocate(); } + private native void allocate(); + public BaseEnv(OrtEnv p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtEnv p); + + public native @Name("operator OrtEnv*") OrtEnv asOrtEnv(); + + public native OrtEnv release(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseMemoryInfo.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseMemoryInfo.java new file mode 100644 index 00000000000..033e5ce8e5e --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseMemoryInfo.java @@ -0,0 +1,33 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +// This is used internally by the C++ API. This is the common base class used by the wrapper objects. +@Name("Ort::Base") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class BaseMemoryInfo extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BaseMemoryInfo(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BaseMemoryInfo(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public BaseMemoryInfo position(long position) { + return (BaseMemoryInfo)super.position(position); + } + + public BaseMemoryInfo() { super((Pointer)null); allocate(); } + private native void allocate(); + public BaseMemoryInfo(OrtMemoryInfo p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtMemoryInfo p); + + public native @Name("operator OrtMemoryInfo*") OrtMemoryInfo asOrtMemoryInfo(); + + public native OrtMemoryInfo release(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseRunOptions.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseRunOptions.java new file mode 100644 index 00000000000..6b2a70460c3 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseRunOptions.java @@ -0,0 +1,31 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +@Name("Ort::Base") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class BaseRunOptions extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BaseRunOptions(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BaseRunOptions(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public BaseRunOptions position(long position) { + return (BaseRunOptions)super.position(position); + } + + public BaseRunOptions() { super((Pointer)null); allocate(); } + private native void allocate(); + public BaseRunOptions(OrtRunOptions p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtRunOptions p); + + public native @Name("operator OrtRunOptions*") OrtRunOptions asOrtRunOptions(); + + public native OrtRunOptions release(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseSession.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseSession.java new file mode 100644 index 00000000000..3f645f033d1 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseSession.java @@ -0,0 +1,31 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +@Name("Ort::Base") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class BaseSession extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BaseSession(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BaseSession(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public BaseSession position(long position) { + return (BaseSession)super.position(position); + } + + public BaseSession() { super((Pointer)null); allocate(); } + private native void allocate(); + public BaseSession(OrtSession p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtSession p); + + public native @Name("operator OrtSession*") OrtSession asOrtSession(); + + public native OrtSession release(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseSessionOptions.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseSessionOptions.java new file mode 100644 index 00000000000..ed060906e1c --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseSessionOptions.java @@ -0,0 +1,31 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +@Name("Ort::Base") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class BaseSessionOptions extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BaseSessionOptions(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BaseSessionOptions(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public BaseSessionOptions position(long position) { + return (BaseSessionOptions)super.position(position); + } + + public BaseSessionOptions() { super((Pointer)null); allocate(); } + private native void allocate(); + public BaseSessionOptions(OrtSessionOptions p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtSessionOptions p); + + public native @Name("operator OrtSessionOptions*") OrtSessionOptions asOrtSessionOptions(); + + public native OrtSessionOptions release(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseTensorTypeAndShapeInfo.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseTensorTypeAndShapeInfo.java new file mode 100644 index 00000000000..497394c0b62 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseTensorTypeAndShapeInfo.java @@ -0,0 +1,31 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +@Name("Ort::Base") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class BaseTensorTypeAndShapeInfo extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BaseTensorTypeAndShapeInfo(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BaseTensorTypeAndShapeInfo(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public BaseTensorTypeAndShapeInfo position(long position) { + return (BaseTensorTypeAndShapeInfo)super.position(position); + } + + public BaseTensorTypeAndShapeInfo() { super((Pointer)null); allocate(); } + private native void allocate(); + public BaseTensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtTensorTypeAndShapeInfo p); + + public native @Name("operator OrtTensorTypeAndShapeInfo*") OrtTensorTypeAndShapeInfo asOrtTensorTypeAndShapeInfo(); + + public native OrtTensorTypeAndShapeInfo release(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseTypeInfo.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseTypeInfo.java new file mode 100644 index 00000000000..d75d86cbe53 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseTypeInfo.java @@ -0,0 +1,31 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +@Name("Ort::Base") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class BaseTypeInfo extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BaseTypeInfo(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BaseTypeInfo(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public BaseTypeInfo position(long position) { + return (BaseTypeInfo)super.position(position); + } + + public BaseTypeInfo() { super((Pointer)null); allocate(); } + private native void allocate(); + public BaseTypeInfo(OrtTypeInfo p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtTypeInfo p); + + public native @Name("operator OrtTypeInfo*") OrtTypeInfo asOrtTypeInfo(); + + public native OrtTypeInfo release(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseValue.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseValue.java new file mode 100644 index 00000000000..f48a7e4cdfa --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/BaseValue.java @@ -0,0 +1,31 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +@Name("Ort::Base") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class BaseValue extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public BaseValue(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public BaseValue(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public BaseValue position(long position) { + return (BaseValue)super.position(position); + } + + public BaseValue() { super((Pointer)null); allocate(); } + private native void allocate(); + public BaseValue(OrtValue p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtValue p); + + public native @Name("operator OrtValue*") OrtValue asOrtValue(); + + public native OrtValue release(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/CustomOpApi.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/CustomOpApi.java new file mode 100644 index 00000000000..9cb80e8ff29 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/CustomOpApi.java @@ -0,0 +1,46 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +// +// Custom OPs (only needed to implement custom OPs) +// + +@Namespace("Ort") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class CustomOpApi extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public CustomOpApi(Pointer p) { super(p); } + + public CustomOpApi(@Const @ByRef OrtApi api) { super((Pointer)null); allocate(api); } + private native void allocate(@Const @ByRef OrtApi api); + + public native OrtTensorTypeAndShapeInfo GetTensorTypeAndShape(@Const OrtValue value); + public native @Cast("size_t") long GetTensorShapeElementCount(@Const OrtTensorTypeAndShapeInfo info); + public native @Cast("ONNXTensorElementDataType") int GetTensorElementType(@Const OrtTensorTypeAndShapeInfo info); + public native @Cast("size_t") long GetDimensionsCount(@Const OrtTensorTypeAndShapeInfo info); + public native void GetDimensions(@Const OrtTensorTypeAndShapeInfo info, @Cast("int64_t*") LongPointer dim_values, @Cast("size_t") long dim_values_length); + public native void GetDimensions(@Const OrtTensorTypeAndShapeInfo info, @Cast("int64_t*") LongBuffer dim_values, @Cast("size_t") long dim_values_length); + public native void GetDimensions(@Const OrtTensorTypeAndShapeInfo info, @Cast("int64_t*") long[] dim_values, @Cast("size_t") long dim_values_length); + public native void SetDimensions(OrtTensorTypeAndShapeInfo info, @Cast("const int64_t*") LongPointer dim_values, @Cast("size_t") long dim_count); + public native void SetDimensions(OrtTensorTypeAndShapeInfo info, @Cast("const int64_t*") LongBuffer dim_values, @Cast("size_t") long dim_count); + public native void SetDimensions(OrtTensorTypeAndShapeInfo info, @Cast("const int64_t*") long[] dim_values, @Cast("size_t") long dim_count); + + public native @Cast("int64_t*") @StdVector LongPointer GetTensorShape(@Const OrtTensorTypeAndShapeInfo info); + public native void ReleaseTensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo input); + public native @Cast("size_t") long KernelContext_GetInputCount(@Const OrtKernelContext context); + public native @Const OrtValue KernelContext_GetInput(@Const OrtKernelContext context, @Cast("size_t") long index); + public native @Cast("size_t") long KernelContext_GetOutputCount(@Const OrtKernelContext context); + public native OrtValue KernelContext_GetOutput(OrtKernelContext context, @Cast("size_t") long index, @Cast("const int64_t*") LongPointer dim_values, @Cast("size_t") long dim_count); + public native OrtValue KernelContext_GetOutput(OrtKernelContext context, @Cast("size_t") long index, @Cast("const int64_t*") LongBuffer dim_values, @Cast("size_t") long dim_count); + public native OrtValue KernelContext_GetOutput(OrtKernelContext context, @Cast("size_t") long index, @Cast("const int64_t*") long[] dim_values, @Cast("size_t") long dim_count); + + public native void ThrowOnError(OrtStatus result); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/CustomOpDomain.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/CustomOpDomain.java new file mode 100644 index 00000000000..13a542921e7 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/CustomOpDomain.java @@ -0,0 +1,24 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class CustomOpDomain extends BaseCustomOpDomain { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public CustomOpDomain(Pointer p) { super(p); } + + public CustomOpDomain(@Cast("const char*") BytePointer domain) { super((Pointer)null); allocate(domain); } + private native void allocate(@Cast("const char*") BytePointer domain); + public CustomOpDomain(String domain) { super((Pointer)null); allocate(domain); } + private native void allocate(String domain); + + public native void Add(OrtCustomOp op); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/Env.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/Env.java new file mode 100644 index 00000000000..32a947353b3 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/Env.java @@ -0,0 +1,41 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class Env extends BaseEnv { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Env(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public Env(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public Env position(long position) { + return (Env)super.position(position); + } + + public Env(@Cast("OrtLoggingLevel") int default_logging_level/*=ORT_LOGGING_LEVEL_WARNING*/, @Cast("const char*") BytePointer logid/*=""*/) { super((Pointer)null); allocate(default_logging_level, logid); } + private native void allocate(@Cast("OrtLoggingLevel") int default_logging_level/*=ORT_LOGGING_LEVEL_WARNING*/, @Cast("const char*") BytePointer logid/*=""*/); + public Env() { super((Pointer)null); allocate(); } + private native void allocate(); + public Env(@Cast("OrtLoggingLevel") int default_logging_level/*=ORT_LOGGING_LEVEL_WARNING*/, String logid/*=""*/) { super((Pointer)null); allocate(default_logging_level, logid); } + private native void allocate(@Cast("OrtLoggingLevel") int default_logging_level/*=ORT_LOGGING_LEVEL_WARNING*/, String logid/*=""*/); + public Env(@Cast("OrtLoggingLevel") int default_logging_level, @Cast("const char*") BytePointer logid, OrtLoggingFunction logging_function, Pointer logger_param) { super((Pointer)null); allocate(default_logging_level, logid, logging_function, logger_param); } + private native void allocate(@Cast("OrtLoggingLevel") int default_logging_level, @Cast("const char*") BytePointer logid, OrtLoggingFunction logging_function, Pointer logger_param); + public Env(@Cast("OrtLoggingLevel") int default_logging_level, String logid, OrtLoggingFunction logging_function, Pointer logger_param) { super((Pointer)null); allocate(default_logging_level, logid, logging_function, logger_param); } + private native void allocate(@Cast("OrtLoggingLevel") int default_logging_level, String logid, OrtLoggingFunction logging_function, Pointer logger_param); + public Env(OrtEnv p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtEnv p); + + public native @ByRef Env EnableTelemetryEvents(); + public native @ByRef Env DisableTelemetryEvents(); + + +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/MemoryInfo.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/MemoryInfo.java new file mode 100644 index 00000000000..ddf46426fa1 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/MemoryInfo.java @@ -0,0 +1,26 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class MemoryInfo extends BaseMemoryInfo { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public MemoryInfo(Pointer p) { super(p); } + + public static native @ByVal MemoryInfo CreateCpu(@Cast("OrtAllocatorType") int type, @Cast("OrtMemType") int mem_type1); + public MemoryInfo(@Cast("const char*") BytePointer name, @Cast("OrtAllocatorType") int type, int id, @Cast("OrtMemType") int mem_type) { super((Pointer)null); allocate(name, type, id, mem_type); } + private native void allocate(@Cast("const char*") BytePointer name, @Cast("OrtAllocatorType") int type, int id, @Cast("OrtMemType") int mem_type); + public MemoryInfo(String name, @Cast("OrtAllocatorType") int type, int id, @Cast("OrtMemType") int mem_type) { super((Pointer)null); allocate(name, type, id, mem_type); } + private native void allocate(String name, @Cast("OrtAllocatorType") int type, int id, @Cast("OrtMemType") int mem_type); + + public MemoryInfo(OrtMemoryInfo p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtMemoryInfo p); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/OrtException.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/OrtException.java new file mode 100644 index 00000000000..7c9e81c47f1 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/OrtException.java @@ -0,0 +1,26 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +// All C++ methods that can fail will throw an exception of this type +@Name("Ort::Exception") @NoOffset @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class OrtException extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public OrtException(Pointer p) { super(p); } + + public OrtException(@Cast({"char*", "std::string&&"}) @StdString BytePointer string, @Cast("OrtErrorCode") int code) { super((Pointer)null); allocate(string, code); } + private native void allocate(@Cast({"char*", "std::string&&"}) @StdString BytePointer string, @Cast("OrtErrorCode") int code); + public OrtException(@Cast({"char*", "std::string&&"}) @StdString String string, @Cast("OrtErrorCode") int code) { super((Pointer)null); allocate(string, code); } + private native void allocate(@Cast({"char*", "std::string&&"}) @StdString String string, @Cast("OrtErrorCode") int code); + + public native @Cast("OrtErrorCode") int GetOrtErrorCode(); + public native @NoException @Cast("const char*") BytePointer what(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/RunOptions.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/RunOptions.java new file mode 100644 index 00000000000..01a4af92a31 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/RunOptions.java @@ -0,0 +1,41 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class RunOptions extends BaseRunOptions { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public RunOptions(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public RunOptions(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public RunOptions position(long position) { + return (RunOptions)super.position(position); + } + + public RunOptions() { super((Pointer)null); allocate(); } + private native void allocate(); + + public native @ByRef RunOptions SetRunLogVerbosityLevel(int arg0); + public native int GetRunLogVerbosityLevel(); + + public native @ByRef RunOptions SetRunLogSeverityLevel(int arg0); + public native int GetRunLogSeverityLevel(); + + public native @ByRef RunOptions SetRunTag(@Cast("const char*") BytePointer run_tag); + public native @ByRef RunOptions SetRunTag(String run_tag); + public native @Cast("const char*") BytePointer GetRunTag(); + + // terminate ALL currently executing Session::Run calls that were made using this RunOptions instance + public native @ByRef RunOptions SetTerminate(); + // unset the terminate flag so this RunOptions instance can be used in a new Session::Run call + public native @ByRef RunOptions UnsetTerminate(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/Session.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/Session.java new file mode 100644 index 00000000000..be643e77c9a --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/Session.java @@ -0,0 +1,55 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class Session extends BaseSession { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Session(Pointer p) { super(p); } + + public Session(@ByRef Env env, @Cast("const char*") BytePointer model_path, @Const @ByRef SessionOptions options) { super((Pointer)null); allocate(env, model_path, options); } + private native void allocate(@ByRef Env env, @Cast("const char*") BytePointer model_path, @Const @ByRef SessionOptions options); + public Session(@ByRef Env env, String model_path, @Const @ByRef SessionOptions options) { super((Pointer)null); allocate(env, model_path, options); } + private native void allocate(@ByRef Env env, String model_path, @Const @ByRef SessionOptions options); + public Session(@ByRef Env env, @Const Pointer model_data, @Cast("size_t") long model_data_length, @Const @ByRef SessionOptions options) { super((Pointer)null); allocate(env, model_data, model_data_length, options); } + private native void allocate(@ByRef Env env, @Const Pointer model_data, @Cast("size_t") long model_data_length, @Const @ByRef SessionOptions options); + + // Run that will allocate the output values + public native @ByVal ValueVector Run(@Const @ByRef RunOptions run_options, @Cast("const char*const*") PointerPointer input_names, @Const Value input_values, @Cast("size_t") long input_count, + @Cast("const char*const*") PointerPointer output_names, @Cast("size_t") long output_count); + public native @ByVal ValueVector Run(@Const @ByRef RunOptions run_options, @Cast("const char*const*") @ByPtrPtr BytePointer input_names, @Const Value input_values, @Cast("size_t") long input_count, + @Cast("const char*const*") @ByPtrPtr BytePointer output_names, @Cast("size_t") long output_count); + public native @ByVal ValueVector Run(@Const @ByRef RunOptions run_options, @Cast("const char*const*") @ByPtrPtr ByteBuffer input_names, @Const Value input_values, @Cast("size_t") long input_count, + @Cast("const char*const*") @ByPtrPtr ByteBuffer output_names, @Cast("size_t") long output_count); + public native @ByVal ValueVector Run(@Const @ByRef RunOptions run_options, @Cast("const char*const*") @ByPtrPtr byte[] input_names, @Const Value input_values, @Cast("size_t") long input_count, + @Cast("const char*const*") @ByPtrPtr byte[] output_names, @Cast("size_t") long output_count); + // Run for when there is a list of prealloated outputs + public native void Run(@Const @ByRef RunOptions run_options, @Cast("const char*const*") PointerPointer input_names, @Const Value input_values, @Cast("size_t") long input_count, + @Cast("const char*const*") PointerPointer output_names, Value output_values, @Cast("size_t") long output_count); + public native void Run(@Const @ByRef RunOptions run_options, @Cast("const char*const*") @ByPtrPtr BytePointer input_names, @Const Value input_values, @Cast("size_t") long input_count, + @Cast("const char*const*") @ByPtrPtr BytePointer output_names, Value output_values, @Cast("size_t") long output_count); + public native void Run(@Const @ByRef RunOptions run_options, @Cast("const char*const*") @ByPtrPtr ByteBuffer input_names, @Const Value input_values, @Cast("size_t") long input_count, + @Cast("const char*const*") @ByPtrPtr ByteBuffer output_names, Value output_values, @Cast("size_t") long output_count); + public native void Run(@Const @ByRef RunOptions run_options, @Cast("const char*const*") @ByPtrPtr byte[] input_names, @Const Value input_values, @Cast("size_t") long input_count, + @Cast("const char*const*") @ByPtrPtr byte[] output_names, Value output_values, @Cast("size_t") long output_count); + + public native @Cast("size_t") long GetInputCount(); + public native @Cast("size_t") long GetOutputCount(); + public native @Cast("size_t") long GetOverridableInitializerCount(); + + public native @Cast("char*") BytePointer GetInputName(@Cast("size_t") long index, OrtAllocator allocator); + public native @Cast("char*") BytePointer GetOutputName(@Cast("size_t") long index, OrtAllocator allocator); + public native @Cast("char*") BytePointer GetOverridableInitializerName(@Cast("size_t") long index, OrtAllocator allocator); + + public native @ByVal TypeInfo GetInputTypeInfo(@Cast("size_t") long index); + public native @ByVal TypeInfo GetOutputTypeInfo(@Cast("size_t") long index); + public native @ByVal TypeInfo GetOverridableInitializerTypeInfo(@Cast("size_t") long index); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/SessionOptions.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/SessionOptions.java new file mode 100644 index 00000000000..d274bac397e --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/SessionOptions.java @@ -0,0 +1,54 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class SessionOptions extends BaseSessionOptions { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public SessionOptions(Pointer p) { super(p); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public SessionOptions(long size) { super((Pointer)null); allocateArray(size); } + private native void allocateArray(long size); + @Override public SessionOptions position(long position) { + return (SessionOptions)super.position(position); + } + + public SessionOptions() { super((Pointer)null); allocate(); } + private native void allocate(); + public SessionOptions(OrtSessionOptions p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtSessionOptions p); + + public native @ByVal SessionOptions Clone(); + + public native @ByRef SessionOptions SetIntraOpNumThreads(int intra_op_num_threads); + public native @ByRef SessionOptions SetInterOpNumThreads(int inter_op_num_threads); + public native @ByRef SessionOptions SetGraphOptimizationLevel(@Cast("GraphOptimizationLevel") int graph_optimization_level); + + public native @ByRef SessionOptions EnableCpuMemArena(); + public native @ByRef SessionOptions DisableCpuMemArena(); + + public native @ByRef SessionOptions SetOptimizedModelFilePath(@Cast("const char*") BytePointer optimized_model_file); + public native @ByRef SessionOptions SetOptimizedModelFilePath(String optimized_model_file); + + public native @ByRef SessionOptions EnableProfiling(@Cast("const char*") BytePointer profile_file_prefix); + public native @ByRef SessionOptions EnableProfiling(String profile_file_prefix); + public native @ByRef SessionOptions DisableProfiling(); + + public native @ByRef SessionOptions EnableMemPattern(); + public native @ByRef SessionOptions DisableMemPattern(); + + public native @ByRef SessionOptions SetExecutionMode(@Cast("ExecutionMode") int execution_mode); + + public native @ByRef SessionOptions SetLogId(@Cast("const char*") BytePointer logid); + public native @ByRef SessionOptions SetLogId(String logid); + + public native @ByRef SessionOptions Add(OrtCustomOpDomain custom_op_domain); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/TensorTypeAndShapeInfo.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/TensorTypeAndShapeInfo.java new file mode 100644 index 00000000000..6f0c4dc9c69 --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/TensorTypeAndShapeInfo.java @@ -0,0 +1,34 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class TensorTypeAndShapeInfo extends BaseTensorTypeAndShapeInfo { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TensorTypeAndShapeInfo(Pointer p) { super(p); } + + public TensorTypeAndShapeInfo(OrtTensorTypeAndShapeInfo p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtTensorTypeAndShapeInfo p); + + public native @Cast("ONNXTensorElementDataType") int GetElementType(); + public native @Cast("size_t") long GetElementCount(); + + public native @Cast("size_t") long GetDimensionsCount(); + public native void GetDimensions(@Cast("int64_t*") LongPointer values, @Cast("size_t") long values_count); + public native void GetDimensions(@Cast("int64_t*") LongBuffer values, @Cast("size_t") long values_count); + public native void GetDimensions(@Cast("int64_t*") long[] values, @Cast("size_t") long values_count); + public native void GetSymbolicDimensions(@Cast("const char**") PointerPointer values, @Cast("size_t") long values_count); + public native void GetSymbolicDimensions(@Cast("const char**") @ByPtrPtr BytePointer values, @Cast("size_t") long values_count); + public native void GetSymbolicDimensions(@Cast("const char**") @ByPtrPtr ByteBuffer values, @Cast("size_t") long values_count); + public native void GetSymbolicDimensions(@Cast("const char**") @ByPtrPtr byte[] values, @Cast("size_t") long values_count); + + public native @Cast("int64_t*") @StdVector LongPointer GetShape(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/TypeInfo.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/TypeInfo.java new file mode 100644 index 00000000000..c8118c59a2f --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/TypeInfo.java @@ -0,0 +1,23 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class TypeInfo extends BaseTypeInfo { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TypeInfo(Pointer p) { super(p); } + + public TypeInfo(OrtTypeInfo p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtTypeInfo p); + + public native @ByVal TensorTypeAndShapeInfo GetTensorTypeAndShapeInfo(); + public native @Cast("ONNXType") int GetONNXType(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/Value.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/Value.java new file mode 100644 index 00000000000..e2ebdeeb80a --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/Value.java @@ -0,0 +1,135 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + + +@Namespace("Ort") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class Value extends BaseValue { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Value(Pointer p) { super(p); } + + public static native @ByVal @Name("CreateTensor") Value CreateTensorFloat(@Const OrtMemoryInfo info, FloatPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorFloat(@Const OrtMemoryInfo info, FloatBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorFloat(@Const OrtMemoryInfo info, float[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorDouble(@Const OrtMemoryInfo info, DoublePointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorDouble(@Const OrtMemoryInfo info, DoubleBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorDouble(@Const OrtMemoryInfo info, double[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorByte(@Const OrtMemoryInfo info, BytePointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorByte(@Const OrtMemoryInfo info, ByteBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorByte(@Const OrtMemoryInfo info, byte[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorShort(@Const OrtMemoryInfo info, ShortPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorShort(@Const OrtMemoryInfo info, ShortBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorShort(@Const OrtMemoryInfo info, short[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorInt(@Const OrtMemoryInfo info, IntPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorInt(@Const OrtMemoryInfo info, IntBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorInt(@Const OrtMemoryInfo info, int[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorLong(@Const OrtMemoryInfo info, @Cast("int64_t*") LongPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorLong(@Const OrtMemoryInfo info, @Cast("int64_t*") LongBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorLong(@Const OrtMemoryInfo info, @Cast("int64_t*") long[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUByte(@Const OrtMemoryInfo info, @Cast("uint8_t*") BytePointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUByte(@Const OrtMemoryInfo info, @Cast("uint8_t*") ByteBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUByte(@Const OrtMemoryInfo info, @Cast("uint8_t*") byte[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUShort(@Const OrtMemoryInfo info, @Cast("uint16_t*") ShortPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUShort(@Const OrtMemoryInfo info, @Cast("uint16_t*") ShortBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUShort(@Const OrtMemoryInfo info, @Cast("uint16_t*") short[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUInt(@Const OrtMemoryInfo info, @Cast("uint32_t*") IntPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUInt(@Const OrtMemoryInfo info, @Cast("uint32_t*") IntBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUInt(@Const OrtMemoryInfo info, @Cast("uint32_t*") int[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorULong(@Const OrtMemoryInfo info, @Cast("uint64_t*") LongPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorULong(@Const OrtMemoryInfo info, @Cast("uint64_t*") LongBuffer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorULong(@Const OrtMemoryInfo info, @Cast("uint64_t*") long[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorBool(@Const OrtMemoryInfo info, @Cast("bool*") BoolPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorBool(@Const OrtMemoryInfo info, @Cast("bool*") boolean[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorBool(@Const OrtMemoryInfo info, @Cast("bool*") BoolPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorBool(@Const OrtMemoryInfo info, @Cast("bool*") boolean[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorBool(@Const OrtMemoryInfo info, @Cast("bool*") BoolPointer p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorBool(@Const OrtMemoryInfo info, @Cast("bool*") boolean[] p_data, @Cast("size_t") long p_data_element_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal Value CreateTensor(@Const OrtMemoryInfo info, Pointer p_data, @Cast("size_t") long p_data_byte_count, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len, + @Cast("ONNXTensorElementDataType") int type); + public static native @ByVal Value CreateTensor(@Const OrtMemoryInfo info, Pointer p_data, @Cast("size_t") long p_data_byte_count, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len, + @Cast("ONNXTensorElementDataType") int type); + public static native @ByVal Value CreateTensor(@Const OrtMemoryInfo info, Pointer p_data, @Cast("size_t") long p_data_byte_count, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len, + @Cast("ONNXTensorElementDataType") int type); + public static native @ByVal @Name("CreateTensor") Value CreateTensorFloat(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorFloat(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorFloat(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorDouble(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorDouble(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorDouble(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorByte(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorByte(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorByte(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorShort(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorShort(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorShort(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorInt(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorInt(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorInt(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorLong(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorLong(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorLong(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUByte(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUByte(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUByte(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUShort(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUShort(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUShort(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUInt(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUInt(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorUInt(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorULong(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorULong(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorULong(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorBool(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorBool(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len); + public static native @ByVal @Name("CreateTensor") Value CreateTensorBool(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len); + public static native @ByVal Value CreateTensor(OrtAllocator allocator, @Cast("const int64_t*") LongPointer shape, @Cast("size_t") long shape_len, @Cast("ONNXTensorElementDataType") int type); + public static native @ByVal Value CreateTensor(OrtAllocator allocator, @Cast("const int64_t*") LongBuffer shape, @Cast("size_t") long shape_len, @Cast("ONNXTensorElementDataType") int type); + public static native @ByVal Value CreateTensor(OrtAllocator allocator, @Cast("const int64_t*") long[] shape, @Cast("size_t") long shape_len, @Cast("ONNXTensorElementDataType") int type); + + public static native @ByVal Value CreateMap(@ByRef Value keys, @ByRef Value values); + public static native @ByVal Value CreateSequence(@ByRef ValueVector values); + public Value(OrtValue p) { super((Pointer)null); allocate(p); } + private native void allocate(OrtValue p); + + + + public native @Cast("bool") boolean IsTensor(); + public native @Cast("size_t") long GetCount(); // If a non tensor, returns 2 for map and N for sequence, where N is the number of elements + public native @ByVal Value GetValue(int index, OrtAllocator allocator); + + public native @Cast("size_t") long GetStringTensorDataLength(); + public native void GetStringTensorContent(Pointer buffer, @Cast("size_t") long buffer_length, @Cast("size_t*") SizeTPointer offsets, @Cast("size_t") long offsets_count); + + public native @Name("GetTensorMutableData") FloatPointer GetTensorMutableDataFloat(); + + public native @Name("GetTensorMutableData") DoublePointer GetTensorMutableDataDouble(); + + public native @Name("GetTensorMutableData") BytePointer GetTensorMutableDataByte(); + + public native @Name("GetTensorMutableData") ShortPointer GetTensorMutableDataShort(); + + public native @Name("GetTensorMutableData") IntPointer GetTensorMutableDataInt(); + + public native @Cast("int64_t*") @Name("GetTensorMutableData") LongPointer GetTensorMutableDataLong(); + + public native @Cast("uint8_t*") @Name("GetTensorMutableData") BytePointer GetTensorMutableDataUByte(); + + public native @Cast("uint16_t*") @Name("GetTensorMutableData") ShortPointer GetTensorMutableDataUShort(); + + public native @Cast("uint32_t*") @Name("GetTensorMutableData") IntPointer GetTensorMutableDataUInt(); + + public native @Cast("uint64_t*") @Name("GetTensorMutableData") LongPointer GetTensorMutableDataULong(); + + public native @Cast("bool*") @Name("GetTensorMutableData") BoolPointer GetTensorMutableDataBool(); + + public native @ByVal TypeInfo GetTypeInfo(); + public native @ByVal TensorTypeAndShapeInfo GetTensorTypeAndShapeInfo(); +} diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/ValueVector.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/ValueVector.java new file mode 100644 index 00000000000..37f5194c9db --- /dev/null +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/ValueVector.java @@ -0,0 +1,36 @@ +// Targeted by JavaCPP version 1.5.3-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.bytedeco.onnxruntime; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.bytedeco.onnxruntime.global.onnxruntime.*; + +@Name("std::vector") @Properties(inherit = org.bytedeco.onnxruntime.presets.onnxruntime.class) +public class ValueVector extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public ValueVector(Pointer p) { super(p); } + public ValueVector() { allocate(); } + private native void allocate(); + + + public boolean empty() { return size() == 0; } + public native long size(); + + @Index(function = "at") public native @ByRef Value get(@Cast("size_t") long i); + + public native @ByVal Iterator begin(); + public native @ByVal Iterator end(); + @NoOffset @Name("iterator") public static class Iterator extends Pointer { + public Iterator(Pointer p) { super(p); } + public Iterator() { } + + public native @Name("operator++") @ByRef Iterator increment(); + public native @Name("operator==") boolean equals(@ByRef Iterator it); + public native @Name("operator*") @ByRef @Const Value get(); + } +} + diff --git a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/global/onnxruntime.java b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/global/onnxruntime.java index 8aa0633d428..ce107678469 100644 --- a/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/global/onnxruntime.java +++ b/onnxruntime/src/gen/java/org/bytedeco/onnxruntime/global/onnxruntime.java @@ -11,6 +11,9 @@ public class onnxruntime extends org.bytedeco.onnxruntime.presets.onnxruntime { static { Loader.load(); } +// Targeting ../ValueVector.java + + // Parsed from onnxruntime/core/session/onnxruntime_c_api.h // Copyright (c) Microsoft Corporation. All rights reserved. @@ -259,4 +262,147 @@ public class onnxruntime extends org.bytedeco.onnxruntime.presets.onnxruntime { // #endif +// Parsed from onnxruntime/core/session/onnxruntime_cxx_api.h + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// Summary: The Ort C++ API is a header only wrapper around the Ort C API. +// +// The C++ API simplifies usage by returning values directly instead of error codes, throwing exceptions on errors +// and automatically releasing resources in the destructors. +// +// Each of the C++ wrapper classes holds only a pointer to the C internal object. Treat them like smart pointers. +// To create an empty object, pass 'nullptr' to the constructor (for example, Env e{nullptr};). +// +// Only move assignment between objects is allowed, there are no copy constructors. Some objects have explicit 'Clone' +// methods for this purpose. + +// #pragma once +// #include "onnxruntime_c_api.h" +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// Targeting ../OrtException.java + + + +// This is used internally by the C++ API. This class holds the global variable that points to the OrtApi, it's in a template so that we can define a global variable in a header and make +// it transparent to the users of the API. + +// #ifdef EXCLUDE_REFERENCE_TO_ORT_DLL + + +// #else + +// #endif + + +// This returns a reference to the OrtApi interface in use, in case someone wants to use the C API functions +@Namespace("Ort") public static native @Const @ByRef OrtApi GetApi(); + +// This is used internally by the C++ API. This macro is to make it easy to generate overloaded methods for all of the various OrtRelease* functions for every Ort* type +// This can't be done in the C API since C doesn't have function overloading. +// #define ORT_DEFINE_RELEASE(NAME) +// inline void OrtRelease(Ort##NAME* ptr) { Global::api_.Release##NAME(ptr); } + +@Namespace("Ort") public static native void OrtRelease(OrtMemoryInfo ptr); +@Namespace("Ort") public static native void OrtRelease(OrtCustomOpDomain ptr); +@Namespace("Ort") public static native void OrtRelease(OrtEnv ptr); +@Namespace("Ort") public static native void OrtRelease(OrtRunOptions ptr); +@Namespace("Ort") public static native void OrtRelease(OrtSession ptr); +@Namespace("Ort") public static native void OrtRelease(OrtSessionOptions ptr); +@Namespace("Ort") public static native void OrtRelease(OrtTensorTypeAndShapeInfo ptr); +@Namespace("Ort") public static native void OrtRelease(OrtTypeInfo ptr); +@Namespace("Ort") public static native void OrtRelease(OrtValue ptr); +// Targeting ../BaseMemoryInfo.java + + +// Targeting ../BaseCustomOpDomain.java + + +// Targeting ../BaseEnv.java + + +// Targeting ../BaseRunOptions.java + + +// Targeting ../BaseSession.java + + +// Targeting ../BaseSessionOptions.java + + +// Targeting ../BaseTensorTypeAndShapeInfo.java + + +// Targeting ../BaseTypeInfo.java + + +// Targeting ../BaseValue.java + + +// Targeting ../Env.java + + +// Targeting ../CustomOpDomain.java + + +// Targeting ../RunOptions.java + + +// Targeting ../SessionOptions.java + + +// Targeting ../Session.java + + +// Targeting ../TensorTypeAndShapeInfo.java + + +// Targeting ../TypeInfo.java + + +// Targeting ../Value.java + + +// Targeting ../AllocatorWithDefaultOptions.java + + +// Targeting ../MemoryInfo.java + + +// Targeting ../CustomOpApi.java + + + + // namespace Ort + +// #include "onnxruntime_cxx_inline.h" + + +// Parsed from onnxruntime/core/providers/dnnl/dnnl_provider_factory.h + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// #include "onnxruntime_c_api.h" + +// #ifdef __cplusplus +// #endif + +/** + * @param use_arena zero: false. non-zero: true. + */ +public static native OrtStatus OrtSessionOptionsAppendExecutionProvider_Dnnl( OrtSessionOptions options, int use_arena); + +// #ifdef __cplusplus +// #endif + + } diff --git a/onnxruntime/src/main/java/org/bytedeco/onnxruntime/presets/onnxruntime.java b/onnxruntime/src/main/java/org/bytedeco/onnxruntime/presets/onnxruntime.java index 17e6abce18e..d85c0f90821 100644 --- a/onnxruntime/src/main/java/org/bytedeco/onnxruntime/presets/onnxruntime.java +++ b/onnxruntime/src/main/java/org/bytedeco/onnxruntime/presets/onnxruntime.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Samuel Audet + * Copyright (C) 2019-2020 Samuel Audet, Alexander Merritt * * Licensed either under the Apache License, Version 2.0, or (at your option) * under the terms of the GNU General Public License as published by @@ -42,11 +42,12 @@ compiler = "cpp11", include = { "onnxruntime/core/session/onnxruntime_c_api.h", -// "onnxruntime/core/session/onnxruntime_cxx_api.h" + "onnxruntime/core/session/onnxruntime_cxx_api.h", + "onnxruntime/core/providers/dnnl/dnnl_provider_factory.h" }, - link = "onnxruntime@.1.1.0", - preload = {"iomp5", "mklml", "mklml_intel", "dnnl@.1"}, - preloadresource = "/org/bytedeco/mkldnn/" + link = "onnxruntime@.1.1.1", + preload = {"gomp@.1##", "iomp5##", "dnnl@.1##"}, + preloadresource = "/org/bytedeco/dnnl/" ), }, target = "org.bytedeco.onnxruntime", @@ -56,6 +57,43 @@ public class onnxruntime implements InfoMapper { static { Loader.checkVersion("org.bytedeco", "onnxruntime"); } public void map(InfoMap infoMap) { - infoMap.put(new Info("ORTCHAR_T", "ORT_EXPORT", "ORT_API_CALL", "NO_EXCEPTION", "ORT_ALL_ARGS_NONNULL", "OrtCustomOpApi").cppTypes().annotations()); + infoMap.put(new Info("ORTCHAR_T", "ORT_EXPORT", "ORT_API_CALL", "NO_EXCEPTION", "ORT_ALL_ARGS_NONNULL", "OrtCustomOpApi").cppTypes().annotations()) + .put(new Info("Ort::stub_api", "Ort::Global::api_", "std::nullptr_t", "Ort::Env::s_api").skip()) + .put(new Info("std::string").annotations("@Cast({\"char*\", \"std::string&&\"}) @StdString").valueTypes("BytePointer", "String").pointerTypes("BytePointer")) + .put(new Info("const std::vector", "std::vector").pointerTypes("ValueVector").define()) + .put(new Info("Ort::Exception").pointerTypes("OrtException")) + .put(new Info("Ort::Value(Ort::Value)", "Ort::Value::operator =(Ort::Value)").skip()) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorFloat")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorDouble")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorByte")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorShort")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorInt")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorLong")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorUByte")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorUShort")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorUInt")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorULong")) + .put(new Info("Ort::Value::CreateTensor").javaNames("CreateTensorBool")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataFloat")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataDouble")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataByte")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataShort")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataInt")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataLong")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataUByte")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataUShort")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataUInt")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataULong")) + .put(new Info("Ort::Value::GetTensorMutableData").javaNames("GetTensorMutableDataBool")) + .put(new Info("Ort::TensorTypeAndShapeInfo", "Ort::Unowned").pointerTypes("TensorTypeAndShapeInfo")) + .put(new Info("Ort::Base").pointerTypes("BaseMemoryInfo")) + .put(new Info("Ort::Base").pointerTypes("BaseCustomOpDomain")) + .put(new Info("Ort::Base").pointerTypes("BaseEnv")) + .put(new Info("Ort::Base").pointerTypes("BaseRunOptions")) + .put(new Info("Ort::Base").pointerTypes("BaseSession")) + .put(new Info("Ort::Base").pointerTypes("BaseSessionOptions")) + .put(new Info("Ort::Base").pointerTypes("BaseTensorTypeAndShapeInfo")) + .put(new Info("Ort::Base").pointerTypes("BaseTypeInfo")) + .put(new Info("Ort::Base").pointerTypes("BaseValue")); } }