Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Microsoft/CNTK into amita…
Browse files Browse the repository at this point in the history
…ga/removeCopyCtorFromMatrix
  • Loading branch information
amitaga committed Mar 4, 2016
2 parents 91e2673 + 79f5349 commit ff32a89
Show file tree
Hide file tree
Showing 52 changed files with 19,091 additions and 489 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Readme text
*.bat text
*.py text
*.pl text
*.ps1 text
*.sh text eol=lf
build-and-test text eol=lf
configure text eol=lf
Expand Down
16 changes: 12 additions & 4 deletions Source/ActionsLib/EvalActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ static void DoEvalBase(const ConfigParameters& config, IDataReader& reader)

int traceLevel = config(L"traceLevel", "0");
size_t numMBsToShowResult = config(L"numMBsToShowResult", "100");
size_t maxSamplesInRAM = config(L"maxSamplesInRAM", (size_t)SIZE_MAX);
size_t numSubminiBatches = config(L"numSubminibatches", (size_t)1);
//TODO: switch to a global parallel setting for both training and evaluation.
bool useParallel = config(L"parallelTrain", false);

ConfigArray evalNodeNames = config(L"evalNodeNames", "");
vector<wstring> evalNodeNamesVector;
Expand All @@ -66,8 +70,8 @@ static void DoEvalBase(const ConfigParameters& config, IDataReader& reader)
}

auto net = ComputationNetwork::CreateFromFile<ElemType>(deviceId, modelPath);

SimpleEvaluator<ElemType> eval(net, numMBsToShowResult, traceLevel);
SimpleEvaluator<ElemType> eval(net, useParallel, numMBsToShowResult, traceLevel, maxSamplesInRAM, numSubminiBatches);
eval.Evaluate(&reader, evalNodeNamesVector, mbSize[0], epochSize);
}

Expand Down Expand Up @@ -114,6 +118,10 @@ void DoCrossValidate(const ConfigParameters& config)

int traceLevel = config(L"traceLevel", "0");
size_t numMBsToShowResult = config(L"numMBsToShowResult", "100");
size_t maxSamplesInRAM = config(L"maxSamplesInRAM", (size_t)SIZE_MAX);
size_t numSubminiBatches = config(L"numSubminibatches", (size_t)1);
//TODO: switch to a global parallel setting for both training and evaluation.
bool useParallel = config(L"parallelTrain", false);

ConfigArray evalNodeNames = config(L"evalNodeNames", "");
vector<wstring> evalNodeNamesVector;
Expand Down Expand Up @@ -146,8 +154,8 @@ void DoCrossValidate(const ConfigParameters& config)

cvModels.push_back(cvModelPath);
auto net = ComputationNetwork::CreateFromFile<ElemType>(deviceId, cvModelPath);

SimpleEvaluator<ElemType> eval(net, numMBsToShowResult, traceLevel);
SimpleEvaluator<ElemType> eval(net, useParallel, numMBsToShowResult, traceLevel, maxSamplesInRAM, numSubminiBatches);

