blob: 15fd049fa38a549c9694ec68a02c31b2f52ae35c [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
Pablo Tellodb9116f2019-07-11 16:50:37 +010030#include <chrono>
31
Georgios Pinitas240cfa62018-02-26 19:58:04 +000032using namespace arm_compute::utils;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010033using namespace arm_compute::graph::frontend;
Georgios Pinitas240cfa62018-02-26 19:58:04 +000034using namespace arm_compute::graph_utils;
35
Georgios Pinitas108ab0b2018-09-14 18:35:11 +010036/** Example demonstrating how to implement InceptionV4's network using the Compute Library's graph API */
Georgios Pinitas240cfa62018-02-26 19:58:04 +000037class InceptionV4Example final : public Example
38{
39public:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010040 InceptionV4Example()
41 : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "InceptionV4")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000042 {
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010043 }
44 bool do_setup(int argc, char **argv) override
45 {
46 // Parse arguments
47 cmd_parser.parse(argc, argv);
48
49 // Consume common parameters
50 common_params = consume_common_graph_parameters(common_opts);
51
52 // Return when help menu is requested
53 if(common_params.help)
54 {
55 cmd_parser.print_help(argv[0]);
56 return false;
57 }
58
59 // Checks
Anthony Barbiercdd68c02018-08-23 15:03:41 +010060 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 +010061
62 // Print parameter values
63 std::cout << common_params << std::endl;
64
65 // Get trainable parameters data path
66 std::string data_path = common_params.data_path;
Georgios Pinitas240cfa62018-02-26 19:58:04 +000067
68 // Create a preprocessor object
69 std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>();
70
Georgios Pinitase2220552018-07-20 13:23:44 +010071 // Create input descriptor
72 const TensorShape tensor_shape = permute_shape(TensorShape(299U, 299U, 3U, 1U), DataLayout::NCHW, common_params.data_layout);
73 TensorDescriptor input_descriptor = TensorDescriptor(tensor_shape, common_params.data_type).set_layout(common_params.data_layout);
74
75 // Set weights trained layout
76 const DataLayout weights_layout = DataLayout::NCHW;
77
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010078 graph << common_params.target
79 << common_params.fast_math_hint
Georgios Pinitase2220552018-07-20 13:23:44 +010080 << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false))
Georgios Pinitas240cfa62018-02-26 19:58:04 +000081 // Conv2d_1a_3x3
82 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010083 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000084 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000085 .set_name("Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000086 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
87 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
88 get_random_accessor(1.f, 1.f),
89 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
90 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +000091 .set_name("Conv2d_1a_3x3/BatchNorm")
92 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000093 // Conv2d_2a_3x3
94 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010095 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000096 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000097 .set_name("Conv2d_2a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000098 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
99 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
100 get_random_accessor(1.f, 1.f),
101 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
102 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000103 .set_name("Conv2d_2a_3x3/BatchNorm")
104 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000105 // Conv2d_2b_3x3
106 << ConvolutionLayer(3U, 3U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100107 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000108 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000109 .set_name("Conv2d_2b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000110 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
111 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
112 get_random_accessor(1.f, 1.f),
113 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
114 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000115 .set_name("Conv2d_2b_3x3/BatchNorm")
116 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000117
Georgios Pinitas62c36392019-01-31 12:53:10 +0000118 graph << get_mixed_3a(data_path, weights_layout).set_name("Mixed_3a/concat");
119 graph << get_mixed_4a(data_path, weights_layout).set_name("Mixed_4a/concat");
120 graph << get_mixed_5a(data_path, weights_layout).set_name("Mixed_5a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100121 // 4 inception A blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000122 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5b").set_name("Mixed_5b/concat");
123 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5c").set_name("Mixed_5c/concat");
124 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5d").set_name("Mixed_5d/concat");
125 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5e").set_name("Mixed_5e/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100126 // reduction A block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000127 graph << get_reductionA_block(data_path, weights_layout).set_name("Mixed_6a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100128 // 7 inception B blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000129 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6b").set_name("Mixed_6b/concat");
130 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6c").set_name("Mixed_6c/concat");
131 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6d").set_name("Mixed_6d/concat");
132 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6e").set_name("Mixed_6e/concat");
133 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6f").set_name("Mixed_6f/concat");
134 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6g").set_name("Mixed_6g/concat");
135 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6h").set_name("Mixed_6h/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100136 // reduction B block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000137 graph << get_reductionB_block(data_path, weights_layout).set_name("Mixed_7a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100138 // 3 inception C blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000139 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7b").set_name("Mixed_7b/concat");
140 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7c").set_name("Mixed_7c/concat");
141 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7d").set_name("Mixed_7d/concat");
142 graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG)).set_name("Logits/AvgPool_1a/AvgPool")
143 << FlattenLayer().set_name("Logits/Flatten")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000144 << FullyConnectedLayer(
145 1001U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100146 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000147 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_biases.npy"))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000148 .set_name("Logits/MatMul")
149 << SoftmaxLayer().set_name("Logits/Predictions")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100150 << OutputLayer(get_output_accessor(common_params, 5));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000151
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000152 // Finalize graph
Georgios Pinitas9a8c6722018-03-21 17:52:35 +0000153 GraphConfig config;
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100154 config.num_threads = common_params.threads;
155 config.use_tuner = common_params.enable_tuner;
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +0100156 config.tuner_mode = common_params.tuner_mode;
Anthony Barbier7b607dc2018-07-13 15:55:24 +0100157 config.tuner_file = common_params.tuner_file;
158
Pablo Tellodb9116f2019-07-11 16:50:37 +0100159 const auto config_start_time = std::chrono::high_resolution_clock::now();
160
161 // Load the precompiled kernels from a file into the kernel library, in this way the next time they are needed
162 // compilation won't be required.
163 if(common_params.enable_cl_cache)
164 {
165 restore_program_cache_from_file();
166 }
167
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100168 graph.finalize(common_params.target, config);
169
Pablo Tellodb9116f2019-07-11 16:50:37 +0100170 const auto config_end_time = std::chrono::high_resolution_clock::now();
171 const auto time_elapsed = config_end_time - config_start_time;
172 const auto time_elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_elapsed).count();
173 std::cout << "Configuration time " << time_elapsed_ms << " ms " << std::endl;
174
175 // Save the opencl kernels to a file
176 if(common_opts.enable_cl_cache)
177 {
178 save_program_cache_to_file();
179 }
180
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100181 return true;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000182 }
183
184 void do_run() override
185 {
186 graph.run();
187 }
188
189private:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100190 CommandLineParser cmd_parser;
191 CommonGraphOptions common_opts;
192 CommonGraphParams common_params;
193 Stream graph;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000194
195private:
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100196 ConcatLayer get_mixed_3a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000197 {
198 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_3a_";
199
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000200 SubStream i_a(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000201 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 +0000202
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000203 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000204 i_b << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100205 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000206 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000207 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000208 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_mean.npy"),
209 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_variance.npy"),
210 get_random_accessor(1.f, 1.f),
211 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_beta.npy"),
212 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000213 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/BatchNorm")
214 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000215
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100216 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000217 }
218
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100219 ConcatLayer get_mixed_4a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000220 {
221 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_4a_";
222
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000223 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000224 i_a << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100225 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000226 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000227 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000228 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
229 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
230 get_random_accessor(1.f, 1.f),
231 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
232 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000233 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/BatchNorm")
234 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000235 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100236 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000237 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000238 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000239 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
240 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
241 get_random_accessor(1.f, 1.f),
242 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
243 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000244 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/BatchNorm")
245 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000246
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000247 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000248 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100249 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000250 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000251 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000252 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
253 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
254 get_random_accessor(1.f, 1.f),
255 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
256 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000257 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/BatchNorm")
258 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000259 << ConvolutionLayer(7U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100260 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000261 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000262 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000263 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
264 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
265 get_random_accessor(1.f, 1.f),
266 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
267 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000268 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/BatchNorm")
269 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000270 << ConvolutionLayer(1U, 7U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100271 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000272 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000273 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000274 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
275 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
276 get_random_accessor(1.f, 1.f),
277 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
278 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000279 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/BatchNorm")
280 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000281 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100282 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000283 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000284 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000285 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
286 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
287 get_random_accessor(1.f, 1.f),
288 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
289 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000290 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/BatchNorm")
291 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000292
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100293 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000294 }
295
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100296 ConcatLayer get_mixed_5a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000297 {
298 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_5a_";
299
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000300 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000301 i_a << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100302 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000303 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000304 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000305 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
306 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
307 get_random_accessor(1.f, 1.f),
308 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
309 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000310 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/BatchNorm")
311 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000312
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000313 SubStream i_b(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000314 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 +0000315
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100316 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000317 }
318
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100319 ConcatLayer get_inceptionA_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000320 {
321 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
322
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000323 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000324 i_a << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100325 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000326 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000327 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000328 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
329 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
330 get_random_accessor(1.f, 1.f),
331 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
332 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000333 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
334 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000335
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000336 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000337 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100338 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000339 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000340 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000341 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
342 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
343 get_random_accessor(1.f, 1.f),
344 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
345 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000346 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
347 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000348 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100349 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000350 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000351 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000352 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
353 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
354 get_random_accessor(1.f, 1.f),
355 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
356 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000357 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm")
358 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000359
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000360 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000361 i_c << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100362 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000363 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000364 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000365 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
366 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
367 get_random_accessor(1.f, 1.f),
368 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
369 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000370 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
371 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000372 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100373 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000374 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000375 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000376 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
377 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
378 get_random_accessor(1.f, 1.f),
379 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
380 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000381 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm")
382 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000383 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100384 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000385 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000386 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000387 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
388 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
389 get_random_accessor(1.f, 1.f),
390 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
391 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000392 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm")
393 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000394
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000395 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000396 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 +0000397 << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100398 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000399 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000400 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000401 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
402 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
403 get_random_accessor(1.f, 1.f),
404 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
405 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000406 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
407 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000408
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100409 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 +0000410 }
411
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100412 ConcatLayer get_reductionA_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000413 {
414 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_6a_";
415
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000416 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000417 i_a << ConvolutionLayer(3U, 3U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100418 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000419 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000420 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000421 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
422 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
423 get_random_accessor(1.f, 1.f),
424 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
425 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000426 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/BatchNorm")
427 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000428
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000429 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000430 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100431 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000432 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000433 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000434 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
435 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
436 get_random_accessor(1.f, 1.f),
437 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
438 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000439 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/BatchNorm")
440 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000441 << ConvolutionLayer(3U, 3U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100442 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000443 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000444 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000445 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
446 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
447 get_random_accessor(1.f, 1.f),
448 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
449 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000450 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/BatchNorm")
451 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000452 << ConvolutionLayer(3U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100453 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000454 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000455 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000456 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
457 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
458 get_random_accessor(1.f, 1.f),
459 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
460 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000461 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/BatchNorm")
462 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000463
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000464 SubStream i_c(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000465 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 +0000466
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100467 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000468 }
469
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100470 ConcatLayer get_inceptionB_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000471 {
472 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
473
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000474 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000475 i_a << ConvolutionLayer(1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100476 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000477 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000478 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000479 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
480 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
481 get_random_accessor(1.f, 1.f),
482 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
483 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000484 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
485 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000486
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000487 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000488 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100489 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000490 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000491 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000492 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
493 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
494 get_random_accessor(1.f, 1.f),
495 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
496 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000497 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
498 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000499 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100500 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000501 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000502 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000503 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
504 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
505 get_random_accessor(1.f, 1.f),
506 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
507 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000508 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm")
509 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000510 << ConvolutionLayer(1U, 7U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100511 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000512 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000513 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000514 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
515 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
516 get_random_accessor(1.f, 1.f),
517 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
518 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000519 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm")
520 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000521
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000522 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000523 i_c << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100524 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000525 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000526 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000527 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
528 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
529 get_random_accessor(1.f, 1.f),
530 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
531 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000532 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
533 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000534 << ConvolutionLayer(1U, 7U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100535 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000536 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000537 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000538 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
539 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
540 get_random_accessor(1.f, 1.f),
541 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
542 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000543 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm")
544 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000545 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100546 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000547 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000548 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000549 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
550 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
551 get_random_accessor(1.f, 1.f),
552 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
553 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000554 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm")
555 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000556 << ConvolutionLayer(1U, 7U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100557 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000558 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000559 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000560 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
561 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
562 get_random_accessor(1.f, 1.f),
563 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
564 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000565 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm")
566 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000567 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100568 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000569 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000570 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000571 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
572 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
573 get_random_accessor(1.f, 1.f),
574 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
575 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000576 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm")
577 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000578
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000579 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000580 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 +0000581 << ConvolutionLayer(1U, 1U, 128U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100582 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000583 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000584 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000585 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
586 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
587 get_random_accessor(1.f, 1.f),
588 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
589 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000590 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
591 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000592
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100593 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 +0000594 }
595
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100596 ConcatLayer get_reductionB_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000597 {
598 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_7a_";
599
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000600 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000601 i_a << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100602 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000603 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000604 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000605 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
606 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
607 get_random_accessor(1.f, 1.f),
608 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
609 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000610 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
611 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000612 << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100613 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000614 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000615 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000616 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
617 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
618 get_random_accessor(1.f, 1.f),
619 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
620 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000621 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/BatchNorm")
622 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000623
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000624 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000625 i_b << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100626 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000627 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000628 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000629 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
630 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
631 get_random_accessor(1.f, 1.f),
632 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
633 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000634 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
635 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000636 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100637 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000638 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000639 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000640 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
641 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
642 get_random_accessor(1.f, 1.f),
643 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
644 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000645 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/BatchNorm")
646 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000647 << ConvolutionLayer(1U, 7U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100648 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000649 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000650 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000651 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
652 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
653 get_random_accessor(1.f, 1.f),
654 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
655 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000656 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/BatchNorm")
657 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000658 << ConvolutionLayer(3U, 3U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100659 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000660 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000661 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000662 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
663 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
664 get_random_accessor(1.f, 1.f),
665 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
666 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000667 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/BatchNorm")
668 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000669
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000670 SubStream i_c(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000671 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 +0000672
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100673 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000674 }
675
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100676 ConcatLayer get_inceptionC_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000677 {
678 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
679
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000680 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000681 i_a << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100682 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000683 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000684 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000685 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
686 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
687 get_random_accessor(1.f, 1.f),
688 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
689 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000690 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
691 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000692
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000693 SubStream i_b(graph);
694 i_b << ConvolutionLayer(
695 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100696 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000697 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
698 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000699 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000700 << BatchNormalizationLayer(
701 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
702 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
703 get_random_accessor(1.f, 1.f),
704 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
705 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000706 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
707 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000708
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100709 SubStream i_b1(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000710 i_b1 << ConvolutionLayer(
711 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100712 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000713 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
714 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000715 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000716 << BatchNormalizationLayer(
717 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
718 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
719 get_random_accessor(1.f, 1.f),
720 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
721 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000722 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm")
723 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000724
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100725 SubStream i_b2(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000726 i_b2 << ConvolutionLayer(
727 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100728 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000729 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
730 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000731 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000732 << BatchNormalizationLayer(
733 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_mean.npy"),
734 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_variance.npy"),
735 get_random_accessor(1.f, 1.f),
736 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_beta.npy"),
737 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000738 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/BatchNorm")
739 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000740
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000741 // Merge b1 and b2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000742 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 +0000743
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000744 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000745 i_c << ConvolutionLayer(
746 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100747 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000748 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
749 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000750 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000751 << BatchNormalizationLayer(
752 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
753 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
754 get_random_accessor(1.f, 1.f),
755 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
756 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000757 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
758 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000759 << ConvolutionLayer(
760 1U, 3U, 448U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100761 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000762 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
763 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000764 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000765 << BatchNormalizationLayer(
766 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_mean.npy"),
767 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_variance.npy"),
768 get_random_accessor(1.f, 1.f),
769 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_beta.npy"),
770 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000771 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/BatchNorm")
772 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000773 << ConvolutionLayer(
774 3U, 1U, 512U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100775 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000776 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
777 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000778 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000779 << BatchNormalizationLayer(
780 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
781 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
782 get_random_accessor(1.f, 1.f),
783 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
784 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000785 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm")
786 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000787
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100788 SubStream i_c1(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000789 i_c1 << ConvolutionLayer(
790 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100791 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000792 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
793 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000794 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000795 << BatchNormalizationLayer(
796 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_mean.npy"),
797 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_variance.npy"),
798 get_random_accessor(1.f, 1.f),
799 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_beta.npy"),
800 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000801 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/BatchNorm")
802 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000803
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100804 SubStream i_c2(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000805 i_c2 << ConvolutionLayer(
806 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100807 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000808 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
809 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000810 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000811 << BatchNormalizationLayer(
812 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_mean.npy"),
813 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_variance.npy"),
814 get_random_accessor(1.f, 1.f),
815 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_beta.npy"),
816 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000817 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/BatchNorm")
818 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000819
820 // Merge i_c1 and i_c2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000821 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 +0000822
823 SubStream i_d(graph);
Georgios Pinitas62c36392019-01-31 12:53:10 +0000824 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 +0000825 << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100826 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000827 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000828 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000829 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
830 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
831 get_random_accessor(1.f, 1.f),
832 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
833 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000834 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
835 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000836
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100837 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 +0000838 }
839};
840
841/** Main program for Inception V4
842 *
Georgios Pinitasbdbbbe82018-11-07 16:06:47 +0000843 * Model is based on:
844 * https://arxiv.org/abs/1602.07261
845 * "Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning"
846 * Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi
847 *
Georgios Pinitas588ebc52018-12-21 13:39:07 +0000848 * Provenance: download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz
849 *
Georgios Pinitas9f28b392018-07-18 20:01:53 +0100850 * @note To list all the possible arguments execute the binary appended with the --help option
851 *
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000852 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100853 * @param[in] argv Arguments
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000854 */
855int main(int argc, char **argv)
856{
857 return arm_compute::utils::run_example<InceptionV4Example>(argc, argv);
858}