Skip to content

Commit 2f39fe3

Browse files
Mark HillebrandMark Hillebrand
authored andcommitted
Re-format code using clang-format (plus some post-processing)
1 parent 1bcefe7 commit 2f39fe3

File tree

275 files changed

+86311
-77086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+86311
-77086
lines changed

.clang-format

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# Requires clang-format version 3.7.1 or later
3+
Language: Cpp
4+
AlignConsecutiveAssignments: false
5+
AlignEscapedNewlinesLeft: true
6+
AlignTrailingComments: true
7+
AllowShortBlocksOnASingleLine: false
8+
AllowShortFunctionsOnASingleLine: Empty
9+
AllowShortIfStatementsOnASingleLine: false
10+
AllowShortLoopsOnASingleLine: false
11+
AlwaysBreakTemplateDeclarations: true
12+
AccessModifierOffset: -4
13+
BreakBeforeBraces: Allman
14+
BreakConstructorInitializersBeforeComma: false
15+
ColumnLimit: 0
16+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
17+
DerivePointerAlignment: true
18+
ForEachMacros: [ BOOST_FOREACH, foreach_column, foreach_coord, foreach_index, foreach_row, foreach_row_in_submat ]
19+
IndentWidth: 4
20+
MaxEmptyLinesToKeep: 1
21+
NamespaceIndentation: None
22+
PointerAlignment: Left
23+
SpaceAfterCStyleCast: true
24+
SpaceBeforeAssignmentOperators: true
25+
SpaceBeforeParens: ControlStatements
26+
SpaceInEmptyParentheses: false
27+
Standard: Cpp11
28+
TabWidth: 4
29+
UseTab: Never
30+
...
31+

Source/ActionsLib/Actions.h

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,44 @@
1616
// implementations of all the commands of CNTK
1717
// ===========================================================================
1818

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

2121
// training (TrainActions.cpp)
22-
template<class ConfigRecordType, typename ElemType> void DoTrain(const ConfigRecordType & config);
23-
template<typename ElemType> void DoAdapt(const ConfigParameters& config);
24-
template<typename ElemType> void DoEdit(const ConfigParameters& config);
22+
template <class ConfigRecordType, typename ElemType>
23+
void DoTrain(const ConfigRecordType& config);
24+
template <typename ElemType>
25+
void DoAdapt(const ConfigParameters& config);
26+
template <typename ElemType>
27+
void DoEdit(const ConfigParameters& config);
2528

2629
// evaluation (EvalActions.cpp)
27-
template<typename ElemType> void DoEval(const ConfigParameters& config);
28-
template<typename ElemType> void DoCrossValidate(const ConfigParameters& config);
29-
template<typename ElemType> void DoWriteOutput(const ConfigParameters& config);
30+
template <typename ElemType>
31+
void DoEval(const ConfigParameters& config);
32+
template <typename ElemType>
33+
void DoCrossValidate(const ConfigParameters& config);
34+
template <typename ElemType>
35+
void DoWriteOutput(const ConfigParameters& config);
3036

3137
// misc (OtherActions.cp)
32-
template<typename ElemType> void DoCreateLabelMap(const ConfigParameters& config);
33-
template<typename ElemType> void DoParameterSVD(const ConfigParameters& config);
34-
template<typename ElemType> void DoWriteWordAndClassInfo(const ConfigParameters& config);
35-
template<typename ElemType> void DoTopologyPlot(const ConfigParameters& config);
38+
template <typename ElemType>
39+
void DoCreateLabelMap(const ConfigParameters& config);
40+
template <typename ElemType>
41+
void DoParameterSVD(const ConfigParameters& config);
42+
template <typename ElemType>
43+
void DoWriteWordAndClassInfo(const ConfigParameters& config);
44+
template <typename ElemType>
45+
void DoTopologyPlot(const ConfigParameters& config);
3646

3747
// deprecated (EsotericActions.cp)
38-
template<typename ElemType> void DoConvertFromDbn(const ConfigParameters& config);
39-
template<typename ElemType> void DoEvalUnroll(const ConfigParameters& config);
40-
template<typename ElemType> void DoEncoderDecoder(const ConfigParameters& config);
41-
template<typename ElemType> void DoBidirectionEncoderDecoder(const ConfigParameters& config);
42-
template<typename ElemType> void DoEvalEncodingBeamSearchDecoding(const ConfigParameters& config);
43-
template<typename ElemType> void DoBeamSearchDecoding(const ConfigParameters& config);
48+
template <typename ElemType>
49+
void DoConvertFromDbn(const ConfigParameters& config);
50+
template <typename ElemType>
51+
void DoEvalUnroll(const ConfigParameters& config);
52+
template <typename ElemType>
53+
void DoEncoderDecoder(const ConfigParameters& config);
54+
template <typename ElemType>
55+
void DoBidirectionEncoderDecoder(const ConfigParameters& config);
56+
template <typename ElemType>
57+
void DoEvalEncodingBeamSearchDecoding(const ConfigParameters& config);
58+
template <typename ElemType>
59+
void DoBeamSearchDecoding(const ConfigParameters& config);

Source/ActionsLib/EsotericActions.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// </copyright>
66
//
77

8-
#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _
8+
#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _
99

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

