-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graph.java
164 lines (143 loc) · 4.91 KB
/
Graph.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package org.tensorflow;
public final class Graph implements AutoCloseable {
private long nativeHandle;
private final Object nativeHandleLock;
private int refcount;
class Reference implements AutoCloseable {
private boolean active;
final /* synthetic */ Graph this$0;
private Reference(Graph graph) {
boolean z = true;
this.this$0 = graph;
synchronized (graph.nativeHandleLock) {
if (graph.nativeHandle == 0) {
z = false;
}
this.active = z;
if (this.active) {
this.active = true;
graph.refcount = graph.refcount + 1;
} else {
throw new IllegalStateException("close() has been called on the Graph");
}
}
}
/* JADX WARNING: inconsistent code. */
/* Code decompiled incorrectly, please refer to instructions dump. */
public void close() {
/*
r2 = this;
r0 = r2.this$0;
r1 = r0.nativeHandleLock;
monitor-enter(r1);
r0 = r2.active; Catch:{ all -> 0x0023 }
if (r0 != 0) goto L_0x000d;
L_0x000b:
monitor-exit(r1); Catch:{ all -> 0x0023 }
L_0x000c:
return;
L_0x000d:
r0 = 0;
r2.active = r0; Catch:{ all -> 0x0023 }
r0 = r2.this$0; Catch:{ all -> 0x0023 }
r0 = org.tensorflow.Graph.access$206(r0); Catch:{ all -> 0x0023 }
if (r0 != 0) goto L_0x0021;
L_0x0018:
r0 = r2.this$0; Catch:{ all -> 0x0023 }
r0 = r0.nativeHandleLock; Catch:{ all -> 0x0023 }
r0.notifyAll(); Catch:{ all -> 0x0023 }
L_0x0021:
monitor-exit(r1); Catch:{ all -> 0x0023 }
goto L_0x000c;
L_0x0023:
r0 = move-exception;
monitor-exit(r1); Catch:{ all -> 0x0023 }
throw r0;
*/
throw new UnsupportedOperationException("Method not decompiled: org.tensorflow.Graph.Reference.close():void");
}
public long nativeHandle() {
long access$100;
synchronized (this.this$0.nativeHandleLock) {
access$100 = this.active ? this.this$0.nativeHandle : 0;
}
return access$100;
}
}
private static native long allocate();
private static native void delete(long j);
private static native void importGraphDef(long j, byte[] bArr, String str) throws IllegalArgumentException;
private static native long operation(long j, String str);
private static native byte[] toGraphDef(long j);
static /* synthetic */ int access$206(Graph graph) {
int i = graph.refcount - 1;
graph.refcount = i;
return i;
}
public Graph() {
this.nativeHandleLock = new Object();
this.refcount = 0;
this.nativeHandle = allocate();
}
Graph(long j) {
this.nativeHandleLock = new Object();
this.refcount = 0;
this.nativeHandle = j;
}
public void close() {
synchronized (this.nativeHandleLock) {
if (this.nativeHandle == 0) {
return;
}
while (this.refcount > 0) {
try {
this.nativeHandleLock.wait();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
}
delete(this.nativeHandle);
this.nativeHandle = 0;
}
}
public Operation operation(String str) {
Operation operation;
synchronized (this.nativeHandleLock) {
long operation2 = operation(this.nativeHandle, str);
if (operation2 == 0) {
operation = null;
} else {
operation = new Operation(this, operation2);
}
}
return operation;
}
public OperationBuilder opBuilder(String str, String str2) {
return new OperationBuilder(this, str, str2);
}
public void importGraphDef(byte[] bArr) throws IllegalArgumentException {
importGraphDef(bArr, "");
}
public void importGraphDef(byte[] bArr, String str) throws IllegalArgumentException {
if (bArr == null || str == null) {
throw new IllegalArgumentException("graphDef and prefix cannot be null");
}
synchronized (this.nativeHandleLock) {
importGraphDef(this.nativeHandle, bArr, str);
}
}
public byte[] toGraphDef() {
byte[] toGraphDef;
synchronized (this.nativeHandleLock) {
toGraphDef = toGraphDef(this.nativeHandle);
}
return toGraphDef;
}
Reference ref() {
return new Reference();
}
static {
TensorFlow.init();
}
}