Skip to content

Commit

Permalink
Merge branch 'master' of https://git01.codeplex.com/cntk into linux-gcc
Browse files Browse the repository at this point in the history
Conflicts:
	DataReader/LMSequenceReader/SequenceReader.cpp
  • Loading branch information
Dong Yu committed Jul 22, 2015
2 parents 75acf2b + c437f85 commit fce1212
Show file tree
Hide file tree
Showing 22 changed files with 188 additions and 163 deletions.
2 changes: 1 addition & 1 deletion CNTK.sln
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CheckInSuites", "CheckInSui
{E6F26F9A-FF64-4F0A-B749-CD309EE357EE} = {E6F26F9A-FF64-4F0A-B749-CD309EE357EE}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NDRMReader", "DataReader\NDRMReader\NDRMReader.vcxproj", "{CE429AA2-3778-4619-8FD1-49BA3B81197B}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SparsePCReader", "DataReader\SparsePCReader\SparsePCReader.vcxproj", "{CE429AA2-3778-4619-8FD1-49BA3B81197B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
3 changes: 3 additions & 0 deletions Common/CrossProcessMutex_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ class CrossProcessMutex
setupTimeout(1);
int r = fcntl(fd, wait ? F_SETLKW : F_SETLK, &m_lock);
if (errno == EINTR) {
sleep(1);
// retrying in the case of signal or timeout
close(fd);
continue;
}
if (r != 0) {
Expand All @@ -80,6 +82,7 @@ class CrossProcessMutex
// we have a race with 'unlink' call in Release()
// our lock is held to the previous instance of the file;
// this is not a problem, we just need to retry locking the new file
close(fd);
continue;
}
else {
Expand Down
6 changes: 2 additions & 4 deletions Common/Include/DataReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DATAREADER_API IDataReader
typedef unsigned int LabelIdType;
unsigned m_seed;
size_t mBlgSize; /// number of utterances per minibatch
bool mDoRandomize;
bool mDoRandomize = true;

virtual void Init(const ConfigParameters& /*config*/) = 0;
virtual void Destroy() = 0;
Expand Down Expand Up @@ -147,9 +147,7 @@ class DataReader: public IDataReader<ElemType>, protected Plugin
virtual void Destroy();

/// number of utterances per minibatch, for data parallelsim
size_t mNbrUttPerMinibatch;

bool mDoRandomize;
size_t mNbrUttPerMinibatch;

public:
// DataReader Constructor
Expand Down
18 changes: 10 additions & 8 deletions DataReader/LMSequenceReader/SequenceReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,8 +1742,8 @@ bool BatchSequenceReader<ElemType>::EnsureDataAvailable(size_t /*mbStartSample*/
mNumRead = m_parser.Parse(CACHE_BLOG_SIZE, &m_labelTemp, &m_featureTemp, &seqPos);
if (mNumRead == 0) return false;

if (mDoRandomize)
std::random_shuffle(m_parser.mSentenceIndex2SentenceInfo.begin(), m_parser.mSentenceIndex2SentenceInfo.end());
//if (mDoRandomize)
std::random_shuffle(m_parser.mSentenceIndex2SentenceInfo.begin(), m_parser.mSentenceIndex2SentenceInfo.end());

m_readNextSampleLine += mNumRead;
sLn = FindNextSentences(mNumRead);
Expand Down Expand Up @@ -1998,10 +1998,9 @@ bool BatchSequenceReader<ElemType>::DataEnd(EndDataType endDataType)
ret = !EnsureDataAvailable(m_mbStartSample);
break;
case endDataSentence: // for fast reader each minibatch is considered a "sentence", so always true
for (auto ptr = mToProcess.begin(); ptr != mToProcess.end(); ptr++)
mProcessed[*ptr] = true;

mSentenceEnd = true;
if (mSentenceEnd)
for (auto ptr = mToProcess.begin(); ptr != mToProcess.end(); ptr++)
mProcessed[*ptr] = true;
ret = mSentenceEnd;
break;
}
Expand Down Expand Up @@ -2094,6 +2093,10 @@ void BatchSequenceReader<ElemType>::GetLabelOutput(std::map < std::wstring,
else // GPU
{
RuntimeError("GetLabelOutput::should use CPU for labels ");
}
if (curDevId != CPUDEVICE && readerMode != ReaderMode::Class)
{
labels->TransferFromDeviceToDevice(CPUDEVICE, curDevId, false, false, false);
}
}

Expand Down Expand Up @@ -2126,5 +2129,4 @@ int BatchSequenceReader<ElemType>::GetSentenceEndIdFromOutputLabel()

template class BatchSequenceReader<double>;
template class BatchSequenceReader<float>;

}}}
}}}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include "stdafx.h"
#define DATAREADER_EXPORTS
#include "DataReader.h"
#include "NDRMReader.h"
#include "SparsePCReader.h"

namespace Microsoft { namespace MSR { namespace CNTK {

template<class ElemType>
void DATAREADER_API GetReader(IDataReader<ElemType>** preader)
{
*preader = new NDRMReader<ElemType>();
*preader = new SparsePCReader<ElemType>();
}

extern "C" DATAREADER_API void GetReaderF(IDataReader<float>** preader)
Expand Down
Loading

0 comments on commit fce1212

Please sign in to comment.