Move primitiveOpNames out from PrimitiveOpTypeName(), as local static variables are not thread-safe under VS2013.

This commit is contained in:
Zhou Wang 2016-10-20 16:46:14 +02:00
Родитель c4c40c9bb7
Коммит fce86cd958
1 изменённых файлов: 52 добавлений и 50 удалений

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

@ -28,8 +28,8 @@ namespace std
namespace CNTK
{
inline const std::wstring& PrimitiveOpTypeName(PrimitiveOpType opType)
{
// Move primitiveOpNames out from PrimitiveOpTypeName(), as local static variables are not thread-safe under VS2013.
// Todo: Move it into PrimitiveOpTypeName() as local static after upgraded to VS2015.
static const std::unordered_map<PrimitiveOpType, std::wstring> primitiveOpNames = {
{PrimitiveOpType::Negate, L"Negate"},
{PrimitiveOpType::Sigmoid, L"Sigmoid"},
@ -80,6 +80,8 @@ namespace CNTK
{PrimitiveOpType::RandomSampleInclusionFrequency, L"RandomSampleInclusionFrequency"},
};
inline const std::wstring& PrimitiveOpTypeName(PrimitiveOpType opType)
{
if (primitiveOpNames.find(opType) == primitiveOpNames.end())
LogicError("Unknown PrimitiveOpType");