Skip to content

Commit

Permalink
added CNTKActionsLib to Linux include path;
Browse files Browse the repository at this point in the history
moved DisableLegacyTruncationSettings() away from being the very first piece of code in CNTK.cpp, hiding it close to where it is used. Also fixed its spelling and made it 'static'
  • Loading branch information
frankseide committed Nov 12, 2015
1 parent e022a2f commit 3b2068e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
71 changes: 36 additions & 35 deletions MachineLearning/CNTK/CNTK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,6 @@ using namespace std;
using namespace Microsoft::MSR;
using namespace Microsoft::MSR::CNTK;

// The following section is to explicitly disable some legacy usage to avoid implicit configuration errors

void DisableLegcyTruncationSettings(const ConfigParameters& TopLevelConfig, const ConfigParameters& commandConfig)
{
if (TopLevelConfig.ExistsCurrent("Truncated"))
{
return;
}

// if any of the action has set a reader/SGD section and has different Truncated value for reader and SGD section
ConfigArray actions = commandConfig("action");
for (size_t i = 0; i < actions.size(); i++)
{
if (actions[i] == "train" || actions[i] == "trainRNN")
{

ConfigParameters sgd = ConfigParameters(commandConfig("SGD"));
ConfigParameters reader = ConfigParameters(commandConfig("reader"));
// reader and SGD sections are two must-have sections in train/trainRNN
if (reader.ExistsCurrent("Truncated") && !sgd.ExistsCurrent("Truncated"))
{
InvalidArgument("DisableLegacyUsage: setting Truncated only in reader section are not allowed. Please move Truncated=true/false to the top level section.");
}
}
}
}
void DisableLegacyUsage(const ConfigParameters& TopLevelConfig, const ConfigArray& commands)
{
for (size_t i = 0; i < commands.size(); i++)
{
ConfigParameters cfgParameters(TopLevelConfig(commands[i]));
DisableLegcyTruncationSettings(TopLevelConfig, cfgParameters);
}
}
// internal test routine forward declaration
template <typename ElemType>
void TestCn(const ConfigParameters& config);
Expand Down Expand Up @@ -1324,6 +1290,40 @@ size_t GetMaxEpochs(const ConfigParameters& configParams)
return maxEpochs;
}

// special temporary function to guard against a now invalid usage of "truncated" which exists in some IPG production setups
static void DisableLegacyTruncationSettings(const ConfigParameters& TopLevelConfig, const ConfigParameters& commandConfig)
{
if (TopLevelConfig.ExistsCurrent("Truncated"))
{
return;
}

// if any of the action has set a reader/SGD section and has different Truncated value for reader and SGD section
ConfigArray actions = commandConfig("action");
for (size_t i = 0; i < actions.size(); i++)
{
if (actions[i] == "train" || actions[i] == "trainRNN")
{

ConfigParameters sgd = ConfigParameters(commandConfig("SGD"));
ConfigParameters reader = ConfigParameters(commandConfig("reader"));
// reader and SGD sections are two must-have sections in train/trainRNN
if (reader.ExistsCurrent("Truncated") && !sgd.ExistsCurrent("Truncated"))
{
InvalidArgument("DisableLegacyUsage: setting Truncated only in reader section are not allowed. Please move Truncated=true/false to the top level section.");
}
}
}
}
static void DisableLegacyUsage(const ConfigParameters& TopLevelConfig, const ConfigArray& commands)
{
for (size_t i = 0; i < commands.size(); i++)
{
ConfigParameters cfgParameters(TopLevelConfig(commands[i]));
DisableLegacyTruncationSettings(TopLevelConfig, cfgParameters);
}
}

// process the command
template <typename ElemType>
void DoCommand(const ConfigParameters& config)
Expand All @@ -1338,7 +1338,8 @@ void DoCommand(const ConfigParameters& config)
std::cerr << "Using " << numCPUThreads << " CPU threads" << endl;
}

DisableLegacyUsage(config, command);
// temporary hack to prevent users from failling for a small breaking change related to the "truncated" flag (will be redone bigger and better some day)
DisableLegacyUsage(config, command);

// summarize command info upfront in the log and stdout
size_t fullTotalMaxEpochs = 0;
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ endif
# The actual compiler/linker flags added can be viewed by running 'mpic++ --showme:compile' and 'mpic++ --showme:link'
CXX = mpic++

INCLUDEPATH:= Common/Include Math/Math MachineLearning/CNTK MachineLearning/CNTKComputationNetworkLib MachineLearning/CNTKSGDLib MachineLearning/CNTKSequenceTrainingLib BrainScript
INCLUDEPATH:= Common/Include Math/Math MachineLearning/CNTK MachineLearning/CNTKActionsLib MachineLearning/CNTKComputationNetworkLib MachineLearning/CNTKSGDLib MachineLearning/CNTKSequenceTrainingLib BrainScript
CPPFLAGS:= -D_POSIX_SOURCE -D_XOPEN_SOURCE=600 -D__USE_XOPEN2K
CXXFLAGS:= -msse3 -std=c++0x -std=c++11 -fopenmp -fpermissive -fPIC -Werror -fcheck-new
LIBPATH:=
Expand Down

0 comments on commit 3b2068e

Please sign in to comment.