issue 2954: c# API memory leak

This commit is contained in:
liqfu 2018-03-21 11:14:28 -07:00
Родитель 3a229624be
Коммит 3e83c56b8f
1 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -22,11 +22,11 @@ namespace CNTK
public static Trainer CreateTrainer(Function model, Function lossFunction, Function evaluationFunction, IList<Learner> parameterLearners, public static Trainer CreateTrainer(Function model, Function lossFunction, Function evaluationFunction, IList<Learner> parameterLearners,
ProgressWriterVector progressWriters = null) ProgressWriterVector progressWriters = null)
{ {
LearnerVector learnerVector = Helper.AsLearnerVector(parameterLearners); using (LearnerVector learnerVector = Helper.AsLearnerVector(parameterLearners))
if (progressWriters != null) if (progressWriters != null)
return CNTKLib.CreateTrainer(model, lossFunction, evaluationFunction, learnerVector, progressWriters); return CNTKLib.CreateTrainer(model, lossFunction, evaluationFunction, learnerVector, progressWriters);
else else
return CNTKLib.CreateTrainer(model, lossFunction, evaluationFunction, learnerVector); return CNTKLib.CreateTrainer(model, lossFunction, evaluationFunction, learnerVector);
} }
/// <summary> /// <summary>
@ -37,8 +37,8 @@ namespace CNTK
/// <returns></returns> /// <returns></returns>
public bool TrainMinibatch(IDictionary<Variable, MinibatchData> arguments, DeviceDescriptor computeDevice) public bool TrainMinibatch(IDictionary<Variable, MinibatchData> arguments, DeviceDescriptor computeDevice)
{ {
UnorderedMapVariableMinibatchData vectorData = Helper.AsUnorderedMapVariableMinibatchData(arguments); using (UnorderedMapVariableMinibatchData vectorData = Helper.AsUnorderedMapVariableMinibatchData(arguments))
return _TrainMinibatch(vectorData, computeDevice); return _TrainMinibatch(vectorData, computeDevice);
} }
/// <summary> /// <summary>
@ -50,9 +50,9 @@ namespace CNTK
[System.Obsolete("TrainMinibatch() without isSweepEndInarguments will be deprecated soon. Please TrainMinibatch() with isSweepEndInarguments.", false)] [System.Obsolete("TrainMinibatch() without isSweepEndInarguments will be deprecated soon. Please TrainMinibatch() with isSweepEndInarguments.", false)]
public bool TrainMinibatch(IDictionary<Variable, Value> arguments, DeviceDescriptor computeDevice) public bool TrainMinibatch(IDictionary<Variable, Value> arguments, DeviceDescriptor computeDevice)
{ {
UnorderedMapVariableValuePtr mapData = Helper.AsUnorderedMapVariableValue(arguments);
bool isSweepEndInarguments = false; bool isSweepEndInarguments = false;
return _TrainMinibatch(mapData, isSweepEndInarguments, computeDevice); using (UnorderedMapVariableValuePtr mapData = Helper.AsUnorderedMapVariableValue(arguments))
return _TrainMinibatch(mapData, isSweepEndInarguments, computeDevice);
} }
/// <summary> /// <summary>
@ -64,8 +64,8 @@ namespace CNTK
/// <returns></returns> /// <returns></returns>
public bool TrainMinibatch(IDictionary<Variable, Value> arguments, bool isSweepEndInarguments, DeviceDescriptor computeDevice) public bool TrainMinibatch(IDictionary<Variable, Value> arguments, bool isSweepEndInarguments, DeviceDescriptor computeDevice)
{ {
UnorderedMapVariableValuePtr mapData = Helper.AsUnorderedMapVariableValue(arguments); using (UnorderedMapVariableValuePtr mapData = Helper.AsUnorderedMapVariableValue(arguments))
return _TrainMinibatch(mapData, isSweepEndInarguments, computeDevice); return _TrainMinibatch(mapData, isSweepEndInarguments, computeDevice);
} }
} }
} }