Browse Source

Don't dispose graph in LoadFromSavedModel.

tags/TensorFlowOpLayer
Oceania2018 4 years ago
parent
commit
c341b37318
2 changed files with 6 additions and 2 deletions
  1. +1
    -1
      src/TensorFlowNET.Core/Sessions/Session.cs
  2. +5
    -1
      src/TensorFlowNet.Benchmarks/Leak/SavedModelCleanup.cs

+ 1
- 1
src/TensorFlowNET.Core/Sessions/Session.cs View File

@@ -39,7 +39,7 @@ namespace Tensorflow

public static Session LoadFromSavedModel(string path)
{
using var graph = new Graph();
var graph = new Graph();
using var status = new Status();
using var opt = c_api.TF_NewSessionOptions();



+ 5
- 1
src/TensorFlowNet.Benchmarks/Leak/SavedModelCleanup.cs View File

@@ -10,7 +10,9 @@ using static Tensorflow.Binding;

namespace Tensorflow.Benchmark.Leak
{
/// <summary>
/// https://github.com/SciSharp/TensorFlow.NET/issues/418
/// </summary>
public class SavedModelCleanup
{
[Benchmark]
@@ -22,6 +24,8 @@ namespace Tensorflow.Benchmark.Leak
for (var i = 0; i < 1024; i++)
{
using var sess = Session.LoadFromSavedModel(ClassifierModelPath);
// destory graph
using var g = sess.graph;
}
}
}


Loading…
Cancel
Save