Skip to content

Commit 0fe34e6

Browse files
committed
Native fixes, dangerous op creation
Signed-off-by: Ryan Nett <[email protected]>
1 parent c1417d2 commit 0fe34e6

File tree

10 files changed

+3366
-2494
lines changed

10 files changed

+3366
-2494
lines changed

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

Lines changed: 214 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,222 @@
22

33
package org.tensorflow.internal.c_api;
44

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.*;
5+
import org.bytedeco.javacpp.BytePointer;
6+
import org.bytedeco.javacpp.Loader;
7+
import org.bytedeco.javacpp.Pointer;
8+
import org.bytedeco.javacpp.annotation.Cast;
9+
import org.bytedeco.javacpp.annotation.Name;
10+
import org.bytedeco.javacpp.annotation.NoOffset;
11+
import org.bytedeco.javacpp.annotation.Properties;
12+
import org.bytedeco.javacpp.annotation.StdString;
1013

1114
// Parsed from tensorflow/core/graph/graph.h
1215

13-
@Name("tensorflow::Node") @Opaque @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
16+
@Name("tensorflow::Node")
17+
@NoOffset
18+
@Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
1419
public class Node extends Pointer {
15-
/** Empty constructor. Calls {@code super((Pointer)null)}. */
16-
public Node() { super((Pointer)null); }
17-
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
18-
public Node(Pointer p) { super(p); }
20+
21+
static {
22+
Loader.load();
23+
}
24+
25+
/**
26+
* Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}.
27+
*/
28+
public Node(Pointer p) {
29+
super(p);
30+
}
31+
32+
public native @StdString
33+
BytePointer DebugString();
34+
35+
public native int id();
36+
37+
public native int cost_id();
38+
39+
public native @StdString
40+
BytePointer name();
41+
42+
public native void set_name(@StdString BytePointer name);
43+
44+
public native void set_name(@StdString String name);
45+
46+
public native @StdString
47+
BytePointer type_string();
48+
49+
// def() provides the NodeDef the user supplied, but the specifics
50+
// of this Node may have changed due to placement, optimization, etc.
51+
// In particular:
52+
// * def().name() will match name();
53+
// * def().op() will match type_string() and op_def().name();
54+
// * def().input() is not reliable, use "in_edges()" below instead;
55+
// * def().device() is the "user's requested device" and may not match
56+
// the actual assigned device, see assigned_device_name() below;
57+
// * def().attr() is authoritative.
58+
// TODO(irving): Replace with NodeInfo.
59+
60+
// input and output types
61+
public native @Cast("tensorflow::int32")
62+
int num_inputs();
63+
64+
public native @Cast("tensorflow::int32")
65+
int num_outputs();
66+
67+
// The device requested by the user. For the actual assigned device,
68+
// use assigned_device_name() below.
69+
public native @StdString
70+
BytePointer requested_device();
71+
72+
// This changes the user requested device but not necessarily the device that
73+
// on which the operation will run.
74+
public native void set_requested_device(@StdString BytePointer device);
75+
76+
public native void set_requested_device(@StdString String device);
77+
78+
// This gives the device the runtime has assigned this node to. If
79+
// you want the device the user requested, use def().device() instead.
80+
// TODO(josh11b): Validate that the assigned_device, if not empty:
81+
// fully specifies a device, and satisfies def().device().
82+
// TODO(josh11b): Move assigned_device_name outside of Node into a
83+
// NodeId->DeviceName map.
84+
public native @StdString
85+
BytePointer assigned_device_name();
86+
87+
public native void set_assigned_device_name(@StdString BytePointer device_name);
88+
89+
public native void set_assigned_device_name(@StdString String device_name);
90+
91+
public native @Cast("bool")
92+
boolean has_assigned_device_name();
93+
94+
public native int assigned_device_name_index();
95+
96+
public native void set_assigned_device_name_index(int index);
97+
98+
// Sets 'original_node_names' field of this node's DebugInfo proto to
99+
// 'names'.
100+
101+
// Read only access to attributes
102+
103+
// Inputs requested by the NodeDef. For the actual inputs, use in_edges.
104+
105+
// Get the neighboring nodes via edges either in or out of this node. This
106+
// includes control edges.
107+
108+
// Node type helpers.
109+
public native @Cast("bool")
110+
boolean IsSource();
111+
112+
public native @Cast("bool")
113+
boolean IsSink();
114+
115+
// Anything other than the special Source & Sink nodes.
116+
public native @Cast("bool")
117+
boolean IsOp();
118+
119+
// Node class helpers
120+
public native @Cast("bool")
121+
boolean IsSwitch();
122+
123+
public native @Cast("bool")
124+
boolean IsMerge();
125+
126+
public native @Cast("bool")
127+
boolean IsEnter();
128+
129+
public native @Cast("bool")
130+
boolean IsExit();
131+
132+
public native @Cast("bool")
133+
boolean IsNextIteration();
134+
135+
public native @Cast("bool")
136+
boolean IsLoopCond();
137+
138+
public native @Cast("bool")
139+
boolean IsControlTrigger();
140+
141+
public native @Cast("bool")
142+
boolean IsSend();
143+
144+
public native @Cast("bool")
145+
boolean IsRecv();
146+
147+
public native @Cast("bool")
148+
boolean IsConstant();
149+
150+
public native @Cast("bool")
151+
boolean IsVariable();
152+
153+
public native @Cast("bool")
154+
boolean IsIdentity();
155+
156+
public native @Cast("bool")
157+
boolean IsGetSessionHandle();
158+
159+
public native @Cast("bool")
160+
boolean IsGetSessionTensor();
161+
162+
public native @Cast("bool")
163+
boolean IsDeleteSessionTensor();
164+
165+
public native @Cast("bool")
166+
boolean IsControlFlow();
167+
168+
public native @Cast("bool")
169+
boolean IsHostSend();
170+
171+
public native @Cast("bool")
172+
boolean IsHostRecv();
173+
174+
public native @Cast("bool")
175+
boolean IsScopedAllocator();
176+
177+
public native @Cast("bool")
178+
boolean IsCollective();
179+
180+
public native @Cast("bool")
181+
boolean IsMetadata();
182+
183+
public native @Cast("bool")
184+
boolean IsFakeParam();
185+
186+
public native @Cast("bool")
187+
boolean IsPartitionedCall();
188+
189+
// Returns true if this node is any kind of function call node.
190+
//
191+
// NOTE: "function call nodes" include partitioned call ops, symbolic gradient
192+
// ops, and ops whose type_string is the name of a function ("function ops").
193+
public native @Cast("bool")
194+
boolean IsFunctionCall();
195+
196+
public native @Cast("bool")
197+
boolean IsIfNode();
198+
199+
public native @Cast("bool")
200+
boolean IsWhileNode();
201+
202+
public native @Cast("bool")
203+
boolean IsCaseNode();
204+
205+
// Is this node a function input
206+
public native @Cast("bool")
207+
boolean IsArg();
208+
209+
// Is this node a function output
210+
public native @Cast("bool")
211+
boolean IsRetval();
212+
213+
// Returns into '*e' the edge connecting to the 'idx' input of this Node.
214+
215+
// Returns into '*edges' the input data edges of this Node, indexed by input
216+
// number. Does not return control edges.
217+
218+
// Returns into '*n' the node that has an output connected to the
219+
// 'idx' input of this Node.
220+
221+
// Returns into '*t' the idx-th input tensor of this node, represented as the
222+
// output tensor of input_node(idx).
19223
}

0 commit comments

Comments
 (0)