fprintf(stderr, "model %ls --> \n", cvModelPath.c_str());
auto evalErrors = eval.Evaluate(&cvDataReader, evalNodeNamesVector, mbSize[0], epochSize);
Expand Down
61 changes: 31 additions & 30 deletions Source/ActionsLib/OtherActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,49 +476,50 @@ template void DoWriteWordAndClassInfo<double>(const ConfigParameters& config);
template <typename ElemType>
void DoTopologyPlot(const ConfigParameters& config)
{
wstring modelPath = config(L"modelPath");
wstring outdot = config(L"outputDotFile"); // filename for the dot language output, if not specified, %modelpath%.dot will be used
wstring outRending = config(L"outputFile"); // filename for the rendered topology plot
wstring modelPath = config(L"modelPath");
wstring outputDotFile = config(L"outputDotFile"); // filename for the dot language output, if not specified, %modelpath%.dot will be used
wstring outputFile = config(L"outputFile"); // filename for the rendered topology plot
// this can be empty, in that case no rendering will be done
// or if this is set, renderCmd must be set, so CNTK will call re
wstring RenderCmd = config(L"RenderCmd"); // if this option is set, then CNTK will call the render to convert the outdotFile to a graph
wstring renderCmd = config(L"renderCmd"); // if this option is set, then CNTK will call the render to convert the outdotFile to a graph
// e.g. "d:\Tools\graphviz\bin\dot.exe -Tpng -x <IN> -o<OUT>"
// where <IN> and <OUT> are two special placeholders

// ========================================
// Sec. 1 option check
// ========================================
if (outdot.empty())
{
outdot = modelPath + L".dot";
}
// output dot file defaults to modelpath.dot
if (outputDotFile.empty())
outputDotFile = modelPath + L".dot";

wstring rescmd;
if (!outRending.empty()) // we need to render the plot
{
std::wregex inputPlaceHolder(L"(.+)(<IN>)(.*)");
std::wregex outputPlaceHolder(L"(.+)(<OUT>)(.*)");
ComputationNetwork net(CPUDEVICE);
net.Load<ElemType>(modelPath);

net.PlotNetworkTopology(outputDotFile);
fprintf(stderr, "Created network description in dot format: %ls\n", outputDotFile.c_str());

rescmd = regex_replace(RenderCmd, inputPlaceHolder, L"$1" + outdot + L"$3");
rescmd = regex_replace(rescmd, outputPlaceHolder, L"$1" + outRending + L"$3");
if (!outputFile.empty())
{
if (renderCmd.empty())
InvalidArgument("plot: If you specify an outputFile, you also need a renderCmd.");
#if 0 // this part is problematic under early version of gcc (< 4.9)
static const wregex inputPlaceHolder(L"(.+)(<IN>)(.*)");
static const wregex outputPlaceHolder(L"(.+)(<OUT>)(.*)");

// patch in the pathnames
renderCmd = regex_replace(renderCmd, inputPlaceHolder, L"$1" + outputDotFile + L"$3");
renderCmd = regex_replace(renderCmd, outputPlaceHolder, L"$1" + outputFile + L"$3");
#endif
msra::strfun::ReplaceAll(renderCmd, wstring(L"<IN>"), outputDotFile);
msra::strfun::ReplaceAll(renderCmd, wstring(L"<OUT>"), outputFile);
}

ComputationNetwork net(-1);
net.Load<ElemType>(modelPath);
net.PlotNetworkTopology(outdot);
fprintf(stderr, "Output network description in dot language to %S\n", outdot.c_str());

if (!outRending.empty())
{
fprintf(stderr, "Executing a third-part tool for rendering dot:\n%S\n", rescmd.c_str());
fprintf(stderr, "Executing third-party tool for rendering dot:\n%ls\n", renderCmd.c_str());
#ifdef __unix__
const auto rc = system(msra::strfun::utf8(rescmd).c_str());
rc /*ignoring the result--this gets flagged by gcc if we don't save the return value*/;
auto rc = system(msra::strfun::utf8(renderCmd).c_str());
rc; // ignoring the result--this gets flagged by gcc if we don't save the return value
#else
_wsystem(rescmd.c_str());
_wsystem(renderCmd.c_str());
#endif
fprintf(stderr, "Done\n");
}
fprintf(stderr, "Done.\n");
}

template void DoTopologyPlot<float>(const ConfigParameters& config);
Expand Down
1 change: 1 addition & 0 deletions Source/CNTK/BrainScript/ExperimentalNetworkBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ L"ParameterTensor(dims, learningRateMultiplier = 1.0, init = 'uniform'/*|fixedVa
L"TransposeDimensions(input, dim1, dim2, tag='') = new ComputationNode [ operation = 'TransposeDimensions' ; inputs = input /*plus the function args*/ ]\n"
L"Transpose(x) = TransposeDimensions(x, 1, 2)\n"
L"Times(A, B, outputRank=1, tag='') = new ComputationNode [ operation = 'Times' ; inputs = ( A : B ) /*plus the function args*/ ]\n"
// TODO: Logistic should be generated with with BinaryStandardNode macro below.
L"Logistic(label, probability, tag='') = new ComputationNode [ operation = 'Logistic' ; inputs = (label : probability) /*plus the function args*/ ]\n"
L"WeightedLogistic(label, probability, instanceWeight, tag='') = new ComputationNode [ operation = 'Logistic' ; inputs = (label : probability : instanceWeight) /*plus the function args*/ ]\n"
L"ReconcileMBLayout(dataInput, layoutInput, tag='') = new ComputationNode [ operation = 'ReconcileMBLayout' ; inputs = (dataInput : layoutInput) /*plus the function args*/ ]\n"
Expand Down
6 changes: 2 additions & 4 deletions Source/CNTK/CNTK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ int wmainWithBS(int argc, wchar_t* argv[]) // called from wmain which is a wrapp
wstring startupMessage = msra::strfun::wstrprintf(L"running on %ls at %ls\n", msra::strfun::utf16(GetHostName()).c_str(), msra::strfun::utf16(TimeDateStamp()).c_str());
startupMessage += msra::strfun::wstrprintf(L"command line: %ls", exePath.c_str());
for (const auto& arg : args)
startupMessage += L" " + arg;
startupMessage += L" " + arg;

fprintf(stderr, "%ls\n", startupMessage.c_str());

Expand Down Expand Up @@ -580,9 +580,7 @@ int wmainOldCNTKConfig(int argc, wchar_t* argv[]) // called from wmain which is
fprintf(stderr, "running on %s at %s\n", GetHostName().c_str(), timestamp.c_str());
fprintf(stderr, "command line: \n");
for (int i = 0; i < argc; i++)
{
fprintf(stderr, "%s ", WCharToString(argv[i]).c_str());
}
fprintf(stderr, "%*s%ls", i > 0 ? 2 : 0, "", argv[i]); // use 2 spaces for better visual separability

// This simply merges all the different config parameters specified (eg, via config files or via command line directly),
// and prints it.
Expand Down
2 changes: 1 addition & 1 deletion Source/CNTK/ModelEditLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ void MELScript<ElemType>::CallFunction(const std::string& p_name, const ConfigPa
case melPropBatchNormMode:
{
bool evalMode = params[2];
netNdl->cn->SetBatchNormlizationNodesBelowEvalMode(evalMode, node);
netNdl->cn->SetBatchNormalizationNodesBelowEvalMode(evalMode, node);
break;
}
default:
Expand Down
29 changes: 16 additions & 13 deletions Source/CNTK/prebuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ echo #define _BUILDINFO_H >> buildinfo.h$$
FOR /F %%i IN ('hostname') DO SET HOST=%%i
:: assuming hostname always exists

:: not sure whether git in path ?
call git --version 2 > nul
if not %ERRORLEVEL% == 9009 (
echo #define _GIT_EXIST >> buildinfo.h$$
FOR /F %%i IN ('git rev-parse --abbrev-ref HEAD') DO SET BRANCH=%%i
FOR /F %%i IN ('git rev-parse HEAD') DO SET COMMIT=%%i
set STATUS=
git diff --quiet --cached
if not errorlevel 1 git diff --quiet
if errorlevel 1 set STATUS= ^(modified^)
echo #define _BUILDBRANCH_ "!BRANCH!" >> buildinfo.h$$
echo #define _BUILDSHA1_ "!COMMIT!!STATUS!">> buildinfo.h$$
:: note: we'll only use git which is in path
where -q git
if not errorlevel 1 (
call git --version > NUL 2>&1
if not errorlevel 1 (
echo #define _GIT_EXIST >> buildinfo.h$$
FOR /F %%i IN ('call git rev-parse --abbrev-ref HEAD') DO SET BRANCH=%%i
FOR /F %%i IN ('call git rev-parse HEAD') DO SET COMMIT=%%i
set STATUS=
call git diff --quiet --cached
if not errorlevel 1 call git diff --quiet
if errorlevel 1 set STATUS= ^(modified^)
echo #define _BUILDBRANCH_ "!BRANCH!" >> buildinfo.h$$
echo #define _BUILDSHA1_ "!COMMIT!!STATUS!">> buildinfo.h$$
)
)

:: For now, math lib is basically hardwired
Expand Down Expand Up @@ -75,4 +78,4 @@ echo #endif >> buildinfo.h$$

::: update file only if it changed (otherwise CNTK.cpp will get rebuilt each time)
fc buildinfo.h$$ buildinfo.h > NUL 2>&1
if ERRORLEVEL 1 move /Y buildinfo.h$$ buildinfo.h
if errorlevel 1 move /Y buildinfo.h$$ buildinfo.h
Loading

0 comments on commit ff32a89

Please sign in to comment.