Skip to content

Commit 8cb6470

Browse files
committed
Graph.Operation: Throw ValueError exception when Current graph is not default graph.
1 parent 70a90e5 commit 8cb6470

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/TensorFlowNET.Core/Graphs/Graph.Operation.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,21 @@ public Operation[] ReturnOperations(IntPtr results)
5454
var handle = return_oper_handle.node + tf_op_size * i;
5555
return_opers[i] = new Operation(*(IntPtr*)handle);
5656
}
57-
}
58-
57+
}
58+
5959
return return_opers;
6060
}
6161

6262
public Operation OperationByName(string operName)
6363
{
6464
var handle = c_api.TF_GraphOperationByName(_handle, operName);
65-
if(graph_key != tf.get_default_graph().graph_key)
66-
{
67-
Console.WriteLine($"Current graph is not default graph.");
68-
// throw new ValueError($"Current graph is not default graph.");
65+
var defaultKey = tf.get_default_graph().graph_key;
66+
if (graph_key != defaultKey)
67+
{
68+
//Console.WriteLine($"Current graph is not default graph.");
69+
throw new ValueError($"Current graph is not default graph. Default Graph Key: {defaultKey}, Current Graph Key: {graph_key}");
6970
}
71+
7072
return new Operation(handle, g: this);
7173
}
7274

0 commit comments

Comments
 (0)