7171
// Special early implementation of RNNs by emulating them as a DNN.
72-
// The code is very restricted to simple RNNs.
73-
// 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.
72+
// The code is very restricted to simple RNNs.
73+
// 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.
7474
// TODO: can probably be removed.
7575
template <typename ElemType>
7676
void DoEvalUnroll(const ConfigParameters& config)
@@ -140,7 +140,7 @@ void DoEncoderDecoder(const ConfigParameters& config)
140140
if (config.Exists("EncoderNetworkBuilder"))
141141
{
142142
ConfigParameters configSNB = config(L"EncoderNetworkBuilder");
143-
encoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
143+
encoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
144144
}
145145
else
146146
{
@@ -150,7 +150,7 @@ void DoEncoderDecoder(const ConfigParameters& config)
150150
if (config.Exists("DecoderNetworkBuilder"))
151151
{
152152
ConfigParameters configSNB = config(L"DecoderNetworkBuilder");
153-
decoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
153+
decoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
154154
}
155155
else
156156
{
@@ -168,7 +168,7 @@ void DoEncoderDecoder(const ConfigParameters& config)
168168
validationDataReader.push_back(cvEncoderDataReader);
169169
validationDataReader.push_back(cvDecoderDataReader);
170170

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

173173
delete encoderDataReader;
174174
delete decoderDataReader;
@@ -222,15 +222,15 @@ void DoBidirectionEncoderDecoder(const ConfigParameters& config)
222222
if (config.Exists("EncoderNetworkBuilder"))
223223
{
224224
ConfigParameters configSNB = config(L"EncoderNetworkBuilder");
225-
encoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
225+
encoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
226226
}
227227
else
228228
LogicError("Need encoder network");
229229

230230
if (config.Exists("DecoderNetworkBuilder"))
231231
{
232232
ConfigParameters configSNB = config(L"DecoderNetworkBuilder");
233-
forwardDecoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
233+
forwardDecoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
234234
}
235235
else
236236
{
@@ -240,7 +240,7 @@ void DoBidirectionEncoderDecoder(const ConfigParameters& config)
240240
if (config.Exists("BackwardDecoderNetworkBuilder"))
241241
{
242242
ConfigParameters configSNB = config(L"BackwardDecoderNetworkBuilder");
243-
backwardDecoderNetBuilder = (IComputationNetBuilder<ElemType>*)new SimpleNetworkBuilder<ElemType>(configSNB);
243+
backwardDecoderNetBuilder = (IComputationNetBuilder<ElemType>*) new SimpleNetworkBuilder<ElemType>(configSNB);
244244
}
245245
else
246246
{
@@ -261,7 +261,7 @@ void DoBidirectionEncoderDecoder(const ConfigParameters& config)
261261
validationDataReader.push_back(cvDecoderDataReader);
262262
validationDataReader.push_back(cvBackwardDecoderDataReader);
263263

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

266266
delete encoderDataReader;
267267
delete decoderDataReader;
@@ -346,7 +346,7 @@ void DoEvalEncodingBeamSearchDecoding(const ConfigParameters& config)
346346
MultiNetworksEvaluator<ElemType> eval(decoderNet, numMBsToShowResult, traceLevel);
347347
eval.InitTrainEncoderDecoderWithHiddenStates(config);
348348

349-
eval.EncodingEvaluateDecodingBeamSearch(nets, readers,
349+
eval.EncodingEvaluateDecodingBeamSearch(nets, readers,
350350
testDataWriter, evalNodeNamesVector,
351351
outputNodeNamesVector,
352352
mbSize[0], beamWidth, epochSize);

Source/ActionsLib/EvalActions.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// </copyright>
66
//
77

8-
#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _
8+
#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _
99

1010
#include "stdafx.h"
1111
#include "Basics.h"
@@ -179,10 +179,10 @@ void DoCrossValidate(const ConfigParameters& config)
179179
minErrIds.push_back(0);
180180
}
181181

182-
for (int i = 0; i<cvErrorResults.size(); i++)
182+
for (int i = 0; i < cvErrorResults.size(); i++)
183183
{
184184
evalErrors = cvErrorResults[i];
185-
for (int j = 0; j<evalErrors.size(); j++)
185+
for (int j = 0; j < evalErrors.size(); j++)
186186
{
187187
if (evalErrors[j] < minErrors[j])
188188
{
@@ -212,7 +212,7 @@ void DoWriteOutput(const ConfigParameters& config)
212212
{
213213
ConfigParameters readerConfig(config(L"reader"));
214214
readerConfig.Insert("traceLevel", config(L"traceLevel", "0"));
215-
readerConfig.Insert("randomize", "None"); //we don't want randomization when output results
215+
readerConfig.Insert("randomize", "None"); //we don't want randomization when output results
216216

217217
DataReader<ElemType> testDataReader(readerConfig);
218218

@@ -247,7 +247,7 @@ void DoWriteOutput(const ConfigParameters& config)
247247
}
248248
else if (config.Exists("outputPath"))
249249
{
250-
wstring outputPath = config(L"outputPath"); // crashes if no default given?
250+
wstring outputPath = config(L"outputPath"); // crashes if no default given?
251251
writer.WriteOutput(testDataReader, mbSize[0], outputPath, outputNodeNamesVector, epochSize);
252252
}
253253
//writer.WriteOutput(testDataReader, mbSize[0], testDataWriter, outputNodeNamesVector, epochSize);

0 commit comments

Comments
 (0)