Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Microsoft.ML.TensorFlow/TensorflowTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,11 @@ private void Dispose(bool disposing)
{
Session.close(); // invoked Dispose()
}

if (Session != null && Session.graph != IntPtr.Zero)
{
Session.graph.Dispose();
Comment thread
eerhardt marked this conversation as resolved.
}
}
finally
{
Expand Down Expand Up @@ -645,10 +650,12 @@ private void UpdateCacheIfNeeded(long position, ITensorValueGetter[] srcTensorGe
Runner runner = new Runner(_parent.Session);

// Feed inputs to the graph.
List<Tensor> inputTensors = new List<Tensor>();
for (int i = 0; i < _parent.Inputs.Length; i++)
{
var tensor = srcTensorGetters[i].GetTensor();
runner.AddInput(_parent.Inputs[i], tensor);
inputTensors.Add(tensor);
Comment thread
eerhardt marked this conversation as resolved.
Outdated
}

// Add outputs.
Expand All @@ -658,6 +665,11 @@ private void UpdateCacheIfNeeded(long position, ITensorValueGetter[] srcTensorGe
// Execute the graph.
var tensors = runner.Run();

foreach (Tensor inputTensor in inputTensors)
{
inputTensor.Dispose();
}

Contracts.Assert(tensors.Length > 0);

for (int j = 0; j < activeOutputColNames.Length; j++)
Expand Down