Skip to content

Commit 8dfc449

Browse files
committed
assume only graph or eager environments
Signed-off-by: Ryan Nett <[email protected]>
1 parent 304dc00 commit 8dfc449

File tree

1 file changed

+3
-7
lines changed
  • tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/op/core

1 file changed

+3
-7
lines changed

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/op/core/Init.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,10 @@ public static Init create(Scope scope) {
9898
@Endpoint(name = "initAdd")
9999
public static void add(Scope scope, Op initializer) {
100100
ExecutionEnvironment exEnv = scope.env();
101-
if(exEnv.isEager()){
102-
return;
103-
}
104-
if (!(exEnv instanceof Graph)) {
105-
throw new IllegalArgumentException("initAdd is only supported on Graph or eager sessions.");
101+
102+
if(exEnv.isGraph()) {
103+
((Graph) exEnv).addInitializer(initializer);
106104
}
107-
Graph graph = (Graph) exEnv;
108-
graph.addInitializer(initializer);
109105
}
110106

111107
private Init(Operation operation) {

0 commit comments

Comments
 (0)