blob: a322b2268d44005ea0e6c9311ec246929e9eb9e0 [file] [log] [blame]
Georgios Pinitas240cfa62018-02-26 19:58:04 +00001/*
Georgios Pinitas62c36392019-01-31 12:53:10 +00002 * Copyright (c) 2018-2019 ARM Limited.
Georgios Pinitas240cfa62018-02-26 19:58:04 +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 */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010024#include "arm_compute/graph.h"
Georgios Pinitas240cfa62018-02-26 19:58:04 +000025#include "support/ToolchainSupport.h"
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010026#include "utils/CommonGraphOptions.h"
Georgios Pinitas240cfa62018-02-26 19:58:04 +000027#include "utils/GraphUtils.h"
28#include "utils/Utils.h"
29
Georgios Pinitas240cfa62018-02-26 19:58:04 +000030using namespace arm_compute::utils;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010031using namespace arm_compute::graph::frontend;
Georgios Pinitas240cfa62018-02-26 19:58:04 +000032using namespace arm_compute::graph_utils;
33
Georgios Pinitas108ab0b2018-09-14 18:35:11 +010034/** Example demonstrating how to implement InceptionV4's network using the Compute Library's graph API */
Georgios Pinitas240cfa62018-02-26 19:58:04 +000035class InceptionV4Example final : public Example
36{
37public:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010038 InceptionV4Example()
39 : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "InceptionV4")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000040 {
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010041 }
42 bool do_setup(int argc, char **argv) override
43 {
44 // Parse arguments
45 cmd_parser.parse(argc, argv);
Georgios Pinitascd60a5f2019-08-21 17:06:54 +010046 cmd_parser.validate();
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010047
48 // Consume common parameters
49 common_params = consume_common_graph_parameters(common_opts);
50
51 // Return when help menu is requested
52 if(common_params.help)
53 {
54 cmd_parser.print_help(argv[0]);
55 return false;
56 }
57
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010058 // Print parameter values
59 std::cout << common_params << std::endl;
60
61 // Get trainable parameters data path
62 std::string data_path = common_params.data_path;
Georgios Pinitas240cfa62018-02-26 19:58:04 +000063
64 // Create a preprocessor object
65 std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>();
66
Georgios Pinitase2220552018-07-20 13:23:44 +010067 // Create input descriptor
68 const TensorShape tensor_shape = permute_shape(TensorShape(299U, 299U, 3U, 1U), DataLayout::NCHW, common_params.data_layout);
69 TensorDescriptor input_descriptor = TensorDescriptor(tensor_shape, common_params.data_type).set_layout(common_params.data_layout);
70
71 // Set weights trained layout
72 const DataLayout weights_layout = DataLayout::NCHW;
73
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010074 graph << common_params.target
75 << common_params.fast_math_hint
Georgios Pinitase2220552018-07-20 13:23:44 +010076 << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false))
Georgios Pinitas240cfa62018-02-26 19:58:04 +000077 // Conv2d_1a_3x3
78 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010079 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000080 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000081 .set_name("Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000082 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
83 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
84 get_random_accessor(1.f, 1.f),
85 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
86 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +000087 .set_name("Conv2d_1a_3x3/BatchNorm")
88 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000089 // Conv2d_2a_3x3
90 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010091 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000092 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000093 .set_name("Conv2d_2a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000094 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
95 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
96 get_random_accessor(1.f, 1.f),
97 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
98 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +000099 .set_name("Conv2d_2a_3x3/BatchNorm")
100 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000101 // Conv2d_2b_3x3
102 << ConvolutionLayer(3U, 3U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100103 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000104 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000105 .set_name("Conv2d_2b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000106 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
107 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
108 get_random_accessor(1.f, 1.f),
109 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
110 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000111 .set_name("Conv2d_2b_3x3/BatchNorm")
112 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000113
Georgios Pinitas62c36392019-01-31 12:53:10 +0000114 graph << get_mixed_3a(data_path, weights_layout).set_name("Mixed_3a/concat");
115 graph << get_mixed_4a(data_path, weights_layout).set_name("Mixed_4a/concat");
116 graph << get_mixed_5a(data_path, weights_layout).set_name("Mixed_5a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100117 // 4 inception A blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000118 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5b").set_name("Mixed_5b/concat");
119 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5c").set_name("Mixed_5c/concat");
120 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5d").set_name("Mixed_5d/concat");
121 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5e").set_name("Mixed_5e/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100122 // reduction A block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000123 graph << get_reductionA_block(data_path, weights_layout).set_name("Mixed_6a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100124 // 7 inception B blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000125 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6b").set_name("Mixed_6b/concat");
126 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6c").set_name("Mixed_6c/concat");
127 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6d").set_name("Mixed_6d/concat");
128 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6e").set_name("Mixed_6e/concat");
129 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6f").set_name("Mixed_6f/concat");
130 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6g").set_name("Mixed_6g/concat");
131 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6h").set_name("Mixed_6h/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100132 // reduction B block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000133 graph << get_reductionB_block(data_path, weights_layout).set_name("Mixed_7a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100134 // 3 inception C blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000135 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7b").set_name("Mixed_7b/concat");
136 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7c").set_name("Mixed_7c/concat");
137 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7d").set_name("Mixed_7d/concat");
138 graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG)).set_name("Logits/AvgPool_1a/AvgPool")
139 << FlattenLayer().set_name("Logits/Flatten")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000140 << FullyConnectedLayer(
141 1001U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100142 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000143 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_biases.npy"))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000144 .set_name("Logits/MatMul")
145 << SoftmaxLayer().set_name("Logits/Predictions")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100146 << OutputLayer(get_output_accessor(common_params, 5));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000147
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000148 // Finalize graph
Georgios Pinitas9a8c6722018-03-21 17:52:35 +0000149 GraphConfig config;
Georgios Pinitasf4261ad2019-12-02 11:58:19 +0000150 config.num_threads = common_params.threads;
151 config.use_tuner = common_params.enable_tuner;
152 config.tuner_mode = common_params.tuner_mode;
153 config.tuner_file = common_params.tuner_file;
154 config.convert_to_uint8 = (common_params.data_type == DataType::QASYMM8);
Anthony Barbier7b607dc2018-07-13 15:55:24 +0100155
Pablo Tellodb9116f2019-07-11 16:50:37 +0100156 // Load the precompiled kernels from a file into the kernel library, in this way the next time they are needed
157 // compilation won't be required.
158 if(common_params.enable_cl_cache)
159 {
160 restore_program_cache_from_file();
161 }
162
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100163 graph.finalize(common_params.target, config);
164
Pablo Tellodb9116f2019-07-11 16:50:37 +0100165 // Save the opencl kernels to a file
166 if(common_opts.enable_cl_cache)
167 {
168 save_program_cache_to_file();
169 }
170
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100171 return true;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000172 }
173
174 void do_run() override
175 {
176 graph.run();
177 }
178
179private:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100180 CommandLineParser cmd_parser;
181 CommonGraphOptions common_opts;
182 CommonGraphParams common_params;
183 Stream graph;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000184
185private:
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100186 ConcatLayer get_mixed_3a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000187 {
188 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_3a_";
189
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000190 SubStream i_a(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000191 i_a << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)).set_name("Mixed_3a/Branch_0/MaxPool_0a_3x3/MaxPool");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000192
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000193 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000194 i_b << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100195 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000196 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000197 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000198 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_mean.npy"),
199 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_variance.npy"),
200 get_random_accessor(1.f, 1.f),
201 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_beta.npy"),
202 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000203 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/BatchNorm")
204 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000205
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100206 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000207 }
208
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100209 ConcatLayer get_mixed_4a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000210 {
211 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_4a_";
212
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000213 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000214 i_a << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100215 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000216 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000217 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000218 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
219 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
220 get_random_accessor(1.f, 1.f),
221 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
222 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000223 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/BatchNorm")
224 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000225 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100226 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000227 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000228 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000229 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
230 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
231 get_random_accessor(1.f, 1.f),
232 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
233 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000234 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/BatchNorm")
235 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000236
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000237 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000238 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100239 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000240 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000241 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000242 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
243 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
244 get_random_accessor(1.f, 1.f),
245 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
246 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000247 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/BatchNorm")
248 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000249 << ConvolutionLayer(7U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100250 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000251 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000252 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000253 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
254 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
255 get_random_accessor(1.f, 1.f),
256 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
257 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000258 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/BatchNorm")
259 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000260 << ConvolutionLayer(1U, 7U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100261 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000262 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000263 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000264 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
265 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
266 get_random_accessor(1.f, 1.f),
267 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
268 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000269 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/BatchNorm")
270 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000271 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100272 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000273 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000274 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000275 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
276 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
277 get_random_accessor(1.f, 1.f),
278 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
279 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000280 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/BatchNorm")
281 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000282
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100283 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000284 }
285
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100286 ConcatLayer get_mixed_5a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000287 {
288 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_5a_";
289
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000290 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000291 i_a << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100292 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000293 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000294 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000295 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
296 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
297 get_random_accessor(1.f, 1.f),
298 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
299 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000300 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/BatchNorm")
301 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000302
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000303 SubStream i_b(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000304 i_b << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)).set_name("Mixed_5a/Branch_1/MaxPool_1a_3x3/MaxPool");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000305
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100306 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000307 }
308
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100309 ConcatLayer get_inceptionA_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000310 {
311 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
312
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000313 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000314 i_a << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100315 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000316 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000317 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000318 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
319 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
320 get_random_accessor(1.f, 1.f),
321 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
322 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000323 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
324 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000325
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000326 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000327 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100328 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000329 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000330 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000331 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
332 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
333 get_random_accessor(1.f, 1.f),
334 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
335 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000336 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
337 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000338 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100339 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000340 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000341 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000342 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
343 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
344 get_random_accessor(1.f, 1.f),
345 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
346 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000347 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm")
348 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000349
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000350 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000351 i_c << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100352 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000353 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000354 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000355 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
356 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
357 get_random_accessor(1.f, 1.f),
358 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
359 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000360 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
361 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000362 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100363 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000364 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000365 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000366 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
367 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
368 get_random_accessor(1.f, 1.f),
369 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
370 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000371 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm")
372 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000373 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100374 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000375 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000376 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000377 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
378 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
379 get_random_accessor(1.f, 1.f),
380 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
381 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000382 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm")
383 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000384
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000385 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000386 i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)).set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000387 << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100388 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000389 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000390 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000391 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
392 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
393 get_random_accessor(1.f, 1.f),
394 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
395 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000396 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
397 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000398
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100399 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000400 }
401
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100402 ConcatLayer get_reductionA_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000403 {
404 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_6a_";
405
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000406 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000407 i_a << ConvolutionLayer(3U, 3U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100408 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000409 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000410 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000411 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
412 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
413 get_random_accessor(1.f, 1.f),
414 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
415 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000416 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/BatchNorm")
417 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000418
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000419 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000420 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100421 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000422 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000423 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000424 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
425 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
426 get_random_accessor(1.f, 1.f),
427 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
428 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000429 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/BatchNorm")
430 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000431 << ConvolutionLayer(3U, 3U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100432 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000433 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000434 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000435 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
436 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
437 get_random_accessor(1.f, 1.f),
438 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
439 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000440 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/BatchNorm")
441 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000442 << ConvolutionLayer(3U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100443 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000444 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000445 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000446 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
447 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
448 get_random_accessor(1.f, 1.f),
449 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
450 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000451 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/BatchNorm")
452 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000453
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000454 SubStream i_c(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000455 i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)).set_name("Mixed_6a/Branch_2/MaxPool_1a_3x3/MaxPool");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000456
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100457 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000458 }
459
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100460 ConcatLayer get_inceptionB_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000461 {
462 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
463
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000464 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000465 i_a << ConvolutionLayer(1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100466 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000467 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000468 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000469 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
470 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
471 get_random_accessor(1.f, 1.f),
472 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
473 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000474 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
475 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000476
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000477 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000478 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100479 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000480 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000481 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000482 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
483 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
484 get_random_accessor(1.f, 1.f),
485 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
486 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000487 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
488 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000489 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100490 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000491 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000492 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000493 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
494 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
495 get_random_accessor(1.f, 1.f),
496 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
497 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000498 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm")
499 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000500 << ConvolutionLayer(1U, 7U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100501 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000502 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000503 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000504 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
505 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
506 get_random_accessor(1.f, 1.f),
507 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
508 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000509 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm")
510 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000511
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000512 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000513 i_c << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100514 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000515 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000516 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000517 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
518 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
519 get_random_accessor(1.f, 1.f),
520 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
521 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000522 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
523 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000524 << ConvolutionLayer(1U, 7U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100525 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000526 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000527 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000528 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
529 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
530 get_random_accessor(1.f, 1.f),
531 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
532 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000533 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm")
534 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000535 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100536 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000537 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000538 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000539 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
540 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
541 get_random_accessor(1.f, 1.f),
542 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
543 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000544 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm")
545 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000546 << ConvolutionLayer(1U, 7U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100547 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000548 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000549 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000550 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
551 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
552 get_random_accessor(1.f, 1.f),
553 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
554 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000555 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm")
556 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000557 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100558 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000559 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000560 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000561 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
562 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
563 get_random_accessor(1.f, 1.f),
564 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
565 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000566 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm")
567 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000568
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000569 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000570 i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)).set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000571 << ConvolutionLayer(1U, 1U, 128U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100572 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000573 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000574 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000575 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
576 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
577 get_random_accessor(1.f, 1.f),
578 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
579 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000580 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
581 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000582
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100583 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000584 }
585
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100586 ConcatLayer get_reductionB_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000587 {
588 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_7a_";
589
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000590 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000591 i_a << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100592 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000593 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000594 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000595 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
596 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
597 get_random_accessor(1.f, 1.f),
598 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
599 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000600 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
601 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000602 << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100603 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000604 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000605 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000606 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
607 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
608 get_random_accessor(1.f, 1.f),
609 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
610 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000611 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/BatchNorm")
612 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000613
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000614 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000615 i_b << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100616 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000617 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000618 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000619 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
620 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
621 get_random_accessor(1.f, 1.f),
622 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
623 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000624 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
625 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000626 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100627 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000628 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000629 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000630 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
631 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
632 get_random_accessor(1.f, 1.f),
633 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
634 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000635 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/BatchNorm")
636 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000637 << ConvolutionLayer(1U, 7U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100638 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000639 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000640 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000641 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
642 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
643 get_random_accessor(1.f, 1.f),
644 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
645 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000646 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/BatchNorm")
647 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000648 << ConvolutionLayer(3U, 3U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100649 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000650 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000651 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000652 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
653 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
654 get_random_accessor(1.f, 1.f),
655 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
656 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000657 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/BatchNorm")
658 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000659
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000660 SubStream i_c(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000661 i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)).set_name("Mixed_7a/Branch_2/MaxPool_1a_3x3/MaxPool");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000662
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100663 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000664 }
665
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100666 ConcatLayer get_inceptionC_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000667 {
668 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
669
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000670 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000671 i_a << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100672 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000673 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000674 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000675 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
676 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
677 get_random_accessor(1.f, 1.f),
678 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
679 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000680 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
681 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000682
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000683 SubStream i_b(graph);
684 i_b << ConvolutionLayer(
685 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100686 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000687 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
688 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000689 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000690 << BatchNormalizationLayer(
691 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
692 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
693 get_random_accessor(1.f, 1.f),
694 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
695 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000696 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
697 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000698
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100699 SubStream i_b1(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000700 i_b1 << ConvolutionLayer(
701 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100702 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000703 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
704 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000705 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000706 << BatchNormalizationLayer(
707 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
708 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
709 get_random_accessor(1.f, 1.f),
710 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
711 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000712 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm")
713 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000714
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100715 SubStream i_b2(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000716 i_b2 << ConvolutionLayer(
717 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100718 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000719 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
720 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000721 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000722 << BatchNormalizationLayer(
723 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_mean.npy"),
724 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_variance.npy"),
725 get_random_accessor(1.f, 1.f),
726 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_beta.npy"),
727 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000728 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/BatchNorm")
729 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000730
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000731 // Merge b1 and b2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000732 i_b << ConcatLayer(std::move(i_b1), std::move(i_b2)).set_name(param_path + "/Branch_1/concat");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000733
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000734 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000735 i_c << ConvolutionLayer(
736 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100737 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000738 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
739 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000740 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000741 << BatchNormalizationLayer(
742 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
743 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
744 get_random_accessor(1.f, 1.f),
745 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
746 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000747 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
748 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000749 << ConvolutionLayer(
750 1U, 3U, 448U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100751 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000752 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
753 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000754 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000755 << BatchNormalizationLayer(
756 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_mean.npy"),
757 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_variance.npy"),
758 get_random_accessor(1.f, 1.f),
759 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_beta.npy"),
760 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000761 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/BatchNorm")
762 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000763 << ConvolutionLayer(
764 3U, 1U, 512U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100765 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000766 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
767 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000768 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000769 << BatchNormalizationLayer(
770 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
771 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
772 get_random_accessor(1.f, 1.f),
773 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
774 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000775 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm")
776 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000777
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100778 SubStream i_c1(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000779 i_c1 << ConvolutionLayer(
780 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100781 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000782 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
783 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000784 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000785 << BatchNormalizationLayer(
786 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_mean.npy"),
787 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_variance.npy"),
788 get_random_accessor(1.f, 1.f),
789 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_beta.npy"),
790 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000791 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/BatchNorm")
792 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000793
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100794 SubStream i_c2(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000795 i_c2 << ConvolutionLayer(
796 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100797 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000798 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
799 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000800 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000801 << BatchNormalizationLayer(
802 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_mean.npy"),
803 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_variance.npy"),
804 get_random_accessor(1.f, 1.f),
805 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_beta.npy"),
806 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000807 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/BatchNorm")
808 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000809
810 // Merge i_c1 and i_c2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000811 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 +0000812
813 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000814 i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)).set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000815 << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100816 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000817 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000818 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000819 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
820 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
821 get_random_accessor(1.f, 1.f),
822 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
823 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000824 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
825 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000826
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100827 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000828 }
829};
830
831/** Main program for Inception V4
832 *
Georgios Pinitasbdbbbe82018-11-07 16:06:47 +0000833 * Model is based on:
834 * https://arxiv.org/abs/1602.07261
835 * "Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning"
836 * Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi
837 *
Georgios Pinitas588ebc52018-12-21 13:39:07 +0000838 * Provenance: download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz
839 *
Georgios Pinitas9f28b392018-07-18 20:01:53 +0100840 * @note To list all the possible arguments execute the binary appended with the --help option
841 *
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000842 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100843 * @param[in] argv Arguments
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000844 */
845int main(int argc, char **argv)
846{
847 return arm_compute::utils::run_example<InceptionV4Example>(argc, argv);
848}