Moving forceDeterministicAlgorithms to globals
This commit is contained in:
Родитель
147efd1e77
Коммит
68ae8803a5
1
Makefile
1
Makefile
|
@ -265,6 +265,7 @@ READER_SRC =\
|
|||
|
||||
COMMON_SRC =\
|
||||
$(SOURCEDIR)/Common/Config.cpp \
|
||||
$(SOURCEDIR)/Common/Globals.cpp \
|
||||
$(SOURCEDIR)/Common/DataReader.cpp \
|
||||
$(SOURCEDIR)/Common/DataWriter.cpp \
|
||||
$(SOURCEDIR)/Common/ExceptionWithCallStack.cpp \
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#endif
|
||||
|
||||
#include "Basics.h"
|
||||
#include "Globals.h"
|
||||
#include "Actions.h"
|
||||
#include "ComputationNetwork.h"
|
||||
#include "ComputationNode.h"
|
||||
|
@ -481,7 +482,7 @@ int wmainWithBS(int argc, wchar_t* argv[]) // called from wmain which is a wrapp
|
|||
let& config = valp.AsRef<ScriptableObjects::IConfigRecord>(); // this is the dictionary
|
||||
|
||||
if (config(L"forceDeterministicAlgorithms", false))
|
||||
ComputationNetwork::ForceDeterministicAlgorithms();
|
||||
Globals::ForceDeterministicAlgorithms();
|
||||
|
||||
#ifndef CPUONLY
|
||||
auto valpp = config.Find(L"deviceId");
|
||||
|
@ -617,7 +618,7 @@ int wmainOldCNTKConfig(int argc, wchar_t* argv[])
|
|||
}
|
||||
|
||||
if (config(L"forceDeterministicAlgorithms", false))
|
||||
ComputationNetwork::ForceDeterministicAlgorithms();
|
||||
Globals::ForceDeterministicAlgorithms();
|
||||
|
||||
// get the command param set they want
|
||||
wstring logpath = config(L"stderr", L"");
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
<ClInclude Include="..\Common\Include\BestGpu.h" />
|
||||
<ClInclude Include="..\Common\Include\DataReader.h" />
|
||||
<ClInclude Include="..\Common\Include\ExceptionWithCallStack.h" />
|
||||
<ClInclude Include="..\Common\Include\Globals.h" />
|
||||
<ClInclude Include="..\Common\Include\StringUtil.h" />
|
||||
<ClInclude Include="..\Common\Include\TensorShape.h" />
|
||||
<ClInclude Include="..\Common\Include\DataWriter.h" />
|
||||
|
|
|
@ -174,6 +174,9 @@
|
|||
</ClInclude>
|
||||
<ClInclude Include="..\Common\Include\basetypes.h" />
|
||||
<ClInclude Include="..\Readers\CompositeDataReader\CompositeDataReader.h" />
|
||||
<ClInclude Include="..\Common\Include\Globals.h">
|
||||
<Filter>Common\Include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="modelEditor.txt">
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
<ClCompile Include="ExceptionWithCallStack.cpp" />
|
||||
<ClCompile Include="File.cpp" />
|
||||
<ClCompile Include="fileutil.cpp" />
|
||||
<ClCompile Include="Globals.cpp" />
|
||||
<ClCompile Include="MPIWrapper.cpp" />
|
||||
<ClCompile Include="TimerUtility.cpp" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
|
||||
//
|
||||
|
||||
#include "Globals.h"
|
||||
|
||||
namespace Microsoft { namespace MSR { namespace CNTK {
|
||||
|
||||
bool Globals::m_forceDeterministicAlgorithms = false;
|
||||
|
||||
}}}
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Microsoft { namespace MSR { namespace CNTK {
|
||||
|
||||
// Class containing global configuration for CNTK.
|
||||
class Globals
|
||||
{
|
||||
public:
|
||||
static void ForceDeterministicAlgorithms()
|
||||
{
|
||||
m_forceDeterministicAlgorithms = true;
|
||||
}
|
||||
|
||||
static bool ShouldForceDeterministicAlgorithms()
|
||||
{
|
||||
return m_forceDeterministicAlgorithms;
|
||||
}
|
||||
|
||||
private:
|
||||
static bool m_forceDeterministicAlgorithms;
|
||||
};
|
||||
}}}
|
|
@ -1056,16 +1056,6 @@ public:
|
|||
m_randomSeedOffset = value;
|
||||
}
|
||||
|
||||
static void ForceDeterministicAlgorithms()
|
||||
{
|
||||
m_forceDeterministicAlgorithms = true;
|
||||
}
|
||||
|
||||
static bool ShouldForceDeterministicAlgorithms()
|
||||
{
|
||||
return m_forceDeterministicAlgorithms;
|
||||
}
|
||||
|
||||
private:
|
||||
DEVICEID_TYPE m_deviceId; // TODO: is this shared by all nodes?
|
||||
unsigned long m_randomSeedOffset;
|
||||
|
@ -1120,8 +1110,6 @@ private:
|
|||
// pool for matrices that can be shared across nodes
|
||||
// TODO: does this apply to anything else besides temporary node-internal intermediate results? What, for example?
|
||||
MatrixPool m_matrixPool;
|
||||
|
||||
static bool m_forceDeterministicAlgorithms;
|
||||
};
|
||||
typedef ComputationNetwork::ComputationNetworkPtr ComputationNetworkPtr;
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ using namespace Microsoft::MSR::ScriptableObjects;
|
|||
|
||||
const static set<wstring> nodeGroupNames{ L"feature", L"label", L"criterion", L"evaluation", L"output" };
|
||||
|
||||
bool ComputationNetwork::m_forceDeterministicAlgorithms = false;
|
||||
|
||||
// construct a ComputationNetwork from a ConfigRecord
|
||||
ComputationNetwork::ComputationNetwork(const IConfigRecordPtr configp) :
|
||||
ComputationNetwork()
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Basics.h"
|
||||
#include "Globals.h"
|
||||
#include "Matrix.h"
|
||||
#include "ComputationNode.h"
|
||||
#include "ConvolutionEngine.h"
|
||||
|
@ -452,7 +453,7 @@ public:
|
|||
m_sharing, m_autoPad, m_lowerPad, m_upperPad);
|
||||
m_convEng = ConvolutionEngine<ElemType>::Create(geometry, m_deviceId, m_imageLayout,
|
||||
m_maxTempMemSizeInSamples, m_poolKind,
|
||||
ConvolutionEngineKind::All, NodeName(), ComputationNetwork::ShouldForceDeterministicAlgorithms());
|
||||
ConvolutionEngineKind::All, NodeName(), Globals::ShouldForceDeterministicAlgorithms());
|
||||
}
|
||||
|
||||
if (Input(0)->GetSampleLayout().GetNumElements() != m_kernelShape.GetNumElements() * m_convEng->Geometry()->KernelCount())
|
||||
|
|
Загрузка…
Ссылка в новой задаче