Skip to content

Commit 984d302

Browse files
committed
Eagerly create the base scope
Signed-off-by: Ryan Nett <[email protected]>
1 parent 85d902d commit 984d302

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,7 @@ public void checkInput(Op input) {
309309
}
310310

311311
@Override
312-
public synchronized Scope baseScope() {
313-
if(baseScope == null){
314-
baseScope = new Scope(this);
315-
}
316-
312+
public Scope baseScope() {
317313
return baseScope;
318314
}
319315

@@ -373,7 +369,7 @@ void detach(Pointer... resources) {
373369
private final WeakPointerScope nativeResources;
374370
private TFE_Context nativeHandle;
375371

376-
private Scope baseScope = null;
372+
private final Scope baseScope = new Scope(this);
377373

378374
private EagerSession(Options options) {
379375
this.nativeResources = new WeakPointerScope();

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,7 @@ public void checkInput(Op input) {
392392
}
393393

394394
@Override
395-
public synchronized Scope baseScope() {
396-
if(baseScope == null){
397-
baseScope = new Scope(this);
398-
}
399-
395+
public Scope baseScope() {
400396
return baseScope;
401397
}
402398

@@ -702,7 +698,7 @@ synchronized SaverDef saverDef() {
702698
private TF_Graph nativeHandle;
703699
private int refcount = 0;
704700
private SaverDef saverDef;
705-
private Scope baseScope = null;
701+
private final Scope baseScope = new Scope(this);
706702

707703
private final List<Op> initializers = new ArrayList<>();
708704

0 commit comments

Comments
 (0)