Skip to content

Commit

Permalink
Undo prefetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Radmilac committed Jul 20, 2015
1 parent 3cbf7fe commit f33224b
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 443 deletions.
6 changes: 2 additions & 4 deletions MachineLearning/CNTK/CNTK.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@
<ClInclude Include="ComputationNetworkHelper.h" />
<ClInclude Include="ComputationNode.h" />
<ClInclude Include="ConvolutionalNodes.h" />
<ClInclude Include="DecoderNode.h" />
<ClInclude Include="MinibatchFetcher.h" />
<ClInclude Include="MinibatchPrefetcher.h" />
<ClInclude Include="DecoderNode.h" />
<ClInclude Include="EvaluationCriterionNodes.h" />
<ClInclude Include="IComputationNetBuilder.h" />
<ClInclude Include="IExecutionEngine.h" />
Expand Down Expand Up @@ -221,4 +219,4 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
</Project>
6 changes: 0 additions & 6 deletions MachineLearning/CNTK/CNTK.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@
<ClInclude Include="IExecutionEngine.h">
<Filter>Execution Engine</Filter>
</ClInclude>
<ClInclude Include="MinibatchFetcher.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="MinibatchPrefetcher.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="ModelEditLanguage.h">
<Filter>Model Editing</Filter>
</ClInclude>
Expand Down
51 changes: 0 additions & 51 deletions MachineLearning/CNTK/MinibatchFetcher.h

This file was deleted.

220 changes: 0 additions & 220 deletions MachineLearning/CNTK/MinibatchPrefetcher.h

This file was deleted.

24 changes: 5 additions & 19 deletions MachineLearning/CNTK/SGD.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include <random>
#include "TimerUtility.h"
#include "Profiler.h"
#include "MinibatchFetcher.h"
#include "MinibatchPrefetcher.h"

#ifdef MPI_SUPPORT
#include "mpi.h"
Expand Down Expand Up @@ -201,9 +199,6 @@ class SGD : ComputationNetworkHelper<ElemType>
size_t numMBsToShowResult = configSGD("numMBsToShowResult", "10");
size_t numMBsToCUDAProfile = configSGD("numMBsToCUDAProfile", "0");

// Whether it is OK for read to happen on a separate thread while compute is happening
bool doPrefetchTrainingData = configSGD("prefetchTrainingData", "false");

bool keepCheckPointFiles = configSGD("keepCheckPointFiles", "false");

bool gradientClippingWithTruncation = configSGD("gradientClippingWithTruncation", "true");
Expand Down Expand Up @@ -269,8 +264,7 @@ class SGD : ComputationNetworkHelper<ElemType>
gradientCheckSigDigit, validateAfterModelReloading, rpi,
learnRateAdjustInterval, UsingAllDataForPreComputedNode,
needAveMultiplier, L2RegWeight, L1RegWeight,
autoAdjustMinibatch, minibatchSizeTuningFrequency, minibatchSizeTuningMax,
doPrefetchTrainingData);
autoAdjustMinibatch, minibatchSizeTuningFrequency, minibatchSizeTuningMax);
}

//autoLearnRateSearchType is applied only if the learning rate for the epoch is not specified in learningRatesPerMB and learningRatesPerSample
Expand Down Expand Up @@ -316,8 +310,7 @@ class SGD : ComputationNetworkHelper<ElemType>
const ElemType L1RegWeight = 0,
const bool autoAdjustMinibatch = false,
const size_t minibatchSizeTuningFrequency = 1,
const size_t minibatchSizeTuningMax = 1048576,
bool doPrefetchTrainingData = true)
const size_t minibatchSizeTuningMax = 1048576)
{
m_numPrevLearnRates = numPrevLearnRates;
m_prevChosenMinibatchSize = 0;
Expand Down Expand Up @@ -477,7 +470,6 @@ class SGD : ComputationNetworkHelper<ElemType>
m_doGradientCheck = doGradientCheck;
m_gradientCheckSigDigit = gradientCheckSigDigit;
m_validateAfterModelReloading = validateAfterModelReloading;
m_doPrefetchTrainingData = doPrefetchTrainingData;

msra::files::make_intermediate_dirs(m_modelPath);
}
Expand Down Expand Up @@ -1708,22 +1700,15 @@ class SGD : ComputationNetworkHelper<ElemType>
trainSetDataReader->StartMinibatchLoop(tunedMBSize, epochNumber, m_epochSize);

AttemptUtteranceDerivativeFeatures(net, trainSetDataReader, FeatureNodes, inputMatrices);
std::unique_ptr<MinibatchFetcher<ElemType>> mbFetcher(
m_doPrefetchTrainingData ?
new MinibatchPrefetcher<ElemType>(trainSetDataReader, inputMatrices, &(net.SentenceBoundary()), &(net.MinibatchPackingFlags())) :
new MinibatchFetcher<ElemType>(trainSetDataReader, inputMatrices, &(net.SentenceBoundary()), &(net.MinibatchPackingFlags())));

fprintf(stderr, "\nStarting minibatch loop, prefetching is: %s\n", m_doPrefetchTrainingData ? "ENABLED" : "DISABLED");

Timer timer;
timer.Start();

while (mbFetcher->GetMinibatch())
while (trainSetDataReader->GetMinibatch(*inputMatrices))
{
#ifdef MPI_SUPPORT
DecimateMinibatch(inputMatrices);
#endif

UpdateEvalTimeStamps(FeatureNodes);
UpdateEvalTimeStamps(labelNodes);

Expand Down Expand Up @@ -1843,6 +1828,7 @@ class SGD : ComputationNetworkHelper<ElemType>
}
}
}

timer.Restart();
totalEpochSamples += actualMBSize;
totalSamplesSeen += actualMBSize;
Expand Down Expand Up @@ -2401,7 +2387,7 @@ class SGD : ComputationNetworkHelper<ElemType>
bool m_needAveMultiplier;
ElemType m_L2RegWeight;
ElemType m_L1RegWeight;
bool m_doPrefetchTrainingData;

};
template class SGD<float>;
template class SGD<double>;
Expand Down
Loading

0 comments on commit f33224b

Please sign in to comment.