Skip to content

Commit

Permalink
Re-format code using clang-format (plus some post-processing)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Hillebrand authored and Mark Hillebrand committed Jan 18, 2016
1 parent 1bcefe7 commit 2f39fe3
Show file tree
Hide file tree
Showing 275 changed files with 86,311 additions and 77,086 deletions.
31 changes: 31 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# Requires clang-format version 3.7.1 or later
Language: Cpp
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: true
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
AccessModifierOffset: -4
BreakBeforeBraces: Allman
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerAlignment: true
ForEachMacros: [ BOOST_FOREACH, foreach_column, foreach_coord, foreach_index, foreach_row, foreach_row_in_submat ]
IndentWidth: 4
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PointerAlignment: Left
SpaceAfterCStyleCast: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

50 changes: 33 additions & 17 deletions Source/ActionsLib/Actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,44 @@
// implementations of all the commands of CNTK
// ===========================================================================

using namespace Microsoft::MSR::CNTK; // TODO: we should not have this in a header
using namespace Microsoft::MSR::CNTK; // TODO: we should not have this in a header

// training (TrainActions.cpp)
template<class ConfigRecordType, typename ElemType> void DoTrain(const ConfigRecordType & config);
template<typename ElemType> void DoAdapt(const ConfigParameters& config);
template<typename ElemType> void DoEdit(const ConfigParameters& config);
template <class ConfigRecordType, typename ElemType>
void DoTrain(const ConfigRecordType& config);
template <typename ElemType>
void DoAdapt(const ConfigParameters& config);
template <typename ElemType>
void DoEdit(const ConfigParameters& config);

// evaluation (EvalActions.cpp)
template<typename ElemType> void DoEval(const ConfigParameters& config);
template<typename ElemType> void DoCrossValidate(const ConfigParameters& config);
template<typename ElemType> void DoWriteOutput(const ConfigParameters& config);
template <typename ElemType>
void DoEval(const ConfigParameters& config);
template <typename ElemType>
void DoCrossValidate(const ConfigParameters& config);
template <typename ElemType>
void DoWriteOutput(const ConfigParameters& config);

// misc (OtherActions.cp)
template<typename ElemType> void DoCreateLabelMap(const ConfigParameters& config);
template<typename ElemType> void DoParameterSVD(const ConfigParameters& config);
template<typename ElemType> void DoWriteWordAndClassInfo(const ConfigParameters& config);
template<typename ElemType> void DoTopologyPlot(const ConfigParameters& config);
template <typename ElemType>
void DoCreateLabelMap(const ConfigParameters& config);
template <typename ElemType>
void DoParameterSVD(const ConfigParameters& config);
template <typename ElemType>
void DoWriteWordAndClassInfo(const ConfigParameters& config);
template <typename ElemType>
void DoTopologyPlot(const ConfigParameters& config);

// deprecated (EsotericActions.cp)
template<typename ElemType> void DoConvertFromDbn(const ConfigParameters& config);
template<typename ElemType> void DoEvalUnroll(const ConfigParameters& config);
template<typename ElemType> void DoEncoderDecoder(const ConfigParameters& config);
template<typename ElemType> void DoBidirectionEncoderDecoder(const ConfigParameters& config);
template<typename ElemType> void DoEvalEncodingBeamSearchDecoding(const ConfigParameters& config);
template<typename ElemType> void DoBeamSearchDecoding(const ConfigParameters& config);
template <typename ElemType>
void DoConvertFromDbn(const ConfigParameters& config);
template <typename ElemType>
void DoEvalUnroll(const ConfigParameters& config);
template <typename ElemType>
void DoEncoderDecoder(const ConfigParameters& config);
template <typename ElemType>
void DoBidirectionEncoderDecoder(const ConfigParameters& config);
template <typename ElemType>
void DoEvalEncodingBeamSearchDecoding(const ConfigParameters& config);
template <typename ElemType>
void DoBeamSearchDecoding(const ConfigParameters& config);
22 changes: 11 additions & 11 deletions Source/ActionsLib/EsotericActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// </copyright>
//

#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _
#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _

#include "stdafx.h"
#include "Basics.h"
Expand Down Expand Up @@ -69,8 +69,8 @@ template void DoConvertFromDbn<double>(const ConfigParameters& config);
// ===========================================================================

