Skip to content

Commit 39e783b

Browse files
committed
NodeBuilder fix
Signed-off-by: Ryan Nett <rnett@calpoly.edu>
1 parent 6c902f1 commit 39e783b

File tree

5 files changed

+57
-13
lines changed

5 files changed

+57
-13
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Targeted by JavaCPP version 1.5.4: DO NOT EDIT THIS FILE
2+
3+
package org.tensorflow.internal.c_api;
4+
5+
import java.nio.*;
6+
import org.bytedeco.javacpp.*;
7+
import org.bytedeco.javacpp.annotation.*;
8+
9+
import static org.tensorflow.internal.c_api.global.tensorflow.*;
10+
11+
@Namespace("tensorflow") @Opaque @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
12+
public class NodeBuilder extends Pointer {
13+
/** Empty constructor. Calls {@code super((Pointer)null)}. */
14+
public NodeBuilder() { super((Pointer)null); }
15+
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
16+
public NodeBuilder(Pointer p) { super(p); }
17+
}

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/TF_OperationDescription.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@
88

99
import static org.tensorflow.internal.c_api.global.tensorflow.*;
1010

11+
// Parsed from tensorflow/c/c_api_internal.h
1112

12-
// Operation being built. The underlying graph must outlive this.
13-
@Opaque @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
13+
@NoOffset @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
1414
public class TF_OperationDescription extends Pointer {
15-
/** Empty constructor. Calls {@code super((Pointer)null)}. */
16-
public TF_OperationDescription() { super((Pointer)null); }
15+
static { Loader.load(); }
1716
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
1817
public TF_OperationDescription(Pointer p) { super(p); }
18+
19+
public TF_OperationDescription(TF_Graph g, @Cast("const char*") BytePointer op_type,
20+
@Cast("const char*") BytePointer node_name) { super((Pointer)null); allocate(g, op_type, node_name); }
21+
private native void allocate(TF_Graph g, @Cast("const char*") BytePointer op_type,
22+
@Cast("const char*") BytePointer node_name);
23+
public TF_OperationDescription(TF_Graph g, String op_type,
24+
String node_name) { super((Pointer)null); allocate(g, op_type, node_name); }
25+
private native void allocate(TF_Graph g, String op_type,
26+
String node_name);
27+
28+
public native @ByRef NodeBuilder node_builder(); public native TF_OperationDescription node_builder(NodeBuilder setter);
29+
public native TF_Graph graph(); public native TF_OperationDescription graph(TF_Graph setter);
30+
1931
}

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/TF_Scope.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public class TF_Scope extends Pointer {
161161
/** Update the builder with properties accumulated in this scope. Does not set
162162
* status(). */
163163
// TODO(skyewm): NodeBuilder is not part of public API
164-
public native void UpdateBuilder(TF_OperationDescription builder);
164+
public native void UpdateBuilder(NodeBuilder builder);
165165
// END_SKIP_DOXYGEN
166166

167167
public native @Cast("bool") boolean ok();

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/global/tensorflow.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,8 @@ public static native void TF_SetConfig(TF_SessionOptions options,
943943
// Destroy an options object. Graph will be deleted once no more
944944
// TFSession's are referencing it.
945945
public static native void TF_DeleteGraph(TF_Graph arg0);
946-
// Targeting ../TF_OperationDescription.java
947-
948946

947+
// Operation being built. The underlying graph must outlive this.
949948
// Targeting ../TF_Operation.java
950949

951950

@@ -3044,6 +3043,11 @@ public static native void TF_RegisterFilesystemPlugin(
30443043
// #endif // TENSORFLOW_C_C_API_H_
30453044

30463045

3046+
// Targeting ../TF_OperationDescription.java
3047+
3048+
3049+
3050+
30473051
// Parsed from tensorflow/c/kernels.h
30483052

30493053
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
@@ -4410,6 +4414,9 @@ public static native void TFE_ContextExportRunMetadata(TFE_Context ctx,
44104414
// #include "tensorflow/core/common_runtime/graph_constructor.h"
44114415
// #include "tensorflow/core/lib/core/status.h"
44124416
// #include "tensorflow/core/lib/gtl/array_slice.h"
4417+
// Targeting ../NodeBuilder.java
4418+
4419+
44134420
// Targeting ../TF_Scope.java
44144421

44154422

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/internal/c_api/presets/tensorflow.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,16 @@
4848
"tensorflow/c/tf_tensor.h",
4949
"tensorflow/c/tf_tstring.h",
5050
"tensorflow/c/c_api.h",
51+
"tensorflow/c/c_api_internal.h",
5152
// "tensorflow/c/env.h",
5253
"tensorflow/c/kernels.h",
5354
"tensorflow/c/ops.h",
5455
"tensorflow/c/eager/c_api.h",
5556
"tensorflow/cc/framework/scope.h"
5657
},
58+
exclude = {
59+
"tensorflow/c/c_api_internal.h"
60+
},
5761
link = "tensorflow_cc@.2",
5862
preload = {"iomp5", "mklml", "mklml_intel", "tensorflow_framework@.2"},
5963
preloadresource = "/org/bytedeco/mkldnn/",
@@ -198,7 +202,11 @@ public void init(ClassProperties properties) {
198202
}
199203

200204
public void map(InfoMap infoMap) {
201-
infoMap.put(new Info("TF_CAPI_EXPORT", "TF_Bool").cppTypes().annotations())
205+
infoMap
206+
.put(new Info("c_api_internal.h")
207+
.linePatterns("struct TF_OperationDescription \\{", "\\};"))
208+
.put(new Info("TF_CAPI_EXPORT", "TF_Bool").cppTypes().annotations())
209+
.put(new Info("tensorflow::string", "string").cppTypes("std::string"))
202210
.put(new Info("TF_Buffer::data").javaText("public native @Const Pointer data(); public native TF_Buffer data(Pointer data);"))
203211
.put(new Info("TF_Status").pointerTypes("TF_Status").base("org.tensorflow.internal.c_api.AbstractTF_Status"))
204212
.put(new Info("TF_Buffer").pointerTypes("TF_Buffer").base("org.tensorflow.internal.c_api.AbstractTF_Buffer"))
@@ -230,14 +238,13 @@ public void map(InfoMap infoMap) {
230238
.put(new Info("TFE_TensorHandle").pointerTypes("TFE_TensorHandle").base("org.tensorflow.internal.c_api.AbstractTFE_TensorHandle"))
231239
.put(new Info("TF_ShapeInferenceContextDimValueKnown", "TFE_NewTensorHandle(const tensorflow::Tensor&, TF_Status*)").skip())
232240
.put(new Info("tensorflow::Scope").javaNames("TF_Scope").pointerTypes("TF_Scope"))
233-
.put(new Info("tensorflow::NodeBuilder").cppTypes("TF_OperationDescription"))
241+
.put(new Info("TF_OperationDescription").pointerTypes("TF_OperationDescription"))
242+
.put(new Info("tensorflow::NodeBuilder").pointerTypes("NodeBuilder"))
234243
.put(new Info("tensorflow::Status").cppTypes("TF_Status"))
235-
.put(new Info("tensorflow::Graph").cppTypes("TF_Graph"))
236-
.put(new Info("string").cppTypes("std::string"))
237244
.put(new Info("gtl::ArraySlice<TF_Operation>").cppTypes("std::vector<TF_Operation>"))
238245
.put(new Info("Output").cppTypes("TF_Output"))
239246
.put(new Info("Operation").cppTypes("TF_Operation"))
240-
.put(new Info("tensorflow::CompositeOpScopes", "tensorflow::GraphDef", "tensorflow::Scope::graph",
247+
.put(new Info("tensorflow::CompositeOpScopes", "tensorflow::Graph", "tensorflow::GraphDef", "tensorflow::Scope::graph",
241248
"tensorflow::Scope::graph_as_shared_ptr",
242249
"tensorflow::Scope::ToGraphDef",
243250
"tensorflow::Scope::ToGraph",
@@ -250,7 +257,8 @@ public void map(InfoMap infoMap) {
250257
"tensorflow::Scope::ColocateWith",
251258
"tensorflow::Scope::WithXlaCluster",
252259
"tensorflow::Scope::WithAssignedDevice",
253-
"tensorflow::CreateOutputWithScope"
260+
"tensorflow::CreateOutputWithScope",
261+
"TF_OperationDescription::colocation_constraints"
254262
).skip());
255263
}
256264
}

0 commit comments

Comments
 (0)