blob: c78bbb285a1be5fb63e0ad6d57781cf6606fe10d [file] [log] [blame]
Georgios Pinitas240cfa62018-02-26 19:58:04 +00001/*
Sang-Hoon Park11fedda2020-01-15 14:44:04 +00002 * Copyright (c) 2018-2020 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"
Inki Daeea2ce172020-04-09 10:01:44 +090025#ifdef ARM_COMPUTE_CL
26#include "arm_compute/runtime/CL/Utils.h"
27#endif /* ARM_COMPUTE_CL */
Georgios Pinitas240cfa62018-02-26 19:58:04 +000028#include "support/ToolchainSupport.h"
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010029#include "utils/CommonGraphOptions.h"
Georgios Pinitas240cfa62018-02-26 19:58:04 +000030#include "utils/GraphUtils.h"
31#include "utils/Utils.h"
32
Inki Daeea2ce172020-04-09 10:01:44 +090033using namespace arm_compute;
Georgios Pinitas240cfa62018-02-26 19:58:04 +000034using namespace arm_compute::utils;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010035using namespace arm_compute::graph::frontend;
Georgios Pinitas240cfa62018-02-26 19:58:04 +000036using namespace arm_compute::graph_utils;
37
Georgios Pinitas108ab0b2018-09-14 18:35:11 +010038/** Example demonstrating how to implement InceptionV4's network using the Compute Library's graph API */
Georgios Pinitas240cfa62018-02-26 19:58:04 +000039class InceptionV4Example final : public Example
40{
41public:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010042 InceptionV4Example()
43 : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "InceptionV4")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000044 {
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010045 }
46 bool do_setup(int argc, char **argv) override
47 {
48 // Parse arguments
49 cmd_parser.parse(argc, argv);
Georgios Pinitascd60a5f2019-08-21 17:06:54 +010050 cmd_parser.validate();
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010051
52 // Consume common parameters
53 common_params = consume_common_graph_parameters(common_opts);
54
55 // Return when help menu is requested
56 if(common_params.help)
57 {
58 cmd_parser.print_help(argv[0]);
59 return false;
60 }
61
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010062 // 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
Sang-Hoon Park11fedda2020-01-15 14:44:04 +000072 const auto operation_layout = common_params.data_layout;
73 const TensorShape tensor_shape = permute_shape(TensorShape(299U, 299U, 3U, 1U), DataLayout::NCHW, operation_layout);
74 TensorDescriptor input_descriptor = TensorDescriptor(tensor_shape, common_params.data_type).set_layout(operation_layout);
Georgios Pinitase2220552018-07-20 13:23:44 +010075
76 // Set weights trained layout
77 const DataLayout weights_layout = DataLayout::NCHW;
78
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010079 graph << common_params.target
80 << common_params.fast_math_hint
Georgios Pinitase2220552018-07-20 13:23:44 +010081 << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false))
Georgios Pinitas240cfa62018-02-26 19:58:04 +000082 // Conv2d_1a_3x3
83 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010084 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000085 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000086 .set_name("Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000087 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
88 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
89 get_random_accessor(1.f, 1.f),
90 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
91 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +000092 .set_name("Conv2d_1a_3x3/BatchNorm")
93 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000094 // Conv2d_2a_3x3
95 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010096 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +000097 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +000098 .set_name("Conv2d_2a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +000099 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
100 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
101 get_random_accessor(1.f, 1.f),
102 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
103 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000104 .set_name("Conv2d_2a_3x3/BatchNorm")
105 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000106 // Conv2d_2b_3x3
107 << ConvolutionLayer(3U, 3U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100108 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000109 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000110 .set_name("Conv2d_2b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000111 << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
112 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
113 get_random_accessor(1.f, 1.f),
114 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
115 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000116 .set_name("Conv2d_2b_3x3/BatchNorm")
117 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000118
Georgios Pinitas62c36392019-01-31 12:53:10 +0000119 graph << get_mixed_3a(data_path, weights_layout).set_name("Mixed_3a/concat");
120 graph << get_mixed_4a(data_path, weights_layout).set_name("Mixed_4a/concat");
121 graph << get_mixed_5a(data_path, weights_layout).set_name("Mixed_5a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100122 // 4 inception A blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000123 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5b").set_name("Mixed_5b/concat");
124 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5c").set_name("Mixed_5c/concat");
125 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5d").set_name("Mixed_5d/concat");
126 graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5e").set_name("Mixed_5e/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100127 // reduction A block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000128 graph << get_reductionA_block(data_path, weights_layout).set_name("Mixed_6a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100129 // 7 inception B blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000130 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6b").set_name("Mixed_6b/concat");
131 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6c").set_name("Mixed_6c/concat");
132 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6d").set_name("Mixed_6d/concat");
133 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6e").set_name("Mixed_6e/concat");
134 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6f").set_name("Mixed_6f/concat");
135 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6g").set_name("Mixed_6g/concat");
136 graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6h").set_name("Mixed_6h/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100137 // reduction B block
Georgios Pinitas62c36392019-01-31 12:53:10 +0000138 graph << get_reductionB_block(data_path, weights_layout).set_name("Mixed_7a/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100139 // 3 inception C blocks
Georgios Pinitas62c36392019-01-31 12:53:10 +0000140 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7b").set_name("Mixed_7b/concat");
141 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7c").set_name("Mixed_7c/concat");
142 graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7d").set_name("Mixed_7d/concat");
Sang-Hoon Park11fedda2020-01-15 14:44:04 +0000143 graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, operation_layout)).set_name("Logits/AvgPool_1a/AvgPool")
Georgios Pinitas62c36392019-01-31 12:53:10 +0000144 << FlattenLayer().set_name("Logits/Flatten")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000145 << FullyConnectedLayer(
146 1001U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100147 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000148 get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_biases.npy"))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000149 .set_name("Logits/MatMul")
150 << SoftmaxLayer().set_name("Logits/Predictions")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100151 << OutputLayer(get_output_accessor(common_params, 5));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000152
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000153 // Finalize graph
Georgios Pinitas9a8c6722018-03-21 17:52:35 +0000154 GraphConfig config;
Georgios Pinitasf4261ad2019-12-02 11:58:19 +0000155 config.num_threads = common_params.threads;
156 config.use_tuner = common_params.enable_tuner;
157 config.tuner_mode = common_params.tuner_mode;
158 config.tuner_file = common_params.tuner_file;
159 config.convert_to_uint8 = (common_params.data_type == DataType::QASYMM8);
Anthony Barbier7b607dc2018-07-13 15:55:24 +0100160
Pablo Tellodb9116f2019-07-11 16:50:37 +0100161 // 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 {
Inki Daeea2ce172020-04-09 10:01:44 +0900165#ifdef ARM_COMPUTE_CL
Pablo Tellodb9116f2019-07-11 16:50:37 +0100166 restore_program_cache_from_file();
Inki Daeea2ce172020-04-09 10:01:44 +0900167#endif /* ARM_COMPUTE_CL */
Pablo Tellodb9116f2019-07-11 16:50:37 +0100168 }
169
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100170 graph.finalize(common_params.target, config);
171
Pablo Tellodb9116f2019-07-11 16:50:37 +0100172 // Save the opencl kernels to a file
173 if(common_opts.enable_cl_cache)
174 {
Inki Daeea2ce172020-04-09 10:01:44 +0900175#ifdef ARM_COMPUTE_CL
Pablo Tellodb9116f2019-07-11 16:50:37 +0100176 save_program_cache_to_file();
Inki Daeea2ce172020-04-09 10:01:44 +0900177#endif /* ARM_COMPUTE_CL */
Pablo Tellodb9116f2019-07-11 16:50:37 +0100178 }
179
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100180 return true;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000181 }
182
183 void do_run() override
184 {
185 graph.run();
186 }
187
188private:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100189 CommandLineParser cmd_parser;
190 CommonGraphOptions common_opts;
191 CommonGraphParams common_params;
192 Stream graph;
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000193
194private:
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100195 ConcatLayer get_mixed_3a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000196 {
197 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_3a_";
198
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000199 SubStream i_a(graph);
Sang-Hoon Park11fedda2020-01-15 14:44:04 +0000200 i_a << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL),
201 true))
202 .set_name("Mixed_3a/Branch_0/MaxPool_0a_3x3/MaxPool");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000203
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000204 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000205 i_b << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100206 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000207 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000208 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000209 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_mean.npy"),
210 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_variance.npy"),
211 get_random_accessor(1.f, 1.f),
212 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_beta.npy"),
213 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000214 .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/BatchNorm")
215 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000216
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100217 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000218 }
219
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100220 ConcatLayer get_mixed_4a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000221 {
222 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_4a_";
223
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000224 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000225 i_a << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100226 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000227 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000228 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000229 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
230 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
231 get_random_accessor(1.f, 1.f),
232 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
233 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000234 .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/BatchNorm")
235 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000236 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100237 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000238 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000239 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000240 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
241 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
242 get_random_accessor(1.f, 1.f),
243 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
244 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000245 .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/BatchNorm")
246 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000247
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000248 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000249 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100250 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000251 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000252 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000253 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
254 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
255 get_random_accessor(1.f, 1.f),
256 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
257 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000258 .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/BatchNorm")
259 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000260 << ConvolutionLayer(7U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100261 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000262 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000263 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000264 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
265 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
266 get_random_accessor(1.f, 1.f),
267 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
268 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000269 .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/BatchNorm")
270 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000271 << ConvolutionLayer(1U, 7U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100272 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000273 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000274 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000275 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
276 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
277 get_random_accessor(1.f, 1.f),
278 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
279 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000280 .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/BatchNorm")
281 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000282 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100283 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000284 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000285 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000286 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
287 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
288 get_random_accessor(1.f, 1.f),
289 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
290 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000291 .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/BatchNorm")
292 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000293
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100294 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000295 }
296
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100297 ConcatLayer get_mixed_5a(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000298 {
299 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_5a_";
300
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000301 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000302 i_a << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100303 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000304 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000305 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000306 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
307 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
308 get_random_accessor(1.f, 1.f),
309 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
310 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000311 .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/BatchNorm")
312 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000313
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000314 SubStream i_b(graph);
Sang-Hoon Park11fedda2020-01-15 14:44:04 +0000315 i_b << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL),
316 true))
317 .set_name("Mixed_5a/Branch_1/MaxPool_1a_3x3/MaxPool");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000318
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100319 return ConcatLayer(std::move(i_a), std::move(i_b));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000320 }
321
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100322 ConcatLayer get_inceptionA_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000323 {
324 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
325
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000326 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000327 i_a << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100328 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000329 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000330 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000331 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
332 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
333 get_random_accessor(1.f, 1.f),
334 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
335 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000336 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
337 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000338
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000339 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000340 i_b << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100341 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000342 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000343 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000344 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
345 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
346 get_random_accessor(1.f, 1.f),
347 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
348 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000349 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
350 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000351 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100352 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000353 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000354 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000355 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
356 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
357 get_random_accessor(1.f, 1.f),
358 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
359 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000360 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm")
361 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000362
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000363 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000364 i_c << ConvolutionLayer(1U, 1U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100365 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000366 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000367 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000368 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
369 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
370 get_random_accessor(1.f, 1.f),
371 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
372 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000373 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
374 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000375 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100376 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000377 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000378 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000379 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
380 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
381 get_random_accessor(1.f, 1.f),
382 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
383 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000384 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm")
385 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000386 << ConvolutionLayer(3U, 3U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100387 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000388 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000389 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000390 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
391 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
392 get_random_accessor(1.f, 1.f),
393 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
394 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000395 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm")
396 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000397
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000398 SubStream i_d(graph);
Sang-Hoon Park11fedda2020-01-15 14:44:04 +0000399 i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL),
400 true))
401 .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000402 << ConvolutionLayer(1U, 1U, 96U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100403 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000404 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000405 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000406 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
407 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
408 get_random_accessor(1.f, 1.f),
409 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
410 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000411 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
412 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000413
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100414 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 +0000415 }
416
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100417 ConcatLayer get_reductionA_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000418 {
419 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_6a_";
420
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000421 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000422 i_a << ConvolutionLayer(3U, 3U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100423 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000424 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000425 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000426 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
427 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
428 get_random_accessor(1.f, 1.f),
429 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
430 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000431 .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/BatchNorm")
432 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000433
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000434 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000435 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100436 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000437 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000438 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000439 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
440 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
441 get_random_accessor(1.f, 1.f),
442 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
443 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000444 .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/BatchNorm")
445 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000446 << ConvolutionLayer(3U, 3U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100447 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000448 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000449 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000450 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
451 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
452 get_random_accessor(1.f, 1.f),
453 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
454 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000455 .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/BatchNorm")
456 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000457 << ConvolutionLayer(3U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100458 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000459 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000460 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000461 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
462 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
463 get_random_accessor(1.f, 1.f),
464 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
465 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000466 .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/BatchNorm")
467 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000468
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000469 SubStream i_c(graph);
Sang-Hoon Park11fedda2020-01-15 14:44:04 +0000470 i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL),
471 true))
472 .set_name("Mixed_6a/Branch_2/MaxPool_1a_3x3/MaxPool");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000473
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100474 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000475 }
476
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100477 ConcatLayer get_inceptionB_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000478 {
479 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
480
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000481 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000482 i_a << ConvolutionLayer(1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100483 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000484 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000485 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000486 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
487 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
488 get_random_accessor(1.f, 1.f),
489 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
490 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000491 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
492 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000493
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000494 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000495 i_b << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100496 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000497 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000498 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000499 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
500 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
501 get_random_accessor(1.f, 1.f),
502 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
503 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000504 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
505 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000506 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100507 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000508 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000509 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000510 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
511 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
512 get_random_accessor(1.f, 1.f),
513 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
514 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000515 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm")
516 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000517 << ConvolutionLayer(1U, 7U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100518 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000519 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000520 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000521 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
522 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
523 get_random_accessor(1.f, 1.f),
524 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
525 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000526 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm")
527 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000528
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000529 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000530 i_c << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100531 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000532 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000533 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000534 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
535 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
536 get_random_accessor(1.f, 1.f),
537 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
538 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000539 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
540 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000541 << ConvolutionLayer(1U, 7U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100542 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000543 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000544 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000545 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
546 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
547 get_random_accessor(1.f, 1.f),
548 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
549 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000550 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm")
551 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000552 << ConvolutionLayer(7U, 1U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100553 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000554 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000555 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000556 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
557 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
558 get_random_accessor(1.f, 1.f),
559 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
560 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000561 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm")
562 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000563 << ConvolutionLayer(1U, 7U, 224U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100564 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000565 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000566 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000567 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
568 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
569 get_random_accessor(1.f, 1.f),
570 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
571 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000572 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm")
573 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000574 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100575 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000576 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000577 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000578 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
579 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
580 get_random_accessor(1.f, 1.f),
581 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
582 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000583 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm")
584 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000585
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000586 SubStream i_d(graph);
Sang-Hoon Park11fedda2020-01-15 14:44:04 +0000587 i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL),
588 true))
589 .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000590 << ConvolutionLayer(1U, 1U, 128U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100591 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000592 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000593 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000594 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
595 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
596 get_random_accessor(1.f, 1.f),
597 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
598 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000599 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
600 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000601
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100602 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 +0000603 }
604
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100605 ConcatLayer get_reductionB_block(const std::string &data_path, DataLayout weights_layout)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000606 {
607 std::string total_path = "/cnn_data/inceptionv4_model/Mixed_7a_";
608
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000609 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000610 i_a << ConvolutionLayer(1U, 1U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100611 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000612 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000613 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000614 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
615 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
616 get_random_accessor(1.f, 1.f),
617 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
618 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000619 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
620 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000621 << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100622 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000623 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000624 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000625 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
626 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
627 get_random_accessor(1.f, 1.f),
628 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
629 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000630 .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/BatchNorm")
631 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000632
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000633 SubStream i_b(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000634 i_b << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100635 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000636 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000637 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000638 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
639 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
640 get_random_accessor(1.f, 1.f),
641 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
642 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000643 .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm")
644 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000645 << ConvolutionLayer(7U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100646 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000647 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000648 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000649 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
650 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
651 get_random_accessor(1.f, 1.f),
652 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
653 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000654 .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/BatchNorm")
655 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000656 << ConvolutionLayer(1U, 7U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100657 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000658 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000659 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000660 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
661 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
662 get_random_accessor(1.f, 1.f),
663 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
664 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000665 .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/BatchNorm")
666 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000667 << ConvolutionLayer(3U, 3U, 320U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100668 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000669 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000670 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000671 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
672 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
673 get_random_accessor(1.f, 1.f),
674 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
675 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000676 .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/BatchNorm")
677 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000678
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000679 SubStream i_c(graph);
Sang-Hoon Park11fedda2020-01-15 14:44:04 +0000680 i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL),
681 true))
682 .set_name("Mixed_7a/Branch_2/MaxPool_1a_3x3/MaxPool");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000683
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100684 return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c));
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000685 }
686
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100687 ConcatLayer get_inceptionC_block(const std::string &data_path, DataLayout weights_layout, std::string &&param_path)
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000688 {
689 std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_";
690
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000691 SubStream i_a(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000692 i_a << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100693 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000694 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000695 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000696 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
697 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
698 get_random_accessor(1.f, 1.f),
699 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
700 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000701 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm")
702 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000703
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000704 SubStream i_b(graph);
705 i_b << ConvolutionLayer(
706 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100707 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000708 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
709 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000710 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000711 << BatchNormalizationLayer(
712 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
713 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
714 get_random_accessor(1.f, 1.f),
715 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
716 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000717 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm")
718 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000719
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100720 SubStream i_b1(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000721 i_b1 << ConvolutionLayer(
722 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100723 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000724 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
725 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000726 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000727 << BatchNormalizationLayer(
728 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
729 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
730 get_random_accessor(1.f, 1.f),
731 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
732 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000733 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm")
734 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000735
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100736 SubStream i_b2(i_b);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000737 i_b2 << ConvolutionLayer(
738 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100739 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000740 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
741 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000742 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000743 << BatchNormalizationLayer(
744 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_mean.npy"),
745 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_variance.npy"),
746 get_random_accessor(1.f, 1.f),
747 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_beta.npy"),
748 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000749 .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/BatchNorm")
750 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000751
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000752 // Merge b1 and b2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000753 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 +0000754
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000755 SubStream i_c(graph);
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000756 i_c << ConvolutionLayer(
757 1U, 1U, 384U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100758 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000759 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
760 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000761 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000762 << BatchNormalizationLayer(
763 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
764 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
765 get_random_accessor(1.f, 1.f),
766 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
767 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000768 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm")
769 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000770 << ConvolutionLayer(
771 1U, 3U, 448U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100772 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000773 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
774 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000775 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000776 << BatchNormalizationLayer(
777 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_mean.npy"),
778 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_variance.npy"),
779 get_random_accessor(1.f, 1.f),
780 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_beta.npy"),
781 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000782 .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/BatchNorm")
783 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Relu")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000784 << ConvolutionLayer(
785 3U, 1U, 512U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100786 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000787 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
788 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000789 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000790 << BatchNormalizationLayer(
791 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
792 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
793 get_random_accessor(1.f, 1.f),
794 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
795 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000796 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm")
797 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000798
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100799 SubStream i_c1(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000800 i_c1 << ConvolutionLayer(
801 3U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100802 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000803 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
804 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000805 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000806 << BatchNormalizationLayer(
807 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_mean.npy"),
808 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_variance.npy"),
809 get_random_accessor(1.f, 1.f),
810 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_beta.npy"),
811 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000812 .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/BatchNorm")
813 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000814
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100815 SubStream i_c2(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000816 i_c2 << ConvolutionLayer(
817 1U, 3U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100818 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000819 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
820 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000821 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Conv2D")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000822 << BatchNormalizationLayer(
823 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_mean.npy"),
824 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_variance.npy"),
825 get_random_accessor(1.f, 1.f),
826 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_beta.npy"),
827 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000828 .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/BatchNorm")
829 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000830
831 // Merge i_c1 and i_c2
Georgios Pinitas62c36392019-01-31 12:53:10 +0000832 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 +0000833
834 SubStream i_d(graph);
Sang-Hoon Park11fedda2020-01-15 14:44:04 +0000835 i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL),
836 true))
837 .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000838 << ConvolutionLayer(1U, 1U, 256U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100839 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000840 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas62c36392019-01-31 12:53:10 +0000841 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D")
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000842 << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
843 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
844 get_random_accessor(1.f, 1.f),
845 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
846 0.001f)
Georgios Pinitas62c36392019-01-31 12:53:10 +0000847 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm")
848 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000849
Georgios Pinitas427bbbf2018-08-28 13:32:02 +0100850 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 +0000851 }
852};
853
854/** Main program for Inception V4
855 *
Georgios Pinitasbdbbbe82018-11-07 16:06:47 +0000856 * Model is based on:
857 * https://arxiv.org/abs/1602.07261
858 * "Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning"
859 * Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi
860 *
Georgios Pinitas588ebc52018-12-21 13:39:07 +0000861 * Provenance: download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz
862 *
Georgios Pinitas9f28b392018-07-18 20:01:53 +0100863 * @note To list all the possible arguments execute the binary appended with the --help option
864 *
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000865 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100866 * @param[in] argv Arguments
Georgios Pinitas240cfa62018-02-26 19:58:04 +0000867 */
868int main(int argc, char **argv)
869{
870 return arm_compute::utils::run_example<InceptionV4Example>(argc, argv);
871}