Skip to content

Commit 0f9886a

Browse files
committed
chore - add .clang-format / re-format files wherever required
1 parent 3475ff9 commit 0f9886a

File tree

3 files changed

+55
-41
lines changed

3 files changed

+55
-41
lines changed

.clang-format

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This file is used by clang-format to autoformat paddle source code
2+
#
3+
# The clang-format is part of llvm toolchain.
4+
# It need to install llvm and clang to format source code style.
5+
#
6+
# The basic usage is,
7+
# clang-format -i -style=file PATH/TO/SOURCE/CODE
8+
#
9+
# The -style=file implicit use ".clang-format" file located in one of
10+
# parent directory.
11+
# The -i means inplace change.
12+
#
13+
# The document of clang-format is
14+
# http://clang.llvm.org/docs/ClangFormat.html
15+
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
16+
---
17+
Language: Cpp
18+
BasedOnStyle: Google
19+
IndentWidth: 2
20+
TabWidth: 2
21+
ContinuationIndentWidth: 4
22+
AccessModifierOffset: -2 # The private/protected/public has no indent in class
23+
Standard: Cpp11
24+
AllowAllParametersOfDeclarationOnNextLine: true
25+
BinPackParameters: false
26+
BinPackArguments: false

examples/1_Introduction/src/basic-operations.cc

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
// - use different overloads of Run method
1111

1212
int main(int argc, char **argv) {
13-
1413
using namespace tensorflow;
1514
using namespace tensorflow::ops;
1615

@@ -66,76 +65,66 @@ int main(int argc, char **argv) {
6665
// std::vector<Tensor>* outputs) const;
6766
//
6867
//
69-
// which takes FeedType (alias of std::unordered_map<Output, Input::Initializer, OutputHash>
70-
// as the first argument.
71-
// Note - In std::unordered_map OutputHash is optional
72-
// So we just need to supply a map whose key of type "Output" and the
73-
// value that respect Initializer
68+
// which takes FeedType (alias of std::unordered_map<Output,
69+
// Input::Initializer, OutputHash> as the first argument.
70+
//
71+
// Note - In std::unordered_map OutputHash is optional So we just need to
72+
// supply a map whose key of type "Output" and the value that respect
73+
// Initializer
7474
//
7575
// {a,2} & {b,3} would satisfiy this requirement since type 'a' & 'b'
7676
// is Output
77-
78-
auto status = session.Run({
79-
{
80-
{a, 2},
81-
{b, 3}
82-
} }, {c}, &outputs);
83-
77+
78+
auto status = session.Run({{{a, 2}, {b, 3}}}, {c}, &outputs);
79+
8480
TF_CHECK_OK(status);
85-
81+
8682
// we know that it will be scalar
8783
// we can also get the underlying data by calling flat
8884
std::cout << "Underlying Scalar value -> " << outputs[0].flat<int>()
8985
<< std::endl;
9086
}
91-
87+
9288
{
9389
// This is yet another example that makes use of Placeholder however
9490
// this time we want one of the placeholder to have a default value
9591
//
9692
// In other words, it does not need to be specified during the session
9793
// execution. if you give a new value it would accept it else would use
9894
// the default value
99-
95+
10096
ClientSession session(scope);
101-
97+
10298
// create an input
10399
auto defaultAInput = Input(8);
104-
100+
105101
// we will use Placeholder as the type for our variables
106102
auto a = PlaceholderWithDefault(scope, defaultAInput, PartialTensorShape());
107103
auto b = Placeholder(scope, DT_INT32);
108-
104+
109105
// define the add operation that takes
110106
// the placeholders a and b as inputs
111107
auto c = Add(scope, a, b);
112-
108+
113109
std::vector<Tensor> outputs;
114-
110+
115111
// In this Run we are not specifying 'a'
116112
// so its default value i.e. 8 will be used
117-
auto status = session.Run({
118-
{
119-
{b, 3}
120-
} }, {c}, &outputs);
121-
113+
auto status = session.Run({{{b, 3}}}, {c}, &outputs);
114+
122115
TF_CHECK_OK(status);
123-
124-
std::cout << "Underlying Scalar value (using default placeholder value [8]) -> " << outputs[0].flat<int>()
125-
<< std::endl;
126-
116+
117+
std::cout
118+
<< "Underlying Scalar value (using default placeholder value [8]) -> "
119+
<< outputs[0].flat<int>() << std::endl;
120+
127121
// here we do specify a value for placeholder 'a' i.e. 9
128-
status = session.Run({
129-
{
130-
{a, 9},
131-
{b, 3}
132-
} }, {c}, &outputs);
133-
122+
status = session.Run({{{a, 9}, {b, 3}}}, {c}, &outputs);
123+
134124
TF_CHECK_OK(status);
135-
136-
std::cout << "Underlying Scalar value (after supplying new value [9]) -> " << outputs[0].flat<int>()
137-
<< std::endl;
138-
125+
126+
std::cout << "Underlying Scalar value (after supplying new value [9]) -> "
127+
<< outputs[0].flat<int>() << std::endl;
139128
}
140129

141130
return 0;

examples/1_Introduction/src/hello-world.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// - a simple peek inside the output using the DebugString & by flattening it
1313

1414
int main(int argc, char **argv) {
15-
1615
using namespace tensorflow;
1716
using namespace tensorflow::ops;
1817

0 commit comments

Comments
 (0)