blob: 75e03fb6b3479033992a6ee6f3c0b4a8d4545829 [file] [log] [blame]
Georgios Pinitas652bde52018-01-10 15:33:28 +00001/*
SiCong Li4841c972021-02-03 12:17:35 +00002 * Copyright (c) 2017-2021 Arm Limited.
Georgios Pinitas652bde52018-01-10 15:33:28 +00003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
SiCongLif466d752021-03-01 15:26:18 +000024#include "arm_compute/core/Types.h"
25#include "arm_compute/core/Utils.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010026#include "arm_compute/graph.h"
27
Georgios Pinitas652bde52018-01-10 15:33:28 +000028#include "support/ToolchainSupport.h"
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010029#include "utils/CommonGraphOptions.h"
Georgios Pinitas652bde52018-01-10 15:33:28 +000030#include "utils/GraphUtils.h"
31#include "utils/Utils.h"
32
Georgios Pinitas652bde52018-01-10 15:33:28 +000033using namespace arm_compute::utils;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010034using namespace arm_compute::graph::frontend;
Georgios Pinitas652bde52018-01-10 15:33:28 +000035using namespace arm_compute::graph_utils;
36
Georgios Pinitas108ab0b2018-09-14 18:35:11 +010037/** Example demonstrating how to implement InceptionV3's network using the Compute Library's graph API */
Georgios Pinitasd8734b52017-12-22 15:27:52 +000038class InceptionV3Example : public Example
Georgios Pinitas652bde52018-01-10 15:33:28 +000039{
40public:
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010041 InceptionV3Example() : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "InceptionV3")
Georgios Pinitas652bde52018-01-10 15:33:28 +000042 {
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010043 }
44 bool do_setup(int argc, char **argv) override
45 {
46 // Parse arguments
47 cmd_parser.parse(argc, argv);
Georgios Pinitascd60a5f2019-08-21 17:06:54 +010048 cmd_parser.validate();
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010049
50 // Consume common parameters
51 common_params = consume_common_graph_parameters(common_opts);
52
53 // Return when help menu is requested
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010054 if (common_params.help)
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010055 {
56 cmd_parser.print_help(argv[0]);
57 return false;
58 }
59
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010060 // Print parameter values
61 std::cout << common_params << std::endl;
62
63 // Get trainable parameters data path
64 std::string data_path = common_params.data_path;
Georgios Pinitas652bde52018-01-10 15:33:28 +000065
Georgios Pinitas140fdc72018-02-16 11:42:38 +000066 // Create a preprocessor object
Georgios Pinitas40f51a62020-11-21 03:04:18 +000067 std::unique_ptr<IPreprocessor> preprocessor = std::make_unique<TFPreproccessor>();
Georgios Pinitas652bde52018-01-10 15:33:28 +000068
Georgios Pinitase2220552018-07-20 13:23:44 +010069 // Create input descriptor
Sang-Hoon Park11fedda2020-01-15 14:44:04 +000070 const auto operation_layout = common_params.data_layout;
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010071 const TensorShape tensor_shape =
72 permute_shape(TensorShape(299U, 299U, 3U, common_params.batches), DataLayout::NCHW, operation_layout);
73 TensorDescriptor input_descriptor =
74 TensorDescriptor(tensor_shape, common_params.data_type).set_layout(operation_layout);
Georgios Pinitase2220552018-07-20 13:23:44 +010075
76 // Set weights trained layout
77 const DataLayout weights_layout = DataLayout::NCHW;
78
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010079 graph
80 << common_params.target << common_params.fast_math_hint
81 << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false))
82 << ConvolutionLayer(3U, 3U, 32U,
83 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_weights.npy",
84 weights_layout),
85 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
86 PadStrideInfo(2, 2, 0, 0))
87 .set_name("Conv2d_1a_3x3/convolution")
88 << BatchNormalizationLayer(
89 get_weights_accessor(data_path,
90 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
91 get_weights_accessor(data_path,
92 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
93 nullptr,
94 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
95 0.001f)
96 .set_name("Conv2d_1a_3x3/BatchNorm/batchnorm")
97 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
98 .set_name("Conv2d_1a_3x3/Relu")
99 << ConvolutionLayer(3U, 3U, 32U,
100 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_weights.npy",
101 weights_layout),
102 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
103 PadStrideInfo(1, 1, 0, 0))
104 .set_name("Conv2d_2a_3x3/convolution")
105 << BatchNormalizationLayer(
106 get_weights_accessor(data_path,
107 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
108 get_weights_accessor(data_path,
109 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
110 nullptr,
111 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
112 0.001f)
113 .set_name("Conv2d_2a_3x3/BatchNorm/batchnorm")
114 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
115 .set_name("Conv2d_2a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000116
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100117 << ConvolutionLayer(3U, 3U, 64U,
118 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_weights.npy",
119 weights_layout),
120 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
121 PadStrideInfo(1, 1, 1, 1))
122 .set_name("Conv2d_2b_3x3/convolution")
123 << BatchNormalizationLayer(
124 get_weights_accessor(data_path,
125 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
126 get_weights_accessor(data_path,
127 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
128 nullptr,
129 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
130 0.001f)
131 .set_name("Conv2d_2b_3x3/BatchNorm/batchnorm")
132 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
133 .set_name("Conv2d_2b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000134
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100135 << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, operation_layout,
136 PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)))
137 .set_name("MaxPool_3a_3x3/MaxPool")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000138
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100139 << ConvolutionLayer(1U, 1U, 80U,
140 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_weights.npy",
141 weights_layout),
142 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
143 PadStrideInfo(1, 1, 0, 0))
144 .set_name("Conv2d_3b_1x1/convolution")
145 << BatchNormalizationLayer(
146 get_weights_accessor(data_path,
147 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_mean.npy"),
148 get_weights_accessor(data_path,
149 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_variance.npy"),
150 nullptr,
151 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_beta.npy"),
152 0.001f)
153 .set_name("Conv2d_3b_1x1/BatchNorm/batchnorm")
154 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
155 .set_name("Conv2d_3b_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000156
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100157 << ConvolutionLayer(3U, 3U, 192U,
158 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_weights.npy",
159 weights_layout),
160 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
161 PadStrideInfo(1, 1, 0, 0))
162 .set_name("Conv2d_4a_3x3/convolution")
163 << BatchNormalizationLayer(
164 get_weights_accessor(data_path,
165 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_mean.npy"),
166 get_weights_accessor(data_path,
167 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_variance.npy"),
168 nullptr,
169 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_beta.npy"),
170 0.001f)
171 .set_name("Conv2d_4a_3x3/BatchNorm/batchnorm")
172 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
173 .set_name("Conv2d_4a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000174
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100175 << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, operation_layout,
176 PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)))
177 .set_name("MaxPool_5a_3x3/MaxPool");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000178
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100179 graph << get_inception_node_A(data_path, "Mixed_5b", weights_layout, 64U, std::make_tuple(48U, 64U),
180 std::make_tuple(64U, 96U, 96U), 32U)
181 .set_name("Mixed_5b/concat");
182 graph << get_inception_node_A(data_path, "Mixed_5c", weights_layout, 64U, std::make_tuple(48U, 64U),
183 std::make_tuple(64U, 96U, 96U), 64U, true)
184 .set_name("Mixed_5c/concat");
185 graph << get_inception_node_A(data_path, "Mixed_5d", weights_layout, 64U, std::make_tuple(48U, 64U),
186 std::make_tuple(64U, 96U, 96U), 64U)
187 .set_name("Mixed_5d/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000188
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100189 graph << get_inception_node_B(data_path, "Mixed_6a", weights_layout, 384U, std::make_tuple(64U, 96U, 96U))
190 .set_name("Mixed_6a/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000191
Georgios Pinitase2220552018-07-20 13:23:44 +0100192 graph << get_inception_node_C(data_path, "Mixed_6b", weights_layout, 192U, std::make_tuple(128U, 128U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100193 std::make_tuple(128U, 128U, 128U, 128U, 192U), 192U)
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100194 .set_name("Mixed_6b/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100195 graph << get_inception_node_C(data_path, "Mixed_6c", weights_layout, 192U, std::make_tuple(160U, 160U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100196 std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100197 .set_name("Mixed_6c/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100198 graph << get_inception_node_C(data_path, "Mixed_6d", weights_layout, 192U, std::make_tuple(160U, 160U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100199 std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100200 .set_name("Mixed_6d/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100201 graph << get_inception_node_C(data_path, "Mixed_6e", weights_layout, 192U, std::make_tuple(192U, 192U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100202 std::make_tuple(192U, 192U, 192U, 192U, 192U), 192U)
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100203 .set_name("Mixed_6e/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000204
Georgios Pinitase2220552018-07-20 13:23:44 +0100205 graph << get_inception_node_D(data_path, "Mixed_7a", weights_layout, std::make_tuple(192U, 320U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100206 std::make_tuple(192U, 192U, 192U, 192U))
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100207 .set_name("Mixed_7a/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000208
Georgios Pinitase2220552018-07-20 13:23:44 +0100209 graph << get_inception_node_E(data_path, "Mixed_7b", weights_layout, 320U, std::make_tuple(384U, 384U, 384U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100210 std::make_tuple(448U, 384U, 384U, 384U), 192U)
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100211 .set_name("Mixed_7b/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100212 graph << get_inception_node_E(data_path, "Mixed_7c", weights_layout, 320U, std::make_tuple(384U, 384U, 384U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100213 std::make_tuple(448U, 384U, 384U, 384U), 192U, true)
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100214 .set_name("Mixed_7c/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000215
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100216 graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 8, operation_layout,
217 PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::CEIL)))
218 .set_name("Logits/AvgPool_1a_8x8/AvgPool")
219 << ConvolutionLayer(
220 1U, 1U, 1001U,
221 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_weights.npy",
222 weights_layout),
223 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_biases.npy"),
224 PadStrideInfo(1, 1, 0, 0))
225 .set_name("Logits/Conv2d_1c_1x1/convolution")
Georgios Pinitas130986a2018-05-14 19:25:37 +0100226 << ReshapeLayer(TensorShape(1001U)).set_name("Predictions/Reshape")
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100227 << SoftmaxLayer().set_name("Predictions/Softmax") << OutputLayer(get_output_accessor(common_params, 5));
Gian Marcoc1b6e372018-02-21 18:03:26 +0000228
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000229 // Finalize graph
Georgios Pinitas9a8c6722018-03-21 17:52:35 +0000230 GraphConfig config;
SiCongLif466d752021-03-01 15:26:18 +0000231 config.num_threads = common_params.threads;
232 config.use_tuner = common_params.enable_tuner;
233 config.tuner_mode = common_params.tuner_mode;
234 config.tuner_file = common_params.tuner_file;
235 config.mlgo_file = common_params.mlgo_file;
236 config.use_synthetic_type = arm_compute::is_data_type_quantized(common_params.data_type);
237 config.synthetic_type = common_params.data_type;
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100238 graph.finalize(common_params.target, config);
239
240 return true;
Georgios Pinitas652bde52018-01-10 15:33:28 +0000241 }
242
243 void do_run() override
244 {
245 graph.run();
246 }
247
248private:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100249 CommandLineParser cmd_parser;
250 CommonGraphOptions common_opts;
251 CommonGraphParams common_params;
252 Stream graph;
Georgios Pinitas652bde52018-01-10 15:33:28 +0000253
254private:
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100255 ConcatLayer get_inception_node_A(const std::string &data_path,
256 std::string &&param_path,
257 DataLayout weights_layout,
258 unsigned int a_filt,
259 std::tuple<unsigned int, unsigned int> b_filters,
Georgios Pinitas652bde52018-01-10 15:33:28 +0000260 std::tuple<unsigned int, unsigned int, unsigned int> c_filters,
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100261 unsigned int d_filt,
262 bool is_name_different = false)
Georgios Pinitas652bde52018-01-10 15:33:28 +0000263 {
264 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitas652bde52018-01-10 15:33:28 +0000265
266 // This is due to a naming issue in the tf model
267 std::string conv_id0 = "_0a_";
268 std::string conv_id1 = "2d_0b_";
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100269 if (is_name_different)
Georgios Pinitas652bde52018-01-10 15:33:28 +0000270 {
271 conv_id0 = "_0b_";
272 conv_id1 = "_1_0c_";
273 }
274
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000275 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000276 i_a << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100277 1U, 1U, a_filt,
278 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
279 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
280 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000281 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100282 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
283 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
284 nullptr, get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
285 0.001f)
286 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
287 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
288 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000289
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000290 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000291 i_b << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100292 1U, 1U, std::get<0>(b_filters),
293 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_weights.npy",
294 weights_layout),
295 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
296 .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/convolution")
297 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 +
298 "1x1_BatchNorm_moving_mean.npy"),
299 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 +
300 "1x1_BatchNorm_moving_variance.npy"),
301 nullptr,
302 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 +
303 "1x1_BatchNorm_beta.npy"),
304 0.001f)
305 .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/BatchNorm/batchnorm")
306 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
307 .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000308 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100309 5U, 5U, std::get<1>(b_filters),
310 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_weights.npy",
311 weights_layout),
312 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 2, 2))
313 .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000314 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100315 get_weights_accessor(data_path,
316 total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_mean.npy"),
317 get_weights_accessor(data_path,
318 total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_variance.npy"),
319 nullptr,
320 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_beta.npy"),
321 0.001f)
322 .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/BatchNorm/batchnorm")
323 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
324 .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000325
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000326 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000327 i_c << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100328 1U, 1U, std::get<0>(c_filters),
329 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
330 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
331 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000332 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100333 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
334 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
335 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
336 0.001f)
337 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
338 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
339 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000340 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100341 3U, 3U, std::get<1>(c_filters),
342 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout),
343 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
344 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000345 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100346 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
347 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
348 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
349 0.001f)
350 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
351 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
352 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000353 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100354 3U, 3U, std::get<2>(c_filters),
355 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout),
356 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
357 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000358 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100359 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
360 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
361 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
362 0.001f)
363 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm/batcnorm")
364 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
365 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000366
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000367 SubStream i_d(graph);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100368 i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout,
369 PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true))
370 .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000371 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100372 1U, 1U, d_filt,
373 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
374 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
375 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000376 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100377 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
378 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
379 nullptr, get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
380 0.001f)
381 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
382 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
383 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000384
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100385 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
Georgios Pinitas652bde52018-01-10 15:33:28 +0000386 }
387
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100388 ConcatLayer get_inception_node_B(const std::string &data_path,
389 std::string &&param_path,
390 DataLayout weights_layout,
391 unsigned int a_filt,
Georgios Pinitas652bde52018-01-10 15:33:28 +0000392 std::tuple<unsigned int, unsigned int, unsigned int> b_filters)
393 {
394 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000395 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000396 i_a << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100397 3U, 3U, a_filt,
398 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_weights.npy", weights_layout),
399 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
400 .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000401 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100402 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
403 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
404 nullptr, get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_beta.npy"),
405 0.001f)
406 .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/BatchNorm/batchnorm")
407 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
408 .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000409
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000410 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000411 i_b << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100412 1U, 1U, std::get<0>(b_filters),
413 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
414 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
415 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000416 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100417 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
418 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
419 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
420 0.001f)
421 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
422 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
423 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000424 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100425 3U, 3U, std::get<1>(b_filters),
426 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
427 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
428 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000429 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100430 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
431 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
432 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
433 0.001f)
434 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm/batchnorm")
435 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
436 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000437 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100438 3U, 3U, std::get<2>(b_filters),
439 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_weights.npy", weights_layout),
440 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
441 .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000442 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100443 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
444 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
445 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_beta.npy"),
446 0.001f)
447 .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/BatchNorm/batchnorm")
448 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
449 .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000450
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000451 SubStream i_c(graph);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100452 i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout,
453 PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)))
454 .set_name(param_path + "/Branch_2/MaxPool_1a_3x3/MaxPool");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000455
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100456 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas652bde52018-01-10 15:33:28 +0000457 }
458
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100459 ConcatLayer
460 get_inception_node_C(const std::string &data_path,
461 std::string &&param_path,
462 DataLayout weights_layout,
463 unsigned int a_filt,
464 std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
465 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
466 unsigned int d_filt)
Georgios Pinitas652bde52018-01-10 15:33:28 +0000467 {
468 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000469 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000470 i_a << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100471 1U, 1U, a_filt,
472 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
473 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
474 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000475 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100476 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
477 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
478 nullptr, get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
479 0.001f)
480 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
481 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
482 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000483
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000484 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000485 i_b << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100486 1U, 1U, std::get<0>(b_filters),
487 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
488 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
489 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000490 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100491 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
492 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
493 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
494 0.001f)
495 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
496 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
497 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000498 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100499 7U, 1U, std::get<1>(b_filters),
500 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
501 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
502 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000503 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100504 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
505 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
506 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
507 0.001f)
508 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
509 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
510 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000511 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100512 1U, 7U, std::get<2>(b_filters),
513 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
514 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
515 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000516 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100517 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
518 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
519 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
520 0.001f)
521 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
522 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
523 .set_name(param_path + "/Branch_0/Conv2d_0c_7x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000524
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000525 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000526 i_c << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100527 1U, 1U, std::get<0>(c_filters),
528 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
529 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
530 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000531 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100532 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
533 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
534 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
535 0.001f)
536 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
537 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
538 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000539 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100540 1U, 7U, std::get<1>(c_filters),
541 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout),
542 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
543 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000544 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100545 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
546 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
547 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
548 0.001f)
549 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm/batchnorm")
550 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
551 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000552 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100553 7U, 1U, std::get<2>(c_filters),
554 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout),
555 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
556 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000557 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100558 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
559 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
560 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
561 0.001f)
562 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm/batchnorm")
563 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
564 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000565 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100566 1U, 7U, std::get<3>(c_filters),
567 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout),
568 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
569 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000570 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100571 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
572 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
573 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
574 0.001f)
575 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm/batchnorm")
576 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
577 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000578 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100579 7U, 1U, std::get<4>(c_filters),
580 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout),
581 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
582 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000583 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100584 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
585 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
586 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
587 0.001f)
588 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm/batchnorm")
589 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
590 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000591
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000592 SubStream i_d(graph);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100593 i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout,
594 PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true))
595 .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000596 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100597 1U, 1U, d_filt,
598 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
599 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
600 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000601 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100602 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
603 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
604 nullptr, get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
605 0.001f)
606 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
607 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
608 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000609
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100610 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
Georgios Pinitas652bde52018-01-10 15:33:28 +0000611 }
612
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100613 ConcatLayer get_inception_node_D(const std::string &data_path,
614 std::string &&param_path,
615 DataLayout weights_layout,
616 std::tuple<unsigned int, unsigned int> a_filters,
Georgios Pinitas652bde52018-01-10 15:33:28 +0000617 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> b_filters)
618 {
619 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000620 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000621 i_a << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100622 1U, 1U, std::get<0>(a_filters),
623 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
624 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
625 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000626 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100627 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
628 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
629 nullptr, get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
630 0.001f)
631 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
632 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
633 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000634 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100635 3U, 3U, std::get<1>(a_filters),
636 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
637 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
638 .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000639 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100640 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
641 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
642 nullptr, get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
643 0.001f)
644 .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/BatchNorm/batchnorm")
645 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
646 .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000647
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000648 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000649 i_b << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100650 1U, 1U, std::get<0>(b_filters),
651 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
652 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
653 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000654 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100655 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
656 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
657 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
658 0.001f)
659 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
660 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
661 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000662 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100663 7U, 1U, std::get<1>(b_filters),
664 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
665 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
666 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000667 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100668 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
669 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
670 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
671 0.001f)
672 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
673 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
674 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000675 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100676 1U, 7U, std::get<2>(b_filters),
677 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
678 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
679 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000680 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100681 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
682 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
683 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
684 0.001f)
685 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
686 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
687 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000688 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100689 3U, 3U, std::get<3>(b_filters),
690 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
691 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
692 .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000693 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100694 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
695 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
696 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
697 0.001f)
698 .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/BatchNorm/batchnorm")
699 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
700 .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000701
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000702 SubStream i_c(graph);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100703 i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout,
704 PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)))
705 .set_name(param_path + "/Branch_2/MaxPool_1a_3x3/MaxPool");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000706
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100707 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas652bde52018-01-10 15:33:28 +0000708 }
709
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100710 ConcatLayer get_inception_node_E(const std::string &data_path,
711 std::string &&param_path,
712 DataLayout weights_layout,
713 unsigned int a_filt,
714 std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
Georgios Pinitas652bde52018-01-10 15:33:28 +0000715 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100716 unsigned int d_filt,
717 bool is_name_different = false)
Georgios Pinitas652bde52018-01-10 15:33:28 +0000718 {
719 // This is due to a naming issue in the tf model
720 std::string conv_id = "_0b_";
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100721 if (is_name_different)
Georgios Pinitas652bde52018-01-10 15:33:28 +0000722 {
723 conv_id = "_0c_";
724 }
725
726 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000727 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000728 i_a << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100729 1U, 1U, a_filt,
730 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
731 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
732 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000733 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100734 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
735 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
736 nullptr, get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
737 0.001f)
738 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
739 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
740 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000741
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000742 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000743 i_b << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100744 1U, 1U, std::get<0>(b_filters),
745 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
746 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
747 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000748 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100749 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
750 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
751 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
752 0.001f)
753 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
754 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
755 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000756
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100757 SubStream i_b1(i_b);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000758 i_b1 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100759 3U, 1U, std::get<1>(b_filters),
760 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout),
761 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 0))
762 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000763 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100764 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
765 get_weights_accessor(data_path,
766 total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
767 nullptr, get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
768 0.001f)
769 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm/batchnorm")
770 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
771 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000772
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100773 SubStream i_b2(i_b);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000774 i_b2 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100775 1U, 3U, std::get<2>(b_filters),
776 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_weights.npy",
777 weights_layout),
778 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 1))
779 .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/convolution")
780 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id +
781 "3x1_BatchNorm_moving_mean.npy"),
782 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id +
783 "3x1_BatchNorm_moving_variance.npy"),
784 nullptr,
785 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id +
786 "3x1_BatchNorm_beta.npy"),
787 0.001f)
788 .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/BatchNorm/batchnorm")
789 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
790 .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000791
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000792 // Merge b1 and b2
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100793 i_b << ConcatLayer(std::move(i_b1), std::move(i_b2)).set_name(param_path + "/Branch_1/concat");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000794
795 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000796 i_c << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100797 1U, 1U, std::get<0>(c_filters),
798 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
799 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
800 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000801 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100802 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
803 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
804 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
805 0.001f)
806 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
807 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
808 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000809 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100810 3U, 3U, std::get<1>(c_filters),
811 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout),
812 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
813 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000814 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100815 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
816 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
817 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
818 0.001f)
819 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
820 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
821 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000822
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100823 SubStream i_c1(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000824 i_c1 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100825 3U, 1U, std::get<2>(c_filters),
826 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout),
827 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 0))
828 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/convolution")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000829 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100830 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
831 get_weights_accessor(data_path,
832 total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
833 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
834 0.001f)
835 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm/batchnorm")
836 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
837 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000838
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100839 SubStream i_c2(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000840 i_c2 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100841 1U, 3U, std::get<3>(c_filters),
842 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_weights.npy", weights_layout),
843 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 1))
844 .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/convolution")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000845 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100846 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_mean.npy"),
847 get_weights_accessor(data_path,
848 total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_variance.npy"),
849 nullptr, get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_beta.npy"),
850 0.001f)
851 .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/BatchNorm/batchnorm")
852 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
853 .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000854
855 // Merge i_c1 and i_c2
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100856 i_c << ConcatLayer(std::move(i_c1), std::move(i_c2)).set_name(param_path + "/Branch_2/concat");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000857
858 SubStream i_d(graph);
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100859 i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout,
860 PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true))
861 .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000862 << ConvolutionLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100863 1U, 1U, d_filt,
864 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
865 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
866 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000867 << BatchNormalizationLayer(
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100868 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
869 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
870 nullptr, get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
871 0.001f)
872 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
873 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
874 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000875
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100876 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
Georgios Pinitas652bde52018-01-10 15:33:28 +0000877 }
878};
879
880/** Main program for Inception V3
881 *
Georgios Pinitasbdbbbe82018-11-07 16:06:47 +0000882 * Model is based on:
883 * https://arxiv.org/abs/1512.00567
884 * "Rethinking the Inception Architecture for Computer Vision"
885 * Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, Zbigniew Wojna
886 *
Georgios Pinitas588ebc52018-12-21 13:39:07 +0000887 * Provenance: download.tensorflow.org/models/inception_v3_2016_08_28.tar.gz
888 *
Georgios Pinitas9f28b392018-07-18 20:01:53 +0100889 * @note To list all the possible arguments execute the binary appended with the --help option
890 *
Georgios Pinitas652bde52018-01-10 15:33:28 +0000891 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100892 * @param[in] argv Arguments
Georgios Pinitas652bde52018-01-10 15:33:28 +0000893 */
894int main(int argc, char **argv)
895{
896 return arm_compute::utils::run_example<InceptionV3Example>(argc, argv);
897}