@@ -36,8 +36,9 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
3636
3737 for (const auto & layer_data : model_data) {
3838 std::string layer_type = layer_data[" type" ];
39- if (comments)
39+ if (comments) {
4040 std::cout << " Processing layer of type: " << layer_type << std::endl;
41+ }
4142
4243 it_lab_ai::Tensor tensor =
4344 it_lab_ai::create_tensor_from_json (layer_data, it_lab_ai::Type::kFloat );
@@ -84,8 +85,9 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
8485 layer_ptrs.push_back (ew_layer.get ());
8586 layers.push_back (std::move (ew_layer));
8687 layerpostop.push_back (true );
87- if (comments)
88+ if (comments) {
8889 std::cout << " Element wise (relu) added to layers" << std::endl;
90+ }
8991 }
9092 if (layer_type.find (" Dense" ) != std::string::npos) {
9193 it_lab_ai::Tensor tmp_bias = it_lab_ai::make_tensor (tensor.get_bias ());
@@ -104,9 +106,10 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
104106 } else {
105107 pooltype = " average" ;
106108 }
107- if (comments)
109+ if (comments) {
108110 std::cout << " PoolingLayer shape: " << shape[0 ] << " x" << shape[1 ]
109111 << std::endl;
112+ }
110113 auto pool_layer =
111114 std::make_unique<it_lab_ai::PoolingLayer>(shape, pooltype, kDefault );
112115 layer_ptrs.push_back (pool_layer.get ());
@@ -129,15 +132,17 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
129132 layer_ptrs.push_back (dropout_layer.get ());
130133 layers.push_back (std::move (dropout_layer));
131134 layerpostop.push_back (false );
132- if (comments)
135+ if (comments) {
133136 std::cout
134137 << " DropOutLayer added to layers with probability 0.4 (turned "
135138 " off for inference)."
136139 << std::endl;
140+ }
137141 }
138142 }
139- if (comments)
143+ if (comments) {
140144 std::cout << " number of layers - " << layers.size () + 1 << std::endl;
145+ }
141146 auto a1 = std::make_unique<it_lab_ai::InputLayer>(it_lab_ai::kNchw ,
142147 it_lab_ai::kNchw );
143148 Layer* a1_ptr = a1.get ();
@@ -148,17 +153,19 @@ void build_graph_linear(it_lab_ai::Graph& graph, it_lab_ai::Tensor& input,
148153 if (comments) std::cout << " Input set in graph." << std::endl;
149154
150155 graph.makeConnection (a1_ptr, layer_ptrs[0 ]);
151- if (comments)
156+ if (comments) {
152157 std::cout << " Connection made between InputLayer and first layer."
153158 << std::endl;
159+ }
154160
155161 for (size_t i = 0 ; i < layers.size () - 1 ; ++i) {
156162 if (layerpostop[i]) {
157163 layer_ptrs[i - 1 ]->postops .layers .push_back (layer_ptrs[i]);
158164 layer_ptrs[i - 1 ]->postops .count ++;
159165 graph.makeConnection (layer_ptrs[i - 1 ], layer_ptrs[i + 1 ]);
160- } else if (!layerpostop[i + 1 ])
166+ } else if (!layerpostop[i + 1 ]) {
161167 graph.makeConnection (layer_ptrs[i], layer_ptrs[i + 1 ]);
168+ }
162169 }
163170
164171 graph.setOutput (layer_ptrs.back (), output);
@@ -460,11 +467,12 @@ ParseResult parse_json_model(const std::string& json_path, bool comments) {
460467 } else if (layer_type.find (" Dropout" ) != std::string::npos) {
461468 auto dropout_layer = std::make_unique<it_lab_ai::DropOutLayer>(0.0 );
462469 layer = std::move (dropout_layer);
463- if (comments)
470+ if (comments) {
464471 std::cout
465472 << " DropOutLayer added to layers with probability 0.4 (turned "
466473 " off for inference)."
467474 << std::endl;
475+ }
468476 } else if (layer_type == " GlobalAveragePool" ) {
469477 auto pool_layer = std::make_unique<it_lab_ai::PoolingLayer>(
470478 it_lab_ai::Shape ({0 , 0 }), " average" , kDefault );
@@ -668,15 +676,15 @@ ParseResult parse_json_model(const std::string& json_path, bool comments) {
668676 }
669677 } else {
670678 it_lab_ai::BinaryOpLayer::Operation op;
671- if (layer_type == " Add" )
679+ if (layer_type == " Add" ) {
672680 op = it_lab_ai::BinaryOpLayer::Operation::kAdd ;
673- else if (layer_type == " Sub" )
681+ } else if (layer_type == " Sub" ) {
674682 op = it_lab_ai::BinaryOpLayer::Operation::kSub ;
675- else if (layer_type == " Mul" )
683+ } else if (layer_type == " Mul" ) {
676684 op = it_lab_ai::BinaryOpLayer::Operation::kMul ;
677- else if (layer_type == " Div" )
685+ } else if (layer_type == " Div" ) {
678686 op = it_lab_ai::BinaryOpLayer::Operation::kDiv ;
679- else {
687+ } else {
680688 op = it_lab_ai::BinaryOpLayer::Operation::kAdd ;
681689 }
682690
0 commit comments