blob: bac85eef15f2d15b5f8479e1c1a99a6c1faf56f3 [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
58 // Checks
Anthony Barbiercdd68c02018-08-23 15:03:41 +010059 ARM_COMPUTE_EXIT_ON_MSG(arm_compute::is_data_type_quantized_asymmetric(common_params.data_type), "QASYMM8 not supported for this graph");
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010060
61 // Print parameter values
62 std::cout << common_params << std::endl;
63
64 // Get trainable parameters data path
65 std::string data_path = common_params.data_path;
Georgios Pinitas240cfa62018-02-26 19:58:04 +000066
67 // Create a preprocessor object
68 std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>();
69
Georgios Pinitase2220552018-07-20 13:23:44 +010070 // Create input descriptor
71 const TensorShape tensor_shape = permute_shape(TensorShape(299U, 299U, 3U, 1U), DataLayout::NCHW, common_params.data_layout);
72 TensorDescriptor input_descriptor = TensorDescriptor(tensor_shape, common_params.data_type).set_layout(common_params.data_layout);
73
74 // Set weights trained layout
75 const DataLayout weights_layout = DataLayout::NCHW;
76
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010077 graph << common_params.target
78 << common_params.fast_math_hint
Georgios Pinitase2220552018-07-20 13:23:44 +010079 << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false))
Georgios Pinitas240cfa62018-02-26 19:58:04 +000080 // Conv2d_1a_3x3
81 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010082 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000083 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000084 .set_name("Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000085 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
86 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
87 get_random_accessor(1.f, 1.f),
88 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
89 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +000090 .set_name("Conv2d_1a_3x3/BatchNorm")
91 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000092 // Conv2d_2a_3x3
93 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010094 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000095 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000096 .set_name("Conv2d_2a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000097 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
98 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
99 get_random_accessor(1.f, 1.f),
100 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
101 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000102 .set_name("Conv2d_2a_3x3/BatchNorm")
103 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000104 // Conv2d_2b_3x3
105 << ConvolutionLayer(3U, 3U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100106 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000107 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000108 .set_name("Conv2d_2b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000109 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
110 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
111 get_random_accessor(1.f, 1.f),
112 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
113 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000114 .set_name("Conv2d_2b_3x3/BatchNorm")
115 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000116
Georgios Pinitas62c36392019-01-31 12:53:10 +0000117 graph << get_mixed_3a(data_path, weights_layout).set_name("Mixed_3a/concat");
118 graph << get_mixed_4a(data_path, weights_layout).set_name("Mixed_4a/concat");
119 graph << get_mixed_5a(data_path, weights_layout).set_name("Mixed_5a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100120 // 4 inception A blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000121 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5b").set_name("Mixed_5b/concat");
122 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5c").set_name("Mixed_5c/concat");
123 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5d").set_name("Mixed_5d/concat");
124 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5e").set_name("Mixed_5e/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100125 // reduction A block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000126 graph << get_reductionA_block(data_path, weights_layout).set_name("Mixed_6a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100127 // 7 inception B blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000128 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6b").set_name("Mixed_6b/concat");
129 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6c").set_name("Mixed_6c/concat");
130 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6d").set_name("Mixed_6d/concat");
131 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6e").set_name("Mixed_6e/concat");
132 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6f").set_name("Mixed_6f/concat");
133 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6g").set_name("Mixed_6g/concat");
134 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6h").set_name("Mixed_6h/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100135 // reduction B block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000136 graph << get_reductionB_block(data_path, weights_layout).set_name("Mixed_7a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100137 // 3 inception C blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000138 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7b").set_name("Mixed_7b/concat");
139 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7c").set_name("Mixed_7c/concat");
140 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7d").set_name("Mixed_7d/concat");
141 graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG)).set_name("Logits/AvgPool_1a/AvgPool")
142 << FlattenLayer().set_name("Logits/Flatten")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000143 << FullyConnectedLayer(
144 1001U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100145 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000146 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_biases.npy"))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000147 .set_name("Logits/MatMul")
148 << SoftmaxLayer().set_name("Logits/Predictions")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100149 << OutputLayer(get_output_accessor(common_params, 5));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000150
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000151 // Finalize graph
Georgios Pinitas9a8c6722018-03-21 17:52:35 +0000152 GraphConfig config;
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100153 config.num_threads = common_params.threads;
154 config.use_tuner = common_params.enable_tuner;
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +0100155 config.tuner_mode = common_params.tuner_mode;
Anthony Barbier7b607dc2018-07-13 15:55:24 +0100156 config.tuner_file = common_params.tuner_file;
157
Pablo Tellodb9116f2019-07-11 16:50:37 +0100158 // Load the precompiled kernels from a file into the kernel library, in this way the next time they are needed
159 // compilation won't be required.
160 if(common_params.enable_cl_cache)
161 {
162 restore_program_cache_from_file();
163 }
164
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100165 graph.finalize(common_params.target, config);
166
Pablo Tellodb9116f2019-07-11 16:50:37 +0100167 // Save the opencl kernels to a file
168 if(common_opts.enable_cl_cache)
169 {
170 save_program_cache_to_file();
171 }
172
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100173 return true;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000174 }
175
176 void do_run() override
177 {
178 graph.run();
179 }
180
181private:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100182 CommandLineParser cmd_parser;
183 CommonGraphOptions common_opts;
184 CommonGraphParams common_params;
185 Stream graph;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000186
187private:
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100188 ConcatLayer get_mixed_3a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000189 {
190 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_3a_";
191
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000192 SubStream i_a(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000193 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 +0000194
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000195 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000196 i_b << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100197 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000198 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000199 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000200 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_mean.npy"),
201 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_variance.npy"),
202 get_random_accessor(1.f, 1.f),
203 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_beta.npy"),
204 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000205 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/BatchNorm")
206 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000207
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100208 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000209 }
210
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100211 ConcatLayer get_mixed_4a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000212 {
213 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_4a_";
214
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000215 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000216 i_a << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100217 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000218 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000219 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000220 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
221 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
222 get_random_accessor(1.f, 1.f),
223 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
224 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000225 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/BatchNorm")
226 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000227 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100228 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000229 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000230 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000231 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
232 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
233 get_random_accessor(1.f, 1.f),
234 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
235 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000236 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/BatchNorm")
237 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000238
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000239 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000240 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100241 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000242 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000243 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000244 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
245 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
246 get_random_accessor(1.f, 1.f),
247 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
248 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000249 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/BatchNorm")
250 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000251 << ConvolutionLayer(7U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100252 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000253 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000254 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000255 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
256 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
257 get_random_accessor(1.f, 1.f),
258 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
259 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000260 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/BatchNorm")
261 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000262 << ConvolutionLayer(1U, 7U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100263 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000264 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000265 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000266 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
267 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
268 get_random_accessor(1.f, 1.f),
269 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
270 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000271 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/BatchNorm")
272 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000273 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100274 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000275 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000276 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000277 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
278 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
279 get_random_accessor(1.f, 1.f),
280 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
281 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000282 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/BatchNorm")
283 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000284
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100285 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000286 }
287
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100288 ConcatLayer get_mixed_5a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000289 {
290 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_5a_";
291
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000292 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000293 i_a << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100294 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000295 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000296 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000297 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
298 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
299 get_random_accessor(1.f, 1.f),
300 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
301 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000302 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/BatchNorm")
303 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000304
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000305 SubStream i_b(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000306 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 +0000307
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100308 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000309 }
310
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100311 ConcatLayer get_inceptionA_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000312 {
313 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
314
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000315 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000316 i_a << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100317 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000318 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000319 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000320 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
321 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
322 get_random_accessor(1.f, 1.f),
323 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
324 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000325 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
326 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000327
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000328 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000329 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100330 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000331 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000332 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000333 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
334 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
335 get_random_accessor(1.f, 1.f),
336 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
337 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000338 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
339 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000340 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100341 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000342 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000343 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000344 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
345 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
346 get_random_accessor(1.f, 1.f),
347 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
348 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000349 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm")
350 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000351
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000352 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000353 i_c << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100354 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000355 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000356 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000357 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
358 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
359 get_random_accessor(1.f, 1.f),
360 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
361 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000362 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
363 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000364 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100365 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000366 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000367 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000368 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
369 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
370 get_random_accessor(1.f, 1.f),
371 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
372 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000373 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm")
374 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000375 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100376 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000377 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000378 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000379 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
380 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
381 get_random_accessor(1.f, 1.f),
382 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
383 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000384 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm")
385 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000386
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000387 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000388 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 +0000389 << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100390 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000391 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000392 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000393 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
394 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
395 get_random_accessor(1.f, 1.f),
396 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
397 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000398 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
399 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000400
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100401 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 +0000402 }
403
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100404 ConcatLayer get_reductionA_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000405 {
406 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_6a_";
407
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000408 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000409 i_a << ConvolutionLayer(3U, 3U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100410 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000411 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000412 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000413 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
414 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
415 get_random_accessor(1.f, 1.f),
416 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
417 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000418 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/BatchNorm")
419 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000420
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000421 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000422 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100423 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000424 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000425 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000426 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
427 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
428 get_random_accessor(1.f, 1.f),
429 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
430 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000431 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/BatchNorm")
432 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000433 << ConvolutionLayer(3U, 3U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100434 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000435 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000436 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000437 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
438 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
439 get_random_accessor(1.f, 1.f),
440 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
441 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000442 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/BatchNorm")
443 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000444 << ConvolutionLayer(3U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100445 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000446 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000447 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000448 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
449 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
450 get_random_accessor(1.f, 1.f),
451 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
452 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000453 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/BatchNorm")
454 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000455
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000456 SubStream i_c(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000457 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 +0000458
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100459 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000460 }
461
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100462 ConcatLayer get_inceptionB_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000463 {
464 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
465
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000466 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000467 i_a << ConvolutionLayer(1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100468 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000469 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000470 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000471 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
472 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
473 get_random_accessor(1.f, 1.f),
474 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
475 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000476 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
477 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000478
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000479 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000480 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100481 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000482 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000483 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000484 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
485 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
486 get_random_accessor(1.f, 1.f),
487 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
488 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000489 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
490 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000491 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100492 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000493 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000494 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000495 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
496 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
497 get_random_accessor(1.f, 1.f),
498 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
499 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000500 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm")
501 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000502 << ConvolutionLayer(1U, 7U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100503 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000504 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000505 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000506 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
507 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
508 get_random_accessor(1.f, 1.f),
509 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
510 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000511 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm")
512 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000513
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000514 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000515 i_c << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100516 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000517 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000518 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000519 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
520 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
521 get_random_accessor(1.f, 1.f),
522 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
523 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000524 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
525 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000526 << ConvolutionLayer(1U, 7U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100527 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000528 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000529 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000530 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
531 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
532 get_random_accessor(1.f, 1.f),
533 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
534 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000535 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm")
536 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000537 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100538 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000539 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000540 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000541 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
542 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
543 get_random_accessor(1.f, 1.f),
544 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
545 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000546 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm")
547 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000548 << ConvolutionLayer(1U, 7U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100549 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000550 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000551 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000552 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
553 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
554 get_random_accessor(1.f, 1.f),
555 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
556 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000557 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm")
558 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000559 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100560 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000561 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000562 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000563 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
564 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
565 get_random_accessor(1.f, 1.f),
566 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
567 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000568 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm")
569 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000570
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000571 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000572 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 +0000573 << ConvolutionLayer(1U, 1U, 128U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100574 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000575 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000576 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000577 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
578 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
579 get_random_accessor(1.f, 1.f),
580 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
581 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000582 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
583 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000584
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100585 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 +0000586 }
587
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100588 ConcatLayer get_reductionB_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000589 {
590 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_7a_";
591
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000592 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000593 i_a << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100594 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000595 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000596 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000597 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
598 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
599 get_random_accessor(1.f, 1.f),
600 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
601 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000602 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
603 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000604 << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100605 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000606 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000607 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000608 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
609 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
610 get_random_accessor(1.f, 1.f),
611 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
612 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000613 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/BatchNorm")
614 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000615
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000616 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000617 i_b << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100618 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000619 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000620 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000621 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
622 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
623 get_random_accessor(1.f, 1.f),
624 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
625 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000626 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
627 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000628 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100629 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000630 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000631 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000632 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
633 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
634 get_random_accessor(1.f, 1.f),
635 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
636 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000637 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/BatchNorm")
638 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000639 << ConvolutionLayer(1U, 7U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100640 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000641 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000642 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000643 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
644 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
645 get_random_accessor(1.f, 1.f),
646 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
647 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000648 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/BatchNorm")
649 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000650 << ConvolutionLayer(3U, 3U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100651 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000652 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000653 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000654 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
655 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
656 get_random_accessor(1.f, 1.f),
657 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
658 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000659 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/BatchNorm")
660 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000661
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000662 SubStream i_c(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000663 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 +0000664
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100665 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000666 }
667
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100668 ConcatLayer get_inceptionC_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000669 {
670 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
671
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000672 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000673 i_a << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100674 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000675 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000676 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000677 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
678 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
679 get_random_accessor(1.f, 1.f),
680 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
681 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000682 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
683 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000684
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000685 SubStream i_b(graph);
686 i_b << ConvolutionLayer(
687 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100688 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000689 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
690 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000691 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000692 << BatchNormalizationLayer(
693 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
694 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
695 get_random_accessor(1.f, 1.f),
696 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
697 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000698 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
699 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000700
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100701 SubStream i_b1(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000702 i_b1 << ConvolutionLayer(
703 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100704 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000705 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
706 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000707 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000708 << BatchNormalizationLayer(
709 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
710 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
711 get_random_accessor(1.f, 1.f),
712 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
713 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000714 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm")
715 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000716
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100717 SubStream i_b2(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000718 i_b2 << ConvolutionLayer(
719 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100720 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000721 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
722 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000723 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000724 << BatchNormalizationLayer(
725 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_mean.npy"),
726 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_variance.npy"),
727 get_random_accessor(1.f, 1.f),
728 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_beta.npy"),
729 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000730 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/BatchNorm")
731 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000732
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000733 // Merge b1 and b2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000734 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 +0000735
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000736 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000737 i_c << ConvolutionLayer(
738 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100739 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000740 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
741 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000742 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000743 << BatchNormalizationLayer(
744 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
745 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
746 get_random_accessor(1.f, 1.f),
747 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
748 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000749 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
750 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000751 << ConvolutionLayer(
752 1U, 3U, 448U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100753 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000754 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
755 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000756 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000757 << BatchNormalizationLayer(
758 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_mean.npy"),
759 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_variance.npy"),
760 get_random_accessor(1.f, 1.f),
761 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_beta.npy"),
762 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000763 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/BatchNorm")
764 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000765 << ConvolutionLayer(
766 3U, 1U, 512U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100767 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000768 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
769 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000770 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000771 << BatchNormalizationLayer(
772 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
773 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
774 get_random_accessor(1.f, 1.f),
775 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
776 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000777 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm")
778 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000779
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100780 SubStream i_c1(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000781 i_c1 << ConvolutionLayer(
782 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100783 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000784 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
785 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000786 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000787 << BatchNormalizationLayer(
788 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_mean.npy"),
789 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_variance.npy"),
790 get_random_accessor(1.f, 1.f),
791 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_beta.npy"),
792 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000793 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/BatchNorm")
794 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000795
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100796 SubStream i_c2(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000797 i_c2 << ConvolutionLayer(
798 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100799 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000800 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
801 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000802 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000803 << BatchNormalizationLayer(
804 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_mean.npy"),
805 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_variance.npy"),
806 get_random_accessor(1.f, 1.f),
807 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_beta.npy"),
808 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000809 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/BatchNorm")
810 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000811
812 // Merge i_c1 and i_c2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000813 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 +0000814
815 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000816 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 +0000817 << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100818 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000819 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000820 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000821 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
822 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
823 get_random_accessor(1.f, 1.f),
824 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
825 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000826 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
827 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000828
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100829 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 +0000830 }
831};
832
833/** Main program for Inception V4
834 *
Georgios Pinitasbdbbbe82018-11-07 16:06:47 +0000835 * Model is based on:
836 * https://arxiv.org/abs/1602.07261
837 * "Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning"
838 * Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi
839 *
Georgios Pinitas588ebc52018-12-21 13:39:07 +0000840 * Provenance: download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz
841 *
Georgios Pinitas9f28b392018-07-18 20:01:53 +0100842 * @note To list all the possible arguments execute the binary appended with the --help option
843 *
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000844 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100845 * @param[in] argv Arguments
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000846 */
847int main(int argc, char **argv)
848{
849 return arm_compute::utils::run_example<InceptionV4Example>(argc, argv);
850}