From d26fee923ed57cc482dfa3b365e0e4218e1ce10e Mon Sep 17 00:00:00 2001 From: Samuel Audet Date: Thu, 5 Sep 2019 16:05:22 +0900 Subject: [PATCH] Add core-api modules using JavaCPP --- core/core-api-platform/pom.xml | 82 + core/core-api/build.sh | 121 + core/core-api/pom.xml | 296 ++ ...mpute_func_Pointer_TF_OpKernelContext.java | 19 + .../Create_func_TF_OpKernelConstruction.java | 48 + .../Deallocator_Pointer_long_Pointer.java | 30 + .../tensorflow/c_api/Delete_func_Pointer.java | 19 + .../c_api/Listener_BytePointer.java | 25 + .../org/tensorflow/c_api/Listener_String.java | 19 + ...nc_TF_ShapeInferenceContext_TF_Status.java | 22 + .../org/tensorflow/c_api/TFE_Context.java | 25 + .../tensorflow/c_api/TFE_ContextOptions.java | 19 + .../gen/java/org/tensorflow/c_api/TFE_Op.java | 29 + .../tensorflow/c_api/TFE_TensorDebugInfo.java | 22 + .../tensorflow/c_api/TFE_TensorHandle.java | 23 + .../org/tensorflow/c_api/TF_ApiDefMap.java | 26 + .../org/tensorflow/c_api/TF_AttrMetadata.java | 55 + .../java/org/tensorflow/c_api/TF_Buffer.java | 46 + .../c_api/TF_DeprecatedSession.java | 23 + .../org/tensorflow/c_api/TF_DeviceList.java | 18 + .../tensorflow/c_api/TF_DimensionHandle.java | 19 + .../tensorflow/c_api/TF_FileStatistics.java | 33 + .../org/tensorflow/c_api/TF_Function.java | 21 + .../tensorflow/c_api/TF_FunctionOptions.java | 19 + .../java/org/tensorflow/c_api/TF_Graph.java | 26 + .../c_api/TF_ImportGraphDefOptions.java | 20 + .../c_api/TF_ImportGraphDefResults.java | 20 + .../java/org/tensorflow/c_api/TF_Input.java | 30 + .../tensorflow/c_api/TF_KernelBuilder.java | 31 + .../java/org/tensorflow/c_api/TF_Library.java | 22 + .../c_api/TF_OpDefinitionBuilder.java | 17 + .../c_api/TF_OpKernelConstruction.java | 17 + .../tensorflow/c_api/TF_OpKernelContext.java | 17 + .../org/tensorflow/c_api/TF_Operation.java | 21 + .../c_api/TF_OperationDescription.java | 19 + .../java/org/tensorflow/c_api/TF_Output.java | 30 + .../java/org/tensorflow/c_api/TF_Server.java | 27 + .../java/org/tensorflow/c_api/TF_Session.java | 24 + .../tensorflow/c_api/TF_SessionOptions.java | 20 + .../org/tensorflow/c_api/TF_ShapeHandle.java | 17 + .../c_api/TF_ShapeInferenceContext.java | 17 + .../java/org/tensorflow/c_api/TF_Status.java | 19 + .../org/tensorflow/c_api/TF_StringStream.java | 17 + .../java/org/tensorflow/c_api/TF_Tensor.java | 36 + .../java/org/tensorflow/c_api/TF_Thread.java | 17 + .../tensorflow/c_api/TF_ThreadOptions.java | 38 + .../org/tensorflow/c_api/TF_WhileParams.java | 37 + .../c_api/TF_WritableFileHandle.java | 19 + .../gen/java/org/tensorflow/c_api/Tensor.java | 25 + .../tensorflow/c_api/Work_func_Pointer.java | 28 + .../tensorflow/c_api/global/tensorflow.java | 4200 +++++++++++++++++ .../tensorflow/c_api/AbstractTF_Buffer.java | 74 + .../tensorflow/c_api/AbstractTF_Graph.java | 57 + .../AbstractTF_ImportGraphDefOptions.java | 57 + .../tensorflow/c_api/AbstractTF_Session.java | 65 + .../c_api/AbstractTF_SessionOptions.java | 57 + .../tensorflow/c_api/AbstractTF_Status.java | 57 + .../tensorflow/c_api/AbstractTF_Tensor.java | 85 + .../tensorflow/c_api/presets/tensorflow.java | 122 + core/pom.xml | 682 ++- 60 files changed, 7120 insertions(+), 6 deletions(-) create mode 100644 core/core-api-platform/pom.xml create mode 100755 core/core-api/build.sh create mode 100644 core/core-api/pom.xml create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/Compute_func_Pointer_TF_OpKernelContext.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/Create_func_TF_OpKernelConstruction.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/Deallocator_Pointer_long_Pointer.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/Delete_func_Pointer.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/Listener_BytePointer.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/Listener_String.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/Shape_inference_func_TF_ShapeInferenceContext_TF_Status.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TFE_Context.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TFE_ContextOptions.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TFE_Op.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TFE_TensorDebugInfo.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TFE_TensorHandle.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_ApiDefMap.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_AttrMetadata.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Buffer.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_DeprecatedSession.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_DeviceList.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_DimensionHandle.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_FileStatistics.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Function.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_FunctionOptions.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Graph.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_ImportGraphDefOptions.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_ImportGraphDefResults.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Input.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_KernelBuilder.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Library.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpDefinitionBuilder.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpKernelConstruction.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpKernelContext.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Operation.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_OperationDescription.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Output.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Server.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Session.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_SessionOptions.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_ShapeHandle.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_ShapeInferenceContext.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Status.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_StringStream.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Tensor.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_Thread.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_ThreadOptions.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_WhileParams.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/TF_WritableFileHandle.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/Tensor.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/Work_func_Pointer.java create mode 100644 core/core-api/src/gen/java/org/tensorflow/c_api/global/tensorflow.java create mode 100644 core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Buffer.java create mode 100644 core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Graph.java create mode 100644 core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_ImportGraphDefOptions.java create mode 100644 core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Session.java create mode 100644 core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_SessionOptions.java create mode 100644 core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Status.java create mode 100644 core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Tensor.java create mode 100644 core/core-api/src/main/java/org/tensorflow/c_api/presets/tensorflow.java diff --git a/core/core-api-platform/pom.xml b/core/core-api-platform/pom.xml new file mode 100644 index 00000000000..e9bd6a5b244 --- /dev/null +++ b/core/core-api-platform/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + + org.tensorflow + parent-core + 2.0.0-SNAPSHOT + + core-api-platform + Core API Library Platform + + + core-api + + + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.linux-x86_64} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.macosx-x86_64} + + + ${project.groupId} + ${javacpp.moduleId} + ${project.version} + ${javacpp.platform.windows-x86_64} + + + + + + + maven-jar-plugin + + + default-jar + + + + ${javacpp.moduleId}.jar ${javacpp.moduleId}-linux-x86_64.jar ${javacpp.moduleId}-macosx-x86_64.jar ${javacpp.moduleId}-windows-x86_64.jar + + + + + + empty-javadoc-jar + + jar + + + javadoc + + + + empty-sources-jar + + jar + + + sources + + + + + + + + diff --git a/core/core-api/build.sh b/core/core-api/build.sh new file mode 100755 index 00000000000..c44c8dabbaa --- /dev/null +++ b/core/core-api/build.sh @@ -0,0 +1,121 @@ +#!/bin/bash +# Script to build native TensorFlow libraries +set -eu + +KERNEL=(`uname -s | tr [A-Z] [a-z]`) +ARCH=(`uname -m | tr [A-Z] [a-z]`) +case $KERNEL in + darwin) + OS=macosx + ;; + mingw32*) + OS=windows + KERNEL=windows + ARCH=x86 + ;; + mingw64*) + OS=windows + KERNEL=windows + ARCH=x86_64 + ;; + *) + OS=$KERNEL + ;; +esac +case $ARCH in + arm*) + ARCH=arm + ;; + aarch64*) + ARCH=arm64 + ;; + i386|i486|i586|i686) + ARCH=x86 + ;; + amd64|x86-64) + ARCH=x86_64 + ;; +esac +PLATFORM=$OS-$ARCH +EXTENSION= +echo "Detected platform \"$PLATFORM\"" + +while [[ $# > 0 ]]; do + case "$1" in + -platform=*) + PLATFORM="${1#-platform=}" + ;; + -platform) + shift + PLATFORM="$1" + ;; + -extension=*) + EXTENSION="${1#-extension=}" + ;; + -extension) + shift + EXTENSION="$1" + ;; + clean) + echo "Cleaning build" + rm -Rf build + ;; + esac + shift +done + +echo -n "Building for platform \"$PLATFORM\"" +if [[ -n "$EXTENSION" ]]; then + echo -n " with extension \"$EXTENSION\"" +fi +echo + +export PYTHON_BIN_PATH=$(which python) +export USE_DEFAULT_PYTHON_LIB_PATH=1 +export TF_ENABLE_XLA=0 +export TF_NEED_OPENCL_SYCL=0 +export TF_NEED_ROCM=0 +export TF_NEED_CUDA=0 +export TF_DOWNLOAD_CLANG=0 +export TF_NEED_MPI=0 +export CC_OPT_FLAGS=-O3 +export TF_SET_ANDROID_WORKSPACE=0 + +TENSORFLOW_VERSION=2.0.0-rc0 + +mkdir -p "build/$PLATFORM$EXTENSION" +cd "build/$PLATFORM$EXTENSION" + +if [[ ! -e "tensorflow-$TENSORFLOW_VERSION.tar.gz" ]]; then + curl -L -o "tensorflow-$TENSORFLOW_VERSION.tar.gz" "https://github.com/tensorflow/tensorflow/archive/v$TENSORFLOW_VERSION.tar.gz" +fi +echo "48ddba718da76df56fd4c48b4bbf4f97f254ba269ec4be67f783684c75563ef8 tensorflow-$TENSORFLOW_VERSION.tar.gz" | sha256sum -c - + +echo "Decompressing archives" +tar --totals -xzf tensorflow-$TENSORFLOW_VERSION.tar.gz + +# Assume Bazel is available in the path: https://www.tensorflow.org/install/source +cd tensorflow-$TENSORFLOW_VERSION + +# Run the build for both the C and Java APIs +bash configure +bazel build --config opt //tensorflow:tensorflow //tensorflow/java:tensorflow + +# Normalize some paths with symbolic links +ln -sf tensorflow-$TENSORFLOW_VERSION ../tensorflow +ln -sf libtensorflow.so.${TENSORFLOW_VERSION%-*} bazel-bin/tensorflow/libtensorflow.so +ln -sf libtensorflow.so.${TENSORFLOW_VERSION%-*} bazel-bin/tensorflow/libtensorflow.so.2 + +# Gather Java source files from everywhere +mkdir -p ../java +cp -r tensorflow/java/src/gen/java/* ../java +cp -r tensorflow/java/src/main/java/* ../java +# cp -r tensorflow/contrib/android/java/* ../java +# cp -r tensorflow/lite/java/src/main/java/* ../java +cp -r bazel-genfiles/tensorflow/java/ops/src/main/java/* ../java +cp -r bazel-genfiles/tensorflow/java/_javac/tensorflow/libtensorflow_sourcegenfiles/* ../java + +# Work around loader bug in NativeLibrary.java +sed -i="" '/TensorFlow.version/d' ../java/org/tensorflow/NativeLibrary.java + +cd ../.. diff --git a/core/core-api/pom.xml b/core/core-api/pom.xml new file mode 100644 index 00000000000..cef084c70ef --- /dev/null +++ b/core/core-api/pom.xml @@ -0,0 +1,296 @@ + + + 4.0.0 + + + org.tensorflow + parent-core + 2.0.0-SNAPSHOT + + core-api + Core API Library + + + ${basedir}/build/${javacpp.platform}${javacpp.platform.extension}/tensorflow/ + + + + + org.bytedeco + javacpp + 1.5.2-SNAPSHOT + + + com.google.guava + guava + 28.0-jre + true + + + com.squareup + javapoet + 1.11.1 + true + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + add-source + generate-sources + + add-source + + + + ${project.basedir}/src/gen/java + ${project.basedir}/build/${javacpp.platform}${javacpp.platform.extension}/java/ + + + + + + + maven-resources-plugin + 3.1.0 + + + javacpp-parser + generate-sources + + resources + + + + + + maven-compiler-plugin + 3.8.0 + + 1.7 + 1.7 + + + + default-compile + + + javacpp-parser + generate-sources + + compile + + + + org/tensorflow/c_api/presets/*.java + + + + + + + org.bytedeco + javacpp + 1.5.2-SNAPSHOT + + ${javacpp.platform.properties} + + + platform.root + ${javacpp.platform.root} + + + platform.compiler + ${javacpp.platform.compiler} + + + platform.extension + ${javacpp.platform.extension} + + + ${project.build.outputDirectory} + + ${tensorflow.path}/ + + + ${tensorflow.path}/bazel-bin/tensorflow/ + + + ${tensorflow.path}/tensorflow/java/src/main/native/eager_operation_builder_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/eager_operation_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/eager_session_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/exception_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/graph_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/graph_operation_builder_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/graph_operation_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/saved_model_bundle_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/server_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/session_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/tensorflow_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/tensor_jni.cc + ${tensorflow.path}/tensorflow/java/src/main/native/utils_jni.cc + + + + + javacpp-validate + validate + + build + + + + ${project.basedir}/src/gen/java + ${project.basedir}/build/${javacpp.platform}${javacpp.platform.extension}/java/ + + + + + javacpp-build + initialize + + build + + + ${javacpp.build.skip} + + bash + ${project.basedir}/build.sh + -platform=${javacpp.platform} + -extension=${javacpp.platform.extension} + + ${project.basedir} + + + + javacpp-clean + clean + + build + + + ${javacpp.build.skip} + + rm + -Rf + build + + ${project.basedir} + + + + javacpp-parser + generate-sources + + parse + + + ${javacpp.parser.skip} + ${project.basedir}/src/gen/java + org.tensorflow.c_api.presets.* + + + + javacpp-compiler + process-classes + + build + + + ${project.build.directory}/native/org/tensorflow/${javacpp.platform}${javacpp.platform.extension}/ + ${javacpp.compiler.skip} + org.tensorflow.c_api.** + true + true + + + + + + maven-jar-plugin + 3.1.0 + + + default-jar + package + + jar + + + + org/tensorflow/** + + + + + javacpp-${javacpp.platform}${javacpp.platform.extension} + package + + jar + + + ${javacpp.platform}${javacpp.platform.extension} + true + + + org/tensorflow/${javacpp.platform}${javacpp.platform.extension}/ + + ${project.build.directory}/native + + org/tensorflow/c_api/windows-*/*.exp + org/tensorflow/c_api/windows-*/*.lib + org/tensorflow/c_api/windows-*/*.obj + + + + + + + maven-source-plugin + 3.0.1 + + + attach-sources + leave-disabled-to-not-generate-sources-twice-on-release + + + attach-source + + jar-no-fork + + + + + + maven-javadoc-plugin + 3.0.1 + + + attach-javadocs + + jar + + + false + 256m + 2048m + + http://bytedeco.org/javacpp/apidocs + + + + + + + + + diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/Compute_func_Pointer_TF_OpKernelContext.java b/core/core-api/src/gen/java/org/tensorflow/c_api/Compute_func_Pointer_TF_OpKernelContext.java new file mode 100644 index 00000000000..346430fa487 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/Compute_func_Pointer_TF_OpKernelContext.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class Compute_func_Pointer_TF_OpKernelContext extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Compute_func_Pointer_TF_OpKernelContext(Pointer p) { super(p); } + protected Compute_func_Pointer_TF_OpKernelContext() { allocate(); } + private native void allocate(); + public native void call(Pointer arg0, TF_OpKernelContext arg1); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/Create_func_TF_OpKernelConstruction.java b/core/core-api/src/gen/java/org/tensorflow/c_api/Create_func_TF_OpKernelConstruction.java new file mode 100644 index 00000000000..dc0371e0914 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/Create_func_TF_OpKernelConstruction.java @@ -0,0 +1,48 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Allocates a new kernel builder and returns a pointer to it. +// +// If non-null, TensorFlow will call create_func when it needs to instantiate +// the kernel. The pointer returned by create_func will be passed to +// compute_func and delete_func, thereby functioning as a "this" pointer for +// referring to kernel instances. +// +// The TF_OpKernelConstruction pointer passed to create_func is owned by +// TensorFlow and will be deleted once create_func returns. It must not be used +// after this. +// +// When TensorFlow needs to perform a computation with this kernel, it will +// call compute_func. This function will receive the pointer returned by +// create_func (or null if no create_func was provided), along with the inputs +// to the computation. +// +// The TF_OpKernelContext pointer received by compute_func is owned by +// TensorFlow and will be deleted once compute_func returns. It must not be used +// after this. +// +// Finally, when TensorFlow no longer needs the kernel, it will call +// delete_func if one is provided. This function will receive the pointer +// returned in `create_func` or nullptr if no `create_func` was provided. +// +// The caller should pass the result of this function to +// TF_RegisterKernelBuilder, which will take ownership of the pointer. If, for +// some reason, the kernel builder will not be registered, the caller should +// delete it with TF_DeleteKernelBuilder. +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class Create_func_TF_OpKernelConstruction extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Create_func_TF_OpKernelConstruction(Pointer p) { super(p); } + protected Create_func_TF_OpKernelConstruction() { allocate(); } + private native void allocate(); + public native Pointer call(TF_OpKernelConstruction arg0); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/Deallocator_Pointer_long_Pointer.java b/core/core-api/src/gen/java/org/tensorflow/c_api/Deallocator_Pointer_long_Pointer.java new file mode 100644 index 00000000000..8bc949874de --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/Deallocator_Pointer_long_Pointer.java @@ -0,0 +1,30 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Return a new tensor that holds the bytes data[0,len-1]. +// +// The data will be deallocated by a subsequent call to TF_DeleteTensor via: +// (*deallocator)(data, len, deallocator_arg) +// Clients must provide a custom deallocator function so they can pass in +// memory managed by something like numpy. +// +// May return NULL (and invoke the deallocator) if the provided data buffer +// (data, len) is inconsistent with a tensor of the given TF_DataType +// and the shape specified by (dima, num_dims). +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class Deallocator_Pointer_long_Pointer extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Deallocator_Pointer_long_Pointer(Pointer p) { super(p); } + protected Deallocator_Pointer_long_Pointer() { allocate(); } + private native void allocate(); + public native void call(Pointer data, @Cast("size_t") long len, Pointer arg); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/Delete_func_Pointer.java b/core/core-api/src/gen/java/org/tensorflow/c_api/Delete_func_Pointer.java new file mode 100644 index 00000000000..bd93cbfca7a --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/Delete_func_Pointer.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class Delete_func_Pointer extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Delete_func_Pointer(Pointer p) { super(p); } + protected Delete_func_Pointer() { allocate(); } + private native void allocate(); + public native void call(Pointer arg0); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/Listener_BytePointer.java b/core/core-api/src/gen/java/org/tensorflow/c_api/Listener_BytePointer.java new file mode 100644 index 00000000000..95ca9a8fa0c --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/Listener_BytePointer.java @@ -0,0 +1,25 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Register a listener method that processes printed messages. +// +// If any listeners are registered, the print operator will call all listeners +// with the printed messages and immediately return without writing to the +// logs. +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class Listener_BytePointer extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Listener_BytePointer(Pointer p) { super(p); } + protected Listener_BytePointer() { allocate(); } + private native void allocate(); + public native void call(@Cast("const char*") BytePointer arg0); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/Listener_String.java b/core/core-api/src/gen/java/org/tensorflow/c_api/Listener_String.java new file mode 100644 index 00000000000..4362be177a0 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/Listener_String.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class Listener_String extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Listener_String(Pointer p) { super(p); } + protected Listener_String() { allocate(); } + private native void allocate(); + public native void call(String arg0); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/Shape_inference_func_TF_ShapeInferenceContext_TF_Status.java b/core/core-api/src/gen/java/org/tensorflow/c_api/Shape_inference_func_TF_ShapeInferenceContext_TF_Status.java new file mode 100644 index 00000000000..bc957436bb2 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/Shape_inference_func_TF_ShapeInferenceContext_TF_Status.java @@ -0,0 +1,22 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Sets the shape inference function for the op. +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class Shape_inference_func_TF_ShapeInferenceContext_TF_Status extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Shape_inference_func_TF_ShapeInferenceContext_TF_Status(Pointer p) { super(p); } + protected Shape_inference_func_TF_ShapeInferenceContext_TF_Status() { allocate(); } + private native void allocate(); + public native void call(TF_ShapeInferenceContext ctx, + TF_Status status); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_Context.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_Context.java new file mode 100644 index 00000000000..26ac7d26964 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_Context.java @@ -0,0 +1,25 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// "Context" under which operations/functions are executed. It encapsulates +// things like the available devices, resource manager etc. +// TFE_Context must outlive all tensor handles created using it. In other +// words, TFE_DeleteContext() must be called after all tensor handles have +// been deleted (with TFE_DeleteTensorHandle). +// +// TODO(ashankar): Merge with TF_Session? +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TFE_Context extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TFE_Context() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TFE_Context(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_ContextOptions.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_ContextOptions.java new file mode 100644 index 00000000000..8c928040dfa --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_ContextOptions.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +// #endif + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TFE_ContextOptions extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TFE_ContextOptions() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TFE_ContextOptions(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_Op.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_Op.java new file mode 100644 index 00000000000..89ffde06592 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_Op.java @@ -0,0 +1,29 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Description of the TensorFlow op to execute. +// +// Assumes that the provided 'ctx' outlives the returned TFE_Op, i.e., +// TFE_DeleteOp() is called before TFE_DeleteContext(). +// +// Very similar to TF_OperationDescription with some differences: +// (1) TF_Output or TFE_TensorHandle* as arguments to TF_AddInput, +// TF_AddInputList +// (2) TF_ColocateWith, TF_AddControlInput etc. do not make sense. +// (3) Implementation detail: Avoid use of NodeBuilder/NodeDefBuilder since +// the additional sanity checks there seem unnecessary; +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TFE_Op extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TFE_Op() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TFE_Op(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_TensorDebugInfo.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_TensorDebugInfo.java new file mode 100644 index 00000000000..cee8f05a12c --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_TensorDebugInfo.java @@ -0,0 +1,22 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Debugging/Profiling information for TFE_TensorHandle +// +// TFE_TensorDebugInfo contains information useful for debugging and +// profiling tensors. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TFE_TensorDebugInfo extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TFE_TensorDebugInfo() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TFE_TensorDebugInfo(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_TensorHandle.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_TensorHandle.java new file mode 100644 index 00000000000..c1cce9d004a --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TFE_TensorHandle.java @@ -0,0 +1,23 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// A handle to a tensor on a device. +// +// Like a TF_Tensor, a TFE_TensorHandle refers to a tensor with a value, shape, +// type etc. Unlike a TF_Tensor, a TFE_TensorHandle may refer to such tensors +// placed in memory of different devices or remote address spaces. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TFE_TensorHandle extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TFE_TensorHandle() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TFE_TensorHandle(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ApiDefMap.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ApiDefMap.java new file mode 100644 index 00000000000..95aa8915044 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ApiDefMap.java @@ -0,0 +1,26 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// TF_ApiDefMap encapsulates a collection of API definitions for an operation. +// +// This object maps the name of a TensorFlow operation to a description of the +// API to generate for it, as defined by the ApiDef protocol buffer ( +// https://www.tensorflow.org/code/tensorflow/core/framework/api_def.proto) +// +// The ApiDef messages are typically used to generate convenience wrapper +// functions for TensorFlow operations in various language bindings. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_ApiDefMap extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_ApiDefMap() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_ApiDefMap(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_AttrMetadata.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_AttrMetadata.java new file mode 100644 index 00000000000..54e5584daea --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_AttrMetadata.java @@ -0,0 +1,55 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// TF_AttrMetadata describes the value of an attribute on an operation. +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_AttrMetadata extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public TF_AttrMetadata() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public TF_AttrMetadata(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_AttrMetadata(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public TF_AttrMetadata position(long position) { + return (TF_AttrMetadata)super.position(position); + } + + // A boolean: 1 if the attribute value is a list, 0 otherwise. + public native @Cast("unsigned char") byte is_list(); public native TF_AttrMetadata is_list(byte setter); + + // Length of the list if is_list is true. Undefined otherwise. + public native @Cast("int64_t") long list_size(); public native TF_AttrMetadata list_size(long setter); + + // Type of elements of the list if is_list != 0. + // Type of the single value stored in the attribute if is_list == 0. + public native @Cast("TF_AttrType") int type(); public native TF_AttrMetadata type(int setter); + + // Total size the attribute value. + // The units of total_size depend on is_list and type. + // (1) If type == TF_ATTR_STRING and is_list == 0 + // then total_size is the byte size of the string + // valued attribute. + // (2) If type == TF_ATTR_STRING and is_list == 1 + // then total_size is the cumulative byte size + // of all the strings in the list. + // (3) If type == TF_ATTR_SHAPE and is_list == 0 + // then total_size is the number of dimensions + // of the shape valued attribute, or -1 + // if its rank is unknown. + // (4) If type == TF_ATTR_SHAPE and is_list == 1 + // then total_size is the cumulative number + // of dimensions of all shapes in the list. + // (5) Otherwise, total_size is undefined. + public native @Cast("int64_t") long total_size(); public native TF_AttrMetadata total_size(long setter); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Buffer.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Buffer.java new file mode 100644 index 00000000000..038fbbb78c0 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Buffer.java @@ -0,0 +1,46 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// -------------------------------------------------------------------------- +// TF_Buffer holds a pointer to a block of data and its associated length. +// Typically, the data consists of a serialized protocol buffer, but other data +// may also be held in a buffer. +// +// By default, TF_Buffer itself does not do any memory management of the +// pointed-to block. If need be, users of this struct should specify how to +// deallocate the block by setting the `data_deallocator` function pointer. +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Buffer extends org.tensorflow.c_api.AbstractTF_Buffer { + static { Loader.load(); } + /** Default native constructor. */ + public TF_Buffer() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public TF_Buffer(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Buffer(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public TF_Buffer position(long position) { + return (TF_Buffer)super.position(position); + } + + public native @Const Pointer data(); public native TF_Buffer data(Pointer data); + public native @Cast("size_t") long length(); public native TF_Buffer length(long setter); + public static class Data_deallocator_Pointer_long extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Data_deallocator_Pointer_long(Pointer p) { super(p); } + protected Data_deallocator_Pointer_long() { allocate(); } + private native void allocate(); + public native void call(Pointer data, @Cast("size_t") long length); + } + public native Data_deallocator_Pointer_long data_deallocator(); public native TF_Buffer data_deallocator(Data_deallocator_Pointer_long setter); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_DeprecatedSession.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_DeprecatedSession.java new file mode 100644 index 00000000000..f81294a6bf8 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_DeprecatedSession.java @@ -0,0 +1,23 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// -------------------------------------------------------------------------- +// The deprecated session API. Please switch to the above instead of +// TF_ExtendGraph(). This deprecated API can be removed at any time without +// notice. + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_DeprecatedSession extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_DeprecatedSession() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_DeprecatedSession(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_DeviceList.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_DeviceList.java new file mode 100644 index 00000000000..f5d4047871f --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_DeviceList.java @@ -0,0 +1,18 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_DeviceList extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_DeviceList() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_DeviceList(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_DimensionHandle.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_DimensionHandle.java new file mode 100644 index 00000000000..37419b48100 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_DimensionHandle.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +// #endif + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_DimensionHandle extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_DimensionHandle() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_DimensionHandle(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_FileStatistics.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_FileStatistics.java new file mode 100644 index 00000000000..2fa8175df35 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_FileStatistics.java @@ -0,0 +1,33 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_FileStatistics extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public TF_FileStatistics() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public TF_FileStatistics(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_FileStatistics(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public TF_FileStatistics position(long position) { + return (TF_FileStatistics)super.position(position); + } + + // The length of the file in bytes. + public native @Cast("int64_t") long length(); public native TF_FileStatistics length(long setter); + // The last modified time in nanoseconds. + public native @Cast("int64_t") long mtime_nsec(); public native TF_FileStatistics mtime_nsec(long setter); + // Whether the name refers to a directory. + public native @Cast("bool") boolean is_directory(); public native TF_FileStatistics is_directory(boolean setter); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Function.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Function.java new file mode 100644 index 00000000000..79f4900bb7d --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Function.java @@ -0,0 +1,21 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// TF_Function is a grouping of operations with defined inputs and outputs. +// Once created and added to graphs, functions can be invoked by creating an +// operation whose operation type matches the function name. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Function extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_Function() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Function(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_FunctionOptions.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_FunctionOptions.java new file mode 100644 index 00000000000..361dc579d97 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_FunctionOptions.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Function definition options. TODO(iga): Define and implement +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_FunctionOptions extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_FunctionOptions() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_FunctionOptions(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Graph.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Graph.java new file mode 100644 index 00000000000..083646361dd --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Graph.java @@ -0,0 +1,26 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// TODO(jeff,sanjay): +// - export functions to set Config fields + +// -------------------------------------------------------------------------- +// The new graph construction API, still under development. + +// Represents a computation graph. Graphs may be shared between sessions. +// Graphs are thread-safe when used as directed below. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Graph extends org.tensorflow.c_api.AbstractTF_Graph { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_Graph() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Graph(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ImportGraphDefOptions.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ImportGraphDefOptions.java new file mode 100644 index 00000000000..da3909383df --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ImportGraphDefOptions.java @@ -0,0 +1,20 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// TF_ImportGraphDefOptions holds options that can be passed to +// TF_GraphImportGraphDef. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_ImportGraphDefOptions extends org.tensorflow.c_api.AbstractTF_ImportGraphDefOptions { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_ImportGraphDefOptions() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_ImportGraphDefOptions(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ImportGraphDefResults.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ImportGraphDefResults.java new file mode 100644 index 00000000000..b7223914efb --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ImportGraphDefResults.java @@ -0,0 +1,20 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// TF_ImportGraphDefResults holds results that are generated by +// TF_GraphImportGraphDefWithResults(). +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_ImportGraphDefResults extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_ImportGraphDefResults() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_ImportGraphDefResults(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Input.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Input.java new file mode 100644 index 00000000000..a2b31d65209 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Input.java @@ -0,0 +1,30 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Represents a specific input of an operation. +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Input extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public TF_Input() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public TF_Input(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Input(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public TF_Input position(long position) { + return (TF_Input)super.position(position); + } + + public native TF_Operation oper(); public native TF_Input oper(TF_Operation setter); + public native int index(); public native TF_Input index(int setter); // The index of the input within oper. +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_KernelBuilder.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_KernelBuilder.java new file mode 100644 index 00000000000..ebcf938cdff --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_KernelBuilder.java @@ -0,0 +1,31 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// -------------------------------------------------------------------------- +// C API for TensorFlow Kernels. +// +// This API allows developers to register custom kernel implementations for +// TensorFlow. +// +// See c_api.h header comments for a discussion about API conventions. +// +// Users wishing to extend TensorFlow with new kernels will call +// `TF_NewKernelBuilder`. The resulting kernel builder can be registered with +// `TF_RegisterKernelBuilder`, which will allow TF to construct user-provided +// kernels when necessary. + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_KernelBuilder extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_KernelBuilder() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_KernelBuilder(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Library.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Library.java new file mode 100644 index 00000000000..6060c1442d3 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Library.java @@ -0,0 +1,22 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// -------------------------------------------------------------------------- +// Load plugins containing custom ops and kernels + +// TF_Library holds information about dynamically loaded TensorFlow plugins. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Library extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_Library() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Library(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpDefinitionBuilder.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpDefinitionBuilder.java new file mode 100644 index 00000000000..4c4e4e47fab --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpDefinitionBuilder.java @@ -0,0 +1,17 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_OpDefinitionBuilder extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_OpDefinitionBuilder() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_OpDefinitionBuilder(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpKernelConstruction.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpKernelConstruction.java new file mode 100644 index 00000000000..4b24fd43150 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpKernelConstruction.java @@ -0,0 +1,17 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_OpKernelConstruction extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_OpKernelConstruction() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_OpKernelConstruction(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpKernelContext.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpKernelContext.java new file mode 100644 index 00000000000..3c6264ab7f5 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OpKernelContext.java @@ -0,0 +1,17 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_OpKernelContext extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_OpKernelContext() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_OpKernelContext(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Operation.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Operation.java new file mode 100644 index 00000000000..6f4ed5be54a --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Operation.java @@ -0,0 +1,21 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Operation that has been added to the graph. Valid until the graph is +// deleted -- in particular adding a new operation to the graph does not +// invalidate old TF_Operation* pointers. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Operation extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_Operation() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Operation(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OperationDescription.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OperationDescription.java new file mode 100644 index 00000000000..3bf1ba1c1d5 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_OperationDescription.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Operation being built. The underlying graph must outlive this. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_OperationDescription extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_OperationDescription() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_OperationDescription(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Output.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Output.java new file mode 100644 index 00000000000..f94ab45efd2 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Output.java @@ -0,0 +1,30 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Represents a specific output of an operation. +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Output extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public TF_Output() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public TF_Output(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Output(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public TF_Output position(long position) { + return (TF_Output)super.position(position); + } + + public native TF_Operation oper(); public native TF_Output oper(TF_Operation setter); + public native int index(); public native TF_Output index(int setter); // The index of the output within oper. +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Server.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Server.java new file mode 100644 index 00000000000..42c261ec105 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Server.java @@ -0,0 +1,27 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// -------------------------------------------------------------------------- +// In-process TensorFlow server functionality, for use in distributed training. +// A Server instance encapsulates a set of devices and a Session target that +// can participate in distributed training. A server belongs to a cluster +// (specified by a ClusterSpec), and corresponds to a particular task in a +// named job. The server can communicate with any other server in the same +// cluster. + +// In-process TensorFlow server. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Server extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_Server() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Server(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Session.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Session.java new file mode 100644 index 00000000000..7ff423be388 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Session.java @@ -0,0 +1,24 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// TODO(josh11b): Register OpDef, available to all operations added +// to this graph. + +// -------------------------------------------------------------------------- +// API for driving Graph execution. + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Session extends org.tensorflow.c_api.AbstractTF_Session { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_Session() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Session(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_SessionOptions.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_SessionOptions.java new file mode 100644 index 00000000000..d65175cf6a0 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_SessionOptions.java @@ -0,0 +1,20 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// -------------------------------------------------------------------------- +// TF_SessionOptions holds options that can be passed during session creation. +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_SessionOptions extends org.tensorflow.c_api.AbstractTF_SessionOptions { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_SessionOptions() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_SessionOptions(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ShapeHandle.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ShapeHandle.java new file mode 100644 index 00000000000..ac16fca4303 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ShapeHandle.java @@ -0,0 +1,17 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_ShapeHandle extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_ShapeHandle() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_ShapeHandle(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ShapeInferenceContext.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ShapeInferenceContext.java new file mode 100644 index 00000000000..a7fb315d649 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ShapeInferenceContext.java @@ -0,0 +1,17 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_ShapeInferenceContext extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_ShapeInferenceContext() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_ShapeInferenceContext(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Status.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Status.java new file mode 100644 index 00000000000..d06e4081dba --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Status.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +// #endif + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Status extends org.tensorflow.c_api.AbstractTF_Status { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_Status() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Status(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_StringStream.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_StringStream.java new file mode 100644 index 00000000000..950d0b2ceab --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_StringStream.java @@ -0,0 +1,17 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_StringStream extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_StringStream() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_StringStream(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Tensor.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Tensor.java new file mode 100644 index 00000000000..5c54346d61a --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Tensor.java @@ -0,0 +1,36 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +// #endif + +// -------------------------------------------------------------------------- +// TF_Tensor holds a multi-dimensional array of elements of a single data type. +// For all types other than TF_STRING, the data buffer stores elements +// in row major order. E.g. if data is treated as a vector of TF_DataType: +// +// element 0: index (0, ..., 0) +// element 1: index (0, ..., 1) +// ... +// +// The format for TF_STRING tensors is: +// start_offset: array[uint64] +// data: byte[...] +// +// The string length (as a varint), followed by the contents of the string +// is encoded at data[start_offset[i]]]. TF_StringEncode and TF_StringDecode +// facilitate this encoding. + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Tensor extends org.tensorflow.c_api.AbstractTF_Tensor { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_Tensor() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Tensor(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Thread.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Thread.java new file mode 100644 index 00000000000..fcef8e2febf --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_Thread.java @@ -0,0 +1,17 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_Thread extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_Thread() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_Thread(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ThreadOptions.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ThreadOptions.java new file mode 100644 index 00000000000..2438e43d6b5 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_ThreadOptions.java @@ -0,0 +1,38 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_ThreadOptions extends Pointer { + static { Loader.load(); } + /** Default native constructor. */ + public TF_ThreadOptions() { super((Pointer)null); allocate(); } + /** Native array allocator. Access with {@link Pointer#position(long)}. */ + public TF_ThreadOptions(long size) { super((Pointer)null); allocateArray(size); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_ThreadOptions(Pointer p) { super(p); } + private native void allocate(); + private native void allocateArray(long size); + @Override public TF_ThreadOptions position(long position) { + return (TF_ThreadOptions)super.position(position); + } + + // Thread stack size to use (in bytes), zero implies that the system default + // will be used. + public native @Cast("size_t") long stack_size(); public native TF_ThreadOptions stack_size(long setter); + + // Guard area size to use near thread stacks to use (in bytes), zero implies + // that the system default will be used. + public native @Cast("size_t") long guard_size(); public native TF_ThreadOptions guard_size(long setter); + + // The NUMA node to use, -1 implies that there should be no NUMA affinity for + // this thread. + public native int numa_node(); public native TF_ThreadOptions numa_node(int setter); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_WhileParams.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_WhileParams.java new file mode 100644 index 00000000000..0d7fb463d3c --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_WhileParams.java @@ -0,0 +1,37 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_WhileParams extends Pointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_WhileParams(Pointer p) { super(p); } + + // The number of inputs to the while loop, i.e. the number of loop variables. + // This is the size of cond_inputs, body_inputs, and body_outputs. + @MemberGetter public native int ninputs(); + + // The while condition graph. The inputs are the current values of the loop + // variables. The output should be a scalar boolean. + @MemberGetter public native TF_Graph cond_graph(); + @MemberGetter public native @Const TF_Output cond_inputs(); + public native @ByRef TF_Output cond_output(); public native TF_WhileParams cond_output(TF_Output setter); + + // The loop body graph. The inputs are the current values of the loop + // variables. The outputs are the updated values of the loop variables. + @MemberGetter public native TF_Graph body_graph(); + @MemberGetter public native @Const TF_Output body_inputs(); + @MemberGetter public native TF_Output body_outputs(); + + // Unique null-terminated name for this while loop. This is used as a prefix + // for created operations. + public native @Cast("const char*") BytePointer name(); public native TF_WhileParams name(BytePointer setter); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/TF_WritableFileHandle.java b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_WritableFileHandle.java new file mode 100644 index 00000000000..f1e12524f3c --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/TF_WritableFileHandle.java @@ -0,0 +1,19 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + +// #endif + +@Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class TF_WritableFileHandle extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public TF_WritableFileHandle() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public TF_WritableFileHandle(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/Tensor.java b/core/core-api/src/gen/java/org/tensorflow/c_api/Tensor.java new file mode 100644 index 00000000000..8b8acadd471 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/Tensor.java @@ -0,0 +1,25 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + /* end extern "C" */ +// #endif + +// #ifdef __cplusplus +// A workaround to ease conversion to and from numpy objects and +// TFE_TensorHandle's. +// +// TODO(ashankar): Figure out an alternative scheme that precludes the need for +// these API-boundary breaking methods. +@Namespace("tensorflow") @Opaque @Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class Tensor extends Pointer { + /** Empty constructor. Calls {@code super((Pointer)null)}. */ + public Tensor() { super((Pointer)null); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Tensor(Pointer p) { super(p); } +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/Work_func_Pointer.java b/core/core-api/src/gen/java/org/tensorflow/c_api/Work_func_Pointer.java new file mode 100644 index 00000000000..45eac347a95 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/Work_func_Pointer.java @@ -0,0 +1,28 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +import static org.tensorflow.c_api.global.tensorflow.*; + + +// Returns a new thread that is running work_func and is identified +// (for debugging/performance-analysis) by thread_name. +// +// The given param (which may be null) is passed to work_func when the thread +// starts. In this way, data may be passed from the thread back to the caller. +// +// Caller takes ownership of the result and must call TF_JoinThread on it +// eventually. +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public class Work_func_Pointer extends FunctionPointer { + static { Loader.load(); } + /** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */ + public Work_func_Pointer(Pointer p) { super(p); } + protected Work_func_Pointer() { allocate(); } + private native void allocate(); + public native void call(Pointer arg0); +} diff --git a/core/core-api/src/gen/java/org/tensorflow/c_api/global/tensorflow.java b/core/core-api/src/gen/java/org/tensorflow/c_api/global/tensorflow.java new file mode 100644 index 00000000000..bff806915b3 --- /dev/null +++ b/core/core-api/src/gen/java/org/tensorflow/c_api/global/tensorflow.java @@ -0,0 +1,4200 @@ +// Targeted by JavaCPP version 1.5.2-SNAPSHOT: DO NOT EDIT THIS FILE + +package org.tensorflow.c_api.global; + +import org.tensorflow.c_api.*; + +import java.nio.*; +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.*; + +public class tensorflow extends org.tensorflow.c_api.presets.tensorflow { + static { Loader.load(); } + +// Parsed from tensorflow/c/tf_attrtype.h + +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +// #ifndef TENSORFLOW_C_TF_ATTRTYPE_H_ +// #define TENSORFLOW_C_TF_ATTRTYPE_H_ + +// #ifdef __cplusplus +// #endif + +// TF_AttrType describes the type of the value of an attribute on an operation. +/** enum TF_AttrType */ +public static final int + TF_ATTR_STRING = 0, + TF_ATTR_INT = 1, + TF_ATTR_FLOAT = 2, + TF_ATTR_BOOL = 3, + TF_ATTR_TYPE = 4, + TF_ATTR_SHAPE = 5, + TF_ATTR_TENSOR = 6, + TF_ATTR_PLACEHOLDER = 7, + TF_ATTR_FUNC = 8; + +// #ifdef __cplusplus /* end extern "C" */ +// #endif + +// #endif // TENSORFLOW_C_TF_ATTRTYPE_H_ + + +// Parsed from tensorflow/c/tf_datatype.h + +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// #ifndef TENSORFLOW_C_TF_DATATYPE_H_ +// #define TENSORFLOW_C_TF_DATATYPE_H_ + +// #include + +// Macro to control visibility of exported symbols in the shared library (.so, +// .dylib, .dll). +// This duplicates the TF_EXPORT macro definition in +// tensorflow/core/platform/macros.h in order to keep this .h file independent +// of any other includes. +// #ifdef SWIG +// #define TF_CAPI_EXPORT +// #else +// #if defined(_WIN32) +// #ifdef TF_COMPILE_LIBRARY +// #define TF_CAPI_EXPORT __declspec(dllexport) +// #else +// #define TF_CAPI_EXPORT __declspec(dllimport) +// #endif // TF_COMPILE_LIBRARY +// #else +// #define TF_CAPI_EXPORT __attribute__((visibility("default"))) +// #endif // _WIN32 +// #endif // SWIG + +// #ifdef __cplusplus +// #endif + +// -------------------------------------------------------------------------- +// TF_DataType holds the type for a scalar value. E.g., one slot in a tensor. +// The enum values here are identical to corresponding values in types.proto. +/** enum TF_DataType */ +public static final int + TF_FLOAT = 1, + TF_DOUBLE = 2, + TF_INT32 = 3, // Int32 tensors are always in 'host' memory. + TF_UINT8 = 4, + TF_INT16 = 5, + TF_INT8 = 6, + TF_STRING = 7, + TF_COMPLEX64 = 8, // Single-precision complex + TF_COMPLEX = 8, // Old identifier kept for API backwards compatibility + TF_INT64 = 9, + TF_BOOL = 10, + TF_QINT8 = 11, // Quantized int8 + TF_QUINT8 = 12, // Quantized uint8 + TF_QINT32 = 13, // Quantized int32 + TF_BFLOAT16 = 14, // Float32 truncated to 16 bits. Only for cast ops. + TF_QINT16 = 15, // Quantized int16 + TF_QUINT16 = 16, // Quantized uint16 + TF_UINT16 = 17, + TF_COMPLEX128 = 18, // Double-precision complex + TF_HALF = 19, + TF_RESOURCE = 20, + TF_VARIANT = 21, + TF_UINT32 = 22, + TF_UINT64 = 23; + +// TF_DataTypeSize returns the sizeof() for the underlying type corresponding +// to the given TF_DataType enum value. Returns 0 for variable length types +// (eg. TF_STRING) or on failure. +public static native @Cast("size_t") long TF_DataTypeSize(@Cast("TF_DataType") int dt); + +// #ifdef __cplusplus /* end extern "C" */ +// #endif + +// #endif // TENSORFLOW_C_TF_DATATYPE_H_ + + +// Parsed from tensorflow/c/tf_status.h + +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// #ifndef TENSORFLOW_C_TF_STATUS_H_ +// #define TENSORFLOW_C_TF_STATUS_H_ + +// #ifdef SWIG +// #define TF_CAPI_EXPORT +// #else +// #if defined(_WIN32) +// #ifdef TF_COMPILE_LIBRARY +// #define TF_CAPI_EXPORT __declspec(dllexport) +// #else +// #define TF_CAPI_EXPORT __declspec(dllimport) +// #endif // TF_COMPILE_LIBRARY +// #else +// #define TF_CAPI_EXPORT __attribute__((visibility("default"))) +// #endif // _WIN32 +// #endif // SWIG + +// #ifdef __cplusplus +// Targeting ../TF_Status.java + + + +// -------------------------------------------------------------------------- +// TF_Code holds an error code. The enum values here are identical to +// corresponding values in error_codes.proto. +/** enum TF_Code */ +public static final int + TF_OK = 0, + TF_CANCELLED = 1, + TF_UNKNOWN = 2, + TF_INVALID_ARGUMENT = 3, + TF_DEADLINE_EXCEEDED = 4, + TF_NOT_FOUND = 5, + TF_ALREADY_EXISTS = 6, + TF_PERMISSION_DENIED = 7, + TF_UNAUTHENTICATED = 16, + TF_RESOURCE_EXHAUSTED = 8, + TF_FAILED_PRECONDITION = 9, + TF_ABORTED = 10, + TF_OUT_OF_RANGE = 11, + TF_UNIMPLEMENTED = 12, + TF_INTERNAL = 13, + TF_UNAVAILABLE = 14, + TF_DATA_LOSS = 15; + +// -------------------------------------------------------------------------- + +// Return a new status object. +public static native TF_Status TF_NewStatus(); + +// Delete a previously created status object. +public static native void TF_DeleteStatus(TF_Status arg0); + +// Record in *s. Any previous information is lost. +// A common use is to clear a status: TF_SetStatus(s, TF_OK, ""); +public static native void TF_SetStatus(TF_Status s, @Cast("TF_Code") int code, + @Cast("const char*") BytePointer msg); +public static native void TF_SetStatus(TF_Status s, @Cast("TF_Code") int code, + String msg); + +// Return the code record in *s. +public static native @Cast("TF_Code") int TF_GetCode(@Const TF_Status s); + +// Return a pointer to the (null-terminated) error message in *s. The +// return value points to memory that is only usable until the next +// mutation to *s. Always returns an empty string if TF_GetCode(s) is +// TF_OK. +public static native @Cast("const char*") BytePointer TF_Message(@Const TF_Status s); + +// #ifdef __cplusplus /* end extern "C" */ +// #endif + +// #endif // TENSORFLOW_C_TF_STATUS_H_ + + +// Parsed from tensorflow/c/tf_tensor.h + +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// #ifndef TENSORFLOW_C_TF_TENSOR_H_ +// #define TENSORFLOW_C_TF_TENSOR_H_ + +// #include +// #include + +// #include "tensorflow/c/tf_datatype.h" +// #include "tensorflow/c/tf_status.h" + +// Macro to control visibility of exported symbols in the shared library (.so, +// .dylib, .dll). +// This duplicates the TF_EXPORT macro definition in +// tensorflow/core/platform/macros.h in order to keep this .h file independent +// of any other includes. +// #ifdef SWIG +// #define TF_CAPI_EXPORT +// #else +// #if defined(_WIN32) +// #ifdef TF_COMPILE_LIBRARY +// #define TF_CAPI_EXPORT __declspec(dllexport) +// #else +// #define TF_CAPI_EXPORT __declspec(dllimport) +// #endif // TF_COMPILE_LIBRARY +// #else +// #define TF_CAPI_EXPORT __attribute__((visibility("default"))) +// #endif // _WIN32 +// #endif // SWIG + +// #ifdef __cplusplus +// Targeting ../TF_Tensor.java + + +// Targeting ../Deallocator_Pointer_long_Pointer.java + + +public static native TF_Tensor TF_NewTensor( + @Cast("TF_DataType") int arg0, @Cast("const int64_t*") LongPointer dims, int num_dims, Pointer data, @Cast("size_t") long len, + Deallocator_Pointer_long_Pointer deallocator, + Pointer deallocator_arg); +public static native TF_Tensor TF_NewTensor( + @Cast("TF_DataType") int arg0, @Cast("const int64_t*") LongBuffer dims, int num_dims, Pointer data, @Cast("size_t") long len, + Deallocator_Pointer_long_Pointer deallocator, + Pointer deallocator_arg); +public static native TF_Tensor TF_NewTensor( + @Cast("TF_DataType") int arg0, @Cast("const int64_t*") long[] dims, int num_dims, Pointer data, @Cast("size_t") long len, + Deallocator_Pointer_long_Pointer deallocator, + Pointer deallocator_arg); + +// Allocate and return a new Tensor. +// +// This function is an alternative to TF_NewTensor and should be used when +// memory is allocated to pass the Tensor to the C API. The allocated memory +// satisfies TensorFlow's memory alignment preferences and should be preferred +// over calling malloc and free. +// +// The caller must set the Tensor values by writing them to the pointer returned +// by TF_TensorData with length TF_TensorByteSize. +public static native TF_Tensor TF_AllocateTensor(@Cast("TF_DataType") int arg0, + @Cast("const int64_t*") LongPointer dims, + int num_dims, @Cast("size_t") long len); +public static native TF_Tensor TF_AllocateTensor(@Cast("TF_DataType") int arg0, + @Cast("const int64_t*") LongBuffer dims, + int num_dims, @Cast("size_t") long len); +public static native TF_Tensor TF_AllocateTensor(@Cast("TF_DataType") int arg0, + @Cast("const int64_t*") long[] dims, + int num_dims, @Cast("size_t") long len); + +// Deletes `tensor` and returns a new TF_Tensor with the same content if +// possible. Returns nullptr and leaves `tensor` untouched if not. +public static native TF_Tensor TF_TensorMaybeMove(TF_Tensor tensor); + +// Destroy a tensor. +public static native void TF_DeleteTensor(TF_Tensor arg0); + +// Return the type of a tensor element. +public static native @Cast("TF_DataType") int TF_TensorType(@Const TF_Tensor arg0); + +// Return the number of dimensions that the tensor has. +public static native int TF_NumDims(@Const TF_Tensor arg0); + +// Return the length of the tensor in the "dim_index" dimension. +// REQUIRES: 0 <= dim_index < TF_NumDims(tensor) +public static native @Cast("int64_t") long TF_Dim(@Const TF_Tensor tensor, int dim_index); + +// Return the size of the underlying data in bytes. +public static native @Cast("size_t") long TF_TensorByteSize(@Const TF_Tensor arg0); + +// Return a pointer to the underlying data buffer. +public static native Pointer TF_TensorData(@Const TF_Tensor arg0); + +// Returns the number of elements in the tensor. +public static native @Cast("int64_t") long TF_TensorElementCount(@Const TF_Tensor tensor); + +// Copy the internal data representation of `from` to `to`. `new_dims` and +// `num_new_dims` specify the new shape of the `to` tensor, `type` specifies its +// data type. On success, *status is set to TF_OK and the two tensors share the +// same data buffer. +// +// This call requires that the `from` tensor and the given type and shape (dims +// and num_dims) are "compatible" (i.e. they occupy the same number of bytes). +// Specifically, given from_type_size = TF_DataTypeSize(TF_TensorType(from)): +// +// ShapeElementCount(dims, num_dims) * TF_DataTypeSize(type) +// +// must equal +// +// TF_TensorElementCount(from) * from_type_size +// +// where TF_ShapeElementCount would be the number of elements in a tensor with +// the given shape. +// +// In addition, this function requires: +// * TF_DataTypeSize(TF_TensorType(from)) != 0 +// * TF_DataTypeSize(type) != 0 +// +// If any of the requirements are not met, *status is set to +// TF_INVALID_ARGUMENT. +public static native void TF_TensorBitcastFrom(@Const TF_Tensor from, + @Cast("TF_DataType") int type, TF_Tensor to, + @Cast("const int64_t*") LongPointer new_dims, + int num_new_dims, + TF_Status status); +public static native void TF_TensorBitcastFrom(@Const TF_Tensor from, + @Cast("TF_DataType") int type, TF_Tensor to, + @Cast("const int64_t*") LongBuffer new_dims, + int num_new_dims, + TF_Status status); +public static native void TF_TensorBitcastFrom(@Const TF_Tensor from, + @Cast("TF_DataType") int type, TF_Tensor to, + @Cast("const int64_t*") long[] new_dims, + int num_new_dims, + TF_Status status); + +// -------------------------------------------------------------------------- +// Encode the string `src` (`src_len` bytes long) into `dst` in the format +// required by TF_STRING tensors. Does not write to memory more than `dst_len` +// bytes beyond `*dst`. `dst_len` should be at least +// TF_StringEncodedSize(src_len). +// +// On success returns the size in bytes of the encoded string. +// Returns an error into `status` otherwise. +public static native @Cast("size_t") long TF_StringEncode(@Cast("const char*") BytePointer src, @Cast("size_t") long src_len, + @Cast("char*") BytePointer dst, @Cast("size_t") long dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringEncode(String src, @Cast("size_t") long src_len, + @Cast("char*") ByteBuffer dst, @Cast("size_t") long dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringEncode(@Cast("const char*") BytePointer src, @Cast("size_t") long src_len, + @Cast("char*") byte[] dst, @Cast("size_t") long dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringEncode(String src, @Cast("size_t") long src_len, + @Cast("char*") BytePointer dst, @Cast("size_t") long dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringEncode(@Cast("const char*") BytePointer src, @Cast("size_t") long src_len, + @Cast("char*") ByteBuffer dst, @Cast("size_t") long dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringEncode(String src, @Cast("size_t") long src_len, + @Cast("char*") byte[] dst, @Cast("size_t") long dst_len, + TF_Status status); + +// Decode a string encoded using TF_StringEncode. +// +// On success, sets `*dst` to the start of the decoded string and `*dst_len` to +// its length. Returns the number of bytes starting at `src` consumed while +// decoding. `*dst` points to memory within the encoded buffer. On failure, +// `*dst` and `*dst_len` are undefined and an error is set in `status`. +// +// Does not read memory more than `src_len` bytes beyond `src`. +public static native @Cast("size_t") long TF_StringDecode(@Cast("const char*") BytePointer src, @Cast("size_t") long src_len, + @Cast("const char**") PointerPointer dst, @Cast("size_t*") SizeTPointer dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringDecode(@Cast("const char*") BytePointer src, @Cast("size_t") long src_len, + @Cast("const char**") @ByPtrPtr BytePointer dst, @Cast("size_t*") SizeTPointer dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringDecode(String src, @Cast("size_t") long src_len, + @Cast("const char**") @ByPtrPtr ByteBuffer dst, @Cast("size_t*") SizeTPointer dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringDecode(@Cast("const char*") BytePointer src, @Cast("size_t") long src_len, + @Cast("const char**") @ByPtrPtr byte[] dst, @Cast("size_t*") SizeTPointer dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringDecode(String src, @Cast("size_t") long src_len, + @Cast("const char**") @ByPtrPtr BytePointer dst, @Cast("size_t*") SizeTPointer dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringDecode(@Cast("const char*") BytePointer src, @Cast("size_t") long src_len, + @Cast("const char**") @ByPtrPtr ByteBuffer dst, @Cast("size_t*") SizeTPointer dst_len, + TF_Status status); +public static native @Cast("size_t") long TF_StringDecode(String src, @Cast("size_t") long src_len, + @Cast("const char**") @ByPtrPtr byte[] dst, @Cast("size_t*") SizeTPointer dst_len, + TF_Status status); + +// Return the size in bytes required to encode a string `len` bytes long into a +// TF_STRING tensor. +public static native @Cast("size_t") long TF_StringEncodedSize(@Cast("size_t") long len); + +// Returns bool iff this tensor is aligned. +public static native @Cast("bool") boolean TF_TensorIsAligned(@Const TF_Tensor arg0); + +// #ifdef __cplusplus /* end extern "C" */ +// #endif + +// #endif // TENSORFLOW_C_TF_TENSOR_H_ + + +// Parsed from tensorflow/c/c_api.h + +/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// #ifndef TENSORFLOW_C_C_API_H_ +// #define TENSORFLOW_C_C_API_H_ + +// #include +// #include + +// #include "tensorflow/c/tf_attrtype.h" +// #include "tensorflow/c/tf_datatype.h" +// #include "tensorflow/c/tf_status.h" +// #include "tensorflow/c/tf_tensor.h" + +// -------------------------------------------------------------------------- +// C API for TensorFlow. +// +// The API leans towards simplicity and uniformity instead of convenience +// since most usage will be by language specific wrappers. +// +// Conventions: +// * We use the prefix TF_ for everything in the API. +// * Objects are always passed around as pointers to opaque structs +// and these structs are allocated/deallocated via the API. +// * TF_Status holds error information. It is an object type +// and therefore is passed around as a pointer to an opaque +// struct as mentioned above. +// * Every call that has a TF_Status* argument clears it on success +// and fills it with error info on failure. +// * unsigned char is used for booleans (instead of the 'bool' type). +// In C++ bool is a keyword while in C99 bool is a macro defined +// in stdbool.h. It is possible for the two to be inconsistent. +// For example, neither the C99 nor the C++11 standard force a byte +// size on the bool type, so the macro defined in stdbool.h could +// be inconsistent with the bool keyword in C++. Thus, the use +// of stdbool.h is avoided and unsigned char is used instead. +// * size_t is used to represent byte sizes of objects that are +// materialized in the address space of the calling process. +// * int is used as an index into arrays. +// * Deletion functions are safe to call on nullptr. +// +// Questions left to address: +// * Might at some point need a way for callers to provide their own Env. +// * Maybe add TF_TensorShape that encapsulates dimension info. +// +// Design decisions made: +// * Backing store for tensor memory has an associated deallocation +// function. This deallocation function will point to client code +// for tensors populated by the client. So the client can do things +// like shadowing a numpy array. +// * We do not provide TF_OK since it is not strictly necessary and we +// are not optimizing for convenience. +// * We make assumption that one session has one graph. This should be +// fine since we have the ability to run sub-graphs. +// * We could allow NULL for some arguments (e.g., NULL options arg). +// However since convenience is not a primary goal, we don't do this. +// * Devices are not in this API. Instead, they are created/used internally +// and the API just provides high level controls over the number of +// devices of each type. + +// Macro to control visibility of exported symbols in the shared library (.so, +// .dylib, .dll). +// This duplicates the TF_EXPORT macro definition in +// tensorflow/core/platform/macros.h in order to keep this .h file independent +// of any other includes. +// #ifdef SWIG +// #define TF_CAPI_EXPORT +// #else +// #if defined(_WIN32) +// #ifdef TF_COMPILE_LIBRARY +// #define TF_CAPI_EXPORT __declspec(dllexport) +// #else +// #define TF_CAPI_EXPORT __declspec(dllimport) +// #endif // TF_COMPILE_LIBRARY +// #else +// #define TF_CAPI_EXPORT __attribute__((visibility("default"))) +// #endif // _WIN32 +// #endif // SWIG + +// #ifdef __cplusplus +// #endif + +// -------------------------------------------------------------------------- +// TF_Version returns a string describing version information of the +// TensorFlow library. TensorFlow using semantic versioning. +public static native @Cast("const char*") BytePointer TF_Version(); +// Targeting ../TF_Buffer.java + + + +// Makes a copy of the input and sets an appropriate deallocator. Useful for +// passing in read-only, input protobufs. +public static native TF_Buffer TF_NewBufferFromString(@Const Pointer proto, + @Cast("size_t") long proto_len); + +// Useful for passing *out* a protobuf. +public static native TF_Buffer TF_NewBuffer(); + +public static native void TF_DeleteBuffer(TF_Buffer arg0); + +public static native @ByVal TF_Buffer TF_GetBuffer(TF_Buffer buffer); +// Targeting ../TF_SessionOptions.java + + + +// Return a new options object. +public static native TF_SessionOptions TF_NewSessionOptions(); + +// Set the target in TF_SessionOptions.options. +// target can be empty, a single entry, or a comma separated list of entries. +// Each entry is in one of the following formats : +// "local" +// ip:port +// host:port +public static native void TF_SetTarget(TF_SessionOptions options, + @Cast("const char*") BytePointer target); +public static native void TF_SetTarget(TF_SessionOptions options, + String target); + +// Set the config in TF_SessionOptions.options. +// config should be a serialized tensorflow.ConfigProto proto. +// If config was not parsed successfully as a ConfigProto, record the +// error information in *status. +public static native void TF_SetConfig(TF_SessionOptions options, + @Const Pointer proto, @Cast("size_t") long proto_len, + TF_Status status); + +// Destroy an options object. +public static native void TF_DeleteSessionOptions(TF_SessionOptions arg0); +// Targeting ../TF_Graph.java + + + +// Return a new graph object. +public static native TF_Graph TF_NewGraph(); + +// Destroy an options object. Graph will be deleted once no more +// TFSession's are referencing it. +public static native void TF_DeleteGraph(TF_Graph arg0); +// Targeting ../TF_OperationDescription.java + + +// Targeting ../TF_Operation.java + + +// Targeting ../TF_Input.java + + +// Targeting ../TF_Output.java + + +// Targeting ../TF_Function.java + + +// Targeting ../TF_FunctionOptions.java + + + +// Sets the shape of the Tensor referenced by `output` in `graph` to +// the shape described by `dims` and `num_dims`. +// +// If the number of dimensions is unknown, `num_dims` must be set to +// -1 and `dims` can be null. If a dimension is unknown, the +// corresponding entry in the `dims` array must be -1. +// +// This does not overwrite the existing shape associated with `output`, +// but merges the input shape with the existing shape. For example, +// setting a shape of [-1, 2] with an existing shape [2, -1] would set +// a final shape of [2, 2] based on shape merging semantics. +// +// Returns an error into `status` if: +// * `output` is not in `graph`. +// * An invalid shape is being set (e.g., the shape being set +// is incompatible with the existing shape). +public static native void TF_GraphSetTensorShape(TF_Graph graph, + @ByVal TF_Output output, + @Cast("const int64_t*") LongPointer dims, + int num_dims, + TF_Status status); +public static native void TF_GraphSetTensorShape(TF_Graph graph, + @ByVal TF_Output output, + @Cast("const int64_t*") LongBuffer dims, + int num_dims, + TF_Status status); +public static native void TF_GraphSetTensorShape(TF_Graph graph, + @ByVal TF_Output output, + @Cast("const int64_t*") long[] dims, + int num_dims, + TF_Status status); + +// Returns the number of dimensions of the Tensor referenced by `output` +// in `graph`. +// +// If the number of dimensions in the shape is unknown, returns -1. +// +// Returns an error into `status` if: +// * `output` is not in `graph`. +public static native int TF_GraphGetTensorNumDims(TF_Graph graph, + @ByVal TF_Output output, + TF_Status status); + +// Returns the shape of the Tensor referenced by `output` in `graph` +// into `dims`. `dims` must be an array large enough to hold `num_dims` +// entries (e.g., the return value of TF_GraphGetTensorNumDims). +// +// If the number of dimensions in the shape is unknown or the shape is +// a scalar, `dims` will remain untouched. Otherwise, each element of +// `dims` will be set corresponding to the size of the dimension. An +// unknown dimension is represented by `-1`. +// +// Returns an error into `status` if: +// * `output` is not in `graph`. +// * `num_dims` does not match the actual number of dimensions. +public static native void TF_GraphGetTensorShape(TF_Graph graph, + @ByVal TF_Output output, + @Cast("int64_t*") LongPointer dims, int num_dims, + TF_Status status); +public static native void TF_GraphGetTensorShape(TF_Graph graph, + @ByVal TF_Output output, + @Cast("int64_t*") LongBuffer dims, int num_dims, + TF_Status status); +public static native void TF_GraphGetTensorShape(TF_Graph graph, + @ByVal TF_Output output, + @Cast("int64_t*") long[] dims, int num_dims, + TF_Status status); + +// Operation will only be added to *graph when TF_FinishOperation() is +// called (assuming TF_FinishOperation() does not return an error). +// *graph must not be deleted until after TF_FinishOperation() is +// called. +public static native TF_OperationDescription TF_NewOperation( + TF_Graph graph, @Cast("const char*") BytePointer op_type, @Cast("const char*") BytePointer oper_name); +public static native TF_OperationDescription TF_NewOperation( + TF_Graph graph, String op_type, String oper_name); + +// Specify the device for `desc`. Defaults to empty, meaning unconstrained. +public static native void TF_SetDevice(TF_OperationDescription desc, + @Cast("const char*") BytePointer device); +public static native void TF_SetDevice(TF_OperationDescription desc, + String device); + +// The calls to TF_AddInput and TF_AddInputList must match (in number, +// order, and type) the op declaration. For example, the "Concat" op +// has registration: +// REGISTER_OP("Concat") +// .Input("concat_dim: int32") +// .Input("values: N * T") +// .Output("output: T") +// .Attr("N: int >= 2") +// .Attr("T: type"); +// that defines two inputs, "concat_dim" and "values" (in that order). +// You must use TF_AddInput() for the first input (since it takes a +// single tensor), and TF_AddInputList() for the second input (since +// it takes a list, even if you were to pass a list with a single +// tensor), as in: +// TF_OperationDescription* desc = TF_NewOperation(graph, "Concat", "c"); +// TF_Output concat_dim_input = {...}; +// TF_AddInput(desc, concat_dim_input); +// TF_Output values_inputs[5] = {{...}, ..., {...}}; +// TF_AddInputList(desc, values_inputs, 5); + +// For inputs that take a single tensor. +public static native void TF_AddInput(TF_OperationDescription desc, + @ByVal TF_Output input); + +// For inputs that take a list of tensors. +// inputs must point to TF_Output[num_inputs]. +public static native void TF_AddInputList(TF_OperationDescription desc, + @Const TF_Output inputs, + int num_inputs); + +// Call once per control input to `desc`. +public static native void TF_AddControlInput(TF_OperationDescription desc, + TF_Operation input); + +// Request that `desc` be co-located on the device where `op` +// is placed. +// +// Use of this is discouraged since the implementation of device placement is +// subject to change. Primarily intended for internal libraries +public static native void TF_ColocateWith(TF_OperationDescription desc, + TF_Operation op); + +// Call some TF_SetAttr*() function for every attr that is not +// inferred from an input and doesn't have a default value you wish to +// keep. + +// `value` must point to a string of length `length` bytes. +public static native void TF_SetAttrString(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Const Pointer value, @Cast("size_t") long length); +public static native void TF_SetAttrString(TF_OperationDescription desc, + String attr_name, + @Const Pointer value, @Cast("size_t") long length); +// `values` and `lengths` each must have lengths `num_values`. +// `values[i]` must point to a string of length `lengths[i]` bytes. +public static native void TF_SetAttrStringList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const void*const*") PointerPointer values, + @Cast("const size_t*") SizeTPointer lengths, + int num_values); +public static native void TF_SetAttrStringList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const void*const*") @ByPtrPtr Pointer values, + @Cast("const size_t*") SizeTPointer lengths, + int num_values); +public static native void TF_SetAttrStringList(TF_OperationDescription desc, + String attr_name, + @Cast("const void*const*") @ByPtrPtr Pointer values, + @Cast("const size_t*") SizeTPointer lengths, + int num_values); +public static native void TF_SetAttrInt(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, @Cast("int64_t") long value); +public static native void TF_SetAttrInt(TF_OperationDescription desc, + String attr_name, @Cast("int64_t") long value); +public static native void TF_SetAttrIntList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") LongPointer values, + int num_values); +public static native void TF_SetAttrIntList(TF_OperationDescription desc, + String attr_name, + @Cast("const int64_t*") LongBuffer values, + int num_values); +public static native void TF_SetAttrIntList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") long[] values, + int num_values); +public static native void TF_SetAttrIntList(TF_OperationDescription desc, + String attr_name, + @Cast("const int64_t*") LongPointer values, + int num_values); +public static native void TF_SetAttrIntList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") LongBuffer values, + int num_values); +public static native void TF_SetAttrIntList(TF_OperationDescription desc, + String attr_name, + @Cast("const int64_t*") long[] values, + int num_values); +public static native void TF_SetAttrFloat(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, float value); +public static native void TF_SetAttrFloat(TF_OperationDescription desc, + String attr_name, float value); +public static native void TF_SetAttrFloatList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Const FloatPointer values, + int num_values); +public static native void TF_SetAttrFloatList(TF_OperationDescription desc, + String attr_name, + @Const FloatBuffer values, + int num_values); +public static native void TF_SetAttrFloatList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Const float[] values, + int num_values); +public static native void TF_SetAttrFloatList(TF_OperationDescription desc, + String attr_name, + @Const FloatPointer values, + int num_values); +public static native void TF_SetAttrFloatList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Const FloatBuffer values, + int num_values); +public static native void TF_SetAttrFloatList(TF_OperationDescription desc, + String attr_name, + @Const float[] values, + int num_values); +public static native void TF_SetAttrBool(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char") byte value); +public static native void TF_SetAttrBool(TF_OperationDescription desc, + String attr_name, + @Cast("unsigned char") byte value); +public static native void TF_SetAttrBoolList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const unsigned char*") BytePointer values, + int num_values); +public static native void TF_SetAttrBoolList(TF_OperationDescription desc, + String attr_name, + @Cast("const unsigned char*") ByteBuffer values, + int num_values); +public static native void TF_SetAttrBoolList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const unsigned char*") byte[] values, + int num_values); +public static native void TF_SetAttrBoolList(TF_OperationDescription desc, + String attr_name, + @Cast("const unsigned char*") BytePointer values, + int num_values); +public static native void TF_SetAttrBoolList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const unsigned char*") ByteBuffer values, + int num_values); +public static native void TF_SetAttrBoolList(TF_OperationDescription desc, + String attr_name, + @Cast("const unsigned char*") byte[] values, + int num_values); +public static native void TF_SetAttrType(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_DataType") int value); +public static native void TF_SetAttrType(TF_OperationDescription desc, + String attr_name, + @Cast("TF_DataType") int value); +public static native void TF_SetAttrTypeList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const TF_DataType*") IntPointer values, + int num_values); +public static native void TF_SetAttrTypeList(TF_OperationDescription desc, + String attr_name, + @Cast("const TF_DataType*") IntBuffer values, + int num_values); +public static native void TF_SetAttrTypeList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const TF_DataType*") int[] values, + int num_values); +public static native void TF_SetAttrTypeList(TF_OperationDescription desc, + String attr_name, + @Cast("const TF_DataType*") IntPointer values, + int num_values); +public static native void TF_SetAttrTypeList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const TF_DataType*") IntBuffer values, + int num_values); +public static native void TF_SetAttrTypeList(TF_OperationDescription desc, + String attr_name, + @Cast("const TF_DataType*") int[] values, + int num_values); +public static native void TF_SetAttrPlaceholder(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const char*") BytePointer placeholder); +public static native void TF_SetAttrPlaceholder(TF_OperationDescription desc, + String attr_name, + String placeholder); + +// Set a 'func' attribute to the specified name. +// `value` must point to a string of length `length` bytes. +public static native void TF_SetAttrFuncName(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const char*") BytePointer value, @Cast("size_t") long length); +public static native void TF_SetAttrFuncName(TF_OperationDescription desc, + String attr_name, + String value, @Cast("size_t") long length); + +// Set `num_dims` to -1 to represent "unknown rank". Otherwise, +// `dims` points to an array of length `num_dims`. `dims[i]` must be +// >= -1, with -1 meaning "unknown dimension". +public static native void TF_SetAttrShape(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") LongPointer dims, int num_dims); +public static native void TF_SetAttrShape(TF_OperationDescription desc, + String attr_name, + @Cast("const int64_t*") LongBuffer dims, int num_dims); +public static native void TF_SetAttrShape(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") long[] dims, int num_dims); +public static native void TF_SetAttrShape(TF_OperationDescription desc, + String attr_name, + @Cast("const int64_t*") LongPointer dims, int num_dims); +public static native void TF_SetAttrShape(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") LongBuffer dims, int num_dims); +public static native void TF_SetAttrShape(TF_OperationDescription desc, + String attr_name, + @Cast("const int64_t*") long[] dims, int num_dims); +// `dims` and `num_dims` must point to arrays of length `num_shapes`. +// Set `num_dims[i]` to -1 to represent "unknown rank". Otherwise, +// `dims[i]` points to an array of length `num_dims[i]`. `dims[i][j]` +// must be >= -1, with -1 meaning "unknown dimension". +public static native void TF_SetAttrShapeList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*const*") PointerPointer dims, + @Const IntPointer num_dims, + int num_shapes); +public static native void TF_SetAttrShapeList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*const*") @ByPtrPtr LongPointer dims, + @Const IntPointer num_dims, + int num_shapes); +public static native void TF_SetAttrShapeList(TF_OperationDescription desc, + String attr_name, + @Cast("const int64_t*const*") @ByPtrPtr LongBuffer dims, + @Const IntBuffer num_dims, + int num_shapes); +public static native void TF_SetAttrShapeList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*const*") @ByPtrPtr long[] dims, + @Const int[] num_dims, + int num_shapes); +public static native void TF_SetAttrShapeList(TF_OperationDescription desc, + String attr_name, + @Cast("const int64_t*const*") @ByPtrPtr LongPointer dims, + @Const IntPointer num_dims, + int num_shapes); +public static native void TF_SetAttrShapeList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*const*") @ByPtrPtr LongBuffer dims, + @Const IntBuffer num_dims, + int num_shapes); +public static native void TF_SetAttrShapeList(TF_OperationDescription desc, + String attr_name, + @Cast("const int64_t*const*") @ByPtrPtr long[] dims, + @Const int[] num_dims, + int num_shapes); +// `proto` must point to an array of `proto_len` bytes representing a +// binary-serialized TensorShapeProto. +public static native void TF_SetAttrTensorShapeProto( + TF_OperationDescription desc, @Cast("const char*") BytePointer attr_name, @Const Pointer proto, + @Cast("size_t") long proto_len, TF_Status status); +public static native void TF_SetAttrTensorShapeProto( + TF_OperationDescription desc, String attr_name, @Const Pointer proto, + @Cast("size_t") long proto_len, TF_Status status); +// `protos` and `proto_lens` must point to arrays of length `num_shapes`. +// `protos[i]` must point to an array of `proto_lens[i]` bytes +// representing a binary-serialized TensorShapeProto. +public static native void TF_SetAttrTensorShapeProtoList( + TF_OperationDescription desc, @Cast("const char*") BytePointer attr_name, + @Cast("const void*const*") PointerPointer protos, @Cast("const size_t*") SizeTPointer proto_lens, int num_shapes, + TF_Status status); +public static native void TF_SetAttrTensorShapeProtoList( + TF_OperationDescription desc, @Cast("const char*") BytePointer attr_name, + @Cast("const void*const*") @ByPtrPtr Pointer protos, @Cast("const size_t*") SizeTPointer proto_lens, int num_shapes, + TF_Status status); +public static native void TF_SetAttrTensorShapeProtoList( + TF_OperationDescription desc, String attr_name, + @Cast("const void*const*") @ByPtrPtr Pointer protos, @Cast("const size_t*") SizeTPointer proto_lens, int num_shapes, + TF_Status status); + +public static native void TF_SetAttrTensor(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + TF_Tensor value, + TF_Status status); +public static native void TF_SetAttrTensor(TF_OperationDescription desc, + String attr_name, + TF_Tensor value, + TF_Status status); +public static native void TF_SetAttrTensorList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_Tensor*const*") PointerPointer values, + int num_values, + TF_Status status); +public static native void TF_SetAttrTensorList(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @ByPtrPtr TF_Tensor values, + int num_values, + TF_Status status); +public static native void TF_SetAttrTensorList(TF_OperationDescription desc, + String attr_name, + @ByPtrPtr TF_Tensor values, + int num_values, + TF_Status status); + +// `proto` should point to a sequence of bytes of length `proto_len` +// representing a binary serialization of an AttrValue protocol +// buffer. +public static native void TF_SetAttrValueProto(TF_OperationDescription desc, + @Cast("const char*") BytePointer attr_name, + @Const Pointer proto, + @Cast("size_t") long proto_len, + TF_Status status); +public static native void TF_SetAttrValueProto(TF_OperationDescription desc, + String attr_name, + @Const Pointer proto, + @Cast("size_t") long proto_len, + TF_Status status); + +// If this function succeeds: +// * *status is set to an OK value, +// * a TF_Operation is added to the graph, +// * a non-null value pointing to the added operation is returned -- +// this value is valid until the underlying graph is deleted. +// Otherwise: +// * *status is set to a non-OK value, +// * the graph is not modified, +// * a null value is returned. +// In either case, it deletes `desc`. +public static native TF_Operation TF_FinishOperation( + TF_OperationDescription desc, TF_Status status); + +// TF_Operation functions. Operations are immutable once created, so +// these are all query functions. + +public static native @Cast("const char*") BytePointer TF_OperationName(TF_Operation oper); +public static native @Cast("const char*") BytePointer TF_OperationOpType(TF_Operation oper); +public static native @Cast("const char*") BytePointer TF_OperationDevice(TF_Operation oper); + +public static native int TF_OperationNumOutputs(TF_Operation oper); +public static native @Cast("TF_DataType") int TF_OperationOutputType(@ByVal TF_Output oper_out); +public static native int TF_OperationOutputListLength(TF_Operation oper, + @Cast("const char*") BytePointer arg_name, + TF_Status status); +public static native int TF_OperationOutputListLength(TF_Operation oper, + String arg_name, + TF_Status status); + +public static native int TF_OperationNumInputs(TF_Operation oper); +public static native @Cast("TF_DataType") int TF_OperationInputType(@ByVal TF_Input oper_in); +public static native int TF_OperationInputListLength(TF_Operation oper, + @Cast("const char*") BytePointer arg_name, + TF_Status status); +public static native int TF_OperationInputListLength(TF_Operation oper, + String arg_name, + TF_Status status); + +// In this code: +// TF_Output producer = TF_OperationInput(consumer); +// There is an edge from producer.oper's output (given by +// producer.index) to consumer.oper's input (given by consumer.index). +public static native @ByVal TF_Output TF_OperationInput(@ByVal TF_Input oper_in); + +// Get the number of current consumers of a specific output of an +// operation. Note that this number can change when new operations +// are added to the graph. +public static native int TF_OperationOutputNumConsumers(@ByVal TF_Output oper_out); + +// Get list of all current consumers of a specific output of an +// operation. `consumers` must point to an array of length at least +// `max_consumers` (ideally set to +// TF_OperationOutputNumConsumers(oper_out)). Beware that a concurrent +// modification of the graph can increase the number of consumers of +// an operation. Returns the number of output consumers (should match +// TF_OperationOutputNumConsumers(oper_out)). +public static native int TF_OperationOutputConsumers(@ByVal TF_Output oper_out, + TF_Input consumers, + int max_consumers); + +// Get the number of control inputs to an operation. +public static native int TF_OperationNumControlInputs(TF_Operation oper); + +// Get list of all control inputs to an operation. `control_inputs` must +// point to an array of length `max_control_inputs` (ideally set to +// TF_OperationNumControlInputs(oper)). Returns the number of control +// inputs (should match TF_OperationNumControlInputs(oper)). +public static native int TF_OperationGetControlInputs( + TF_Operation oper, @Cast("TF_Operation**") PointerPointer control_inputs, int max_control_inputs); +public static native int TF_OperationGetControlInputs( + TF_Operation oper, @ByPtrPtr TF_Operation control_inputs, int max_control_inputs); + +// Get the number of operations that have `*oper` as a control input. +// Note that this number can change when new operations are added to +// the graph. +public static native int TF_OperationNumControlOutputs(TF_Operation oper); + +// Get the list of operations that have `*oper` as a control input. +// `control_outputs` must point to an array of length at least +// `max_control_outputs` (ideally set to +// TF_OperationNumControlOutputs(oper)). Beware that a concurrent +// modification of the graph can increase the number of control +// outputs. Returns the number of control outputs (should match +// TF_OperationNumControlOutputs(oper)). +public static native int TF_OperationGetControlOutputs( + TF_Operation oper, @Cast("TF_Operation**") PointerPointer control_outputs, + int max_control_outputs); +public static native int TF_OperationGetControlOutputs( + TF_Operation oper, @ByPtrPtr TF_Operation control_outputs, + int max_control_outputs); +// Targeting ../TF_AttrMetadata.java + + + +// Returns metadata about the value of the attribute `attr_name` of `oper`. +public static native @ByVal TF_AttrMetadata TF_OperationGetAttrMetadata( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, TF_Status status); +public static native @ByVal TF_AttrMetadata TF_OperationGetAttrMetadata( + TF_Operation oper, String attr_name, TF_Status status); + +// Fills in `value` with the value of the attribute `attr_name`. `value` must +// point to an array of length at least `max_length` (ideally set to +// TF_AttrMetadata.total_size from TF_OperationGetAttrMetadata(oper, +// attr_name)). +public static native void TF_OperationGetAttrString(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + Pointer value, + @Cast("size_t") long max_length, + TF_Status status); +public static native void TF_OperationGetAttrString(TF_Operation oper, + String attr_name, + Pointer value, + @Cast("size_t") long max_length, + TF_Status status); + +// Get the list of strings in the value of the attribute `attr_name`. Fills in +// `values` and `lengths`, each of which must point to an array of length at +// least `max_values`. +// +// The elements of values will point to addresses in `storage` which must be at +// least `storage_size` bytes in length. Ideally, max_values would be set to +// TF_AttrMetadata.list_size and `storage` would be at least +// TF_AttrMetadata.total_size, obtained from TF_OperationGetAttrMetadata(oper, +// attr_name). +// +// Fails if storage_size is too small to hold the requested number of strings. +public static native void TF_OperationGetAttrStringList( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, @Cast("void**") PointerPointer values, @Cast("size_t*") SizeTPointer lengths, + int max_values, Pointer storage, @Cast("size_t") long storage_size, TF_Status status); +public static native void TF_OperationGetAttrStringList( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, @Cast("void**") @ByPtrPtr Pointer values, @Cast("size_t*") SizeTPointer lengths, + int max_values, Pointer storage, @Cast("size_t") long storage_size, TF_Status status); +public static native void TF_OperationGetAttrStringList( + TF_Operation oper, String attr_name, @Cast("void**") @ByPtrPtr Pointer values, @Cast("size_t*") SizeTPointer lengths, + int max_values, Pointer storage, @Cast("size_t") long storage_size, TF_Status status); + +public static native void TF_OperationGetAttrInt(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("int64_t*") LongPointer value, + TF_Status status); +public static native void TF_OperationGetAttrInt(TF_Operation oper, + String attr_name, + @Cast("int64_t*") LongBuffer value, + TF_Status status); +public static native void TF_OperationGetAttrInt(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("int64_t*") long[] value, + TF_Status status); +public static native void TF_OperationGetAttrInt(TF_Operation oper, + String attr_name, + @Cast("int64_t*") LongPointer value, + TF_Status status); +public static native void TF_OperationGetAttrInt(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("int64_t*") LongBuffer value, + TF_Status status); +public static native void TF_OperationGetAttrInt(TF_Operation oper, + String attr_name, + @Cast("int64_t*") long[] value, + TF_Status status); + +// Fills in `values` with the value of the attribute `attr_name` of `oper`. +// `values` must point to an array of length at least `max_values` (ideally set +// TF_AttrMetadata.list_size from TF_OperationGetAttrMetadata(oper, +// attr_name)). +public static native void TF_OperationGetAttrIntList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("int64_t*") LongPointer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrIntList(TF_Operation oper, + String attr_name, + @Cast("int64_t*") LongBuffer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrIntList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("int64_t*") long[] values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrIntList(TF_Operation oper, + String attr_name, + @Cast("int64_t*") LongPointer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrIntList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("int64_t*") LongBuffer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrIntList(TF_Operation oper, + String attr_name, + @Cast("int64_t*") long[] values, + int max_values, + TF_Status status); + +public static native void TF_OperationGetAttrFloat(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + FloatPointer value, + TF_Status status); +public static native void TF_OperationGetAttrFloat(TF_Operation oper, + String attr_name, + FloatBuffer value, + TF_Status status); +public static native void TF_OperationGetAttrFloat(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + float[] value, + TF_Status status); +public static native void TF_OperationGetAttrFloat(TF_Operation oper, + String attr_name, + FloatPointer value, + TF_Status status); +public static native void TF_OperationGetAttrFloat(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + FloatBuffer value, + TF_Status status); +public static native void TF_OperationGetAttrFloat(TF_Operation oper, + String attr_name, + float[] value, + TF_Status status); + +// Fills in `values` with the value of the attribute `attr_name` of `oper`. +// `values` must point to an array of length at least `max_values` (ideally set +// to TF_AttrMetadata.list_size from TF_OperationGetAttrMetadata(oper, +// attr_name)). +public static native void TF_OperationGetAttrFloatList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + FloatPointer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrFloatList(TF_Operation oper, + String attr_name, + FloatBuffer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrFloatList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + float[] values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrFloatList(TF_Operation oper, + String attr_name, + FloatPointer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrFloatList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + FloatBuffer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrFloatList(TF_Operation oper, + String attr_name, + float[] values, + int max_values, + TF_Status status); + +public static native void TF_OperationGetAttrBool(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") BytePointer value, + TF_Status status); +public static native void TF_OperationGetAttrBool(TF_Operation oper, + String attr_name, + @Cast("unsigned char*") ByteBuffer value, + TF_Status status); +public static native void TF_OperationGetAttrBool(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") byte[] value, + TF_Status status); +public static native void TF_OperationGetAttrBool(TF_Operation oper, + String attr_name, + @Cast("unsigned char*") BytePointer value, + TF_Status status); +public static native void TF_OperationGetAttrBool(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") ByteBuffer value, + TF_Status status); +public static native void TF_OperationGetAttrBool(TF_Operation oper, + String attr_name, + @Cast("unsigned char*") byte[] value, + TF_Status status); + +// Fills in `values` with the value of the attribute `attr_name` of `oper`. +// `values` must point to an array of length at least `max_values` (ideally set +// to TF_AttrMetadata.list_size from TF_OperationGetAttrMetadata(oper, +// attr_name)). +public static native void TF_OperationGetAttrBoolList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") BytePointer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrBoolList(TF_Operation oper, + String attr_name, + @Cast("unsigned char*") ByteBuffer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrBoolList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") byte[] values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrBoolList(TF_Operation oper, + String attr_name, + @Cast("unsigned char*") BytePointer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrBoolList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") ByteBuffer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrBoolList(TF_Operation oper, + String attr_name, + @Cast("unsigned char*") byte[] values, + int max_values, + TF_Status status); + +public static native void TF_OperationGetAttrType(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_DataType*") IntPointer value, + TF_Status status); +public static native void TF_OperationGetAttrType(TF_Operation oper, + String attr_name, + @Cast("TF_DataType*") IntBuffer value, + TF_Status status); +public static native void TF_OperationGetAttrType(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_DataType*") int[] value, + TF_Status status); +public static native void TF_OperationGetAttrType(TF_Operation oper, + String attr_name, + @Cast("TF_DataType*") IntPointer value, + TF_Status status); +public static native void TF_OperationGetAttrType(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_DataType*") IntBuffer value, + TF_Status status); +public static native void TF_OperationGetAttrType(TF_Operation oper, + String attr_name, + @Cast("TF_DataType*") int[] value, + TF_Status status); + +// Fills in `values` with the value of the attribute `attr_name` of `oper`. +// `values` must point to an array of length at least `max_values` (ideally set +// to TF_AttrMetadata.list_size from TF_OperationGetAttrMetadata(oper, +// attr_name)). +public static native void TF_OperationGetAttrTypeList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_DataType*") IntPointer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrTypeList(TF_Operation oper, + String attr_name, + @Cast("TF_DataType*") IntBuffer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrTypeList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_DataType*") int[] values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrTypeList(TF_Operation oper, + String attr_name, + @Cast("TF_DataType*") IntPointer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrTypeList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_DataType*") IntBuffer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrTypeList(TF_Operation oper, + String attr_name, + @Cast("TF_DataType*") int[] values, + int max_values, + TF_Status status); + +// Fills in `value` with the value of the attribute `attr_name` of `oper`. +// `values` must point to an array of length at least `num_dims` (ideally set to +// TF_Attr_Meta.size from TF_OperationGetAttrMetadata(oper, attr_name)). +public static native void TF_OperationGetAttrShape(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("int64_t*") LongPointer value, + int num_dims, + TF_Status status); +public static native void TF_OperationGetAttrShape(TF_Operation oper, + String attr_name, + @Cast("int64_t*") LongBuffer value, + int num_dims, + TF_Status status); +public static native void TF_OperationGetAttrShape(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("int64_t*") long[] value, + int num_dims, + TF_Status status); +public static native void TF_OperationGetAttrShape(TF_Operation oper, + String attr_name, + @Cast("int64_t*") LongPointer value, + int num_dims, + TF_Status status); +public static native void TF_OperationGetAttrShape(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("int64_t*") LongBuffer value, + int num_dims, + TF_Status status); +public static native void TF_OperationGetAttrShape(TF_Operation oper, + String attr_name, + @Cast("int64_t*") long[] value, + int num_dims, + TF_Status status); + +// Fills in `dims` with the list of shapes in the attribute `attr_name` of +// `oper` and `num_dims` with the corresponding number of dimensions. On return, +// for every i where `num_dims[i]` > 0, `dims[i]` will be an array of +// `num_dims[i]` elements. A value of -1 for `num_dims[i]` indicates that the +// i-th shape in the list is unknown. +// +// The elements of `dims` will point to addresses in `storage` which must be +// large enough to hold at least `storage_size` int64_ts. Ideally, `num_shapes` +// would be set to TF_AttrMetadata.list_size and `storage_size` would be set to +// TF_AttrMetadata.total_size from TF_OperationGetAttrMetadata(oper, +// attr_name). +// +// Fails if storage_size is insufficient to hold the requested shapes. +public static native void TF_OperationGetAttrShapeList( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, @Cast("int64_t**") PointerPointer dims, IntPointer num_dims, + int num_shapes, @Cast("int64_t*") LongPointer storage, int storage_size, TF_Status status); +public static native void TF_OperationGetAttrShapeList( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, @Cast("int64_t**") @ByPtrPtr LongPointer dims, IntPointer num_dims, + int num_shapes, @Cast("int64_t*") LongPointer storage, int storage_size, TF_Status status); +public static native void TF_OperationGetAttrShapeList( + TF_Operation oper, String attr_name, @Cast("int64_t**") @ByPtrPtr LongBuffer dims, IntBuffer num_dims, + int num_shapes, @Cast("int64_t*") LongBuffer storage, int storage_size, TF_Status status); +public static native void TF_OperationGetAttrShapeList( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, @Cast("int64_t**") @ByPtrPtr long[] dims, int[] num_dims, + int num_shapes, @Cast("int64_t*") long[] storage, int storage_size, TF_Status status); +public static native void TF_OperationGetAttrShapeList( + TF_Operation oper, String attr_name, @Cast("int64_t**") @ByPtrPtr LongPointer dims, IntPointer num_dims, + int num_shapes, @Cast("int64_t*") LongPointer storage, int storage_size, TF_Status status); +public static native void TF_OperationGetAttrShapeList( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, @Cast("int64_t**") @ByPtrPtr LongBuffer dims, IntBuffer num_dims, + int num_shapes, @Cast("int64_t*") LongBuffer storage, int storage_size, TF_Status status); +public static native void TF_OperationGetAttrShapeList( + TF_Operation oper, String attr_name, @Cast("int64_t**") @ByPtrPtr long[] dims, int[] num_dims, + int num_shapes, @Cast("int64_t*") long[] storage, int storage_size, TF_Status status); + +// Sets `value` to the binary-serialized TensorShapeProto of the value of +// `attr_name` attribute of `oper`'. +public static native void TF_OperationGetAttrTensorShapeProto( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, TF_Buffer value, + TF_Status status); +public static native void TF_OperationGetAttrTensorShapeProto( + TF_Operation oper, String attr_name, TF_Buffer value, + TF_Status status); + +// Fills in `values` with binary-serialized TensorShapeProto values of the +// attribute `attr_name` of `oper`. `values` must point to an array of length at +// least `num_values` (ideally set to TF_AttrMetadata.list_size from +// TF_OperationGetAttrMetadata(oper, attr_name)). +public static native void TF_OperationGetAttrTensorShapeProtoList( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, @Cast("TF_Buffer**") PointerPointer values, + int max_values, TF_Status status); +public static native void TF_OperationGetAttrTensorShapeProtoList( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, @ByPtrPtr TF_Buffer values, + int max_values, TF_Status status); +public static native void TF_OperationGetAttrTensorShapeProtoList( + TF_Operation oper, String attr_name, @ByPtrPtr TF_Buffer values, + int max_values, TF_Status status); + +// Gets the TF_Tensor valued attribute of `attr_name` of `oper`. +// +// Allocates a new TF_Tensor which the caller is expected to take +// ownership of (and can deallocate using TF_DeleteTensor). +public static native void TF_OperationGetAttrTensor(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_Tensor**") PointerPointer value, + TF_Status status); +public static native void TF_OperationGetAttrTensor(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @ByPtrPtr TF_Tensor value, + TF_Status status); +public static native void TF_OperationGetAttrTensor(TF_Operation oper, + String attr_name, + @ByPtrPtr TF_Tensor value, + TF_Status status); + +// Fills in `values` with the TF_Tensor values of the attribute `attr_name` of +// `oper`. `values` must point to an array of TF_Tensor* of length at least +// `max_values` (ideally set to TF_AttrMetadata.list_size from +// TF_OperationGetAttrMetadata(oper, attr_name)). +// +// The caller takes ownership of all the non-null TF_Tensor* entries in `values` +// (which can be deleted using TF_DeleteTensor(values[i])). +public static native void TF_OperationGetAttrTensorList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @Cast("TF_Tensor**") PointerPointer values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrTensorList(TF_Operation oper, + @Cast("const char*") BytePointer attr_name, + @ByPtrPtr TF_Tensor values, + int max_values, + TF_Status status); +public static native void TF_OperationGetAttrTensorList(TF_Operation oper, + String attr_name, + @ByPtrPtr TF_Tensor values, + int max_values, + TF_Status status); + +// Sets `output_attr_value` to the binary-serialized AttrValue proto +// representation of the value of the `attr_name` attr of `oper`. +public static native void TF_OperationGetAttrValueProto( + TF_Operation oper, @Cast("const char*") BytePointer attr_name, TF_Buffer output_attr_value, + TF_Status status); +public static native void TF_OperationGetAttrValueProto( + TF_Operation oper, String attr_name, TF_Buffer output_attr_value, + TF_Status status); + +// Returns the operation in the graph with `oper_name`. Returns nullptr if +// no operation found. +public static native TF_Operation TF_GraphOperationByName( + TF_Graph graph, @Cast("const char*") BytePointer oper_name); +public static native TF_Operation TF_GraphOperationByName( + TF_Graph graph, String oper_name); + +// Iterate through the operations of a graph. To use: +// size_t pos = 0; +// TF_Operation* oper; +// while ((oper = TF_GraphNextOperation(graph, &pos)) != nullptr) { +// DoSomethingWithOperation(oper); +// } +public static native TF_Operation TF_GraphNextOperation(TF_Graph graph, + @Cast("size_t*") SizeTPointer pos); + +// Write out a serialized representation of `graph` (as a GraphDef protocol +// message) to `output_graph_def` (allocated by TF_NewBuffer()). +// `output_graph_def`'s underlying buffer will be freed when TF_DeleteBuffer() +// is called. +// +// May fail on very large graphs in the future. +public static native void TF_GraphToGraphDef(TF_Graph graph, + TF_Buffer output_graph_def, + TF_Status status); + +// Returns the serialized OpDef proto with name `op_name`, or a bad status if no +// such op exists. This can return OpDefs of functions copied into the graph. +public static native void TF_GraphGetOpDef(TF_Graph graph, + @Cast("const char*") BytePointer op_name, + TF_Buffer output_op_def, + TF_Status status); +public static native void TF_GraphGetOpDef(TF_Graph graph, + String op_name, + TF_Buffer output_op_def, + TF_Status status); + +// Returns the serialized VersionDef proto for this graph. +public static native void TF_GraphVersions(TF_Graph graph, + TF_Buffer output_version_def, + TF_Status status); +// Targeting ../TF_ImportGraphDefOptions.java + + + +public static native TF_ImportGraphDefOptions TF_NewImportGraphDefOptions(); +public static native void TF_DeleteImportGraphDefOptions( + TF_ImportGraphDefOptions opts); + +// Set the prefix to be prepended to the names of nodes in `graph_def` that will +// be imported into `graph`. `prefix` is copied and has no lifetime +// requirements. +public static native void TF_ImportGraphDefOptionsSetPrefix( + TF_ImportGraphDefOptions opts, @Cast("const char*") BytePointer prefix); +public static native void TF_ImportGraphDefOptionsSetPrefix( + TF_ImportGraphDefOptions opts, String prefix); + +// Set the execution device for nodes in `graph_def`. +// Only applies to nodes where a device was not already explicitly specified. +// `device` is copied and has no lifetime requirements. +public static native void TF_ImportGraphDefOptionsSetDefaultDevice( + TF_ImportGraphDefOptions opts, @Cast("const char*") BytePointer device); +public static native void TF_ImportGraphDefOptionsSetDefaultDevice( + TF_ImportGraphDefOptions opts, String device); + +// Set whether to uniquify imported operation names. If true, imported operation +// names will be modified if their name already exists in the graph. If false, +// conflicting names will be treated as an error. Note that this option has no +// effect if a prefix is set, since the prefix will guarantee all names are +// unique. Defaults to false. +public static native void TF_ImportGraphDefOptionsSetUniquifyNames( + TF_ImportGraphDefOptions opts, @Cast("unsigned char") byte uniquify_names); + +// If true, the specified prefix will be modified if it already exists as an +// operation name or prefix in the graph. If false, a conflicting prefix will be +// treated as an error. This option has no effect if no prefix is specified. +public static native void TF_ImportGraphDefOptionsSetUniquifyPrefix( + TF_ImportGraphDefOptions opts, @Cast("unsigned char") byte uniquify_prefix); + +// Set any imported nodes with input `src_name:src_index` to have that input +// replaced with `dst`. `src_name` refers to a node in the graph to be imported, +// `dst` references a node already existing in the graph being imported into. +// `src_name` is copied and has no lifetime requirements. +public static native void TF_ImportGraphDefOptionsAddInputMapping( + TF_ImportGraphDefOptions opts, @Cast("const char*") BytePointer src_name, int src_index, + @ByVal TF_Output dst); +public static native void TF_ImportGraphDefOptionsAddInputMapping( + TF_ImportGraphDefOptions opts, String src_name, int src_index, + @ByVal TF_Output dst); + +// Set any imported nodes with control input `src_name` to have that input +// replaced with `dst`. `src_name` refers to a node in the graph to be imported, +// `dst` references an operation already existing in the graph being imported +// into. `src_name` is copied and has no lifetime requirements. +public static native void TF_ImportGraphDefOptionsRemapControlDependency( + TF_ImportGraphDefOptions opts, @Cast("const char*") BytePointer src_name, TF_Operation dst); +public static native void TF_ImportGraphDefOptionsRemapControlDependency( + TF_ImportGraphDefOptions opts, String src_name, TF_Operation dst); + +// Cause the imported graph to have a control dependency on `oper`. `oper` +// should exist in the graph being imported into. +public static native void TF_ImportGraphDefOptionsAddControlDependency( + TF_ImportGraphDefOptions opts, TF_Operation oper); + +// Add an output in `graph_def` to be returned via the `return_outputs` output +// parameter of TF_GraphImportGraphDef(). If the output is remapped via an input +// mapping, the corresponding existing tensor in `graph` will be returned. +// `oper_name` is copied and has no lifetime requirements. +public static native void TF_ImportGraphDefOptionsAddReturnOutput( + TF_ImportGraphDefOptions opts, @Cast("const char*") BytePointer oper_name, int index); +public static native void TF_ImportGraphDefOptionsAddReturnOutput( + TF_ImportGraphDefOptions opts, String oper_name, int index); + +// Returns the number of return outputs added via +// TF_ImportGraphDefOptionsAddReturnOutput(). +public static native int TF_ImportGraphDefOptionsNumReturnOutputs( + @Const TF_ImportGraphDefOptions opts); + +// Add an operation in `graph_def` to be returned via the `return_opers` output +// parameter of TF_GraphImportGraphDef(). `oper_name` is copied and has no +// lifetime requirements. +public static native void TF_ImportGraphDefOptionsAddReturnOperation( + TF_ImportGraphDefOptions opts, @Cast("const char*") BytePointer oper_name); +public static native void TF_ImportGraphDefOptionsAddReturnOperation( + TF_ImportGraphDefOptions opts, String oper_name); + +// Returns the number of return operations added via +// TF_ImportGraphDefOptionsAddReturnOperation(). +public static native int TF_ImportGraphDefOptionsNumReturnOperations( + @Const TF_ImportGraphDefOptions opts); +// Targeting ../TF_ImportGraphDefResults.java + + + +// Fetches the return outputs requested via +// TF_ImportGraphDefOptionsAddReturnOutput(). The number of fetched outputs is +// returned in `num_outputs`. The array of return outputs is returned in +// `outputs`. `*outputs` is owned by and has the lifetime of `results`. +public static native void TF_ImportGraphDefResultsReturnOutputs( + TF_ImportGraphDefResults results, IntPointer num_outputs, @Cast("TF_Output**") PointerPointer outputs); +public static native void TF_ImportGraphDefResultsReturnOutputs( + TF_ImportGraphDefResults results, IntPointer num_outputs, @ByPtrPtr TF_Output outputs); +public static native void TF_ImportGraphDefResultsReturnOutputs( + TF_ImportGraphDefResults results, IntBuffer num_outputs, @ByPtrPtr TF_Output outputs); +public static native void TF_ImportGraphDefResultsReturnOutputs( + TF_ImportGraphDefResults results, int[] num_outputs, @ByPtrPtr TF_Output outputs); + +// Fetches the return operations requested via +// TF_ImportGraphDefOptionsAddReturnOperation(). The number of fetched +// operations is returned in `num_opers`. The array of return operations is +// returned in `opers`. `*opers` is owned by and has the lifetime of `results`. +public static native void TF_ImportGraphDefResultsReturnOperations( + TF_ImportGraphDefResults results, IntPointer num_opers, @Cast("TF_Operation***") @ByPtrPtr PointerPointer opers); +public static native void TF_ImportGraphDefResultsReturnOperations( + TF_ImportGraphDefResults results, IntBuffer num_opers, @Cast("TF_Operation***") @ByPtrPtr PointerPointer opers); +public static native void TF_ImportGraphDefResultsReturnOperations( + TF_ImportGraphDefResults results, int[] num_opers, @Cast("TF_Operation***") @ByPtrPtr PointerPointer opers); + +// Fetches any input mappings requested via +// TF_ImportGraphDefOptionsAddInputMapping() that didn't appear in the GraphDef +// and weren't used as input to any node in the imported graph def. The number +// of fetched mappings is returned in `num_missing_unused_input_mappings`. The +// array of each mapping's source node name is returned in `src_names`, and the +// array of each mapping's source index is returned in `src_indexes`. +// +// `*src_names`, `*src_indexes`, and the memory backing each string in +// `src_names` are owned by and have the lifetime of `results`. +public static native void TF_ImportGraphDefResultsMissingUnusedInputMappings( + TF_ImportGraphDefResults results, IntPointer num_missing_unused_input_mappings, + @Cast("const char***") @ByPtrPtr PointerPointer src_names, @Cast("int**") PointerPointer src_indexes); +public static native void TF_ImportGraphDefResultsMissingUnusedInputMappings( + TF_ImportGraphDefResults results, IntPointer num_missing_unused_input_mappings, + @Cast("const char***") @ByPtrPtr PointerPointer src_names, @ByPtrPtr IntPointer src_indexes); +public static native void TF_ImportGraphDefResultsMissingUnusedInputMappings( + TF_ImportGraphDefResults results, IntBuffer num_missing_unused_input_mappings, + @Cast("const char***") @ByPtrPtr PointerPointer src_names, @ByPtrPtr IntBuffer src_indexes); +public static native void TF_ImportGraphDefResultsMissingUnusedInputMappings( + TF_ImportGraphDefResults results, int[] num_missing_unused_input_mappings, + @Cast("const char***") @ByPtrPtr PointerPointer src_names, @ByPtrPtr int[] src_indexes); + +// Deletes a results object returned by TF_GraphImportGraphDefWithResults(). +public static native void TF_DeleteImportGraphDefResults( + TF_ImportGraphDefResults results); + +// Import the graph serialized in `graph_def` into `graph`. Returns nullptr and +// a bad status on error. Otherwise, returns a populated +// TF_ImportGraphDefResults instance. The returned instance must be deleted via +// TF_DeleteImportGraphDefResults(). +public static native TF_ImportGraphDefResults TF_GraphImportGraphDefWithResults(TF_Graph graph, @Const TF_Buffer graph_def, + @Const TF_ImportGraphDefOptions options, + TF_Status status); + +// Import the graph serialized in `graph_def` into `graph`. +// Convenience function for when only return outputs are needed. +// +// `num_return_outputs` must be the number of return outputs added (i.e. the +// result of TF_ImportGraphDefOptionsNumReturnOutputs()). If +// `num_return_outputs` is non-zero, `return_outputs` must be of length +// `num_return_outputs`. Otherwise it can be null. +public static native void TF_GraphImportGraphDefWithReturnOutputs( + TF_Graph graph, @Const TF_Buffer graph_def, + @Const TF_ImportGraphDefOptions options, TF_Output return_outputs, + int num_return_outputs, TF_Status status); + +// Import the graph serialized in `graph_def` into `graph`. +// Convenience function for when no results are needed. +public static native void TF_GraphImportGraphDef( + TF_Graph graph, @Const TF_Buffer graph_def, + @Const TF_ImportGraphDefOptions options, TF_Status status); + +// Adds a copy of function `func` and optionally its gradient function `grad` +// to `g`. Once `func`/`grad` is added to `g`, it can be called by creating +// an operation using the function's name. +// Any changes to `func`/`grad` (including deleting it) done after this method +// returns, won't affect the copy of `func`/`grad` in `g`. +// If `func` or `grad` are already in `g`, TF_GraphCopyFunction has no +// effect on them, but can establish the function->gradient relationship +// between them if `func` does not already have a gradient. If `func` already +// has a gradient different from `grad`, an error is returned. +// +// `func` must not be null. +// If `grad` is null and `func` is not in `g`, `func` is added without a +// gradient. +// If `grad` is null and `func` is in `g`, TF_GraphCopyFunction is a noop. +// `grad` must have appropriate signature as described in the doc of +// GradientDef in tensorflow/core/framework/function.proto. +// +// If successful, status is set to OK and `func` and `grad` are added to `g`. +// Otherwise, status is set to the encountered error and `g` is unmodified. +public static native void TF_GraphCopyFunction(TF_Graph g, + @Const TF_Function func, + @Const TF_Function grad, + TF_Status status); + +// Returns the number of TF_Functions registered in `g`. +public static native int TF_GraphNumFunctions(TF_Graph g); + +// Fills in `funcs` with the TF_Function* registered in `g`. +// `funcs` must point to an array of TF_Function* of length at least +// `max_func`. In usual usage, max_func should be set to the result of +// TF_GraphNumFunctions(g). In this case, all the functions registered in +// `g` will be returned. Else, an unspecified subset. +// +// If successful, returns the number of TF_Function* successfully set in +// `funcs` and sets status to OK. The caller takes ownership of +// all the returned TF_Functions. They must be deleted with TF_DeleteFunction. +// On error, returns 0, sets status to the encountered error, and the contents +// of funcs will be undefined. +public static native int TF_GraphGetFunctions(TF_Graph g, @Cast("TF_Function**") PointerPointer funcs, + int max_func, TF_Status status); +public static native int TF_GraphGetFunctions(TF_Graph g, @ByPtrPtr TF_Function funcs, + int max_func, TF_Status status); + +// Note: The following function may fail on very large protos in the future. + +public static native void TF_OperationToNodeDef(TF_Operation oper, + TF_Buffer output_node_def, + TF_Status status); +// Targeting ../TF_WhileParams.java + + + +// Creates a TF_WhileParams for creating a while loop in `g`. `inputs` are +// outputs that already exist in `g` used as initial values for the loop +// variables. +// +// The returned TF_WhileParams will have all fields initialized except +// `cond_output`, `body_outputs`, and `name`. The `body_outputs` buffer will be +// allocated to size `ninputs`. The caller should build `cond_graph` and +// `body_graph` starting from the inputs, and store the final outputs in +// `cond_output` and `body_outputs`. +// +// If `status` is OK, the caller must call either TF_FinishWhile or +// TF_AbortWhile on the returned TF_WhileParams. If `status` isn't OK, the +// returned TF_WhileParams is not valid, and the caller should not call +// TF_FinishWhile() or TF_AbortWhile(). +// +// Missing functionality (TODO): +// - Gradients +// - Reference-type inputs +// - Directly referencing external tensors from the cond/body graphs (this is +// possible in the Python API) +public static native @ByVal TF_WhileParams TF_NewWhile(TF_Graph g, TF_Output inputs, + int ninputs, + TF_Status status); + +// Builds the while loop specified by `params` and returns the output tensors of +// the while loop in `outputs`. `outputs` should be allocated to size +// `params.ninputs`. +// +// `params` is no longer valid once this returns. +// +// Either this or TF_AbortWhile() must be called after a successful +// TF_NewWhile() call. +public static native void TF_FinishWhile(@Const TF_WhileParams params, + TF_Status status, + TF_Output outputs); + +// Frees `params`s resources without building a while loop. `params` is no +// longer valid after this returns. Either this or TF_FinishWhile() must be +// called after a successful TF_NewWhile() call. +public static native void TF_AbortWhile(@Const TF_WhileParams params); + +// Adds operations to compute the partial derivatives of sum of `y`s w.r.t `x`s, +// i.e., d(y_1 + y_2 + ...)/dx_1, d(y_1 + y_2 + ...)/dx_2... +// +// `dx` are used as initial gradients (which represent the symbolic partial +// derivatives of some loss function `L` w.r.t. `y`). +// `dx` must be nullptr or have size `ny`. +// If `dx` is nullptr, the implementation will use dx of `OnesLike` for all +// shapes in `y`. +// The partial derivatives are returned in `dy`. `dy` should be allocated to +// size `nx`. +// +// Gradient nodes are automatically named under the "gradients/" prefix. To +// guarantee name uniqueness, subsequent calls to the same graph will +// append an incremental tag to the prefix: "gradients_1/", "gradients_2/", ... +// See TF_AddGradientsWithPrefix, which provides a means to specify a custom +// name prefix for operations added to a graph to compute the gradients. +// +// WARNING: This function does not yet support all the gradients that python +// supports. See +// https://www.tensorflow.org/code/tensorflow/cc/gradients/README.md +// for instructions on how to add C++ more gradients. +public static native void TF_AddGradients(TF_Graph g, TF_Output y, int ny, + TF_Output x, int nx, TF_Output dx, + TF_Status status, TF_Output dy); + +// Adds operations to compute the partial derivatives of sum of `y`s w.r.t `x`s, +// i.e., d(y_1 + y_2 + ...)/dx_1, d(y_1 + y_2 + ...)/dx_2... +// This is a variant of TF_AddGradients that allows to caller to pass a custom +// name prefix to the operations added to a graph to compute the gradients. +// +// `dx` are used as initial gradients (which represent the symbolic partial +// derivatives of some loss function `L` w.r.t. `y`). +// `dx` must be nullptr or have size `ny`. +// If `dx` is nullptr, the implementation will use dx of `OnesLike` for all +// shapes in `y`. +// The partial derivatives are returned in `dy`. `dy` should be allocated to +// size `nx`. +// `prefix` names the scope into which all gradients operations are being added. +// `prefix` must be unique within the provided graph otherwise this operation +// will fail. If `prefix` is nullptr, the default prefixing behaviour takes +// place, see TF_AddGradients for more details. +// +// WARNING: This function does not yet support all the gradients that python +// supports. See +// https://www.tensorflow.org/code/tensorflow/cc/gradients/README.md +// for instructions on how to add C++ more gradients. +public static native void TF_AddGradientsWithPrefix(TF_Graph g, @Cast("const char*") BytePointer prefix, + TF_Output y, int ny, + TF_Output x, int nx, + TF_Output dx, TF_Status status, + TF_Output dy); +public static native void TF_AddGradientsWithPrefix(TF_Graph g, String prefix, + TF_Output y, int ny, + TF_Output x, int nx, + TF_Output dx, TF_Status status, + TF_Output dy); + +// Create a TF_Function from a TF_Graph +// +// Params: +// fn_body - the graph whose operations (or subset of whose operations) will be +// converted to TF_Function. +// fn_name - the name of the new TF_Function. Should match the operation +// name (OpDef.name) regexp [A-Z][A-Za-z0-9_.\\-/]*. +// If `append_hash_to_fn_name` is false, `fn_name` must be distinct +// from other function and operation names (at least those +// registered in graphs where this function will be used). +// append_hash_to_fn_name - Must be 0 or 1. If set to 1, the actual name +// of the function will be `fn_name` appended with +// '_'. +// If set to 0, the function's name will be `fn_name`. +// num_opers - `num_opers` contains the number of elements in the `opers` array +// or a special value of -1 meaning that no array is given. +// The distinction between an empty array of operations and no +// array of operations is necessary to distinguish the case of +// creating a function with no body (e.g. identity or permutation) +// and the case of creating a function whose body contains all +// the nodes in the graph (except for the automatic skipping, see +// below). +// opers - Array of operations to become the body of the function or null. +// - If no array is given (`num_opers` = -1), all the +// operations in `fn_body` will become part of the function +// except operations referenced in `inputs`. These operations +// must have a single output (these operations are typically +// placeholders created for the sole purpose of representing +// an input. We can relax this constraint if there are +// compelling use cases). +// - If an array is given (`num_opers` >= 0), all operations +// in it will become part of the function. In particular, no +// automatic skipping of dummy input operations is performed. +// ninputs - number of elements in `inputs` array +// inputs - array of TF_Outputs that specify the inputs to the function. +// If `ninputs` is zero (the function takes no inputs), `inputs` +// can be null. The names used for function inputs are normalized +// names of the operations (usually placeholders) pointed to by +// `inputs`. These operation names should start with a letter. +// Normalization will convert all letters to lowercase and +// non-alphanumeric characters to '_' to make resulting names match +// the "[a-z][a-z0-9_]*" pattern for operation argument names. +// `inputs` cannot contain the same tensor twice. +// noutputs - number of elements in `outputs` array +// outputs - array of TF_Outputs that specify the outputs of the function. +// If `noutputs` is zero (the function returns no outputs), `outputs` +// can be null. `outputs` can contain the same tensor more than once. +// output_names - The names of the function's outputs. `output_names` array +// must either have the same length as `outputs` +// (i.e. `noutputs`) or be null. In the former case, +// the names should match the regular expression for ArgDef +// names - "[a-z][a-z0-9_]*". In the latter case, +// names for outputs will be generated automatically. +// opts - various options for the function, e.g. XLA's inlining control. +// description - optional human-readable description of this function. +// status - Set to OK on success and an appropriate error on failure. +// +// Note that when the same TF_Output is listed as both an input and an output, +// the corresponding function's output will equal to this input, +// instead of the original node's output. +// +// Callers must also satisfy the following constraints: +// - `inputs` cannot refer to TF_Outputs within a control flow context. For +// example, one cannot use the output of "switch" node as input. +// - `inputs` and `outputs` cannot have reference types. Reference types are +// not exposed through C API and are being replaced with Resources. We support +// reference types inside function's body to support legacy code. Do not +// use them in new code. +// - Every node in the function's body must have all of its inputs (including +// control inputs). In other words, for every node in the body, each input +// must be either listed in `inputs` or must come from another node in +// the body. In particular, it is an error to have a control edge going from +// a node outside of the body into a node in the body. This applies to control +// edges going from nodes referenced in `inputs` to nodes in the body when +// the former nodes are not in the body (automatically skipped or not +// included in explicitly specified body). +// +// Returns: +// On success, a newly created TF_Function instance. It must be deleted by +// calling TF_DeleteFunction. +// +// On failure, null. +public static native TF_Function TF_GraphToFunction( + @Const TF_Graph fn_body, @Cast("const char*") BytePointer fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Cast("const TF_Operation*const*") PointerPointer opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") PointerPointer output_names, + @Const TF_FunctionOptions opts, @Cast("const char*") BytePointer description, TF_Status status); +public static native TF_Function TF_GraphToFunction( + @Const TF_Graph fn_body, @Cast("const char*") BytePointer fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr BytePointer output_names, + @Const TF_FunctionOptions opts, @Cast("const char*") BytePointer description, TF_Status status); +public static native TF_Function TF_GraphToFunction( + @Const TF_Graph fn_body, String fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr ByteBuffer output_names, + @Const TF_FunctionOptions opts, String description, TF_Status status); +public static native TF_Function TF_GraphToFunction( + @Const TF_Graph fn_body, @Cast("const char*") BytePointer fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr byte[] output_names, + @Const TF_FunctionOptions opts, @Cast("const char*") BytePointer description, TF_Status status); +public static native TF_Function TF_GraphToFunction( + @Const TF_Graph fn_body, String fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr BytePointer output_names, + @Const TF_FunctionOptions opts, String description, TF_Status status); +public static native TF_Function TF_GraphToFunction( + @Const TF_Graph fn_body, @Cast("const char*") BytePointer fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr ByteBuffer output_names, + @Const TF_FunctionOptions opts, @Cast("const char*") BytePointer description, TF_Status status); +public static native TF_Function TF_GraphToFunction( + @Const TF_Graph fn_body, String fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr byte[] output_names, + @Const TF_FunctionOptions opts, String description, TF_Status status); + +// Similar to TF_GraphToFunction but allows specifying control outputs of the +// function. +// +// The arguments of TF_GraphToFunction have the same meaning, but the new +// arguments are as follows: +// +// ncontrol_outputs: Number of control outputs of the function. +// control_outputs: vector of TF_Operation objects to be marked as control +// outputs of the function. Operations marked as control outputs are +// guaranteed to execute. +// control_output_names: Optional. If not nullptr, vector of strings, one +// per control output, with their names to be added to the function's +// OpDef. +public static native TF_Function TF_GraphToFunctionWithControlOutputs( + @Const TF_Graph fn_body, @Cast("const char*") BytePointer fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Cast("const TF_Operation*const*") PointerPointer opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") PointerPointer output_names, + int ncontrol_outputs, @Cast("const TF_Operation*const*") PointerPointer control_outputs, + @Cast("const char*const*") PointerPointer control_output_names, @Const TF_FunctionOptions opts, + @Cast("const char*") BytePointer description, TF_Status status); +public static native TF_Function TF_GraphToFunctionWithControlOutputs( + @Const TF_Graph fn_body, @Cast("const char*") BytePointer fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr BytePointer output_names, + int ncontrol_outputs, @Const @ByPtrPtr TF_Operation control_outputs, + @Cast("const char*const*") @ByPtrPtr BytePointer control_output_names, @Const TF_FunctionOptions opts, + @Cast("const char*") BytePointer description, TF_Status status); +public static native TF_Function TF_GraphToFunctionWithControlOutputs( + @Const TF_Graph fn_body, String fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr ByteBuffer output_names, + int ncontrol_outputs, @Const @ByPtrPtr TF_Operation control_outputs, + @Cast("const char*const*") @ByPtrPtr ByteBuffer control_output_names, @Const TF_FunctionOptions opts, + String description, TF_Status status); +public static native TF_Function TF_GraphToFunctionWithControlOutputs( + @Const TF_Graph fn_body, @Cast("const char*") BytePointer fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr byte[] output_names, + int ncontrol_outputs, @Const @ByPtrPtr TF_Operation control_outputs, + @Cast("const char*const*") @ByPtrPtr byte[] control_output_names, @Const TF_FunctionOptions opts, + @Cast("const char*") BytePointer description, TF_Status status); +public static native TF_Function TF_GraphToFunctionWithControlOutputs( + @Const TF_Graph fn_body, String fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr BytePointer output_names, + int ncontrol_outputs, @Const @ByPtrPtr TF_Operation control_outputs, + @Cast("const char*const*") @ByPtrPtr BytePointer control_output_names, @Const TF_FunctionOptions opts, + String description, TF_Status status); +public static native TF_Function TF_GraphToFunctionWithControlOutputs( + @Const TF_Graph fn_body, @Cast("const char*") BytePointer fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr ByteBuffer output_names, + int ncontrol_outputs, @Const @ByPtrPtr TF_Operation control_outputs, + @Cast("const char*const*") @ByPtrPtr ByteBuffer control_output_names, @Const TF_FunctionOptions opts, + @Cast("const char*") BytePointer description, TF_Status status); +public static native TF_Function TF_GraphToFunctionWithControlOutputs( + @Const TF_Graph fn_body, String fn_name, + @Cast("unsigned char") byte append_hash_to_fn_name, int num_opers, + @Const @ByPtrPtr TF_Operation opers, int ninputs, @Const TF_Output inputs, + int noutputs, @Const TF_Output outputs, @Cast("const char*const*") @ByPtrPtr byte[] output_names, + int ncontrol_outputs, @Const @ByPtrPtr TF_Operation control_outputs, + @Cast("const char*const*") @ByPtrPtr byte[] control_output_names, @Const TF_FunctionOptions opts, + String description, TF_Status status); + +// Returns the name of the graph function. +// The return value points to memory that is only usable until the next +// mutation to *func. +public static native @Cast("const char*") BytePointer TF_FunctionName(TF_Function func); + +// Write out a serialized representation of `func` (as a FunctionDef protocol +// message) to `output_func_def` (allocated by TF_NewBuffer()). +// `output_func_def`'s underlying buffer will be freed when TF_DeleteBuffer() +// is called. +// +// May fail on very large graphs in the future. +public static native void TF_FunctionToFunctionDef(TF_Function func, + TF_Buffer output_func_def, + TF_Status status); + +// Construct and return the function whose FunctionDef representation is +// serialized in `proto`. `proto_len` must equal the number of bytes +// pointed to by `proto`. +// Returns: +// On success, a newly created TF_Function instance. It must be deleted by +// calling TF_DeleteFunction. +// +// On failure, null. +public static native TF_Function TF_FunctionImportFunctionDef( + @Const Pointer proto, @Cast("size_t") long proto_len, TF_Status status); + +// Sets function attribute named `attr_name` to value stored in `proto`. +// If this attribute is already set to another value, it is overridden. +// `proto` should point to a sequence of bytes of length `proto_len` +// representing a binary serialization of an AttrValue protocol +// buffer. +public static native void TF_FunctionSetAttrValueProto(TF_Function func, + @Cast("const char*") BytePointer attr_name, + @Const Pointer proto, + @Cast("size_t") long proto_len, + TF_Status status); +public static native void TF_FunctionSetAttrValueProto(TF_Function func, + String attr_name, + @Const Pointer proto, + @Cast("size_t") long proto_len, + TF_Status status); + +// Sets `output_attr_value` to the binary-serialized AttrValue proto +// representation of the value of the `attr_name` attr of `func`. +// If `attr_name` attribute is not present, status is set to an error. +public static native void TF_FunctionGetAttrValueProto( + TF_Function func, @Cast("const char*") BytePointer attr_name, TF_Buffer output_attr_value, + TF_Status status); +public static native void TF_FunctionGetAttrValueProto( + TF_Function func, String attr_name, TF_Buffer output_attr_value, + TF_Status status); + +// Frees the memory used by the `func` struct. +// TF_DeleteFunction is a noop if `func` is null. +// Deleting a function does not remove it from any graphs it was copied to. +public static native void TF_DeleteFunction(TF_Function func); + +// Attempts to evaluate `output`. This will only be possible if `output` doesn't +// depend on any graph inputs (this function is safe to call if this isn't the +// case though). +// +// If the evaluation is successful, this function returns true and `output`s +// value is returned in `result`. Otherwise returns false. An error status is +// returned if something is wrong with the graph or input. Note that this may +// return false even if no error status is set. +public static native @Cast("unsigned char") byte TF_TryEvaluateConstant(TF_Graph graph, + @ByVal TF_Output output, + @Cast("TF_Tensor**") PointerPointer result, + TF_Status status); +public static native @Cast("unsigned char") byte TF_TryEvaluateConstant(TF_Graph graph, + @ByVal TF_Output output, + @ByPtrPtr TF_Tensor result, + TF_Status status); +// Targeting ../TF_Session.java + + + +// Return a new execution session with the associated graph, or NULL on +// error. Does not take ownership of any input parameters. +// +// *`graph` must be a valid graph (not deleted or nullptr). `graph` will be be +// kept alive for the lifetime of the returned TF_Session. New nodes can still +// be added to `graph` after this call. +public static native TF_Session TF_NewSession(TF_Graph graph, + @Const TF_SessionOptions opts, + TF_Status status); + +// This function creates a new TF_Session (which is created on success) using +// `session_options`, and then initializes state (restoring tensors and other +// assets) using `run_options`. +// +// Any NULL and non-NULL value combinations for (`run_options, `meta_graph_def`) +// are valid. +// +// - `export_dir` must be set to the path of the exported SavedModel. +// - `tags` must include the set of tags used to identify one MetaGraphDef in +// the SavedModel. +// - `graph` must be a graph newly allocated with TF_NewGraph(). +// +// If successful, populates `graph` with the contents of the Graph and +// `meta_graph_def` with the MetaGraphDef of the loaded model. +public static native TF_Session TF_LoadSessionFromSavedModel( + @Const TF_SessionOptions session_options, @Const TF_Buffer run_options, + @Cast("const char*") BytePointer export_dir, @Cast("const char*const*") PointerPointer tags, int tags_len, + TF_Graph graph, TF_Buffer meta_graph_def, TF_Status status); +public static native TF_Session TF_LoadSessionFromSavedModel( + @Const TF_SessionOptions session_options, @Const TF_Buffer run_options, + @Cast("const char*") BytePointer export_dir, @Cast("const char*const*") @ByPtrPtr BytePointer tags, int tags_len, + TF_Graph graph, TF_Buffer meta_graph_def, TF_Status status); +public static native TF_Session TF_LoadSessionFromSavedModel( + @Const TF_SessionOptions session_options, @Const TF_Buffer run_options, + String export_dir, @Cast("const char*const*") @ByPtrPtr ByteBuffer tags, int tags_len, + TF_Graph graph, TF_Buffer meta_graph_def, TF_Status status); +public static native TF_Session TF_LoadSessionFromSavedModel( + @Const TF_SessionOptions session_options, @Const TF_Buffer run_options, + @Cast("const char*") BytePointer export_dir, @Cast("const char*const*") @ByPtrPtr byte[] tags, int tags_len, + TF_Graph graph, TF_Buffer meta_graph_def, TF_Status status); +public static native TF_Session TF_LoadSessionFromSavedModel( + @Const TF_SessionOptions session_options, @Const TF_Buffer run_options, + String export_dir, @Cast("const char*const*") @ByPtrPtr BytePointer tags, int tags_len, + TF_Graph graph, TF_Buffer meta_graph_def, TF_Status status); +public static native TF_Session TF_LoadSessionFromSavedModel( + @Const TF_SessionOptions session_options, @Const TF_Buffer run_options, + @Cast("const char*") BytePointer export_dir, @Cast("const char*const*") @ByPtrPtr ByteBuffer tags, int tags_len, + TF_Graph graph, TF_Buffer meta_graph_def, TF_Status status); +public static native TF_Session TF_LoadSessionFromSavedModel( + @Const TF_SessionOptions session_options, @Const TF_Buffer run_options, + String export_dir, @Cast("const char*const*") @ByPtrPtr byte[] tags, int tags_len, + TF_Graph graph, TF_Buffer meta_graph_def, TF_Status status); + +// Close a session. +// +// Contacts any other processes associated with the session, if applicable. +// May not be called after TF_DeleteSession(). +public static native void TF_CloseSession(TF_Session arg0, TF_Status status); + +// Destroy a session object. +// +// Even if error information is recorded in *status, this call discards all +// local resources associated with the session. The session may not be used +// during or after this call (and the session drops its reference to the +// corresponding graph). +public static native void TF_DeleteSession(TF_Session arg0, TF_Status status); + +// Run the graph associated with the session starting with the supplied inputs +// (inputs[0,ninputs-1] with corresponding values in input_values[0,ninputs-1]). +// +// Any NULL and non-NULL value combinations for (`run_options`, +// `run_metadata`) are valid. +// +// - `run_options` may be NULL, in which case it will be ignored; or +// non-NULL, in which case it must point to a `TF_Buffer` containing the +// serialized representation of a `RunOptions` protocol buffer. +// - `run_metadata` may be NULL, in which case it will be ignored; or +// non-NULL, in which case it must point to an empty, freshly allocated +// `TF_Buffer` that may be updated to contain the serialized representation +// of a `RunMetadata` protocol buffer. +// +// The caller retains ownership of `input_values` (which can be deleted using +// TF_DeleteTensor). The caller also retains ownership of `run_options` and/or +// `run_metadata` (when not NULL) and should manually call TF_DeleteBuffer on +// them. +// +// On success, the tensors corresponding to outputs[0,noutputs-1] are placed in +// output_values[]. Ownership of the elements of output_values[] is transferred +// to the caller, which must eventually call TF_DeleteTensor on them. +// +// On failure, output_values[] contains NULLs. +public static native void TF_SessionRun( + TF_Session session, + @Const TF_Buffer run_options, + @Const TF_Output inputs, @Cast("TF_Tensor*const*") PointerPointer input_values, int ninputs, + @Const TF_Output outputs, @Cast("TF_Tensor**") PointerPointer output_values, int noutputs, + @Cast("const TF_Operation*const*") PointerPointer target_opers, int ntargets, + TF_Buffer run_metadata, + TF_Status arg11); +public static native void TF_SessionRun( + TF_Session session, + @Const TF_Buffer run_options, + @Const TF_Output inputs, @ByPtrPtr TF_Tensor input_values, int ninputs, + @Const TF_Output outputs, @ByPtrPtr TF_Tensor output_values, int noutputs, + @Const @ByPtrPtr TF_Operation target_opers, int ntargets, + TF_Buffer run_metadata, + TF_Status arg11); + +// Set up the graph with the intended feeds (inputs) and fetches (outputs) for a +// sequence of partial run calls. +// +// On success, returns a handle that is used for subsequent PRun calls. The +// handle should be deleted with TF_DeletePRunHandle when it is no longer +// needed. +// +// On failure, out_status contains a tensorflow::Status with an error +// message. *handle is set to nullptr. +public static native void TF_SessionPRunSetup( + TF_Session arg0, + @Const TF_Output inputs, int ninputs, + @Const TF_Output outputs, int noutputs, + @Cast("const TF_Operation*const*") PointerPointer target_opers, int ntargets, + @Cast("const char**") PointerPointer handle, + TF_Status arg8); +public static native void TF_SessionPRunSetup( + TF_Session arg0, + @Const TF_Output inputs, int ninputs, + @Const TF_Output outputs, int noutputs, + @Const @ByPtrPtr TF_Operation target_opers, int ntargets, + @Cast("const char**") @ByPtrPtr BytePointer handle, + TF_Status arg8); +public static native void TF_SessionPRunSetup( + TF_Session arg0, + @Const TF_Output inputs, int ninputs, + @Const TF_Output outputs, int noutputs, + @Const @ByPtrPtr TF_Operation target_opers, int ntargets, + @Cast("const char**") @ByPtrPtr ByteBuffer handle, + TF_Status arg8); +public static native void TF_SessionPRunSetup( + TF_Session arg0, + @Const TF_Output inputs, int ninputs, + @Const TF_Output outputs, int noutputs, + @Const @ByPtrPtr TF_Operation target_opers, int ntargets, + @Cast("const char**") @ByPtrPtr byte[] handle, + TF_Status arg8); + +// Continue to run the graph with additional feeds and fetches. The +// execution state is uniquely identified by the handle. +public static native void TF_SessionPRun( + TF_Session arg0, @Cast("const char*") BytePointer handle, + @Const TF_Output inputs, @Cast("TF_Tensor*const*") PointerPointer input_values, int ninputs, + @Const TF_Output outputs, @Cast("TF_Tensor**") PointerPointer output_values, int noutputs, + @Cast("const TF_Operation*const*") PointerPointer target_opers, int ntargets, + TF_Status arg10); +public static native void TF_SessionPRun( + TF_Session arg0, @Cast("const char*") BytePointer handle, + @Const TF_Output inputs, @ByPtrPtr TF_Tensor input_values, int ninputs, + @Const TF_Output outputs, @ByPtrPtr TF_Tensor output_values, int noutputs, + @Const @ByPtrPtr TF_Operation target_opers, int ntargets, + TF_Status arg10); +public static native void TF_SessionPRun( + TF_Session arg0, String handle, + @Const TF_Output inputs, @ByPtrPtr TF_Tensor input_values, int ninputs, + @Const TF_Output outputs, @ByPtrPtr TF_Tensor output_values, int noutputs, + @Const @ByPtrPtr TF_Operation target_opers, int ntargets, + TF_Status arg10); + +// Deletes a handle allocated by TF_SessionPRunSetup. +// Once called, no more calls to TF_SessionPRun should be made. +public static native void TF_DeletePRunHandle(@Cast("const char*") BytePointer handle); +public static native void TF_DeletePRunHandle(String handle); +// Targeting ../TF_DeprecatedSession.java + + + +public static native TF_DeprecatedSession TF_NewDeprecatedSession( + @Const TF_SessionOptions arg0, TF_Status status); +public static native void TF_CloseDeprecatedSession(TF_DeprecatedSession arg0, + TF_Status status); +public static native void TF_DeleteDeprecatedSession(TF_DeprecatedSession arg0, + TF_Status status); +public static native void TF_Reset(@Const TF_SessionOptions opt, + @Cast("const char**") PointerPointer containers, int ncontainers, + TF_Status status); +public static native void TF_Reset(@Const TF_SessionOptions opt, + @Cast("const char**") @ByPtrPtr BytePointer containers, int ncontainers, + TF_Status status); +public static native void TF_Reset(@Const TF_SessionOptions opt, + @Cast("const char**") @ByPtrPtr ByteBuffer containers, int ncontainers, + TF_Status status); +public static native void TF_Reset(@Const TF_SessionOptions opt, + @Cast("const char**") @ByPtrPtr byte[] containers, int ncontainers, + TF_Status status); +// Treat the bytes proto[0,proto_len-1] as a serialized GraphDef and +// add the nodes in that GraphDef to the graph for the session. +// +// Prefer use of TF_Session and TF_GraphImportGraphDef over this. +public static native void TF_ExtendGraph(TF_DeprecatedSession arg0, + @Const Pointer proto, @Cast("size_t") long proto_len, + TF_Status arg3); + +// See TF_SessionRun() above. +public static native void TF_Run(TF_DeprecatedSession arg0, + @Const TF_Buffer run_options, + @Cast("const char**") PointerPointer input_names, @Cast("TF_Tensor**") PointerPointer inputs, + int ninputs, @Cast("const char**") PointerPointer output_names, + @Cast("TF_Tensor**") PointerPointer outputs, int noutputs, + @Cast("const char**") PointerPointer target_oper_names, int ntargets, + TF_Buffer run_metadata, TF_Status arg11); +public static native void TF_Run(TF_DeprecatedSession arg0, + @Const TF_Buffer run_options, + @Cast("const char**") @ByPtrPtr BytePointer input_names, @ByPtrPtr TF_Tensor inputs, + int ninputs, @Cast("const char**") @ByPtrPtr BytePointer output_names, + @ByPtrPtr TF_Tensor outputs, int noutputs, + @Cast("const char**") @ByPtrPtr BytePointer target_oper_names, int ntargets, + TF_Buffer run_metadata, TF_Status arg11); +public static native void TF_Run(TF_DeprecatedSession arg0, + @Const TF_Buffer run_options, + @Cast("const char**") @ByPtrPtr ByteBuffer input_names, @ByPtrPtr TF_Tensor inputs, + int ninputs, @Cast("const char**") @ByPtrPtr ByteBuffer output_names, + @ByPtrPtr TF_Tensor outputs, int noutputs, + @Cast("const char**") @ByPtrPtr ByteBuffer target_oper_names, int ntargets, + TF_Buffer run_metadata, TF_Status arg11); +public static native void TF_Run(TF_DeprecatedSession arg0, + @Const TF_Buffer run_options, + @Cast("const char**") @ByPtrPtr byte[] input_names, @ByPtrPtr TF_Tensor inputs, + int ninputs, @Cast("const char**") @ByPtrPtr byte[] output_names, + @ByPtrPtr TF_Tensor outputs, int noutputs, + @Cast("const char**") @ByPtrPtr byte[] target_oper_names, int ntargets, + TF_Buffer run_metadata, TF_Status arg11); + +// See TF_SessionPRunSetup() above. +public static native void TF_PRunSetup(TF_DeprecatedSession arg0, + @Cast("const char**") PointerPointer input_names, int ninputs, + @Cast("const char**") PointerPointer output_names, int noutputs, + @Cast("const char**") PointerPointer target_oper_names, + int ntargets, @Cast("const char**") PointerPointer handle, + TF_Status arg8); +public static native void TF_PRunSetup(TF_DeprecatedSession arg0, + @Cast("const char**") @ByPtrPtr BytePointer input_names, int ninputs, + @Cast("const char**") @ByPtrPtr BytePointer output_names, int noutputs, + @Cast("const char**") @ByPtrPtr BytePointer target_oper_names, + int ntargets, @Cast("const char**") @ByPtrPtr BytePointer handle, + TF_Status arg8); +public static native void TF_PRunSetup(TF_DeprecatedSession arg0, + @Cast("const char**") @ByPtrPtr ByteBuffer input_names, int ninputs, + @Cast("const char**") @ByPtrPtr ByteBuffer output_names, int noutputs, + @Cast("const char**") @ByPtrPtr ByteBuffer target_oper_names, + int ntargets, @Cast("const char**") @ByPtrPtr ByteBuffer handle, + TF_Status arg8); +public static native void TF_PRunSetup(TF_DeprecatedSession arg0, + @Cast("const char**") @ByPtrPtr byte[] input_names, int ninputs, + @Cast("const char**") @ByPtrPtr byte[] output_names, int noutputs, + @Cast("const char**") @ByPtrPtr byte[] target_oper_names, + int ntargets, @Cast("const char**") @ByPtrPtr byte[] handle, + TF_Status arg8); + +// See TF_SessionPRun above. +public static native void TF_PRun(TF_DeprecatedSession arg0, @Cast("const char*") BytePointer handle, + @Cast("const char**") PointerPointer input_names, @Cast("TF_Tensor**") PointerPointer inputs, + int ninputs, @Cast("const char**") PointerPointer output_names, + @Cast("TF_Tensor**") PointerPointer outputs, int noutputs, + @Cast("const char**") PointerPointer target_oper_names, int ntargets, + TF_Status arg10); +public static native void TF_PRun(TF_DeprecatedSession arg0, @Cast("const char*") BytePointer handle, + @Cast("const char**") @ByPtrPtr BytePointer input_names, @ByPtrPtr TF_Tensor inputs, + int ninputs, @Cast("const char**") @ByPtrPtr BytePointer output_names, + @ByPtrPtr TF_Tensor outputs, int noutputs, + @Cast("const char**") @ByPtrPtr BytePointer target_oper_names, int ntargets, + TF_Status arg10); +public static native void TF_PRun(TF_DeprecatedSession arg0, String handle, + @Cast("const char**") @ByPtrPtr ByteBuffer input_names, @ByPtrPtr TF_Tensor inputs, + int ninputs, @Cast("const char**") @ByPtrPtr ByteBuffer output_names, + @ByPtrPtr TF_Tensor outputs, int noutputs, + @Cast("const char**") @ByPtrPtr ByteBuffer target_oper_names, int ntargets, + TF_Status arg10); +public static native void TF_PRun(TF_DeprecatedSession arg0, @Cast("const char*") BytePointer handle, + @Cast("const char**") @ByPtrPtr byte[] input_names, @ByPtrPtr TF_Tensor inputs, + int ninputs, @Cast("const char**") @ByPtrPtr byte[] output_names, + @ByPtrPtr TF_Tensor outputs, int noutputs, + @Cast("const char**") @ByPtrPtr byte[] target_oper_names, int ntargets, + TF_Status arg10); +public static native void TF_PRun(TF_DeprecatedSession arg0, String handle, + @Cast("const char**") @ByPtrPtr BytePointer input_names, @ByPtrPtr TF_Tensor inputs, + int ninputs, @Cast("const char**") @ByPtrPtr BytePointer output_names, + @ByPtrPtr TF_Tensor outputs, int noutputs, + @Cast("const char**") @ByPtrPtr BytePointer target_oper_names, int ntargets, + TF_Status arg10); +public static native void TF_PRun(TF_DeprecatedSession arg0, @Cast("const char*") BytePointer handle, + @Cast("const char**") @ByPtrPtr ByteBuffer input_names, @ByPtrPtr TF_Tensor inputs, + int ninputs, @Cast("const char**") @ByPtrPtr ByteBuffer output_names, + @ByPtrPtr TF_Tensor outputs, int noutputs, + @Cast("const char**") @ByPtrPtr ByteBuffer target_oper_names, int ntargets, + TF_Status arg10); +public static native void TF_PRun(TF_DeprecatedSession arg0, String handle, + @Cast("const char**") @ByPtrPtr byte[] input_names, @ByPtrPtr TF_Tensor inputs, + int ninputs, @Cast("const char**") @ByPtrPtr byte[] output_names, + @ByPtrPtr TF_Tensor outputs, int noutputs, + @Cast("const char**") @ByPtrPtr byte[] target_oper_names, int ntargets, + TF_Status arg10); +// Targeting ../TF_DeviceList.java + + + +// Lists all devices in a TF_Session. +// +// Caller takes ownership of the returned TF_DeviceList* which must eventually +// be freed with a call to TF_DeleteDeviceList. +public static native TF_DeviceList TF_SessionListDevices(TF_Session session, + TF_Status status); + +// Lists all devices in a TF_Session. +// +// Caller takes ownership of the returned TF_DeviceList* which must eventually +// be freed with a call to TF_DeleteDeviceList. +public static native TF_DeviceList TF_DeprecatedSessionListDevices( + TF_DeprecatedSession session, TF_Status status); + +// Deallocates the device list. +public static native void TF_DeleteDeviceList(TF_DeviceList list); + +// Counts the number of elements in the device list. +public static native int TF_DeviceListCount(@Const TF_DeviceList list); + +// Retrieves the full name of the device (e.g. /job:worker/replica:0/...) +// The return value will be a pointer to a null terminated string. The caller +// must not modify or delete the string. It will be deallocated upon a call to +// TF_DeleteDeviceList. +// +// If index is out of bounds, an error code will be set in the status object, +// and a null pointer will be returned. +public static native @Cast("const char*") BytePointer TF_DeviceListName(@Const TF_DeviceList list, + int index, + TF_Status status); + +// Retrieves the type of the device at the given index. +// +// The caller must not modify or delete the string. It will be deallocated upon +// a call to TF_DeleteDeviceList. +// +// If index is out of bounds, an error code will be set in the status object, +// and a null pointer will be returned. +public static native @Cast("const char*") BytePointer TF_DeviceListType(@Const TF_DeviceList list, + int index, + TF_Status status); + +// Retrieve the amount of memory associated with a given device. +// +// If index is out of bounds, an error code will be set in the status object, +// and -1 will be returned. +public static native @Cast("int64_t") long TF_DeviceListMemoryBytes( + @Const TF_DeviceList list, int index, TF_Status status); + +// Retrieve the incarnation number of a given device. +// +// If index is out of bounds, an error code will be set in the status object, +// and 0 will be returned. +public static native @Cast("uint64_t") long TF_DeviceListIncarnation( + @Const TF_DeviceList list, int index, TF_Status status); +// Targeting ../TF_Library.java + + + +// Load the library specified by library_filename and register the ops and +// kernels present in that library. +// +// Pass "library_filename" to a platform-specific mechanism for dynamically +// loading a library. The rules for determining the exact location of the +// library are platform-specific and are not documented here. +// +// On success, place OK in status and return the newly created library handle. +// The caller owns the library handle. +// +// On failure, place an error status in status and return NULL. +public static native TF_Library TF_LoadLibrary(@Cast("const char*") BytePointer library_filename, + TF_Status status); +public static native TF_Library TF_LoadLibrary(String library_filename, + TF_Status status); + +// Get the OpList of OpDefs defined in the library pointed by lib_handle. +// +// Returns a TF_Buffer. The memory pointed to by the result is owned by +// lib_handle. The data in the buffer will be the serialized OpList proto for +// ops defined in the library. +public static native @ByVal TF_Buffer TF_GetOpList(TF_Library lib_handle); + +// Frees the memory associated with the library handle. +// Does NOT unload the library. +public static native void TF_DeleteLibraryHandle(TF_Library lib_handle); + +// Get the OpList of all OpDefs defined in this address space. +// Returns a TF_Buffer, ownership of which is transferred to the caller +// (and can be freed using TF_DeleteBuffer). +// +// The data in the buffer will be the serialized OpList proto for ops registered +// in this address space. +public static native TF_Buffer TF_GetAllOpList(); +// Targeting ../TF_ApiDefMap.java + + + +// Creates a new TF_ApiDefMap instance. +// +// Params: +// op_list_buffer - TF_Buffer instance containing serialized OpList +// protocol buffer. (See +// https://www.tensorflow.org/code/tensorflow/core/framework/op_def.proto +// for the OpList proto definition). +// status - Set to OK on success and an appropriate error on failure. +public static native TF_ApiDefMap TF_NewApiDefMap(TF_Buffer op_list_buffer, + TF_Status status); + +// Deallocates a TF_ApiDefMap. +public static native void TF_DeleteApiDefMap(TF_ApiDefMap apimap); + +// Add ApiDefs to the map. +// +// `text` corresponds to a text representation of an ApiDefs protocol message. +// (https://www.tensorflow.org/code/tensorflow/core/framework/api_def.proto). +// +// The provided ApiDefs will be merged with existing ones in the map, with +// precedence given to the newly added version in case of conflicts with +// previous calls to TF_ApiDefMapPut. +public static native void TF_ApiDefMapPut(TF_ApiDefMap api_def_map, + @Cast("const char*") BytePointer text, @Cast("size_t") long text_len, + TF_Status status); +public static native void TF_ApiDefMapPut(TF_ApiDefMap api_def_map, + String text, @Cast("size_t") long text_len, + TF_Status status); + +// Returns a serialized ApiDef protocol buffer for the TensorFlow operation +// named `name`. +public static native TF_Buffer TF_ApiDefMapGet(TF_ApiDefMap api_def_map, + @Cast("const char*") BytePointer name, + @Cast("size_t") long name_len, + TF_Status status); +public static native TF_Buffer TF_ApiDefMapGet(TF_ApiDefMap api_def_map, + String name, + @Cast("size_t") long name_len, + TF_Status status); + +// -------------------------------------------------------------------------- +// Kernel definition information. + +// Returns a serialized KernelList protocol buffer containing KernelDefs for all +// registered kernels. +public static native TF_Buffer TF_GetAllRegisteredKernels(TF_Status status); + +// Returns a serialized KernelList protocol buffer containing KernelDefs for all +// kernels registered for the operation named `name`. +public static native TF_Buffer TF_GetRegisteredKernelsForOp( + @Cast("const char*") BytePointer name, TF_Status status); +public static native TF_Buffer TF_GetRegisteredKernelsForOp( + String name, TF_Status status); +// Targeting ../TF_Server.java + + + +// Creates a new in-process TensorFlow server configured using a serialized +// ServerDef protocol buffer provided via `proto` and `proto_len`. +// +// The server will not serve any requests until TF_ServerStart is invoked. +// The server will stop serving requests once TF_ServerStop or +// TF_DeleteServer is invoked. +public static native TF_Server TF_NewServer(@Const Pointer proto, + @Cast("size_t") long proto_len, + TF_Status status); + +// Starts an in-process TensorFlow server. +public static native void TF_ServerStart(TF_Server server, TF_Status status); + +// Stops an in-process TensorFlow server. +public static native void TF_ServerStop(TF_Server server, TF_Status status); + +// Blocks until the server has been successfully stopped (via TF_ServerStop or +// TF_ServerClose). +public static native void TF_ServerJoin(TF_Server server, TF_Status status); + +// Returns the target string that can be provided to TF_SetTarget() to connect +// a TF_Session to `server`. +// +// The returned string is valid only until TF_DeleteServer is invoked. +public static native @Cast("const char*") BytePointer TF_ServerTarget(TF_Server server); + +// Destroy an in-process TensorFlow server, frees memory. If server is running +// it will be stopped and joined. +public static native void TF_DeleteServer(TF_Server server); +// Targeting ../Listener_BytePointer.java + + +public static native void TF_RegisterLogListener( + Listener_BytePointer listener); +// Targeting ../Listener_String.java + + +public static native void TF_RegisterLogListener( + Listener_String listener); + +// #ifdef __cplusplus /* end extern "C" */ +// #endif + +// #endif // TENSORFLOW_C_C_API_H_ + + +// Parsed from tensorflow/c/env.h + +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// #include +// #include +// #include + +// #ifndef TENSORFLOW_C_ENV_H_ +// #define TENSORFLOW_C_ENV_H_ + +// #include "tensorflow/c/c_api.h" + +// -------------------------------------------------------------------------- +// C API for tensorflow::Env. + +// #ifdef __cplusplus +// Targeting ../TF_WritableFileHandle.java + + +// Targeting ../TF_StringStream.java + + +// Targeting ../TF_Thread.java + + +// Targeting ../TF_FileStatistics.java + + +// Targeting ../TF_ThreadOptions.java + + + +// Creates the specified directory. Typical status code are: +// * TF_OK - successfully created the directory +// * TF_ALREADY_EXISTS - directory already exists +// * TF_PERMISSION_DENIED - dirname is not writable +public static native void TF_CreateDir(@Cast("const char*") BytePointer dirname, TF_Status status); +public static native void TF_CreateDir(String dirname, TF_Status status); + +// Deletes the specified directory. Typical status codes are: +// * TF_OK - successfully deleted the directory +// * TF_FAILED_PRECONDITION - the directory is not empty +public static native void TF_DeleteDir(@Cast("const char*") BytePointer dirname, TF_Status status); +public static native void TF_DeleteDir(String dirname, TF_Status status); + +// Deletes the specified directory and all subdirectories and files underneath +// it. This is accomplished by traversing the directory tree rooted at dirname +// and deleting entries as they are encountered. +// +// If dirname itself is not readable or does not exist, *undeleted_dir_count is +// set to 1, *undeleted_file_count is set to 0 and an appropriate status (e.g. +// TF_NOT_FOUND) is returned. +// +// If dirname and all its descendants were successfully deleted, TF_OK is +// returned and both error counters are set to zero. +// +// Otherwise, while traversing the tree, undeleted_file_count and +// undeleted_dir_count are updated if an entry of the corresponding type could +// not be deleted. The returned error status represents the reason that any one +// of these entries could not be deleted. +// +// Typical status codes: +// * TF_OK - dirname exists and we were able to delete everything underneath +// * TF_NOT_FOUND - dirname doesn't exist +// * TF_PERMISSION_DENIED - dirname or some descendant is not writable +// * TF_UNIMPLEMENTED - some underlying functions (like Delete) are not +// implemented +public static native void TF_DeleteRecursively(@Cast("const char*") BytePointer dirname, + @Cast("int64_t*") LongPointer undeleted_file_count, + @Cast("int64_t*") LongPointer undeleted_dir_count, + TF_Status status); +public static native void TF_DeleteRecursively(String dirname, + @Cast("int64_t*") LongBuffer undeleted_file_count, + @Cast("int64_t*") LongBuffer undeleted_dir_count, + TF_Status status); +public static native void TF_DeleteRecursively(@Cast("const char*") BytePointer dirname, + @Cast("int64_t*") long[] undeleted_file_count, + @Cast("int64_t*") long[] undeleted_dir_count, + TF_Status status); +public static native void TF_DeleteRecursively(String dirname, + @Cast("int64_t*") LongPointer undeleted_file_count, + @Cast("int64_t*") LongPointer undeleted_dir_count, + TF_Status status); +public static native void TF_DeleteRecursively(@Cast("const char*") BytePointer dirname, + @Cast("int64_t*") LongBuffer undeleted_file_count, + @Cast("int64_t*") LongBuffer undeleted_dir_count, + TF_Status status); +public static native void TF_DeleteRecursively(String dirname, + @Cast("int64_t*") long[] undeleted_file_count, + @Cast("int64_t*") long[] undeleted_dir_count, + TF_Status status); + +// Obtains statistics for the given path. If status is TF_OK, *stats is +// updated, otherwise it is not touched. +public static native void TF_FileStat(@Cast("const char*") BytePointer filename, + TF_FileStatistics stats, + TF_Status status); +public static native void TF_FileStat(String filename, + TF_FileStatistics stats, + TF_Status status); + +// Creates or truncates the given filename and returns a handle to be used for +// appending data to the file. If status is TF_OK, *handle is updated and the +// caller is responsible for freeing it (see TF_CloseWritableFile). +public static native void TF_NewWritableFile(@Cast("const char*") BytePointer filename, + @Cast("TF_WritableFileHandle**") PointerPointer handle, + TF_Status status); +public static native void TF_NewWritableFile(@Cast("const char*") BytePointer filename, + @ByPtrPtr TF_WritableFileHandle handle, + TF_Status status); +public static native void TF_NewWritableFile(String filename, + @ByPtrPtr TF_WritableFileHandle handle, + TF_Status status); + +// Closes the given handle and frees its memory. If there was a problem closing +// the file, it is indicated by status. Memory is freed in any case. +public static native void TF_CloseWritableFile(TF_WritableFileHandle handle, + TF_Status status); + +// Syncs content of the handle to the filesystem. Blocks waiting for the +// filesystem to indicate that the content has been persisted. +public static native void TF_SyncWritableFile(TF_WritableFileHandle handle, + TF_Status status); + +// Flush local buffers to the filesystem. If the process terminates after a +// successful flush, the contents may still be persisted, since the underlying +// filesystem may eventually flush the contents. If the OS or machine crashes +// after a successful flush, the contents may or may not be persisted, depending +// on the implementation. +public static native void TF_FlushWritableFile(TF_WritableFileHandle handle, + TF_Status status); + +// Appends the given bytes to the file. Any failure to do so is indicated in +// status. +public static native void TF_AppendWritableFile(TF_WritableFileHandle handle, + @Cast("const char*") BytePointer data, + @Cast("size_t") long length, + TF_Status status); +public static native void TF_AppendWritableFile(TF_WritableFileHandle handle, + String data, + @Cast("size_t") long length, + TF_Status status); + +// Deletes the named file and indicates whether successful in *status. +public static native void TF_DeleteFile(@Cast("const char*") BytePointer filename, + TF_Status status); +public static native void TF_DeleteFile(String filename, + TF_Status status); + +// Retrieves the next item from the given TF_StringStream and places a pointer +// to it in *result. If no more items are in the list, *result is set to NULL +// and false is returned. +// +// Ownership of the items retrieved with this function remains with the library. +// Item points are invalidated after a call to TF_StringStreamDone. +public static native @Cast("bool") boolean TF_StringStreamNext(TF_StringStream list, + @Cast("const char**") PointerPointer result); +public static native @Cast("bool") boolean TF_StringStreamNext(TF_StringStream list, + @Cast("const char**") @ByPtrPtr BytePointer result); +public static native @Cast("bool") boolean TF_StringStreamNext(TF_StringStream list, + @Cast("const char**") @ByPtrPtr ByteBuffer result); +public static native @Cast("bool") boolean TF_StringStreamNext(TF_StringStream list, + @Cast("const char**") @ByPtrPtr byte[] result); + +// Frees the resources associated with given string list. All pointers returned +// by TF_StringStreamNext are invalid after this call. +public static native void TF_StringStreamDone(TF_StringStream list); + +// Retrieves the list of children of the given directory. You can iterate +// through the list with TF_StringStreamNext. The caller is responsible for +// freeing the list (see TF_StringStreamDone). +public static native TF_StringStream TF_GetChildren(@Cast("const char*") BytePointer filename, + TF_Status status); +public static native TF_StringStream TF_GetChildren(String filename, + TF_Status status); + +// Retrieves a list of directory names on the local machine that may be used for +// temporary storage. You can iterate through the list with TF_StringStreamNext. +// The caller is responsible for freeing the list (see TF_StringStreamDone). +public static native TF_StringStream TF_GetLocalTempDirectories(); + +// Returns the number of nanoseconds since the Unix epoch. +public static native @Cast("uint64_t") long TF_NowNanos(); + +// Returns the number of microseconds since the Unix epoch. +public static native @Cast("uint64_t") long TF_NowMicros(); + +// Returns the number of seconds since the Unix epoch. +public static native @Cast("uint64_t") long TF_NowSeconds(); + +// Populates a TF_ThreadOptions struct with system-default values. +public static native void TF_DefaultThreadOptions(TF_ThreadOptions options); +// Targeting ../Work_func_Pointer.java + + +public static native TF_Thread TF_StartThread(@Const TF_ThreadOptions options, + @Cast("const char*") BytePointer thread_name, + Work_func_Pointer work_func, + Pointer param); +public static native TF_Thread TF_StartThread(@Const TF_ThreadOptions options, + String thread_name, + Work_func_Pointer work_func, + Pointer param); + +// Waits for the given thread to finish execution, then deletes it. +public static native void TF_JoinThread(TF_Thread thread); + +// #ifdef __cplusplus +// #endif + +// #endif // TENSORFLOW_C_ENV_H_ + + +// Parsed from tensorflow/c/kernels.h + +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// #ifndef TENSORFLOW_C_KERNELS_H_ +// #define TENSORFLOW_C_KERNELS_H_ + +// #include + +// #include "tensorflow/c/tf_datatype.h" +// #include "tensorflow/c/tf_status.h" + +// Macro to control visibility of exported symbols in the shared library (.so, +// .dylib, .dll). +// This duplicates the TF_EXPORT macro definition in +// tensorflow/core/platform/macros.h in order to keep this .h file independent +// of any other includes. +// #ifdef SWIG +// #define TF_CAPI_EXPORT +// #else +// #if defined(_WIN32) +// #ifdef TF_COMPILE_LIBRARY +// #define TF_CAPI_EXPORT __declspec(dllexport) +// #else +// #define TF_CAPI_EXPORT __declspec(dllimport) +// #endif // TF_COMPILE_LIBRARY +// #else +// #define TF_CAPI_EXPORT __attribute__((visibility("default"))) +// #endif // _WIN32 +// #endif // SWIG + +// #ifdef __cplusplus +// #endif +// Targeting ../TF_KernelBuilder.java + + +// Targeting ../TF_OpKernelConstruction.java + + +// Targeting ../TF_OpKernelContext.java + + +// Targeting ../Create_func_TF_OpKernelConstruction.java + + +// Targeting ../Compute_func_Pointer_TF_OpKernelContext.java + + +// Targeting ../Delete_func_Pointer.java + + +public static native TF_KernelBuilder TF_NewKernelBuilder( + @Cast("const char*") BytePointer op_name, @Cast("const char*") BytePointer device_name, + Create_func_TF_OpKernelConstruction create_func, + Compute_func_Pointer_TF_OpKernelContext compute_func, + Delete_func_Pointer delete_func); +public static native TF_KernelBuilder TF_NewKernelBuilder( + String op_name, String device_name, + Create_func_TF_OpKernelConstruction create_func, + Compute_func_Pointer_TF_OpKernelContext compute_func, + Delete_func_Pointer delete_func); + +// Specifies that this kernel's attribute only supports the given type. +public static native void TF_KernelBuilder_TypeConstraint( + TF_KernelBuilder kernel_builder, @Cast("const char*") BytePointer attr_name, + @Cast("const TF_DataType") int type, TF_Status status); +public static native void TF_KernelBuilder_TypeConstraint( + TF_KernelBuilder kernel_builder, String attr_name, + @Cast("const TF_DataType") int type, TF_Status status); + +// Specify that this kernel requires/provides an input/output arg +// in host memory (instead of the default, device memory). +public static native void TF_KernelBuilder_HostMemory( + TF_KernelBuilder kernel_builder, @Cast("const char*") BytePointer arg_name); +public static native void TF_KernelBuilder_HostMemory( + TF_KernelBuilder kernel_builder, String arg_name); + +// Register the given kernel builder with the TensorFlow runtime. If +// registration fails, the given status will be populated. +// +// This call takes ownership of the `builder` pointer. +public static native void TF_RegisterKernelBuilder(@Cast("const char*") BytePointer kernel_name, + TF_KernelBuilder builder, + TF_Status status); +public static native void TF_RegisterKernelBuilder(String kernel_name, + TF_KernelBuilder builder, + TF_Status status); + +// Deletes the given TF_KernelBuilder. This should be called only if the kernel +// builder is not registered with TensorFlow via TF_RegisterKernelBuilder. +public static native void TF_DeleteKernelBuilder(TF_KernelBuilder builder); + +// -------------------------------------------------------------------------- +// OpKernelContext routines + +// TF_NumInputs returns the number of inputs available in ctx. +public static native int TF_NumInputs(TF_OpKernelContext ctx); + +// TF_NumOutputs returns the number of outputs to be placed in *ctx by the +// kernel. +public static native int TF_NumOutputs(TF_OpKernelContext ctx); + +// Retrieves the ith input from ctx. If TF_GetCode(status) is TF_OK, *tensor is +// populated and its ownership is passed to the caller. In any other case, +// *tensor is not modified. +// +// If i < 0 or i >= TF_NumInputs(ctx), *status is set to TF_OUT_OF_RANGE. +public static native void TF_GetInput(TF_OpKernelContext ctx, int i, + @Cast("TF_Tensor**") PointerPointer tensor, TF_Status status); +public static native void TF_GetInput(TF_OpKernelContext ctx, int i, + @ByPtrPtr TF_Tensor tensor, TF_Status status); + +// Sets the ith output of ctx to tensor. If TF_GetCode(status) is anything but +// TF_OK, ctx is left unmodified. +// +// If i < 0 or i >= TF_NumOutputs(ctx), *status is set to TF_OUT_OF_RANGE. +public static native void TF_SetOutput(TF_OpKernelContext ctx, int i, + @Const TF_Tensor tensor, + TF_Status status); + +// Notifies the given OpKernelConstruction that kernel construction has failed. +public static native void TF_OpKernelConstruction_Failure( + TF_OpKernelConstruction ctx, TF_Status status); + +// Notifies the given OpKernelContext that the kernel's compute function has +// failed. +public static native void TF_OpKernelContext_Failure(TF_OpKernelContext ctx, + TF_Status status); + +// Returns the expected output data type of the ith output. If i < 0 or +// i >= TF_NumOutputs(ctx), the program aborts. +public static native @Cast("TF_DataType") int TF_ExpectedOutputDataType( + TF_OpKernelContext ctx, int i); + +// Returns the step ID of the given context. +public static native @Cast("int64_t") long TF_StepId(TF_OpKernelContext ctx); + +// Interprets the named kernel construction attribute as a TF_DataType and +// places it into *val. *status is set to TF_OK. +// +// If the attribute could not be found or could not be interpreted as +// TF_DataType, *status is populated with an error. +public static native void TF_OpKernelConstruction_GetAttrType( + TF_OpKernelConstruction ctx, @Cast("const char*") BytePointer attr_name, @Cast("TF_DataType*") IntPointer val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrType( + TF_OpKernelConstruction ctx, String attr_name, @Cast("TF_DataType*") IntBuffer val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrType( + TF_OpKernelConstruction ctx, @Cast("const char*") BytePointer attr_name, @Cast("TF_DataType*") int[] val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrType( + TF_OpKernelConstruction ctx, String attr_name, @Cast("TF_DataType*") IntPointer val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrType( + TF_OpKernelConstruction ctx, @Cast("const char*") BytePointer attr_name, @Cast("TF_DataType*") IntBuffer val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrType( + TF_OpKernelConstruction ctx, String attr_name, @Cast("TF_DataType*") int[] val, + TF_Status status); + +// Interprets the named kernel construction attribute as int32_t and +// places it into *val. *status is set to TF_OK. +// +// If the attribute could not be found or could not be interpreted as +// int32, *status is populated with an error. +public static native void TF_OpKernelConstruction_GetAttrInt32( + TF_OpKernelConstruction ctx, @Cast("const char*") BytePointer attr_name, IntPointer val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrInt32( + TF_OpKernelConstruction ctx, String attr_name, IntBuffer val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrInt32( + TF_OpKernelConstruction ctx, @Cast("const char*") BytePointer attr_name, int[] val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrInt32( + TF_OpKernelConstruction ctx, String attr_name, IntPointer val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrInt32( + TF_OpKernelConstruction ctx, @Cast("const char*") BytePointer attr_name, IntBuffer val, + TF_Status status); +public static native void TF_OpKernelConstruction_GetAttrInt32( + TF_OpKernelConstruction ctx, String attr_name, int[] val, + TF_Status status); + +// Allocates Tensor for output at given index. Caller takes ownership of +// returned TF_Tensor and should deallocate it using TF_DeleteTensor(tensor). +// +// This function should be used to allocate outputs inside kernel +// compute function. +public static native TF_Tensor TF_AllocateOutput(TF_OpKernelContext context, + int index, @Cast("TF_DataType") int dtype, + @Cast("int64_t*") LongPointer dims, int num_dims, + @Cast("size_t") long len); +public static native TF_Tensor TF_AllocateOutput(TF_OpKernelContext context, + int index, @Cast("TF_DataType") int dtype, + @Cast("int64_t*") LongBuffer dims, int num_dims, + @Cast("size_t") long len); +public static native TF_Tensor TF_AllocateOutput(TF_OpKernelContext context, + int index, @Cast("TF_DataType") int dtype, + @Cast("int64_t*") long[] dims, int num_dims, + @Cast("size_t") long len); + +// #ifdef __cplusplus /* end extern "C" */ +// #endif + +// #endif // TENSORFLOW_C_KERNELS_H_ + + +// Parsed from tensorflow/c/ops.h + +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// Routines for registering new ops and for implementing op shape inference +// functions. +// +// This API is alpha software and is subject to change. +// +// REGISTRATION +// ------------ +// +// In order to register a new op, create a new TF_OpDefinitionBuilder: +// +// TF_OpDefinitionBuilder* builder = TF_NewOpDefinitionBuilder("OpName"); +// +// Inputs, outputs and attributes can be added to the builder with the +// corresponding functions, e.g. +// +// TF_OpDefinitionBuilderAddInput(builder, "input1: int32"); +// TF_OpDefinitionBuilderAddOutput(builder, "output1: int64"); +// TF_OpDefinitionBuilderAddAttr(builder, "attr: int32"); +// +// The builder may then be registered with TensorFlow using the +// TF_RegisterOpDefinition function. E.g. +// +// TF_Status* status = TF_NewStatus(); +// TF_RegisterOpDefinition(builder, &status); +// if (TF_GetCode(status) != TF_OK) { +// // handle error +// } +// +// SHAPE INFERENCE +// --------------- +// +// You can provide a shape inference function that TensorFlow will call when it +// wants to understand the shape of outputs that the op will produce. Use the +// TF_OpDefinitionBuilderSetShapeInferenceFunction function to register a shape +// inference function pointer with TensorFlow. The following is an example of a +// very simple shape inference function: +// +// void identity_shape_fn(TF_ShapeInferenceContext* ctx, TF_Status* status) { +// TF_ShapeHandle* input = TF_NewShapeHandle(); +// TF_ShapeInferenceContextGetInput(ctx, 0, input, status); +// if (TF_GetCode(status) == TF_OK) { +// TF_ShapeInferenceContextSetOutput(ctx, 0, input, status); +// } +// TF_DeleteShapeHandle(input); +// } +// +// The following code registers the inference function with TensorFlow: +// +// TF_OpDefinitionBuilderSetShapeInferenceFunction(builder, &identity_shape_fn); +// +// For more details about shape inference, see the documentation for +// TF_OpDefinitionBuilderSetShapeInferenceFunction. + +// #ifndef TENSORFLOW_C_OPS_H_ +// #define TENSORFLOW_C_OPS_H_ + +// #include +// #include +// #include + +// #include "tensorflow/c/tf_datatype.h" +// #include "tensorflow/c/tf_status.h" + +// #ifdef SWIG +// #define TF_CAPI_EXPORT +// #else +// #if defined(_WIN32) +// #ifdef TF_COMPILE_LIBRARY +// #define TF_CAPI_EXPORT __declspec(dllexport) +// #else +// #define TF_CAPI_EXPORT __declspec(dllimport) +// #endif // TF_COMPILE_LIBRARY +// #else +// #define TF_CAPI_EXPORT __attribute__((visibility("default"))) +// #endif // _WIN32 +// #endif // SWIG + +// #ifdef __cplusplus +// Targeting ../TF_DimensionHandle.java + + +// Targeting ../TF_OpDefinitionBuilder.java + + +// Targeting ../TF_ShapeHandle.java + + +// Targeting ../TF_ShapeInferenceContext.java + + + +// Returns a newly allocated op definition builder for the given op name. The +// returned builder may be customized with the `TF_OpDefinitionBuilder...` +// functions and then registered with TensorFlow with TF_RegisterOpDefinition. +// +// The returned pointer is either freed by a call to TF_RegisterOpDefinition, or +// can be manually deleted by TF_DeleteOpDefinitionBuilder if it is never +// registered. +public static native TF_OpDefinitionBuilder TF_NewOpDefinitionBuilder( + @Cast("const char*") BytePointer op_name); +public static native TF_OpDefinitionBuilder TF_NewOpDefinitionBuilder( + String op_name); + +// Registers the given op builder with TensorFlow. Indicates success or +// otherwise in the given status. +// +// `builder` is freed whether the op was successfully registered or not. You +// must call either this function or TF_DeleteOpDefinitionBuilder to free the +// builder, but never both. +public static native void TF_RegisterOpDefinition( + TF_OpDefinitionBuilder builder, TF_Status status); + +// Frees the given op definition builder. You must call either this function or +// TF_RegisterOpDefinition to free the builder, but never both. +public static native void TF_DeleteOpDefinitionBuilder( + TF_OpDefinitionBuilder builder); + +//---------------------------------------------------- +// Attribute functions. + +// Adds an attr to the given TF_OpDefinitionBuilder. The spec has +// format ":" or ":=" +// where matches regexp [a-zA-Z][a-zA-Z0-9_]*. +// By convention, names containing only capital letters are reserved for +// attributes whose values can be inferred by the operator implementation if not +// supplied by the user. If the attribute name contains characters other than +// capital letters, the operator expects the user to provide the attribute value +// at operation runtime. +// +// can be: +// "string", "int", "float", "bool", "type", "shape", or "tensor" +// "numbertype", "realnumbertype", "quantizedtype" +// (meaning "type" with a restriction on valid values) +// "{int32,int64}" or {realnumbertype,quantizedtype,string}" +// (meaning "type" with a restriction containing unions of value types) +// "{\"foo\", \"bar\n baz\"}", or "{'foo', 'bar\n baz'}" +// (meaning "string" with a restriction on valid values) +// "list(string)", ..., "list(tensor)", "list(numbertype)", ... +// (meaning lists of the above types) +// "int >= 2" (meaning "int" with a restriction on valid values) +// "list(string) >= 2", "list(int) >= 2" +// (meaning "list(string)" / "list(int)" with length at least 2) +// , if included, should use the Proto text format +// of . For lists use [a, b, c] format. +// +// Note that any attr specifying the length of an input or output will +// get a default minimum of 1 unless the >= # syntax is used. +public static native void TF_OpDefinitionBuilderAddAttr( + TF_OpDefinitionBuilder builder, @Cast("const char*") BytePointer attr_spec); +public static native void TF_OpDefinitionBuilderAddAttr( + TF_OpDefinitionBuilder builder, String attr_spec); + +// Adds an input to this TF_OpDefinitionBuilder. +// The spec has form ":" or ":Ref()" +// where matches regexp [a-z][a-z0-9_]* and can be: +// * For a single tensor: +// * For a sequence of tensors with the same type: * +// * For a sequence of tensors with different types: +// Where: +// is either one of "float", "int32", "string", ... +// or the name of an attr (see TF_OpDefinitionBuilderAddAttr) +// with type "type". +// is the name of an attr with type "int". +// is the name of an attr with type "list(type)". +public static native void TF_OpDefinitionBuilderAddInput( + TF_OpDefinitionBuilder builder, @Cast("const char*") BytePointer input_spec); +public static native void TF_OpDefinitionBuilderAddInput( + TF_OpDefinitionBuilder builder, String input_spec); + +// Adds an output to this TF_OpDefinitionBuilder. +// The spec has form ":" or ":Ref()" +// where matches regexp [a-z][a-z0-9_]* and can be: +// * For a single tensor: +// * For a sequence of tensors with the same type: * +// * For a sequence of tensors with different types: +// Where: +// is either one of "float", "int32", "string", ... +// or the name of an attr (see TF_OpDefinitionBuilderAddAttr) +// with type "type". +// is the name of an attr with type "int". +// is the name of an attr with type "list(type)". +public static native void TF_OpDefinitionBuilderAddOutput( + TF_OpDefinitionBuilder builder, @Cast("const char*") BytePointer output_spec); +public static native void TF_OpDefinitionBuilderAddOutput( + TF_OpDefinitionBuilder builder, String output_spec); + +// Sets the commutative property for the op built by the given builder. +public static native void TF_OpDefinitionBuilderSetIsCommutative( + TF_OpDefinitionBuilder builder, @Cast("bool") boolean is_commutative); + +// Sets the is_aggregate property of the builder to the given value. +// +// If is_aggregate is true, then the operation produced by this builder accepts +// N >= 2 inputs and produces 1 output all of the same type. Should be +// associative and commutative, and produce output with the same shape as the +// input. The optimizer may replace an aggregate op taking input from multiple +// devices with a tree of aggregate ops that aggregate locally within each +// device (and possibly within groups of nearby devices) before communicating. +public static native void TF_OpDefinitionBuilderSetIsAggregate( + TF_OpDefinitionBuilder builder, @Cast("bool") boolean is_aggregate); + +// Sets the is_stateful property of the builder to the given value. +// +// The op built by this builder is stateful if its behavior depends on some +// state beyond its input tensors (e.g. variable reading op) or if it has a +// side-effect (e.g. printing or asserting ops). Equivalently, stateless ops +// must always produce the same output for the same input and have no +// side-effects. +// +// By default Ops may be moved between devices. Stateful ops should either not +// be moved, or should only be moved if that state can also be moved (e.g. via +// some sort of save / restore). Stateful ops are guaranteed to never be +// optimized away by Common Subexpression Elimination (CSE). +public static native void TF_OpDefinitionBuilderSetIsStateful( + TF_OpDefinitionBuilder builder, @Cast("bool") boolean is_stateful); + +// Sets the allows_uninitialized_input property of the operation built by this +// builder. +// +// By default, all inputs to an Op must be initialized Tensors. Ops that may +// initialize tensors for the first time should set this field to true, to allow +// the Op to take an uninitialized Tensor as input. +public static native void TF_OpDefinitionBuilderSetAllowsUninitializedInput( + TF_OpDefinitionBuilder builder, @Cast("bool") boolean allows_uninitialized_input); + +// Adds a deprecation warning for the given op. This indicates to the user that +// `version` is the first TensorFlow GraphDef version for which the operation is +// deprecated. `explanation` should contain the reason for the deprecation and +// what to use instead. +// +// This function is only an indicator that the operation may disappear in a +// version of TensorFlow after `version`. It does not affect op registration. +public static native void TF_OpDefinitionBuilderDeprecated( + TF_OpDefinitionBuilder builder, int version, @Cast("const char*") BytePointer explanation); +public static native void TF_OpDefinitionBuilderDeprecated( + TF_OpDefinitionBuilder builder, int version, String explanation); +// Targeting ../Shape_inference_func_TF_ShapeInferenceContext_TF_Status.java + + +public static native void TF_OpDefinitionBuilderSetShapeInferenceFunction( + TF_OpDefinitionBuilder builder, + Shape_inference_func_TF_ShapeInferenceContext_TF_Status shape_inference_func); + +//---------------------------------------------------- +// Functions for TF_ShapeInferenceContext. +// +// Functions for implementing shape inference functions. TensorFlow uses these +// functions to determine the shape of tensors produced by an operation without +// having to actually run the operation. If an operation chooses to provide a +// shape inference function, it will be invoked by TensorFlow as needed. +// +// When invoked by TensorFlow, the shape inference function is provided with a +// TF_ShapeInferenceContext pointer. The function's implementation will use the +// accessor and mutator functions with names beginning with +// TF_ShapeInferenceContext to examine the input state and determine the output +// shape. + +// Returns the number of inputs in the given shape inference context. +public static native @Cast("int64_t") long TF_ShapeInferenceContextNumInputs( + TF_ShapeInferenceContext ctx); + +// Returns a newly allocated shape handle. The shapes represented by these +// handles may be queried or mutated with the corresponding +// TF_ShapeInferenceContext... functions. +public static native TF_ShapeHandle TF_NewShapeHandle(); + +// Places the ith input of the given shape inference context into the given +// shape handle, or returns a status other than TF_OK indicating why the input +// could not be retrieved +// (for example, if i < 0 || i >= TF_ShapeInferenceContextNumInputs(ctx)). +public static native void TF_ShapeInferenceContextGetInput( + TF_ShapeInferenceContext ctx, int i, TF_ShapeHandle handle, + TF_Status status); + +// Places the given shape handle into the `i`th output position of the given +// context. Internally, the shape handle is copied; the caller may subsequently +// delete `handle`. +public static native void TF_ShapeInferenceContextSetOutput(TF_ShapeInferenceContext ctx, + int i, TF_ShapeHandle handle, + TF_Status status); + +// Returns a newly-allocate shape handle representing a vector of the given +// size. The returned handle should be freed with TF_DeleteShapeHandle. +public static native TF_ShapeHandle TF_ShapeInferenceContextVectorFromSize( + TF_ShapeInferenceContext ctx, @Cast("size_t") long size); + +// Returns a newly allocated dimension handle. It must be freed with +// TF_DeleteDimensionHandle. +public static native TF_DimensionHandle TF_NewDimensionHandle(); + +// Interprets the named shape inference context attribute as a TF_DataType and +// places it into *val. *status is set to TF_OK. +// +// If the attribute could not be found or could not be interpreted as +// TF_DataType, *status is populated with an error. +public static native void TF_ShapeInferenceContext_GetAttrType( + TF_ShapeInferenceContext ctx, @Cast("const char*") BytePointer attr_name, @Cast("TF_DataType*") IntPointer val, + TF_Status status); +public static native void TF_ShapeInferenceContext_GetAttrType( + TF_ShapeInferenceContext ctx, String attr_name, @Cast("TF_DataType*") IntBuffer val, + TF_Status status); +public static native void TF_ShapeInferenceContext_GetAttrType( + TF_ShapeInferenceContext ctx, @Cast("const char*") BytePointer attr_name, @Cast("TF_DataType*") int[] val, + TF_Status status); +public static native void TF_ShapeInferenceContext_GetAttrType( + TF_ShapeInferenceContext ctx, String attr_name, @Cast("TF_DataType*") IntPointer val, + TF_Status status); +public static native void TF_ShapeInferenceContext_GetAttrType( + TF_ShapeInferenceContext ctx, @Cast("const char*") BytePointer attr_name, @Cast("TF_DataType*") IntBuffer val, + TF_Status status); +public static native void TF_ShapeInferenceContext_GetAttrType( + TF_ShapeInferenceContext ctx, String attr_name, @Cast("TF_DataType*") int[] val, + TF_Status status); + +// Returns the rank of the shape represented by the given handle. +public static native @Cast("int64_t") long TF_ShapeInferenceContextRank( + TF_ShapeInferenceContext ctx, TF_ShapeHandle handle); + +// Returns 1 if `handle` has a known rank, 0 otherwise. +public static native int TF_ShapeInferenceContextRankKnown( + TF_ShapeInferenceContext ctx, TF_ShapeHandle handle); + +// If has rank , or its rank is unknown, return OK and return the +// shape with asserted rank in <*result>. Otherwise an error is placed into +// `status`. +public static native void TF_ShapeInferenceContextWithRank( + TF_ShapeInferenceContext ctx, TF_ShapeHandle handle, @Cast("int64_t") long rank, + TF_ShapeHandle result, TF_Status status); + +// If has rank at least , or its rank is unknown, return OK and +// return the shape with asserted rank in <*result>. Otherwise an error is +// placed into `status`. +public static native void TF_ShapeInferenceContextWithRankAtLeast( + TF_ShapeInferenceContext ctx, TF_ShapeHandle handle, @Cast("int64_t") long rank, + TF_ShapeHandle result, TF_Status status); + +// If has rank at most , or its rank is unknown, return OK and +// return the shape with asserted rank in <*result>. Otherwise an error is +// placed into `status`. +public static native void TF_ShapeInferenceContextWithRankAtMost( + TF_ShapeInferenceContext ctx, TF_ShapeHandle handle, @Cast("int64_t") long rank, + TF_ShapeHandle result, TF_Status status); + +// Places a handle to the ith dimension of the given shape into *result. +public static native void TF_ShapeInferenceContextDim( + TF_ShapeInferenceContext ctx, TF_ShapeHandle shape_handle, @Cast("int64_t") long i, + TF_DimensionHandle result); + +// Returns in <*result> a sub-shape of , with dimensions +// [start:end]. and can be negative, to index from the end of the +// shape. and are set to the rank of if > rank of +// . +public static native void TF_ShapeInferenceContextSubshape( + TF_ShapeInferenceContext ctx, TF_ShapeHandle shape_handle, @Cast("int64_t") long start, + @Cast("int64_t") long end, TF_ShapeHandle result, TF_Status status); + +// Places an unknown shape in all outputs for the given inference context. Used +// for shape inference functions with ops whose output shapes are unknown. +public static native void TF_ShapeInferenceContextSetUnknownShape( + TF_ShapeInferenceContext ctx, TF_Status status); + +// Returns whether the given handle represents a known dimension. +public static native int TF_DimensionHandleValueKnown( + TF_DimensionHandle dim_handle); + +// Returns the value of the given dimension. +public static native @Cast("int64_t") long TF_DimensionHandleValue( + TF_DimensionHandle dim_handle); + +// Returns in <*result> the result of appending the dimensions of to +// those of . +public static native void TF_ShapeInferenceContextConcatenateShapes( + TF_ShapeInferenceContext ctx, TF_ShapeHandle first, + TF_ShapeHandle second, TF_ShapeHandle result, TF_Status status); + +// Frees the given shape handle. +public static native void TF_DeleteShapeHandle(TF_ShapeHandle handle); + +// Frees the given dimension handle. +public static native void TF_DeleteDimensionHandle(TF_DimensionHandle handle); + +// #ifdef __cplusplus /* end extern "C" */ +// #endif + +// #endif // TENSORFLOW_C_OPS_H_ + + +// Parsed from tensorflow/c/eager/c_api.h + +/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +// #ifndef TENSORFLOW_C_EAGER_C_API_H_ +// #define TENSORFLOW_C_EAGER_C_API_H_ + +// C API extensions to experiment with eager execution of kernels. +// WARNING: Unlike tensorflow/c/c_api.h, the API here is not guaranteed to be +// stable and can change without notice. + +// #include "tensorflow/c/c_api.h" + +// Macro to control visibility of exported symbols in the shared library (.so, +// .dylib, .dll). +// This duplicates the TF_EXPORT macro definition in +// tensorflow/core/platform/macros.h in order to keep this .h file independent +// of any other includes.$a +// #ifdef SWIG +// #define TF_CAPI_EXPORT +// #else +// #if defined(_WIN32) +// #ifdef TF_COMPILE_LIBRARY +// #define TF_CAPI_EXPORT __declspec(dllexport) +// #else +// #define TF_CAPI_EXPORT __declspec(dllimport) +// #endif // TF_COMPILE_LIBRARY +// #else +// #define TF_CAPI_EXPORT __attribute__((visibility("default"))) +// #endif // _WIN32 +// #endif // SWIG + +// #ifdef __cplusplus +// Targeting ../TFE_ContextOptions.java + + + +// Return a new options object. +public static native TFE_ContextOptions TFE_NewContextOptions(); + +// Set the config in TF_ContextOptions.options. +// config should be a serialized tensorflow.ConfigProto proto. +// If config was not parsed successfully as a ConfigProto, record the +// error information in *status. +public static native void TFE_ContextOptionsSetConfig( + TFE_ContextOptions options, @Const Pointer proto, @Cast("size_t") long proto_len, + TF_Status status); + +// Controls how to act when we try to run an operation on a given device but +// some input tensors are not on that device. +// LINT.IfChange +// Note: Keep in sync with internal copy of enum in eager/context.h. +/** enum TFE_ContextDevicePlacementPolicy */ +public static final int + // Running operations with input tensors on the wrong device will fail. + TFE_DEVICE_PLACEMENT_EXPLICIT = 0, + // Copy the tensor to the right device but log a warning. + TFE_DEVICE_PLACEMENT_WARN = 1, + // Silently copy the tensor, which has a performance cost since the operation + // will be blocked till the copy completes. This is the default placement + // policy. + TFE_DEVICE_PLACEMENT_SILENT = 2, + // Placement policy which silently copies int32 tensors but not other dtypes. + TFE_DEVICE_PLACEMENT_SILENT_FOR_INT32 = 3; +// LINT.ThenChange(//tensorflow/core/common_runtime/eager/context.h) + +// Sets the default execution mode (sync/async). Note that this can be +// overridden per thread using TFE_ContextSetExecutorForThread. +public static native void TFE_ContextOptionsSetAsync(TFE_ContextOptions arg0, + @Cast("unsigned char") byte enable); + +public static native void TFE_ContextOptionsSetDevicePlacementPolicy( + TFE_ContextOptions arg0, @Cast("TFE_ContextDevicePlacementPolicy") int arg1); + +// Destroy an options object. +public static native void TFE_DeleteContextOptions(TFE_ContextOptions arg0); +// Targeting ../TFE_Context.java + + + +public static native TFE_Context TFE_NewContext( + @Const TFE_ContextOptions opts, TF_Status status); +public static native void TFE_DeleteContext(TFE_Context ctx); +public static native TF_DeviceList TFE_ContextListDevices(TFE_Context ctx, + TF_Status status); + +// Clears the internal caches in the TFE context. Useful when reseeding random +// ops. +public static native void TFE_ContextClearCaches(TFE_Context ctx); + +// Sets a thread-local device placement policy. After this call, other calls to +// TFE_Execute in the same thread will use the device policy specified here +// instead of the device policy used to construct the context. This has no +// effect on the device policy used by other program threads. +public static native void TFE_ContextSetThreadLocalDevicePlacementPolicy( + TFE_Context ctx, @Cast("TFE_ContextDevicePlacementPolicy") int policy); + +// Returns the device placement policy to be used by this context in the current +// thread. +public static native @Cast("TFE_ContextDevicePlacementPolicy") int TFE_ContextGetDevicePlacementPolicy(TFE_Context ctx); + +// A tensorflow.ServerDef specifies remote workers (in addition to the current +// workers name). Operations created on this context can then be executed on +// any of these remote workers by setting an appropriate device. +// +// If the following is set, all servers identified by the +// ServerDef must be up when the context is created. +public static native void TFE_ContextSetServerDef(TFE_Context ctx, + int keep_alive_secs, + @Const Pointer proto, + @Cast("size_t") long proto_len, + TF_Status status); + +// Causes the calling thread to block till all ops dispatched in async mode +// have been executed. Note that "execution" here refers to kernel execution / +// scheduling of copies, etc. Similar to sync execution, it doesn't guarantee +// that lower level device queues (like GPU streams) have been flushed. +// +// This call may not block for execution of ops enqueued concurrently with this +// call. +public static native void TFE_ContextAsyncWait(TFE_Context arg0, + TF_Status status); + +// When an error happens, any pending operations are discarded and newly issued +// ops return an error. This call clears the error state and re-enables +// execution of newly issued ops. +// +// Note that outputs of discarded ops remain in a corrupt state and should not +// be used for future calls. +// TODO(agarwal): mark the affected handles and raise errors if they are used. +public static native void TFE_ContextAsyncClearError(TFE_Context arg0); +// Targeting ../TFE_TensorHandle.java + + + +public static native TFE_TensorHandle TFE_NewTensorHandle(TF_Tensor t, + TF_Status status); +// Indicates that the caller will not be using `h` any more. +public static native void TFE_DeleteTensorHandle(TFE_TensorHandle h); +public static native @Cast("TF_DataType") int TFE_TensorHandleDataType(TFE_TensorHandle h); +// This function will block till the operation that produces `h` has completed. +public static native int TFE_TensorHandleNumDims(TFE_TensorHandle h, + TF_Status status); +public static native @Cast("int64_t") long TFE_TensorHandleNumElements(TFE_TensorHandle h, + TF_Status status); +// This function will block till the operation that produces `h` has completed. +public static native @Cast("int64_t") long TFE_TensorHandleDim(TFE_TensorHandle h, + int dim_index, + TF_Status status); + +// Returns the device of the operation that produced `h`. If `h` was produced by +// a copy, returns the destination device of the copy. Note that the returned +// device name is not always the device holding the tensor handle's memory. If +// you want the latter, use TFE_TensorHandleBackingDeviceName. This function +// will block till the operation that produces `h` has completed. +public static native @Cast("const char*") BytePointer TFE_TensorHandleDeviceName( + TFE_TensorHandle h, TF_Status status); + +// Returns the name of the device in whose memory `h` resides. +// +// This function will block till the operation that produces `h` has completed. +public static native @Cast("const char*") BytePointer TFE_TensorHandleBackingDeviceName( + TFE_TensorHandle h, TF_Status status); + +// Return a pointer to a new TFE_TensorHandle that shares the underlying tensor +// with `h`. On success, `status` is set to OK. On failure, `status` reflects +// the error and a nullptr is returned. +public static native TFE_TensorHandle TFE_TensorHandleCopySharingTensor( + TFE_TensorHandle h, TF_Status status); + +// This function will block till the operation that produces `h` has +// completed. The memory returned might alias the internal memory used by +// TensorFlow. Hence, callers should not mutate this memory (for example by +// modifying the memory region pointed to by TF_TensorData() on the returned +// TF_Tensor). +public static native TF_Tensor TFE_TensorHandleResolve(TFE_TensorHandle h, + TF_Status status); + +// Create a new TFE_TensorHandle with the same contents as 'h' but placed +// in the memory of the device name 'device_name'. +// If source and destination are the same device, then this creates a new handle +// that shares the underlying buffer. Otherwise, it currently requires at least +// one of the source or destination devices to be CPU (i.e., for the source or +// destination tensor to be placed in host memory). +// If async execution is enabled, the copy may be enqueued and the call will +// return "non-ready" handle. Else, this function returns after the copy has +// been done. +public static native TFE_TensorHandle TFE_TensorHandleCopyToDevice( + TFE_TensorHandle h, TFE_Context ctx, @Cast("const char*") BytePointer device_name, + TF_Status status); +public static native TFE_TensorHandle TFE_TensorHandleCopyToDevice( + TFE_TensorHandle h, TFE_Context ctx, String device_name, + TF_Status status); +// Targeting ../TFE_TensorDebugInfo.java + + + +// Retrieves TFE_TensorDebugInfo for `handle`. +// If TFE_TensorHandleTensorDebugInfo succeeds, `status` is set to OK and caller +// is responsible for deleting returned TFE_TensorDebugInfo. +// If TFE_TensorHandleTensorDebugInfo fails, `status` is set to appropriate +// error and nullptr is returned. This function can block till the operation +// that produces `handle` has completed. +public static native TFE_TensorDebugInfo TFE_TensorHandleTensorDebugInfo( + TFE_TensorHandle handle, TF_Status status); + +// Deletes `debug_info`. +public static native void TFE_DeleteTensorDebugInfo( + TFE_TensorDebugInfo debug_info); + +// Returns the number of dimensions used to represent the tensor on its device. +// The number of dimensions used to reprensent the tensor on device can be +// different from the number returned by TFE_TensorHandleNumDims. +// The return value was current at the time of TFE_TensorDebugInfo creation. +public static native int TFE_TensorDebugInfoOnDeviceNumDims( + TFE_TensorDebugInfo debug_info); + +// Returns the number of elements in dimension `dim_index`. +// Tensor representation on device can be transposed from its representation +// on host. The data contained in dimension `dim_index` on device +// can correspond to the data contained in another dimension in on-host +// representation. The dimensions are indexed using the standard TensorFlow +// major-to-minor order (slowest varying dimension first), +// not the XLA's minor-to-major order. +// On-device dimensions can be padded. TFE_TensorDebugInfoOnDeviceDim returns +// the number of elements in a dimension after padding. +// The return value was current at the time of TFE_TensorDebugInfo creation. +public static native @Cast("int64_t") long TFE_TensorDebugInfoOnDeviceDim( + TFE_TensorDebugInfo debug_info, int dim_index); +// Targeting ../TFE_Op.java + + + +public static native TFE_Op TFE_NewOp(TFE_Context ctx, + @Cast("const char*") BytePointer op_or_function_name, + TF_Status status); +public static native TFE_Op TFE_NewOp(TFE_Context ctx, + String op_or_function_name, + TF_Status status); + +public static native void TFE_DeleteOp(TFE_Op op); + +public static native void TFE_OpSetDevice(TFE_Op op, @Cast("const char*") BytePointer device_name, + TF_Status status); +public static native void TFE_OpSetDevice(TFE_Op op, String device_name, + TF_Status status); +// The returned string remains valid throughout the lifetime of 'op'. +public static native @Cast("const char*") BytePointer TFE_OpGetDevice(TFE_Op op, + TF_Status status); + +// When 'enable' is set to 1, and if TensorFlow library is built with XLA +// support, a subsequent TFE_Execute() call on `op` will run the op via XLA. +// +// If the library is not built with XLA support, this call would be a no-op. +public static native void TFE_OpSetXLACompilation(TFE_Op op, + @Cast("unsigned char") byte enable); + +public static native void TFE_OpAddInput(TFE_Op op, TFE_TensorHandle input, + TF_Status status); + +public static native void TFE_OpAddInputList(TFE_Op op, + @Cast("TFE_TensorHandle**") PointerPointer inputs, + int num_inputs, + TF_Status status); +public static native void TFE_OpAddInputList(TFE_Op op, + @ByPtrPtr TFE_TensorHandle inputs, + int num_inputs, + TF_Status status); + +public static native @Cast("TF_AttrType") int TFE_OpGetAttrType(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") BytePointer is_list, + TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpGetAttrType(TFE_Op op, + String attr_name, + @Cast("unsigned char*") ByteBuffer is_list, + TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpGetAttrType(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") byte[] is_list, + TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpGetAttrType(TFE_Op op, + String attr_name, + @Cast("unsigned char*") BytePointer is_list, + TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpGetAttrType(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") ByteBuffer is_list, + TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpGetAttrType(TFE_Op op, + String attr_name, + @Cast("unsigned char*") byte[] is_list, + TF_Status status); +// Get an attribute type given an op name; a fusion of TFE_NewOp and +// TFE_OpGetAttrType for use from Python without the overhead of the individual +// calls and memory management of TFE_Op. +public static native @Cast("TF_AttrType") int TFE_OpNameGetAttrType( + TFE_Context ctx, @Cast("const char*") BytePointer op_or_function_name, @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") BytePointer is_list, TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpNameGetAttrType( + TFE_Context ctx, String op_or_function_name, String attr_name, + @Cast("unsigned char*") ByteBuffer is_list, TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpNameGetAttrType( + TFE_Context ctx, @Cast("const char*") BytePointer op_or_function_name, @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") byte[] is_list, TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpNameGetAttrType( + TFE_Context ctx, String op_or_function_name, String attr_name, + @Cast("unsigned char*") BytePointer is_list, TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpNameGetAttrType( + TFE_Context ctx, @Cast("const char*") BytePointer op_or_function_name, @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char*") ByteBuffer is_list, TF_Status status); +public static native @Cast("TF_AttrType") int TFE_OpNameGetAttrType( + TFE_Context ctx, String op_or_function_name, String attr_name, + @Cast("unsigned char*") byte[] is_list, TF_Status status); + +public static native void TFE_OpSetAttrString(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Const Pointer value, + @Cast("size_t") long length); +public static native void TFE_OpSetAttrString(TFE_Op op, + String attr_name, + @Const Pointer value, + @Cast("size_t") long length); +public static native void TFE_OpSetAttrInt(TFE_Op op, @Cast("const char*") BytePointer attr_name, + @Cast("int64_t") long value); +public static native void TFE_OpSetAttrInt(TFE_Op op, String attr_name, + @Cast("int64_t") long value); +public static native void TFE_OpSetAttrFloat(TFE_Op op, @Cast("const char*") BytePointer attr_name, + float value); +public static native void TFE_OpSetAttrFloat(TFE_Op op, String attr_name, + float value); +public static native void TFE_OpSetAttrBool(TFE_Op op, @Cast("const char*") BytePointer attr_name, + @Cast("unsigned char") byte value); +public static native void TFE_OpSetAttrBool(TFE_Op op, String attr_name, + @Cast("unsigned char") byte value); +public static native void TFE_OpSetAttrType(TFE_Op op, @Cast("const char*") BytePointer attr_name, + @Cast("TF_DataType") int value); +public static native void TFE_OpSetAttrType(TFE_Op op, String attr_name, + @Cast("TF_DataType") int value); +// If the number of dimensions is unknown, `num_dims` must be set to +// -1 and `dims` can be null. If a dimension is unknown, the +// corresponding entry in the `dims` array must be -1. +public static native void TFE_OpSetAttrShape(TFE_Op op, @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") LongPointer dims, + int num_dims, + TF_Status out_status); +public static native void TFE_OpSetAttrShape(TFE_Op op, String attr_name, + @Cast("const int64_t*") LongBuffer dims, + int num_dims, + TF_Status out_status); +public static native void TFE_OpSetAttrShape(TFE_Op op, @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") long[] dims, + int num_dims, + TF_Status out_status); +public static native void TFE_OpSetAttrShape(TFE_Op op, String attr_name, + @Cast("const int64_t*") LongPointer dims, + int num_dims, + TF_Status out_status); +public static native void TFE_OpSetAttrShape(TFE_Op op, @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") LongBuffer dims, + int num_dims, + TF_Status out_status); +public static native void TFE_OpSetAttrShape(TFE_Op op, String attr_name, + @Cast("const int64_t*") long[] dims, + int num_dims, + TF_Status out_status); + +// Sets the attribute attr_name to be a function specified by 'function'. +// +// TODO(ashankar,iga): Add this functionality to the C API for graph +// construction. Perhaps we want an AttrValueMap equivalent in the C API? +public static native void TFE_OpSetAttrFunction(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Const TFE_Op value); +public static native void TFE_OpSetAttrFunction(TFE_Op op, + String attr_name, + @Const TFE_Op value); + +public static native void TFE_OpSetAttrFunctionName(TFE_Op op, @Cast("const char*") BytePointer attr_name, + @Cast("const char*") BytePointer data, @Cast("size_t") long length); +public static native void TFE_OpSetAttrFunctionName(TFE_Op op, String attr_name, + String data, @Cast("size_t") long length); + +public static native void TFE_OpSetAttrTensor(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + TF_Tensor tensor, + TF_Status status); +public static native void TFE_OpSetAttrTensor(TFE_Op op, + String attr_name, + TF_Tensor tensor, + TF_Status status); + +public static native void TFE_OpSetAttrStringList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const void*const*") PointerPointer values, + @Cast("const size_t*") SizeTPointer lengths, + int num_values); +public static native void TFE_OpSetAttrStringList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const void*const*") @ByPtrPtr Pointer values, + @Cast("const size_t*") SizeTPointer lengths, + int num_values); +public static native void TFE_OpSetAttrStringList(TFE_Op op, + String attr_name, + @Cast("const void*const*") @ByPtrPtr Pointer values, + @Cast("const size_t*") SizeTPointer lengths, + int num_values); +public static native void TFE_OpSetAttrIntList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") LongPointer values, + int num_values); +public static native void TFE_OpSetAttrIntList(TFE_Op op, + String attr_name, + @Cast("const int64_t*") LongBuffer values, + int num_values); +public static native void TFE_OpSetAttrIntList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") long[] values, + int num_values); +public static native void TFE_OpSetAttrIntList(TFE_Op op, + String attr_name, + @Cast("const int64_t*") LongPointer values, + int num_values); +public static native void TFE_OpSetAttrIntList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const int64_t*") LongBuffer values, + int num_values); +public static native void TFE_OpSetAttrIntList(TFE_Op op, + String attr_name, + @Cast("const int64_t*") long[] values, + int num_values); +public static native void TFE_OpSetAttrFloatList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Const FloatPointer values, + int num_values); +public static native void TFE_OpSetAttrFloatList(TFE_Op op, + String attr_name, + @Const FloatBuffer values, + int num_values); +public static native void TFE_OpSetAttrFloatList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Const float[] values, + int num_values); +public static native void TFE_OpSetAttrFloatList(TFE_Op op, + String attr_name, + @Const FloatPointer values, + int num_values); +public static native void TFE_OpSetAttrFloatList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Const FloatBuffer values, + int num_values); +public static native void TFE_OpSetAttrFloatList(TFE_Op op, + String attr_name, + @Const float[] values, + int num_values); +public static native void TFE_OpSetAttrBoolList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const unsigned char*") BytePointer values, + int num_values); +public static native void TFE_OpSetAttrBoolList(TFE_Op op, + String attr_name, + @Cast("const unsigned char*") ByteBuffer values, + int num_values); +public static native void TFE_OpSetAttrBoolList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const unsigned char*") byte[] values, + int num_values); +public static native void TFE_OpSetAttrBoolList(TFE_Op op, + String attr_name, + @Cast("const unsigned char*") BytePointer values, + int num_values); +public static native void TFE_OpSetAttrBoolList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const unsigned char*") ByteBuffer values, + int num_values); +public static native void TFE_OpSetAttrBoolList(TFE_Op op, + String attr_name, + @Cast("const unsigned char*") byte[] values, + int num_values); +public static native void TFE_OpSetAttrTypeList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const TF_DataType*") IntPointer values, + int num_values); +public static native void TFE_OpSetAttrTypeList(TFE_Op op, + String attr_name, + @Cast("const TF_DataType*") IntBuffer values, + int num_values); +public static native void TFE_OpSetAttrTypeList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const TF_DataType*") int[] values, + int num_values); +public static native void TFE_OpSetAttrTypeList(TFE_Op op, + String attr_name, + @Cast("const TF_DataType*") IntPointer values, + int num_values); +public static native void TFE_OpSetAttrTypeList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const TF_DataType*") IntBuffer values, + int num_values); +public static native void TFE_OpSetAttrTypeList(TFE_Op op, + String attr_name, + @Cast("const TF_DataType*") int[] values, + int num_values); +public static native void TFE_OpSetAttrShapeList( + TFE_Op op, @Cast("const char*") BytePointer attr_name, @Cast("const int64_t**") PointerPointer dims, + @Const IntPointer num_dims, int num_values, TF_Status out_status); +public static native void TFE_OpSetAttrShapeList( + TFE_Op op, @Cast("const char*") BytePointer attr_name, @Cast("const int64_t**") @ByPtrPtr LongPointer dims, + @Const IntPointer num_dims, int num_values, TF_Status out_status); +public static native void TFE_OpSetAttrShapeList( + TFE_Op op, String attr_name, @Cast("const int64_t**") @ByPtrPtr LongBuffer dims, + @Const IntBuffer num_dims, int num_values, TF_Status out_status); +public static native void TFE_OpSetAttrShapeList( + TFE_Op op, @Cast("const char*") BytePointer attr_name, @Cast("const int64_t**") @ByPtrPtr long[] dims, + @Const int[] num_dims, int num_values, TF_Status out_status); +public static native void TFE_OpSetAttrShapeList( + TFE_Op op, String attr_name, @Cast("const int64_t**") @ByPtrPtr LongPointer dims, + @Const IntPointer num_dims, int num_values, TF_Status out_status); +public static native void TFE_OpSetAttrShapeList( + TFE_Op op, @Cast("const char*") BytePointer attr_name, @Cast("const int64_t**") @ByPtrPtr LongBuffer dims, + @Const IntBuffer num_dims, int num_values, TF_Status out_status); +public static native void TFE_OpSetAttrShapeList( + TFE_Op op, String attr_name, @Cast("const int64_t**") @ByPtrPtr long[] dims, + @Const int[] num_dims, int num_values, TF_Status out_status); +public static native void TFE_OpSetAttrFunctionList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Cast("const TFE_Op**") PointerPointer value, + int num_values); +public static native void TFE_OpSetAttrFunctionList(TFE_Op op, + @Cast("const char*") BytePointer attr_name, + @Const @ByPtrPtr TFE_Op value, + int num_values); +public static native void TFE_OpSetAttrFunctionList(TFE_Op op, + String attr_name, + @Const @ByPtrPtr TFE_Op value, + int num_values); + +// Returns the length (number of tensors) of the input argument `input_name` +// found in the provided `op`. +public static native int TFE_OpGetInputLength(TFE_Op op, + @Cast("const char*") BytePointer input_name, + TF_Status status); +public static native int TFE_OpGetInputLength(TFE_Op op, + String input_name, + TF_Status status); + +// Returns the length (number of tensors) of the output argument `output_name` +// found in the provided `op`. +public static native int TFE_OpGetOutputLength(TFE_Op op, + @Cast("const char*") BytePointer output_name, + TF_Status status); +public static native int TFE_OpGetOutputLength(TFE_Op op, + String output_name, + TF_Status status); + +// Execute the operation defined by 'op' and return handles to computed +// tensors in `retvals`. +// +// 'retvals' must point to a pre-allocated array of TFE_TensorHandle* and +// '*num_retvals' should be set to the size of this array. It is an error if +// the size of 'retvals' is less than the number of outputs. This call sets +// *num_retvals to the number of outputs. +// +// If async execution is enabled, the call may simply enqueue the execution +// and return "non-ready" handles in `retvals`. Note that any handles contained +// in 'op' should not be mutated till the kernel execution actually finishes. +// +// For sync execution, if any of the inputs to `op` are not ready, this call +// will block till they become ready and then return when the kernel execution +// is done. +// TODO(agarwal): change num_retvals to int from int*. +public static native void TFE_Execute(TFE_Op op, @Cast("TFE_TensorHandle**") PointerPointer retvals, + IntPointer num_retvals, TF_Status status); +public static native void TFE_Execute(TFE_Op op, @ByPtrPtr TFE_TensorHandle retvals, + IntPointer num_retvals, TF_Status status); +public static native void TFE_Execute(TFE_Op op, @ByPtrPtr TFE_TensorHandle retvals, + IntBuffer num_retvals, TF_Status status); +public static native void TFE_Execute(TFE_Op op, @ByPtrPtr TFE_TensorHandle retvals, + int[] num_retvals, TF_Status status); + +// Add a function (serialized FunctionDef protocol buffer) to ctx so +// that it can be invoked using TFE_Execute. +public static native void TFE_ContextAddFunctionDef( + TFE_Context ctx, @Cast("const char*") BytePointer serialized_function_def, @Cast("size_t") long size, + TF_Status status); +public static native void TFE_ContextAddFunctionDef( + TFE_Context ctx, String serialized_function_def, @Cast("size_t") long size, + TF_Status status); + +// Adds a function (created from TF_GraphToFunction or +// TF_FunctionImportFunctionDef) to the context, allowing it to be executed with +// TFE_Execute by creating an op with the same name as the function. +public static native void TFE_ContextAddFunction(TFE_Context ctx, + TF_Function function, + TF_Status status); + +// Removes a function from the context. Once removed, you can no longer +// TFE_Execute it or TFE_Execute any TFE_Op which has it as an attribute or any +// other function which calls it as an attribute. +public static native void TFE_ContextRemoveFunction(TFE_Context ctx, + @Cast("const char*") BytePointer name, + TF_Status status); +public static native void TFE_ContextRemoveFunction(TFE_Context ctx, + String name, + TF_Status status); + +// Checks whether a function is registered under `name`. +public static native @Cast("unsigned char") byte TFE_ContextHasFunction(TFE_Context ctx, + @Cast("const char*") BytePointer name); +public static native @Cast("unsigned char") byte TFE_ContextHasFunction(TFE_Context ctx, + String name); + +// Enables tracing of RunMetadata on the ops executed from this context. +public static native void TFE_ContextEnableRunMetadata(TFE_Context ctx); + +// Disables tracing of RunMetadata on the ops executed from this context. +public static native void TFE_ContextDisableRunMetadata(TFE_Context ctx); + +// Populates the passed-in buffer with a serialized RunMetadata protocol buffer +// containing any run metadata information accumulated so far and clears this +// information. +// If async mode is enabled, this call blocks till all currently pending ops are +// done. +public static native void TFE_ContextExportRunMetadata(TFE_Context ctx, + TF_Buffer buf, + TF_Status status); + +// Some TF ops need a step container to be set to limit the lifetime of some +// resources (mostly TensorArray and Stack, used in while loop gradients in +// graph mode). Calling this on a context tells it to start a step. +public static native void TFE_ContextStartStep(TFE_Context ctx); + +// Ends a step. When there is no active step (that is, every started step has +// been ended) step containers will be cleared. Note: it is not safe to call +// TFE_ContextEndStep while ops which rely on the step container may be running. +public static native void TFE_ContextEndStep(TFE_Context ctx); + +// #ifdef __cplusplus +// Targeting ../Tensor.java + + + // namespace tensorflow + +public static native TFE_TensorHandle TFE_NewTensorHandle(@Const @ByRef Tensor t, + TF_Status status); +// #endif + +// #endif // TENSORFLOW_C_EAGER_C_API_H_ + + +} diff --git a/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Buffer.java b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Buffer.java new file mode 100644 index 00000000000..f1739e8512e --- /dev/null +++ b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Buffer.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2015-2019 Samuel Audet + * + * 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 + * the Free Software Foundation (subject to the "Classpath" exception), + * either version 2, or any later version (collectively, the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/ + * http://www.gnu.org/software/classpath/license.html + * + * or as provided in the LICENSE.txt file that accompanied this code. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.tensorflow.c_api; + +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.Properties; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public abstract class AbstractTF_Buffer extends Pointer { + protected static class DeleteDeallocator extends TF_Buffer implements Pointer.Deallocator { + DeleteDeallocator(TF_Buffer s) { super(s); } + @Override public void deallocate() { if (!isNull()) TF_DeleteBuffer(this); setNull(); } + } + + public AbstractTF_Buffer(Pointer p) { super(p); } + + /** + * Calls TF_NewBuffer(), and registers a deallocator. + * @return TF_Buffer created. Do not call TF_DeleteBuffer() on it. + */ + public static TF_Buffer newBuffer() { + TF_Buffer b = TF_NewBuffer(); + if (b != null) { + b.deallocator(new DeleteDeallocator(b)); + } + return b; + } + + /** Returns {@code newBufferFromString(new BytePointer(proto)). */ + public static TF_Buffer newBufferFromString(byte[] proto) { + return newBufferFromString(new BytePointer(proto)); + } + + /** + * Calls TF_NewBufferFromString(), and registers a deallocator. + * @return TF_Buffer created. Do not call TF_DeleteBuffer() on it. + */ + public static TF_Buffer newBufferFromString(Pointer proto) { + TF_Buffer b = TF_NewBufferFromString(proto, proto.limit()); + if (b != null) { + b.deallocator(new DeleteDeallocator(b)); + } + return b; + } + + /** + * Calls the deallocator, if registered, otherwise has no effect. + */ + public void delete() { + deallocate(); + } +} diff --git a/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Graph.java b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Graph.java new file mode 100644 index 00000000000..164a40477aa --- /dev/null +++ b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Graph.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2015-2019 Samuel Audet + * + * 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 + * the Free Software Foundation (subject to the "Classpath" exception), + * either version 2, or any later version (collectively, the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/ + * http://www.gnu.org/software/classpath/license.html + * + * or as provided in the LICENSE.txt file that accompanied this code. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.tensorflow.c_api; + +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.Properties; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public abstract class AbstractTF_Graph extends Pointer { + protected static class DeleteDeallocator extends TF_Graph implements Pointer.Deallocator { + DeleteDeallocator(TF_Graph s) { super(s); } + @Override public void deallocate() { if (!isNull()) TF_DeleteGraph(this); setNull(); } + } + + public AbstractTF_Graph(Pointer p) { super(p); } + + /** + * Calls TF_NewGraph(), and registers a deallocator. + * @return TF_Graph created. Do not call TF_DeleteGraph() on it. + */ + public static TF_Graph newGraph() { + TF_Graph g = TF_NewGraph(); + if (g != null) { + g.deallocator(new DeleteDeallocator(g)); + } + return g; + } + + /** + * Calls the deallocator, if registered, otherwise has no effect. + */ + public void delete() { + deallocate(); + } +} diff --git a/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_ImportGraphDefOptions.java b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_ImportGraphDefOptions.java new file mode 100644 index 00000000000..a92446d0b10 --- /dev/null +++ b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_ImportGraphDefOptions.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2015-2019 Samuel Audet + * + * 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 + * the Free Software Foundation (subject to the "Classpath" exception), + * either version 2, or any later version (collectively, the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/ + * http://www.gnu.org/software/classpath/license.html + * + * or as provided in the LICENSE.txt file that accompanied this code. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.tensorflow.c_api; + +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.Properties; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public abstract class AbstractTF_ImportGraphDefOptions extends Pointer { + protected static class DeleteDeallocator extends TF_ImportGraphDefOptions implements Pointer.Deallocator { + DeleteDeallocator(TF_ImportGraphDefOptions s) { super(s); } + @Override public void deallocate() { if (!isNull()) TF_DeleteImportGraphDefOptions(this); setNull(); } + } + + public AbstractTF_ImportGraphDefOptions(Pointer p) { super(p); } + + /** + * Calls TF_NewImportGraphDefOptions(), and registers a deallocator. + * @return TF_ImportGraphDefOptions created. Do not call TF_DeleteImportGraphDefOptions() on it. + */ + public static TF_ImportGraphDefOptions newImportGraphDefOptions() { + TF_ImportGraphDefOptions o = TF_NewImportGraphDefOptions(); + if (o != null) { + o.deallocator(new DeleteDeallocator(o)); + } + return o; + } + + /** + * Calls the deallocator, if registered, otherwise has no effect. + */ + public void delete() { + deallocate(); + } +} diff --git a/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Session.java b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Session.java new file mode 100644 index 00000000000..ff42a38ece0 --- /dev/null +++ b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Session.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2015-2019 Samuel Audet + * + * 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 + * the Free Software Foundation (subject to the "Classpath" exception), + * either version 2, or any later version (collectively, the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/ + * http://www.gnu.org/software/classpath/license.html + * + * or as provided in the LICENSE.txt file that accompanied this code. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.tensorflow.c_api; + +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.Properties; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public abstract class AbstractTF_Session extends Pointer { + protected static class DeleteDeallocator extends TF_Session implements Pointer.Deallocator { + DeleteDeallocator(TF_Session s) { super(s); } + @Override public void deallocate() { if (!isNull()) TF_DeleteSession(this, TF_Status.newStatus()); setNull(); } + } + + /** References to prevent deallocation. */ + protected TF_Graph graph; + protected TF_SessionOptions opts; + protected TF_Status status; + + public AbstractTF_Session(Pointer p) { super(p); } + + /** + * Calls TF_NewSession(), and registers a deallocator. + * @return TF_Session created. Do not call TF_DeleteSession() on it. + */ + public static TF_Session newSession(TF_Graph graph, TF_SessionOptions opts, TF_Status status) { + TF_Session s = TF_NewSession(graph, opts, status); + if (s != null) { + s.graph = graph; + s.opts = opts; + s.status = status; + s.deallocator(new DeleteDeallocator(s)); + } + return s; + } + + /** + * Calls the deallocator, if registered, otherwise has no effect. + */ + public void delete() { + deallocate(); + } +} diff --git a/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_SessionOptions.java b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_SessionOptions.java new file mode 100644 index 00000000000..fd3485ecee8 --- /dev/null +++ b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_SessionOptions.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2015-2019 Samuel Audet + * + * 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 + * the Free Software Foundation (subject to the "Classpath" exception), + * either version 2, or any later version (collectively, the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/ + * http://www.gnu.org/software/classpath/license.html + * + * or as provided in the LICENSE.txt file that accompanied this code. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.tensorflow.c_api; + +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.Properties; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public abstract class AbstractTF_SessionOptions extends Pointer { + protected static class DeleteDeallocator extends TF_SessionOptions implements Pointer.Deallocator { + DeleteDeallocator(TF_SessionOptions s) { super(s); } + @Override public void deallocate() { if (!isNull()) TF_DeleteSessionOptions(this); setNull(); } + } + + public AbstractTF_SessionOptions(Pointer p) { super(p); } + + /** + * Calls TF_NewSessionOptions(), and registers a deallocator. + * @return TF_SessionOptions created. Do not call TF_DeleteSessionOptions() on it. + */ + public static TF_SessionOptions newSessionOptions() { + TF_SessionOptions o = TF_NewSessionOptions(); + if (o != null) { + o.deallocator(new DeleteDeallocator(o)); + } + return o; + } + + /** + * Calls the deallocator, if registered, otherwise has no effect. + */ + public void delete() { + deallocate(); + } +} diff --git a/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Status.java b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Status.java new file mode 100644 index 00000000000..e4748c345a5 --- /dev/null +++ b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Status.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2015-2019 Samuel Audet + * + * 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 + * the Free Software Foundation (subject to the "Classpath" exception), + * either version 2, or any later version (collectively, the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/ + * http://www.gnu.org/software/classpath/license.html + * + * or as provided in the LICENSE.txt file that accompanied this code. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.tensorflow.c_api; + +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.Properties; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public abstract class AbstractTF_Status extends Pointer { + protected static class DeleteDeallocator extends TF_Status implements Pointer.Deallocator { + DeleteDeallocator(TF_Status s) { super(s); } + @Override public void deallocate() { if (!isNull()) TF_DeleteStatus(this); setNull(); } + } + + public AbstractTF_Status(Pointer p) { super(p); } + + /** + * Calls TF_NewStatus(), and registers a deallocator. + * @return TF_Status created. Do not call TF_DeleteStatus() on it. + */ + public static TF_Status newStatus() { + TF_Status s = TF_NewStatus(); + if (s != null) { + s.deallocator(new DeleteDeallocator(s)); + } + return s; + } + + /** + * Calls the deallocator, if registered, otherwise has no effect. + */ + public void delete() { + deallocate(); + } +} diff --git a/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Tensor.java b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Tensor.java new file mode 100644 index 00000000000..52725d7809f --- /dev/null +++ b/core/core-api/src/main/java/org/tensorflow/c_api/AbstractTF_Tensor.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2015-2019 Samuel Audet + * + * 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 + * the Free Software Foundation (subject to the "Classpath" exception), + * either version 2, or any later version (collectively, the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/ + * http://www.gnu.org/software/classpath/license.html + * + * or as provided in the LICENSE.txt file that accompanied this code. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.tensorflow.c_api; + +import org.bytedeco.javacpp.*; +import org.bytedeco.javacpp.annotation.Properties; + +import static org.tensorflow.c_api.global.tensorflow.*; + +@Properties(inherit = org.tensorflow.c_api.presets.tensorflow.class) +public abstract class AbstractTF_Tensor extends Pointer { + protected static class DeleteDeallocator extends TF_Tensor implements Pointer.Deallocator { + DeleteDeallocator(TF_Tensor s) { super(s); } + @Override public void deallocate() { if (!isNull()) TF_DeleteTensor(this); setNull(); } + } + + /** TensorFlow crashes if we don't pass it a deallocator, so... */ + protected static Deallocator_Pointer_long_Pointer dummyDeallocator = new Deallocator_Pointer_long_Pointer() { + @Override public void call(Pointer data, long len, Pointer arg) { } + }; + + static { + PointerScope s = PointerScope.getInnerScope(); + if (s != null) { + s.detach(dummyDeallocator); + } + } + + /** A reference to prevent deallocation. */ + protected Pointer pointer; + + public AbstractTF_Tensor(Pointer p) { super(p); } + + /** + * Calls TF_NewTensor(), and registers a deallocator. + * @return TF_Tensor created. Do not call TF_DeleteTensor() on it. + */ + public static TF_Tensor newTensor(int dtype, long[] dims, Pointer data) { + TF_Tensor t = TF_NewTensor(dtype, dims, dims.length, data, data.limit(), dummyDeallocator, null); + if (t != null) { + t.pointer = data; + t.deallocator(new DeleteDeallocator(t)); + } + return t; + } + + /** + * Calls TF_AllocateTensor(), and registers a deallocator. + * @return TF_Tensor created. Do not call TF_DeleteTensor() on it. + */ + public static TF_Tensor allocateTensor(int dtype, long[] dims, long length) { + TF_Tensor t = TF_AllocateTensor(dtype, dims, dims.length, length); + if (t != null) { + t.deallocator(new DeleteDeallocator(t)); + } + return t; + } + + /** + * Calls the deallocator, if registered, otherwise has no effect. + */ + public void delete() { + deallocate(); + } +} diff --git a/core/core-api/src/main/java/org/tensorflow/c_api/presets/tensorflow.java b/core/core-api/src/main/java/org/tensorflow/c_api/presets/tensorflow.java new file mode 100644 index 00000000000..54a36472a31 --- /dev/null +++ b/core/core-api/src/main/java/org/tensorflow/c_api/presets/tensorflow.java @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2019 Samuel Audet + * + * 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 + * the Free Software Foundation (subject to the "Classpath" exception), + * either version 2, or any later version (collectively, the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.gnu.org/licenses/ + * http://www.gnu.org/software/classpath/license.html + * + * or as provided in the LICENSE.txt file that accompanied this code. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.tensorflow.c_api.presets; + +import org.bytedeco.javacpp.BytePointer; +import org.bytedeco.javacpp.Loader; +import org.bytedeco.javacpp.annotation.Platform; +import org.bytedeco.javacpp.annotation.Properties; +import org.bytedeco.javacpp.tools.Info; +import org.bytedeco.javacpp.tools.InfoMap; +import org.bytedeco.javacpp.tools.InfoMapper; +import org.bytedeco.javacpp.tools.Logger; + +/** + * + * @author Samuel Audet + */ +@Properties( + value = { + @Platform( + value = {"linux", "macosx", "windows"}, + include = { + "tensorflow/c/tf_attrtype.h", + "tensorflow/c/tf_datatype.h", + "tensorflow/c/tf_status.h", + "tensorflow/c/tf_tensor.h", + "tensorflow/c/c_api.h", + "tensorflow/c/env.h", + "tensorflow/c/kernels.h", + "tensorflow/c/ops.h", + "tensorflow/c/eager/c_api.h" + }, + link = {"tensorflow_framework@.2", "tensorflow@.2"} + ), + @Platform( + 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", + 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.tensorflow.c_api", + global = "org.tensorflow.c_api.global.tensorflow") +public class tensorflow implements InfoMapper { + + public void map(InfoMap infoMap) { + infoMap.put(new Info("TF_CAPI_EXPORT").cppTypes().annotations()) + .put(new Info("TF_Buffer::data").javaText("public native @Const Pointer data(); public native TF_Buffer data(Pointer data);")) + .put(new Info("TF_Status").pointerTypes("TF_Status").base("org.tensorflow.c_api.AbstractTF_Status")) + .put(new Info("TF_Buffer").pointerTypes("TF_Buffer").base("org.tensorflow.c_api.AbstractTF_Buffer")) + .put(new Info("TF_Tensor").pointerTypes("TF_Tensor").base("org.tensorflow.c_api.AbstractTF_Tensor")) + .put(new Info("TF_SessionOptions").pointerTypes("TF_SessionOptions").base("org.tensorflow.c_api.AbstractTF_SessionOptions")) + .put(new Info("TF_Graph").pointerTypes("TF_Graph").base("org.tensorflow.c_api.AbstractTF_Graph")) + .put(new Info("TF_Graph::graph").javaText("public native @MemberGetter @ByRef Graph graph();")) + .put(new Info("TF_Graph::refiner").javaText("public native @MemberGetter @ByRef ShapeRefiner refiner();")) + .put(new Info("TF_ImportGraphDefOptions").pointerTypes("TF_ImportGraphDefOptions").base("org.tensorflow.c_api.AbstractTF_ImportGraphDefOptions")) + .put(new Info("TF_Operation", "TFE_MonitoringCounterCell", "TFE_MonitoringSamplerCell", + "TFE_MonitoringCounter0", "TFE_MonitoringCounter1", "TFE_MonitoringCounter2", + "TFE_MonitoringIntGaugeCell", "TFE_MonitoringStringGaugeCell", "TFE_MonitoringBoolGaugeCell", + "TFE_MonitoringIntGauge0", "TFE_MonitoringIntGauge1", "TFE_MonitoringIntGauge2", + "TFE_MonitoringStringGauge0", "TFE_MonitoringStringGauge1", "TFE_MonitoringStringGauge2", + "TFE_MonitoringBoolGauge0", "TFE_MonitoringBoolGauge1", "TFE_MonitoringBoolGauge2", + "TFE_MonitoringSampler0", "TFE_MonitoringSampler1", "TFE_MonitoringSampler2").purify()) + .put(new Info("TF_Operation::node").javaText("public native @MemberGetter @ByRef Node node();")) + .put(new Info("TFE_MonitoringCounterCell::cell").javaText("public native @MemberGetter @ByRef CounterCell cell();")) + .put(new Info("TFE_MonitoringSamplerCell::cell").javaText("public native @MemberGetter @ByRef SamplerCell cell();")) + .put(new Info("TFE_MonitoringIntGaugeCell::cell").javaText("public native @MemberGetter @ByRef IntGaugeCell cell();")) + .put(new Info("TFE_MonitoringStringGaugeCell::cell").javaText("public native @MemberGetter @ByRef StringGaugeCell cell();")) + .put(new Info("TFE_MonitoringBoolGaugeCell::cell").javaText("public native @MemberGetter @ByRef BoolGaugeCell cell();")) + .put(new Info("TFE_Context::context").javaText("@MemberGetter public native @ByRef EagerContext context();")) + .put(new Info("TFE_Op::operation").javaText("@MemberGetter public native @ByRef EagerOperation operation();")) + .put(new Info("TF_ShapeInferenceContextDimValueKnown").skip()) + .put(new Info("TF_Session").pointerTypes("TF_Session").base("org.tensorflow.c_api.AbstractTF_Session")) + .put(new Info("TF_WhileParams").purify()); + } +} diff --git a/core/pom.xml b/core/pom.xml index ac6b62c0ad4..edaf7a13f6b 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -32,11 +32,685 @@ annotation-processor - tensorflow-core-native - tensorflow-core + core-api + core-api-platform + + ${os.adjusted.name}-${os.arch} + false + false + false + + ${javacpp.platform} + linux-armhf${javacpp.platform.extension} + linux-arm64${javacpp.platform.extension} + linux-ppc64le${javacpp.platform.extension} + linux-x86${javacpp.platform.extension} + linux-x86_64${javacpp.platform.extension} + macosx-x86_64${javacpp.platform.extension} + windows-x86${javacpp.platform.extension} + windows-x86_64${javacpp.platform.extension} + + + + javacpp-platform-default + + + !javacpp.platform + + + + ${os.name}-${os.arch} + + + + + javacpp-platform-custom + + + javacpp.platform + + + + ${javacpp.platform}${javacpp.platform.extension} + ${javacpp.platform}${javacpp.platform.extension} + ${javacpp.platform}${javacpp.platform.extension} + ${javacpp.platform}${javacpp.platform.extension} + ${javacpp.platform}${javacpp.platform.extension} + ${javacpp.platform}${javacpp.platform.extension} + ${javacpp.platform}${javacpp.platform.extension} + ${javacpp.platform}${javacpp.platform.extension} + + + + + javacpp-platform-host + + + javacpp.platform.host + + + + ${os.name}-${os.arch}${javacpp.platform.extension} + ${os.name}-${os.arch}${javacpp.platform.extension} + ${os.name}-${os.arch}${javacpp.platform.extension} + ${os.name}-${os.arch}${javacpp.platform.extension} + ${os.name}-${os.arch}${javacpp.platform.extension} + ${os.name}-${os.arch}${javacpp.platform.extension} + ${os.name}-${os.arch}${javacpp.platform.extension} + ${os.name}-${os.arch}${javacpp.platform.extension} + ${os.name}-${os.arch}${javacpp.platform.extension} + + + + + javacpp.platform.custom-true + + + javacpp.platform.custom + + + + + + + + + + + + + + + + + javacpp-platform-none + + + javacpp.platform.none + + + + + + + + + + + + + + + + + javacpp-platform-linux-armhf + + + javacpp.platform + linux-armhf + + + + ${javacpp.platform}${javacpp.platform.extension} + + + + + + + + + + + + javacpp-platform-linux-arm64 + + + javacpp.platform + linux-arm64 + + + + + ${javacpp.platform}${javacpp.platform.extension} + + + + + + + + + + + javacpp-platform-linux-ppc64le + + + javacpp.platform + linux-ppc64le + + + + + + ${javacpp.platform}${javacpp.platform.extension} + + + + + + + + + + javacpp-platform-linux-x86 + + + javacpp.platform + linux-x86 + + + + + + + ${javacpp.platform}${javacpp.platform.extension} + + + + + + + + + javacpp-platform-linux-x86_64 + + + javacpp.platform + linux-x86_64 + + + + + + + + ${javacpp.platform}${javacpp.platform.extension} + + + + + + + + javacpp-platform-macosx-x86_64 + + + javacpp.platform + macosx-x86_64 + + + + + + + + + ${javacpp.platform}${javacpp.platform.extension} + + + + + + + javacpp-platform-windows-x86 + + + javacpp.platform + windows-x86 + + + + + + + + + + ${javacpp.platform}${javacpp.platform.extension} + + + + + + javacpp-platform-windows-x86_64 + + + javacpp.platform + windows-x86_64 + + + + + + + + + + + ${javacpp.platform}${javacpp.platform.extension} + + + + + + javacpp.platform.linux-armhf-true + + + javacpp.platform.linux-armhf + + + + linux-armhf + + + + + javacpp.platform.linux-arm64-true + + + javacpp.platform.linux-arm64 + + + + linux-arm64 + + + + + javacpp.platform.linux-ppc64le-true + + + javacpp.platform.linux-ppc64le + + + + linux-ppc64le + + + + + javacpp.platform.linux-x86-true + + + javacpp.platform.linux-x86 + + + + linux-x86 + + + + + javacpp.platform.linux-x86_64-true + + + javacpp.platform.linux-x86_64 + + + + linux-x86_64 + + + + + javacpp.platform.macosx-x86_64-true + + + javacpp.platform.macosx-x86_64 + + + + macosx-x86_64 + + + + + javacpp.platform.windows-x86-true + + + javacpp.platform.windows-x86 + + + + windows-x86 + + + + + javacpp.platform.windows-x86_64-true + + + javacpp.platform.windows-x86_64 + + + + windows-x86_64 + + + + + javacpp.platform.custom-linux-arm + + + javacpp.platform.host + + linuxarm + + + linux-armhf + + + + + javacpp.platform.custom-linux-armhf + + + javacpp.platform.host + + linuxarmhf + + + linux-armhf + + + + + javacpp.platform.custom-linux-aarch64 + + + javacpp.platform.host + + linuxaarch64 + + + linux-arm64 + + + + + javacpp.platform.custom-linux-armv8 + + + javacpp.platform.host + + linuxarmv8 + + + linux-arm64 + + + + + javacpp.platform.custom-linux-arm64 + + + javacpp.platform.host + + linuxarm64 + + + linux-arm64 + + + + + javacpp.platform.custom-linux-ppc64le + + + javacpp.platform.host + + linuxppc64le + + + linux-ppc64le + + + + + javacpp.platform.custom-linux-amd64 + + + javacpp.platform.host + + linuxamd64 + + + linux-x86_64 + + + + + javacpp.platform.custom-linux-x86-64 + + + javacpp.platform.host + + linuxx86-64 + + + linux-x86_64 + + + + + javacpp.platform.custom-linux-x86_64 + + + javacpp.platform.host + + linuxx86_64 + + + linux-x86_64 + + + + + javacpp.platform.custom-macosx-amd64 + + + javacpp.platform.host + + mac os xamd64 + + + macosx-x86_64 + + + + + javacpp.platform.custom-macosx-x86-64 + + + javacpp.platform.host + + mac os xx86-64 + + + macosx-x86_64 + + + + + javacpp.platform.custom-macosx-x86_64 + + + javacpp.platform.host + + mac os xx86_64 + + + macosx-x86_64 + + + + + javacpp.platform.custom-windows-amd64 + + + javacpp.platform.host + + windowsamd64 + + + windows-x86_64 + + + + + javacpp.platform.custom-windows-x86-64 + + + javacpp.platform.host + + windowsx86-64 + + + windows-x86_64 + + + + + javacpp.platform.custom-windows-x86_64 + + + javacpp.platform.host + + windowsx86_64 + + + windows-x86_64 + + + + + + linuxos + + linux + + + linux + linux + + + + macosx + + mac os x + + + darwin + macosx + + + + windowsos + + windows + + + windows + windows + + + + arm + + arm + + + armhf + + + + aarch64 + + aarch64 + + + arm64 + + + + armv8 + + armv8 + + + arm64 + + + + i386 + + i386 + + + x86 + + + + i486 + + i486 + + + x86 + + + + i586 + + i586 + + + x86 + + + + i686 + + i686 + + + x86 + + + + amd64 + + amd64 + + + x86_64 + + + + x86-64 + + x86-64 + + + x86_64 + + + linux @@ -74,9 +748,5 @@ - - ${os.adjusted.name}-${os.arch} - -