Skip to content

Commit

Permalink
merged with fseide/winlstm;
Browse files Browse the repository at this point in the history
fixed a few error throws to XXXError() calls;
moved one Validate() dimension check under isFinal condition
  • Loading branch information
frankseide committed Oct 14, 2015
2 parents a4ed652 + fc9897b commit 146140e
Show file tree
Hide file tree
Showing 28 changed files with 1,739 additions and 198 deletions.
13 changes: 13 additions & 0 deletions CNTK.sln
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CheckInSuites", "CheckInSui
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SparsePCReader", "DataReader\SparsePCReader\SparsePCReader.vcxproj", "{CE429AA2-3778-4619-8FD1-49BA3B81197B}"
ProjectSection(ProjectDependencies) = postProject
{60BDB847-D0C4-4FD3-A947-0C15C08BCDB5} = {60BDB847-D0C4-4FD3-A947-0C15C08BCDB5}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Speech", "Speech", "{C47CDAA5-6D6C-429E-BC89-7CA0F868FDC8}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -201,6 +204,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LSTM", "LSTM", "{19EE975B-2
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ParseConfig", "MachineLearning\ParseConfig\ParseConfig.vcxproj", "{7C4E77C9-6B17-4B02-82C1-DB62EEE2635B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageReader", "DataReader\ImageReader\ImageReader.vcxproj", "{9BD0A746-0BBD-45B6-B81C-053F03C26CFB}"
ProjectSection(ProjectDependencies) = postProject
{60BDB847-D0C4-4FD3-A947-0C15C08BCDB5} = {60BDB847-D0C4-4FD3-A947-0C15C08BCDB5}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CNTKComputationNetworkLib", "MachineLearning\CNTKComputationNetworkLib\CNTKComputationNetworkLib.vcxproj", "{928ABD1B-4D3B-4017-AEF1-0FA1B4467513}"
ProjectSection(ProjectDependencies) = postProject
{60BDB847-D0C4-4FD3-A947-0C15C08BCDB5} = {60BDB847-D0C4-4FD3-A947-0C15C08BCDB5}
Expand Down Expand Up @@ -476,6 +484,10 @@ Global
{EAD17188-072C-4726-B840-A769C36DAD1B}.Debug|x64.Build.0 = Debug|x64
{EAD17188-072C-4726-B840-A769C36DAD1B}.Release|x64.ActiveCfg = Release|x64
{EAD17188-072C-4726-B840-A769C36DAD1B}.Release|x64.Build.0 = Release|x64
{9BD0A746-0BBD-45B6-B81C-053F03C26CFB}.Debug|x64.ActiveCfg = Debug|x64
{9BD0A746-0BBD-45B6-B81C-053F03C26CFB}.Debug|x64.Build.0 = Debug|x64
{9BD0A746-0BBD-45B6-B81C-053F03C26CFB}.Release|x64.ActiveCfg = Release|x64
{9BD0A746-0BBD-45B6-B81C-053F03C26CFB}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -517,6 +529,7 @@ Global
{B6725C9F-A6D2-4269-9B74-7888A90F7884} = {5E666C53-2D82-49C9-9127-3FDDC321C741}
{B27DD434-EECD-4EE0-A03B-1150EB87258E} = {B6725C9F-A6D2-4269-9B74-7888A90F7884}
{A4884465-CFBB-4A64-A9DE-690E1A63EF7E} = {B6725C9F-A6D2-4269-9B74-7888A90F7884}
{9BD0A746-0BBD-45B6-B81C-053F03C26CFB} = {33EBFE78-A1A8-4961-8938-92A271941F94}
{3E9C89B1-C045-4F42-92B2-F9FFFFC2DBD4} = {39E42C4B-A078-4CA4-9D92-B883D8129601}
{C70E1572-20FF-496C-A0A9-10AA6755A07C} = {39E42C4B-A078-4CA4-9D92-B883D8129601}
{EAD17188-072C-4726-B840-A769C36DAD1B} = {DD043083-71A4-409A-AA91-F9C548DCF7EC}
Expand Down
59 changes: 58 additions & 1 deletion Common/Include/basetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ OACR_WARNING_DISABLE(POTENTIAL_ARGUMENT_TYPE_MISMATCH, "Not level1 or level2_sec
#include <locale> // std::wstring_convert
#include <string>
#include <algorithm> // for transform()
#include <mutex>
#include <unordered_map>
#include <chrono>
#include <thread>
#include <stack>
#include <mutex>
#include <memory>
#ifdef _MSC_VER
#include <codecvt> // std::codecvt_utf8
#endif
Expand Down Expand Up @@ -1004,4 +1006,59 @@ static inline std::wstring FormatWin32Error(DWORD error)
return res;
}
#endif // _WIN32

// Very simple version of thread-safe stack. Add other functions as needed.
template<typename T>
class conc_stack
{
public:
typedef typename std::stack<T>::value_type value_type;

conc_stack() {}

value_type pop_or_create(std::function<value_type()> factory)
{
std::lock_guard<std::mutex> g(m_locker);
if (m_stack.size() == 0)
return factory();
auto res = std::move(m_stack.top());
m_stack.pop();
return res;
}

void push(const value_type& item)
{
std::lock_guard<std::mutex> g(m_locker);
m_stack.push(item);
}

void push(value_type&& item)
{
std::lock_guard<std::mutex> g(m_locker);
m_stack.push(std::forward<value_type>(item));
}

public:
conc_stack(const conc_stack&) = delete;
conc_stack& operator=(const conc_stack&) = delete;
conc_stack(conc_stack&&) = delete;
conc_stack& operator=(conc_stack&&) = delete;

private:
std::stack<value_type> m_stack;
std::mutex m_locker;
};

// make_unique was added in GCC 4.9.0
#if __GNUC__ >= 4 && __GNUC_MINOR__ < 9
namespace std
{
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
}
#endif

#endif // _BASETYPES_
30 changes: 30 additions & 0 deletions DataReader/ImageReader/Exports.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// <copyright file="Exports.cpp" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//
// Exports.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#define DATAREADER_EXPORTS
#include "DataReader.h"
#include "ImageReader.h"

namespace Microsoft { namespace MSR { namespace CNTK {

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

extern "C" DATAREADER_API void GetReaderF(IDataReader<float>** preader)
{
GetReader(preader);
}
extern "C" DATAREADER_API void GetReaderD(IDataReader<double>** preader)
{
GetReader(preader);
}
}}}
Loading

0 comments on commit 146140e

Please sign in to comment.