blob: a7f57ecdcedb3b2b5c1e1a8e69eb53f4db2a6ce7 [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);
46
47 // Consume common parameters
48 common_params = consume_common_graph_parameters(common_opts);
49
50 // Return when help menu is requested
51 if(common_params.help)
52 {
53 cmd_parser.print_help(argv[0]);
54 return false;
55 }
56
57 // Checks
Anthony Barbiercdd68c02018-08-23 15:03:41 +010058 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 +010059
60 // Print parameter values
61 std::cout << common_params << std::endl;
62
63 // Get trainable parameters data path
64 std::string data_path = common_params.data_path;
Georgios Pinitas240cfa62018-02-26 19:58:04 +000065
66 // Create a preprocessor object
67 std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>();
68
Georgios Pinitase2220552018-07-20 13:23:44 +010069 // Create input descriptor
70 const TensorShape tensor_shape = permute_shape(TensorShape(299U, 299U, 3U, 1U), DataLayout::NCHW, common_params.data_layout);
71 TensorDescriptor input_descriptor = TensorDescriptor(tensor_shape, common_params.data_type).set_layout(common_params.data_layout);
72
73 // Set weights trained layout
74 const DataLayout weights_layout = DataLayout::NCHW;
75
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010076 graph << common_params.target
77 << common_params.fast_math_hint
Georgios Pinitase2220552018-07-20 13:23:44 +010078 << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false))
Georgios Pinitas240cfa62018-02-26 19:58:04 +000079 // Conv2d_1a_3x3
80 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010081 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000082 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000083 .set_name("Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000084 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
85 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
86 get_random_accessor(1.f, 1.f),
87 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
88 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +000089 .set_name("Conv2d_1a_3x3/BatchNorm")
90 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000091 // Conv2d_2a_3x3
92 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010093 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000094 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000095 .set_name("Conv2d_2a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000096 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
97 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
98 get_random_accessor(1.f, 1.f),
99 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
100 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000101 .set_name("Conv2d_2a_3x3/BatchNorm")
102 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000103 // Conv2d_2b_3x3
104 << ConvolutionLayer(3U, 3U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100105 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000106 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000107 .set_name("Conv2d_2b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000108 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
109 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
110 get_random_accessor(1.f, 1.f),
111 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
112 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000113 .set_name("Conv2d_2b_3x3/BatchNorm")
114 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000115
Georgios Pinitas62c36392019-01-31 12:53:10 +0000116 graph << get_mixed_3a(data_path, weights_layout).set_name("Mixed_3a/concat");
117 graph << get_mixed_4a(data_path, weights_layout).set_name("Mixed_4a/concat");
118 graph << get_mixed_5a(data_path, weights_layout).set_name("Mixed_5a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100119 // 4 inception A blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000120 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5b").set_name("Mixed_5b/concat");
121 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5c").set_name("Mixed_5c/concat");
122 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5d").set_name("Mixed_5d/concat");
123 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5e").set_name("Mixed_5e/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100124 // reduction A block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000125 graph << get_reductionA_block(data_path, weights_layout).set_name("Mixed_6a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100126 // 7 inception B blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000127 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6b").set_name("Mixed_6b/concat");
128 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6c").set_name("Mixed_6c/concat");
129 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6d").set_name("Mixed_6d/concat");
130 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6e").set_name("Mixed_6e/concat");
131 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6f").set_name("Mixed_6f/concat");
132 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6g").set_name("Mixed_6g/concat");
133 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6h").set_name("Mixed_6h/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100134 // reduction B block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000135 graph << get_reductionB_block(data_path, weights_layout).set_name("Mixed_7a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100136 // 3 inception C blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000137 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7b").set_name("Mixed_7b/concat");
138 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7c").set_name("Mixed_7c/concat");
139 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7d").set_name("Mixed_7d/concat");
140 graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG)).set_name("Logits/AvgPool_1a/AvgPool")
141 << FlattenLayer().set_name("Logits/Flatten")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000142 << FullyConnectedLayer(
143 1001U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100144 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000145 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_biases.npy"))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000146 .set_name("Logits/MatMul")
147 << SoftmaxLayer().set_name("Logits/Predictions")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100148 << OutputLayer(get_output_accessor(common_params, 5));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000149
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000150 // Finalize graph
Georgios Pinitas9a8c6722018-03-21 17:52:35 +0000151 GraphConfig config;
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100152 config.num_threads = common_params.threads;
153 config.use_tuner = common_params.enable_tuner;
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +0100154 config.tuner_mode = common_params.tuner_mode;
Anthony Barbier7b607dc2018-07-13 15:55:24 +0100155 config.tuner_file = common_params.tuner_file;
156
Pablo Tellodb9116f2019-07-11 16:50:37 +0100157 // Load the precompiled kernels from a file into the kernel library, in this way the next time they are needed
158 // compilation won't be required.
159 if(common_params.enable_cl_cache)
160 {
161 restore_program_cache_from_file();
162 }
163
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100164 graph.finalize(common_params.target, config);
165
Pablo Tellodb9116f2019-07-11 16:50:37 +0100166 // Save the opencl kernels to a file
167 if(common_opts.enable_cl_cache)
168 {
169 save_program_cache_to_file();
170 }
171
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100172 return true;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000173 }
174
175 void do_run() override
176 {
177 graph.run();
178 }
179
180private:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100181 CommandLineParser cmd_parser;
182 CommonGraphOptions common_opts;
183 CommonGraphParams common_params;
184 Stream graph;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000185
186private:
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100187 ConcatLayer get_mixed_3a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000188 {
189 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_3a_";
190
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000191 SubStream i_a(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000192 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 +0000193
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000194 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000195 i_b << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100196 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000197 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000198 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000199 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_mean.npy"),
200 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_variance.npy"),
201 get_random_accessor(1.f, 1.f),
202 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_beta.npy"),
203 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000204 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/BatchNorm")
205 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000206
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100207 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000208 }
209
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100210 ConcatLayer get_mixed_4a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000211 {
212 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_4a_";
213
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000214 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000215 i_a << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100216 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000217 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000218 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000219 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
220 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
221 get_random_accessor(1.f, 1.f),
222 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
223 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000224 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/BatchNorm")
225 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000226 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100227 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000228 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000229 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000230 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
231 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
232 get_random_accessor(1.f, 1.f),
233 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
234 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000235 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/BatchNorm")
236 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000237
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000238 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000239 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100240 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000241 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000242 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000243 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
244 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
245 get_random_accessor(1.f, 1.f),
246 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
247 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000248 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/BatchNorm")
249 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000250 << ConvolutionLayer(7U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100251 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000252 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000253 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000254 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
255 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
256 get_random_accessor(1.f, 1.f),
257 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
258 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000259 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/BatchNorm")
260 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000261 << ConvolutionLayer(1U, 7U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100262 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000263 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000264 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000265 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
266 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
267 get_random_accessor(1.f, 1.f),
268 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
269 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000270 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/BatchNorm")
271 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000272 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100273 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000274 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000275 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000276 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
277 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
278 get_random_accessor(1.f, 1.f),
279 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
280 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000281 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/BatchNorm")
282 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000283
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100284 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000285 }
286
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100287 ConcatLayer get_mixed_5a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000288 {
289 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_5a_";
290
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000291 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000292 i_a << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100293 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000294 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000295 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000296 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
297 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
298 get_random_accessor(1.f, 1.f),
299 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
300 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000301 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/BatchNorm")
302 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000303
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000304 SubStream i_b(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000305 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 +0000306
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100307 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000308 }
309
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100310 ConcatLayer get_inceptionA_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000311 {
312 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
313
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000314 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000315 i_a << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100316 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000317 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000318 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000319 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
320 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
321 get_random_accessor(1.f, 1.f),
322 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
323 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000324 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
325 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000326
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000327 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000328 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100329 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000330 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000331 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000332 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
333 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
334 get_random_accessor(1.f, 1.f),
335 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
336 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000337 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
338 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000339 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100340 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000341 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000342 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000343 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
344 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
345 get_random_accessor(1.f, 1.f),
346 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
347 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000348 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm")
349 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000350
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000351 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000352 i_c << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100353 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000354 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000355 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000356 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
357 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
358 get_random_accessor(1.f, 1.f),
359 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
360 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000361 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
362 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000363 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100364 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000365 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000366 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000367 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
368 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
369 get_random_accessor(1.f, 1.f),
370 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
371 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000372 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm")
373 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000374 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100375 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000376 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000377 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000378 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
379 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
380 get_random_accessor(1.f, 1.f),
381 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
382 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000383 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm")
384 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000385
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000386 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000387 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 +0000388 << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100389 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000390 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000391 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000392 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
393 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
394 get_random_accessor(1.f, 1.f),
395 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
396 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000397 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
398 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000399
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100400 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 +0000401 }
402
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100403 ConcatLayer get_reductionA_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000404 {
405 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_6a_";
406
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000407 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000408 i_a << ConvolutionLayer(3U, 3U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100409 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000410 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000411 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000412 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
413 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
414 get_random_accessor(1.f, 1.f),
415 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
416 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000417 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/BatchNorm")
418 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000419
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000420 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000421 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100422 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000423 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000424 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000425 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
426 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
427 get_random_accessor(1.f, 1.f),
428 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
429 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000430 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/BatchNorm")
431 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000432 << ConvolutionLayer(3U, 3U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100433 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000434 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000435 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000436 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
437 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
438 get_random_accessor(1.f, 1.f),
439 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
440 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000441 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/BatchNorm")
442 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000443 << ConvolutionLayer(3U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100444 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000445 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000446 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000447 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
448 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
449 get_random_accessor(1.f, 1.f),
450 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
451 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000452 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/BatchNorm")
453 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000454
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000455 SubStream i_c(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000456 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 +0000457
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100458 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000459 }
460
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100461 ConcatLayer get_inceptionB_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000462 {
463 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
464
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000465 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000466 i_a << ConvolutionLayer(1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100467 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000468 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000469 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000470 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
471 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
472 get_random_accessor(1.f, 1.f),
473 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
474 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000475 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
476 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000477
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000478 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000479 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100480 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000481 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000482 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000483 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
484 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
485 get_random_accessor(1.f, 1.f),
486 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
487 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000488 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
489 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000490 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100491 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000492 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000493 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000494 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
495 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
496 get_random_accessor(1.f, 1.f),
497 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
498 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000499 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm")
500 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000501 << ConvolutionLayer(1U, 7U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100502 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000503 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000504 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000505 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
506 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
507 get_random_accessor(1.f, 1.f),
508 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
509 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000510 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm")
511 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000512
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000513 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000514 i_c << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100515 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000516 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000517 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000518 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
519 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
520 get_random_accessor(1.f, 1.f),
521 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
522 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000523 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
524 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000525 << ConvolutionLayer(1U, 7U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100526 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000527 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000528 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000529 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
530 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
531 get_random_accessor(1.f, 1.f),
532 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
533 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000534 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm")
535 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000536 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100537 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000538 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000539 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000540 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
541 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
542 get_random_accessor(1.f, 1.f),
543 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
544 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000545 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm")
546 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000547 << ConvolutionLayer(1U, 7U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100548 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000549 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000550 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000551 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
552 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
553 get_random_accessor(1.f, 1.f),
554 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
555 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000556 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm")
557 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000558 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100559 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000560 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000561 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000562 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
563 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
564 get_random_accessor(1.f, 1.f),
565 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
566 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000567 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm")
568 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000569
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000570 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000571 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 +0000572 << ConvolutionLayer(1U, 1U, 128U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100573 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000574 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000575 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000576 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
577 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
578 get_random_accessor(1.f, 1.f),
579 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
580 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000581 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
582 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000583
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100584 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 +0000585 }
586
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100587 ConcatLayer get_reductionB_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000588 {
589 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_7a_";
590
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000591 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000592 i_a << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100593 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000594 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000595 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000596 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
597 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
598 get_random_accessor(1.f, 1.f),
599 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
600 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000601 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
602 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000603 << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100604 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000605 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000606 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000607 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
608 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
609 get_random_accessor(1.f, 1.f),
610 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
611 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000612 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/BatchNorm")
613 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000614
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000615 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000616 i_b << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100617 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000618 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000619 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000620 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
621 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
622 get_random_accessor(1.f, 1.f),
623 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
624 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000625 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
626 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000627 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100628 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000629 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000630 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000631 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
632 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
633 get_random_accessor(1.f, 1.f),
634 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
635 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000636 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/BatchNorm")
637 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000638 << ConvolutionLayer(1U, 7U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100639 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000640 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000641 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000642 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
643 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
644 get_random_accessor(1.f, 1.f),
645 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
646 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000647 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/BatchNorm")
648 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000649 << ConvolutionLayer(3U, 3U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100650 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000651 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000652 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000653 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
654 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
655 get_random_accessor(1.f, 1.f),
656 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
657 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000658 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/BatchNorm")
659 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000660
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000661 SubStream i_c(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000662 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 +0000663
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100664 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000665 }
666
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100667 ConcatLayer get_inceptionC_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000668 {
669 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
670
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000671 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000672 i_a << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100673 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000674 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000675 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000676 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
677 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
678 get_random_accessor(1.f, 1.f),
679 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
680 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000681 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
682 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000683
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000684 SubStream i_b(graph);
685 i_b << ConvolutionLayer(
686 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100687 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000688 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
689 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000690 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000691 << BatchNormalizationLayer(
692 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
693 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
694 get_random_accessor(1.f, 1.f),
695 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
696 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000697 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
698 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000699
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100700 SubStream i_b1(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000701 i_b1 << ConvolutionLayer(
702 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100703 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000704 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
705 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000706 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000707 << BatchNormalizationLayer(
708 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
709 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
710 get_random_accessor(1.f, 1.f),
711 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
712 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000713 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm")
714 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000715
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100716 SubStream i_b2(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000717 i_b2 << ConvolutionLayer(
718 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100719 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000720 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
721 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000722 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000723 << BatchNormalizationLayer(
724 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_mean.npy"),
725 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_variance.npy"),
726 get_random_accessor(1.f, 1.f),
727 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_beta.npy"),
728 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000729 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/BatchNorm")
730 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000731
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000732 // Merge b1 and b2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000733 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 +0000734
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000735 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000736 i_c << ConvolutionLayer(
737 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100738 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000739 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
740 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000741 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000742 << BatchNormalizationLayer(
743 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
744 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
745 get_random_accessor(1.f, 1.f),
746 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
747 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000748 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
749 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000750 << ConvolutionLayer(
751 1U, 3U, 448U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100752 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000753 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
754 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000755 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000756 << BatchNormalizationLayer(
757 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_mean.npy"),
758 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_variance.npy"),
759 get_random_accessor(1.f, 1.f),
760 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_beta.npy"),
761 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000762 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/BatchNorm")
763 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000764 << ConvolutionLayer(
765 3U, 1U, 512U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100766 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000767 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
768 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000769 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000770 << BatchNormalizationLayer(
771 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
772 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
773 get_random_accessor(1.f, 1.f),
774 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
775 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000776 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm")
777 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000778
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100779 SubStream i_c1(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000780 i_c1 << ConvolutionLayer(
781 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100782 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000783 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
784 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000785 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000786 << BatchNormalizationLayer(
787 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_mean.npy"),
788 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_variance.npy"),
789 get_random_accessor(1.f, 1.f),
790 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_beta.npy"),
791 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000792 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/BatchNorm")
793 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000794
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100795 SubStream i_c2(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000796 i_c2 << ConvolutionLayer(
797 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100798 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000799 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
800 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000801 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000802 << BatchNormalizationLayer(
803 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_mean.npy"),
804 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_variance.npy"),
805 get_random_accessor(1.f, 1.f),
806 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_beta.npy"),
807 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000808 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/BatchNorm")
809 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000810
811 // Merge i_c1 and i_c2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000812 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 +0000813
814 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000815 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 +0000816 << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100817 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000818 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000819 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000820 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
821 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
822 get_random_accessor(1.f, 1.f),
823 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
824 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000825 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
826 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000827
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100828 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 +0000829 }
830};
831
832/** Main program for Inception V4
833 *
Georgios Pinitasbdbbbe82018-11-07 16:06:47 +0000834 * Model is based on:
835 * https://arxiv.org/abs/1602.07261
836 * "Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning"
837 * Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi
838 *
Georgios Pinitas588ebc52018-12-21 13:39:07 +0000839 * Provenance: download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz
840 *
Georgios Pinitas9f28b392018-07-18 20:01:53 +0100841 * @note To list all the possible arguments execute the binary appended with the --help option
842 *
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000843 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100844 * @param[in] argv Arguments
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000845 */
846int main(int argc, char **argv)
847{
848 return arm_compute::utils::run_example<InceptionV4Example>(argc, argv);
849}