Skip to content

Commit 12d579c

Browse files
committed
Add missing requireHandles
Signed-off-by: Ryan Nett <[email protected]>
1 parent c5717b0 commit 12d579c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/GraphOperation.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public String device() {
194194

195195
/** Get the number of inputs to the op, not including control inputs. */
196196
public int numInputs() {
197+
requireHandle(unsafeNativeHandle);
197198
return TF_OperationNumInputs(getUnsafeNativeHandle());
198199
}
199200

@@ -244,6 +245,7 @@ public Output<?>[] inputList(int idx, int length) {
244245

245246
/** Get the op's inputs, not including control inputs. */
246247
public List<Operand<?>> inputs() {
248+
requireHandle(unsafeNativeHandle);
247249
try (PointerScope scope = new PointerScope()) {
248250
int numInputs = numInputs();
249251
TF_Output handles = new TF_Output(numInputs);
@@ -269,6 +271,7 @@ public List<Operand<?>> inputs() {
269271
* @param index the output to look for usages of
270272
*/
271273
public int numConsumers(int index) {
274+
requireHandle(unsafeNativeHandle);
272275
try (PointerScope scope = new PointerScope()) {
273276
TF_Output output = new TF_Output().oper(getUnsafeNativeHandle()).index(index);
274277
return TF_OperationOutputNumConsumers(output);
@@ -282,6 +285,7 @@ public int numConsumers(int index) {
282285
* @param index the output to look for usages of
283286
*/
284287
public Set<GraphOperation> consumers(int index) {
288+
requireHandle(unsafeNativeHandle);
285289
try (PointerScope scope = new PointerScope()) {
286290
TF_Output output = new TF_Output().oper(getUnsafeNativeHandle()).index(index);
287291
int numConsumers = numConsumers(index);
@@ -305,6 +309,7 @@ public Set<GraphOperation> consumers(int index) {
305309
* dependencies.
306310
*/
307311
public int numConsumers() {
312+
requireHandle(unsafeNativeHandle);
308313
int all = 0;
309314
for (int i = 0; i < numOutputs(); i++) {
310315
all += numConsumers(i);
@@ -316,6 +321,7 @@ public int numConsumers() {
316321
* Get the ops that use any of this op's outputs as an input, not including control dependencies.
317322
*/
318323
public Set<GraphOperation> consumers() {
324+
requireHandle(unsafeNativeHandle);
319325
Set<GraphOperation> all = new LinkedHashSet<>();
320326
for (int i = 0; i < numOutputs(); i++) {
321327
all.addAll(consumers(i));
@@ -325,13 +331,15 @@ public Set<GraphOperation> consumers() {
325331

326332
/** Get the number of control inputs for this op. */
327333
public int numControlInputs() {
334+
requireHandle(unsafeNativeHandle);
328335
try (PointerScope scope = new PointerScope()) {
329336
return TF_OperationNumControlInputs(getUnsafeNativeHandle());
330337
}
331338
}
332339

333340
/** Get the control inputs of this op. */
334341
public Set<GraphOperation> controlInputs() {
342+
requireHandle(unsafeNativeHandle);
335343
try (PointerScope scope = new PointerScope()) {
336344
int numInputs = numControlInputs();
337345
PointerPointer<TF_Operation> handles = new PointerPointer<>(numInputs);
@@ -350,13 +358,15 @@ public Set<GraphOperation> controlInputs() {
350358

351359
/** Get the number of ops with this op as a control dependency. */
352360
public int numControlConsumers() {
361+
requireHandle(unsafeNativeHandle);
353362
try (PointerScope scope = new PointerScope()) {
354363
return TF_OperationNumControlOutputs(getUnsafeNativeHandle());
355364
}
356365
}
357366

358367
/** Get the ops with this op as a control dependency. */
359368
public Set<GraphOperation> controlConsumers() {
369+
requireHandle(unsafeNativeHandle);
360370
try (PointerScope scope = new PointerScope()) {
361371
int numConsumers = numControlConsumers();
362372
PointerPointer<TF_Operation> handles = new PointerPointer<>(numConsumers);

0 commit comments

Comments
 (0)