blob: 639554ebfcc6c4fdbf6e6a70c2c7e59178675e86 [file] [log] [blame]
Georgios Pinitas652bde52018-01-10 15:33:28 +00001/*
2 * Copyright (c) 2017-2018 ARM Limited.
3 *
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 Pinitas652bde52018-01-10 15:33:28 +000025#include "support/ToolchainSupport.h"
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010026#include "utils/CommonGraphOptions.h"
Georgios Pinitas652bde52018-01-10 15:33:28 +000027#include "utils/GraphUtils.h"
28#include "utils/Utils.h"
29
Georgios Pinitas652bde52018-01-10 15:33:28 +000030using namespace arm_compute::utils;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010031using namespace arm_compute::graph::frontend;
Georgios Pinitas652bde52018-01-10 15:33:28 +000032using namespace arm_compute::graph_utils;
33
34/** Example demonstrating how to implement InceptionV3's network using the Compute Library's graph API
35 *
36 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010037 * @param[in] argv Arguments
Georgios Pinitas652bde52018-01-10 15:33:28 +000038 */
Georgios Pinitasd8734b52017-12-22 15:27:52 +000039class InceptionV3Example : public Example
Georgios Pinitas652bde52018-01-10 15:33:28 +000040{
41public:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010042 InceptionV3Example()
43 : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "InceptionV3")
Georgios Pinitas652bde52018-01-10 15:33:28 +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);
50
51 // Consume common parameters
52 common_params = consume_common_graph_parameters(common_opts);
53
54 // Return when help menu is requested
55 if(common_params.help)
56 {
57 cmd_parser.print_help(argv[0]);
58 return false;
59 }
60
61 // Checks
62 ARM_COMPUTE_ERROR_ON_MSG(arm_compute::is_data_type_quantized_asymmetric(common_params.data_type), "Unsupported data type!");
63
64 // Print parameter values
65 std::cout << common_params << std::endl;
66
67 // Get trainable parameters data path
68 std::string data_path = common_params.data_path;
Georgios Pinitas652bde52018-01-10 15:33:28 +000069
Georgios Pinitas140fdc72018-02-16 11:42:38 +000070 // Create a preprocessor object
71 std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>();
Georgios Pinitas652bde52018-01-10 15:33:28 +000072
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010073 graph << common_params.target
74 << common_params.fast_math_hint
75 << InputLayer(TensorDescriptor(TensorShape(299U, 299U, 3U, 1U), common_params.data_type),
76 get_input_accessor(common_params, std::move(preprocessor), false))
Georgios Pinitas652bde52018-01-10 15:33:28 +000077 << ConvolutionLayer(3U, 3U, 32U,
78 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_weights.npy"),
79 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +010080 .set_name("Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +000081 << BatchNormalizationLayer(get_weights_accessor(data_path,
82 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
83 get_weights_accessor(data_path,
84 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
85 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
86 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +000087 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +010088 .set_name("Conv2d_1a_3x3/BatchNorm/batchnorm")
89 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +000090 << ConvolutionLayer(3U, 3U, 32U,
91 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_weights.npy"),
92 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +010093 .set_name("Conv2d_2a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +000094 << BatchNormalizationLayer(get_weights_accessor(data_path,
95 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
96 get_weights_accessor(data_path,
97 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
98 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
99 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000100 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100101 .set_name("Conv2d_2a_3x3/BatchNorm/batchnorm")
102 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000103
104 << ConvolutionLayer(3U, 3U, 64U,
105 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_weights.npy"),
106 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100107 .set_name("Conv2d_2b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000108 << BatchNormalizationLayer(get_weights_accessor(data_path,
109 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
110 get_weights_accessor(data_path,
111 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
112 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
113 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000114 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100115 .set_name("Conv2d_2b_3x3/BatchNorm/batchnorm")
116 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000117
Georgios Pinitas130986a2018-05-14 19:25:37 +0100118 << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name("MaxPool_3a_3x3/MaxPool")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000119
120 << ConvolutionLayer(1U, 1U, 80U,
121 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_weights.npy"),
122 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100123 .set_name("Conv2d_3b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000124 << BatchNormalizationLayer(get_weights_accessor(data_path,
125 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_mean.npy"),
126 get_weights_accessor(data_path,
127 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_variance.npy"),
128 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
129 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000130 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100131 .set_name("Conv2d_3b_1x1/BatchNorm/batchnorm")
132 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_3b_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000133
134 << ConvolutionLayer(3U, 3U, 192U,
135 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_weights.npy"),
136 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100137 .set_name("Conv2d_4a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000138 << BatchNormalizationLayer(get_weights_accessor(data_path,
139 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_mean.npy"),
140 get_weights_accessor(data_path,
141 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_variance.npy"),
142 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
143 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000144 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100145 .set_name("Conv2d_4a_3x3/BatchNorm/batchnorm")
146 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_4a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000147
Georgios Pinitas130986a2018-05-14 19:25:37 +0100148 << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name("MaxPool_5a_3x3/MaxPool");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000149
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100150 graph << get_inception_node_A(data_path, "Mixed_5b", 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100151 32U)
152 .set_name("Mixed_5b/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100153 graph << get_inception_node_A(data_path, "Mixed_5c", 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100154 64U, true)
155 .set_name("Mixed_5c/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100156 graph << get_inception_node_A(data_path, "Mixed_5d", 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100157 64U)
158 .set_name("Mixed_5d/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000159
Georgios Pinitas130986a2018-05-14 19:25:37 +0100160 graph << get_inception_node_B(data_path, "Mixed_6a", 384U, std::make_tuple(64U, 96U, 96U)).set_name("Mixed_6a/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000161
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100162 graph << get_inception_node_C(data_path, "Mixed_6b", 192U, std::make_tuple(128U, 128U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100163 std::make_tuple(128U, 128U, 128U, 128U, 192U), 192U)
164 .set_name("Mixed_6b/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100165 graph << get_inception_node_C(data_path, "Mixed_6c", 192U, std::make_tuple(160U, 160U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100166 std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
167 .set_name("Mixed_6c/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100168 graph << get_inception_node_C(data_path, "Mixed_6d", 192U, std::make_tuple(160U, 160U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100169 std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
170 .set_name("Mixed_6d/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100171 graph << get_inception_node_C(data_path, "Mixed_6e", 192U, std::make_tuple(192U, 192U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100172 std::make_tuple(192U, 192U, 192U, 192U, 192U), 192U)
173 .set_name("Mixed_6e/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000174
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100175 graph << get_inception_node_D(data_path, "Mixed_7a", std::make_tuple(192U, 320U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100176 std::make_tuple(192U, 192U, 192U, 192U))
177 .set_name("Mixed_7a/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000178
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100179 graph << get_inception_node_E(data_path, "Mixed_7b", 320U, std::make_tuple(384U, 384U, 384U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100180 std::make_tuple(448U, 384U, 384U, 384U), 192U)
181 .set_name("Mixed_7b/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100182 graph << get_inception_node_E(data_path, "Mixed_7c", 320U, std::make_tuple(384U, 384U, 384U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100183 std::make_tuple(448U, 384U, 384U, 384U), 192U, true)
184 .set_name("Mixed_7c/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000185
Georgios Pinitas130986a2018-05-14 19:25:37 +0100186 graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 8, PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::CEIL))).set_name("Logits/AvgPool_1a_8x8/AvgPool")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000187 << ConvolutionLayer(1U, 1U, 1001U, get_weights_accessor(data_path,
188 "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_weights.npy"),
189 get_weights_accessor(data_path,
190 "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_biases.npy"),
191 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100192 .set_name("Logits/Conv2d_1c_1x1/convolution")
193 << ReshapeLayer(TensorShape(1001U)).set_name("Predictions/Reshape")
194 << SoftmaxLayer().set_name("Predictions/Softmax")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100195 << OutputLayer(get_output_accessor(common_params, 5));
Gian Marcoc1b6e372018-02-21 18:03:26 +0000196
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000197 // Finalize graph
Georgios Pinitas9a8c6722018-03-21 17:52:35 +0000198 GraphConfig config;
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100199 config.num_threads = common_params.threads;
200 config.use_tuner = common_params.enable_tuner;
201 graph.finalize(common_params.target, config);
202
203 return true;
Georgios Pinitas652bde52018-01-10 15:33:28 +0000204 }
205
206 void do_run() override
207 {
208 graph.run();
209 }
210
211private:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100212 CommandLineParser cmd_parser;
213 CommonGraphOptions common_opts;
214 CommonGraphParams common_params;
215 Stream graph;
Georgios Pinitas652bde52018-01-10 15:33:28 +0000216
217private:
218 BranchLayer get_inception_node_A(const std::string &data_path, std::string &&param_path,
219 unsigned int a_filt,
220 std::tuple<unsigned int, unsigned int> b_filters,
221 std::tuple<unsigned int, unsigned int, unsigned int> c_filters,
222 unsigned int d_filt,
223 bool is_name_different = false)
224 {
225 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitas652bde52018-01-10 15:33:28 +0000226
227 // This is due to a naming issue in the tf model
228 std::string conv_id0 = "_0a_";
229 std::string conv_id1 = "2d_0b_";
230 if(is_name_different)
231 {
232 conv_id0 = "_0b_";
233 conv_id1 = "_1_0c_";
234 }
235
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000236 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000237 i_a << ConvolutionLayer(
238 1U, 1U, a_filt,
239 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
240 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
241 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100242 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000243 << BatchNormalizationLayer(
244 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
245 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
246 get_random_accessor(1.f, 1.f),
247 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000248 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100249 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
250 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000251
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000252 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000253 i_b << ConvolutionLayer(
254 1U, 1U, std::get<0>(b_filters),
255 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_weights.npy"),
256 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
257 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100258 .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000259 << BatchNormalizationLayer(
260 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_mean.npy"),
261 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_variance.npy"),
262 get_random_accessor(1.f, 1.f),
263 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000264 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100265 .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/BatchNorm/batchnorm")
266 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000267 << ConvolutionLayer(
268 5U, 5U, std::get<1>(b_filters),
269 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_weights.npy"),
270 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
271 PadStrideInfo(1, 1, 2, 2))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100272 .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000273 << BatchNormalizationLayer(
274 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_mean.npy"),
275 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_variance.npy"),
276 get_random_accessor(1.f, 1.f),
277 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000278 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100279 .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/BatchNorm/batchnorm")
280 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000281
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000282 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000283 i_c << ConvolutionLayer(
284 1U, 1U, std::get<0>(c_filters),
285 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"),
286 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
287 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100288 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000289 << BatchNormalizationLayer(
290 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
291 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
292 get_random_accessor(1.f, 1.f),
293 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000294 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100295 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
296 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000297 << ConvolutionLayer(
298 3U, 3U, std::get<1>(c_filters),
299 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy"),
300 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
301 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100302 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000303 << BatchNormalizationLayer(
304 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
305 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
306 get_random_accessor(1.f, 1.f),
307 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000308 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100309 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
310 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000311 << ConvolutionLayer(
312 3U, 3U, std::get<2>(c_filters),
313 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy"),
314 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
315 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100316 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000317 << BatchNormalizationLayer(
318 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
319 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
320 get_random_accessor(1.f, 1.f),
321 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000322 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100323 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm/batcnorm")
324 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000325
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000326 SubStream i_d(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100327 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 Pinitas652bde52018-01-10 15:33:28 +0000328 << ConvolutionLayer(
329 1U, 1U, d_filt,
330 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"),
331 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
332 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100333 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000334 << BatchNormalizationLayer(
335 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
336 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
337 get_random_accessor(1.f, 1.f),
338 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000339 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100340 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
341 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000342
343 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
344 }
345
346 BranchLayer get_inception_node_B(const std::string &data_path, std::string &&param_path,
347 unsigned int a_filt,
348 std::tuple<unsigned int, unsigned int, unsigned int> b_filters)
349 {
350 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000351 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000352 i_a << ConvolutionLayer(
353 3U, 3U, a_filt,
354 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_weights.npy"),
355 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
356 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100357 .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000358 << BatchNormalizationLayer(
359 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
360 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
361 get_random_accessor(1.f, 1.f),
362 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000363 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100364 .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/BatchNorm/batchnorm")
365 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000366
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000367 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000368 i_b << ConvolutionLayer(
369 1U, 1U, std::get<0>(b_filters),
370 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
371 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
372 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100373 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000374 << BatchNormalizationLayer(
375 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
376 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
377 get_random_accessor(1.f, 1.f),
378 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000379 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100380 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
381 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000382 << ConvolutionLayer(
383 3U, 3U, std::get<1>(b_filters),
384 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy"),
385 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
386 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100387 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000388 << BatchNormalizationLayer(
389 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
390 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
391 get_random_accessor(1.f, 1.f),
392 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000393 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100394 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm/batchnorm")
395 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000396 << ConvolutionLayer(
397 3U, 3U, std::get<2>(b_filters),
398 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_weights.npy"),
399 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
400 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100401 .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000402 << BatchNormalizationLayer(
403 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
404 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
405 get_random_accessor(1.f, 1.f),
406 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000407 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100408 .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/BatchNorm/batchnorm")
409 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000410
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000411 SubStream i_c(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100412 i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name(param_path + "/Branch_2/MaxPool_1a_3x3/MaxPool");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000413
414 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c));
415 }
416
417 BranchLayer get_inception_node_C(const std::string &data_path, std::string &&param_path,
418 unsigned int a_filt,
419 std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
420 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
421 unsigned int d_filt)
422 {
423 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000424 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000425 i_a << ConvolutionLayer(
426 1U, 1U, a_filt,
427 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
428 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
429 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100430 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000431 << BatchNormalizationLayer(
432 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
433 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
434 get_random_accessor(1.f, 1.f),
435 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000436 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100437 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
438 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000439
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000440 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000441 i_b << ConvolutionLayer(
442 1U, 1U, std::get<0>(b_filters),
443 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
444 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
445 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100446 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000447 << BatchNormalizationLayer(
448 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
449 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
450 get_random_accessor(1.f, 1.f),
451 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000452 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100453 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
454 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000455 << ConvolutionLayer(
456 7U, 1U, std::get<1>(b_filters),
457 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy"),
458 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
459 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100460 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000461 << BatchNormalizationLayer(
462 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
463 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
464 get_random_accessor(1.f, 1.f),
465 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000466 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100467 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
468 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000469 << ConvolutionLayer(
470 1U, 7U, std::get<2>(b_filters),
471 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy"),
472 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
473 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100474 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000475 << BatchNormalizationLayer(
476 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
477 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
478 get_random_accessor(1.f, 1.f),
479 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000480 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100481 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
482 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0c_7x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000483
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000484 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000485 i_c << ConvolutionLayer(
486 1U, 1U, std::get<0>(c_filters),
487 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"),
488 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
489 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100490 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000491 << BatchNormalizationLayer(
492 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
493 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
494 get_random_accessor(1.f, 1.f),
495 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000496 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100497 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
498 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000499 << ConvolutionLayer(
500 1U, 7U, std::get<1>(c_filters),
501 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy"),
502 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
503 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100504 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000505 << BatchNormalizationLayer(
506 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
507 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
508 get_random_accessor(1.f, 1.f),
509 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000510 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100511 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm/batchnorm")
512 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000513 << ConvolutionLayer(
514 7U, 1U, std::get<2>(c_filters),
515 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy"),
516 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
517 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100518 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000519 << BatchNormalizationLayer(
520 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
521 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
522 get_random_accessor(1.f, 1.f),
523 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000524 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100525 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm/batchnorm")
526 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000527 << ConvolutionLayer(
528 1U, 7U, std::get<3>(c_filters),
529 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy"),
530 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
531 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100532 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000533 << BatchNormalizationLayer(
534 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
535 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
536 get_random_accessor(1.f, 1.f),
537 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000538 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100539 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm/batchnorm")
540 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000541 << ConvolutionLayer(
542 7U, 1U, std::get<4>(c_filters),
543 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy"),
544 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
545 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100546 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000547 << BatchNormalizationLayer(
548 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
549 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
550 get_random_accessor(1.f, 1.f),
551 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000552 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100553 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm/batchnorm")
554 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000555
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000556 SubStream i_d(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100557 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 Pinitas652bde52018-01-10 15:33:28 +0000558 << ConvolutionLayer(
559 1U, 1U, d_filt,
560 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"),
561 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
562 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100563 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000564 << BatchNormalizationLayer(
565 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
566 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
567 get_random_accessor(1.f, 1.f),
568 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000569 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100570 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
571 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000572
573 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
574 }
575
576 BranchLayer get_inception_node_D(const std::string &data_path, std::string &&param_path,
577 std::tuple<unsigned int, unsigned int> a_filters,
578 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> b_filters)
579 {
580 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000581 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000582 i_a << ConvolutionLayer(
583 1U, 1U, std::get<0>(a_filters),
584 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
585 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
586 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100587 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000588 << BatchNormalizationLayer(
589 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
590 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
591 get_random_accessor(1.f, 1.f),
592 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000593 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100594 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
595 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000596 << ConvolutionLayer(
597 3U, 3U, std::get<1>(a_filters),
598 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy"),
599 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
600 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100601 .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000602 << BatchNormalizationLayer(
603 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
604 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
605 get_random_accessor(1.f, 1.f),
606 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000607 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100608 .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/BatchNorm/batchnorm")
609 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000610
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000611 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000612 i_b << ConvolutionLayer(
613 1U, 1U, std::get<0>(b_filters),
614 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
615 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
616 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100617 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000618 << BatchNormalizationLayer(
619 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
620 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
621 get_random_accessor(1.f, 1.f),
622 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000623 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100624 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
625 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000626 << ConvolutionLayer(
627 7U, 1U, std::get<1>(b_filters),
628 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy"),
629 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
630 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100631 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000632 << BatchNormalizationLayer(
633 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
634 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
635 get_random_accessor(1.f, 1.f),
636 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000637 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100638 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
639 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000640 << ConvolutionLayer(
641 1U, 7U, std::get<2>(b_filters),
642 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy"),
643 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
644 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100645 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000646 << BatchNormalizationLayer(
647 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
648 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
649 get_random_accessor(1.f, 1.f),
650 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000651 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100652 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
653 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000654 << ConvolutionLayer(
655 3U, 3U, std::get<3>(b_filters),
656 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy"),
657 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
658 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100659 .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000660 << BatchNormalizationLayer(
661 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
662 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
663 get_random_accessor(1.f, 1.f),
664 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000665 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100666 .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/BatchNorm/batchnorm")
667 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000668
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000669 SubStream i_c(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100670 i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name(param_path + "/Branch_2/MaxPool_1a_3x3/MaxPool");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000671
672 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c));
673 }
674
675 BranchLayer get_inception_node_E(const std::string &data_path, std::string &&param_path,
676 unsigned int a_filt,
677 std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
678 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
679 unsigned int d_filt,
680 bool is_name_different = false)
681 {
682 // This is due to a naming issue in the tf model
683 std::string conv_id = "_0b_";
684 if(is_name_different)
685 {
686 conv_id = "_0c_";
687 }
688
689 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000690 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000691 i_a << ConvolutionLayer(
692 1U, 1U, a_filt,
693 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
694 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
695 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100696 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000697 << BatchNormalizationLayer(
698 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
699 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
700 get_random_accessor(1.f, 1.f),
701 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000702 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100703 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
704 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000705
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000706 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000707 i_b << ConvolutionLayer(
708 1U, 1U, std::get<0>(b_filters),
709 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
710 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
711 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100712 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000713 << BatchNormalizationLayer(
714 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
715 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
716 get_random_accessor(1.f, 1.f),
717 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000718 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100719 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
720 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000721
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100722 SubStream i_b1(i_b);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000723 i_b1 << ConvolutionLayer(
724 3U, 1U, std::get<1>(b_filters),
725 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000726 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
727 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100728 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000729 << BatchNormalizationLayer(
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000730 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
731 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000732 get_random_accessor(1.f, 1.f),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000733 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
734 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100735 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm/batchnorm")
736 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000737
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100738 SubStream i_b2(i_b);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000739 i_b2 << ConvolutionLayer(
740 1U, 3U, std::get<2>(b_filters),
741 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_weights.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000742 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
743 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100744 .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000745 << BatchNormalizationLayer(
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000746 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_mean.npy"),
747 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_variance.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000748 get_random_accessor(1.f, 1.f),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000749 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_beta.npy"),
750 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100751 .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/BatchNorm/batchnorm")
752 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000753
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000754 // Merge b1 and b2
Georgios Pinitas130986a2018-05-14 19:25:37 +0100755 i_b << BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_b1), std::move(i_b2)).set_name(param_path + "/Branch_1/concat");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000756
757 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000758 i_c << ConvolutionLayer(
759 1U, 1U, std::get<0>(c_filters),
760 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"),
761 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
762 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100763 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000764 << BatchNormalizationLayer(
765 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
766 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
767 get_random_accessor(1.f, 1.f),
768 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000769 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100770 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
771 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000772 << ConvolutionLayer(
773 3U, 3U, std::get<1>(c_filters),
774 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy"),
775 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
776 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100777 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000778 << BatchNormalizationLayer(
779 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
780 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
781 get_random_accessor(1.f, 1.f),
782 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000783 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100784 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
785 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000786
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100787 SubStream i_c1(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000788 i_c1 << ConvolutionLayer(
789 3U, 1U, std::get<2>(c_filters),
790 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy"),
791 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
792 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100793 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/convolution")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000794 << BatchNormalizationLayer(
795 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
796 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
797 get_random_accessor(1.f, 1.f),
798 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
799 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100800 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm/batchnorm")
801 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000802
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100803 SubStream i_c2(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000804 i_c2 << ConvolutionLayer(
805 1U, 3U, std::get<3>(c_filters),
806 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_weights.npy"),
807 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
808 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100809 .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/convolution")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000810 << BatchNormalizationLayer(
811 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_mean.npy"),
812 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_variance.npy"),
813 get_random_accessor(1.f, 1.f),
814 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_beta.npy"),
815 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100816 .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/BatchNorm/batchnorm")
817 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_3x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000818
819 // Merge i_c1 and i_c2
Georgios Pinitas130986a2018-05-14 19:25:37 +0100820 i_c << BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_c1), std::move(i_c2)).set_name(param_path + "/Branch_2/concat");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000821
822 SubStream i_d(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100823 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 Pinitas652bde52018-01-10 15:33:28 +0000824 << ConvolutionLayer(
825 1U, 1U, d_filt,
826 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"),
827 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
828 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100829 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000830 << BatchNormalizationLayer(
831 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
832 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
833 get_random_accessor(1.f, 1.f),
834 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000835 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100836 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
837 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000838
839 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
840 }
841};
842
843/** Main program for Inception V3
844 *
845 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100846 * @param[in] argv Arguments
Georgios Pinitas652bde52018-01-10 15:33:28 +0000847 */
848int main(int argc, char **argv)
849{
850 return arm_compute::utils::run_example<InceptionV3Example>(argc, argv);
851}