Skip to content

Commit c341b37

Browse files
committed
Don't dispose graph in LoadFromSavedModel.
1 parent 1ccde6e commit c341b37

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/TensorFlowNET.Core/Sessions/Session.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public Session as_default()
3939

4040
public static Session LoadFromSavedModel(string path)
4141
{
42-
using var graph = new Graph();
42+
var graph = new Graph();
4343
using var status = new Status();
4444
using var opt = c_api.TF_NewSessionOptions();
4545

src/TensorFlowNet.Benchmarks/Leak/SavedModelCleanup.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
namespace Tensorflow.Benchmark.Leak
1212
{
13-
13+
/// <summary>
14+
/// https://github.com/SciSharp/TensorFlow.NET/issues/418
15+
/// </summary>
1416
public class SavedModelCleanup
1517
{
1618
[Benchmark]
@@ -22,6 +24,8 @@ public void Run()
2224
for (var i = 0; i < 1024; i++)
2325
{
2426
using var sess = Session.LoadFromSavedModel(ClassifierModelPath);
27+
// destory graph
28+
using var g = sess.graph;
2529
}
2630
}
2731
}

0 commit comments

Comments
 (0)