// Special early implementation of RNNs by emulating them as a DNN.
// The code is very restricted to simple RNNs.
// The idea can be used for more complicated network but need to know which nodes are stateful or time-dependent so that unroll is done in a correct way to represent recurrent networks.
// The code is very restricted to simple RNNs.
// The idea can be used for more complicated network but need to know which nodes are stateful or time-dependent so that unroll is done in a correct way to represent recurrent networks.
// TODO: can probably be removed.
template <typename ElemType>
void DoEvalUnroll(const ConfigParameters& config)
Expand Down Expand Up @@ -140,7 +140,7 @@ void DoEncoderDecoder(const ConfigParameters& config)
if (config.Exists("EncoderNetworkBuilder"))
{
ConfigParameters configSNB = config(L"EncoderNetworkBuilder");
encoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
encoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
}
else
{
Expand All @@ -150,7 +150,7 @@ void DoEncoderDecoder(const ConfigParameters& config)
if (config.Exists("DecoderNetworkBuilder"))
{
ConfigParameters configSNB = config(L"DecoderNetworkBuilder");
decoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
decoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
}
else
{
Expand All @@ -168,7 +168,7 @@ void DoEncoderDecoder(const ConfigParameters& config)
validationDataReader.push_back(cvEncoderDataReader);
validationDataReader.push_back(cvDecoderDataReader);

sgd.EncoderDecoder(netBuilders, (int)config(L"deviceId"), trainDataReader, validationDataReader, makeMode);
sgd.EncoderDecoder(netBuilders, (int) config(L"deviceId"), trainDataReader, validationDataReader, makeMode);

delete encoderDataReader;
delete decoderDataReader;
Expand Down Expand Up @@ -222,15 +222,15 @@ void DoBidirectionEncoderDecoder(const ConfigParameters& config)
if (config.Exists("EncoderNetworkBuilder"))
{
ConfigParameters configSNB = config(L"EncoderNetworkBuilder");
encoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
encoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
}
else
LogicError("Need encoder network");

if (config.Exists("DecoderNetworkBuilder"))
{
ConfigParameters configSNB = config(L"DecoderNetworkBuilder");
forwardDecoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
forwardDecoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
}
else
{
Expand All @@ -240,7 +240,7 @@ void DoBidirectionEncoderDecoder(const ConfigParameters& config)
if (config.Exists("BackwardDecoderNetworkBuilder"))
{
ConfigParameters configSNB = config(L"BackwardDecoderNetworkBuilder");
backwardDecoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
backwardDecoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
}
else
{
Expand All @@ -261,7 +261,7 @@ void DoBidirectionEncoderDecoder(const ConfigParameters& config)
validationDataReader.push_back(cvDecoderDataReader);
validationDataReader.push_back(cvBackwardDecoderDataReader);

sgd.EncoderDecoder(netBuilders, (int)config(L"deviceId"), trainDataReader, validationDataReader, makeMode);
sgd.EncoderDecoder(netBuilders, (int) config(L"deviceId"), trainDataReader, validationDataReader, makeMode);

delete encoderDataReader;
delete decoderDataReader;
Expand Down Expand Up @@ -346,7 +346,7 @@ void DoEvalEncodingBeamSearchDecoding(const ConfigParameters& config)
MultiNetworksEvaluator<ElemType> eval(decoderNet, numMBsToShowResult, traceLevel);
eval.InitTrainEncoderDecoderWithHiddenStates(config);

eval.EncodingEvaluateDecodingBeamSearch(nets, readers,
eval.EncodingEvaluateDecodingBeamSearch(nets, readers,
testDataWriter, evalNodeNamesVector,
outputNodeNamesVector,
mbSize[0], beamWidth, epochSize);
Expand Down
10 changes: 5 additions & 5 deletions Source/ActionsLib/EvalActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// </copyright>
//

#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _
#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _

#include "stdafx.h"
#include "Basics.h"
Expand Down Expand Up @@ -179,10 +179,10 @@ void DoCrossValidate(const ConfigParameters& config)
minErrIds.push_back(0);
}

for (int i = 0; i<cvErrorResults.size(); i++)
for (int i = 0; i < cvErrorResults.size(); i++)
{
evalErrors = cvErrorResults[i];
for (int j = 0; j<evalErrors.size(); j++)
for (int j = 0; j < evalErrors.size(); j++)
{
if (evalErrors[j] < minErrors[j])
{
Expand Down Expand Up @@ -212,7 +212,7 @@ void DoWriteOutput(const ConfigParameters& config)
{
ConfigParameters readerConfig(config(L"reader"));
readerConfig.Insert("traceLevel", config(L"traceLevel", "0"));
readerConfig.Insert("randomize", "None"); //we don't want randomization when output results
readerConfig.Insert("randomize", "None"); //we don't want randomization when output results

DataReader<ElemType> testDataReader(readerConfig);

Expand Down Expand Up @@ -247,7 +247,7 @@ void DoWriteOutput(const ConfigParameters& config)
}
else if (config.Exists("outputPath"))
{
wstring outputPath = config(L"outputPath"); // crashes if no default given?
wstring outputPath = config(L"outputPath"); // crashes if no default given?
writer.WriteOutput(testDataReader, mbSize[0], outputPath, outputNodeNamesVector, epochSize);
}
//writer.WriteOutput(testDataReader, mbSize[0], testDataWriter, outputNodeNamesVector, epochSize);
Expand Down
Loading

0 comments on commit 2f39fe3

Please sign in to comment.