blob: 67f4e3cacf2e353277b67ca01248e3dc754e0b5a [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
Georgios Pinitas6ed43b52018-07-12 17:34:22 +010062 ARM_COMPUTE_EXIT_ON_MSG(arm_compute::is_data_type_quantized_asymmetric(common_params.data_type), "Unsupported data type!");
63 ARM_COMPUTE_EXIT_ON_MSG(common_params.data_layout == DataLayout::NHWC, "Unsupported data layout!");
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010064
65 // Print parameter values
66 std::cout << common_params << std::endl;
67
68 // Get trainable parameters data path
69 std::string data_path = common_params.data_path;
Georgios Pinitas652bde52018-01-10 15:33:28 +000070
Georgios Pinitas140fdc72018-02-16 11:42:38 +000071 // Create a preprocessor object
72 std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>();
Georgios Pinitas652bde52018-01-10 15:33:28 +000073
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010074 graph << common_params.target
75 << common_params.fast_math_hint
76 << InputLayer(TensorDescriptor(TensorShape(299U, 299U, 3U, 1U), common_params.data_type),
77 get_input_accessor(common_params, std::move(preprocessor), false))
Georgios Pinitas652bde52018-01-10 15:33:28 +000078 << ConvolutionLayer(3U, 3U, 32U,
79 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_weights.npy"),
80 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +010081 .set_name("Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +000082 << BatchNormalizationLayer(get_weights_accessor(data_path,
83 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
84 get_weights_accessor(data_path,
85 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
86 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
87 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +000088 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +010089 .set_name("Conv2d_1a_3x3/BatchNorm/batchnorm")
90 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +000091 << ConvolutionLayer(3U, 3U, 32U,
92 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_weights.npy"),
93 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +010094 .set_name("Conv2d_2a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +000095 << BatchNormalizationLayer(get_weights_accessor(data_path,
96 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
97 get_weights_accessor(data_path,
98 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
99 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
100 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000101 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100102 .set_name("Conv2d_2a_3x3/BatchNorm/batchnorm")
103 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000104
105 << ConvolutionLayer(3U, 3U, 64U,
106 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_weights.npy"),
107 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100108 .set_name("Conv2d_2b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000109 << BatchNormalizationLayer(get_weights_accessor(data_path,
110 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
111 get_weights_accessor(data_path,
112 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
113 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
114 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000115 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100116 .set_name("Conv2d_2b_3x3/BatchNorm/batchnorm")
117 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000118
Georgios Pinitas130986a2018-05-14 19:25:37 +0100119 << 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 +0000120
121 << ConvolutionLayer(1U, 1U, 80U,
122 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_weights.npy"),
123 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100124 .set_name("Conv2d_3b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000125 << BatchNormalizationLayer(get_weights_accessor(data_path,
126 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_mean.npy"),
127 get_weights_accessor(data_path,
128 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_variance.npy"),
129 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
130 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000131 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100132 .set_name("Conv2d_3b_1x1/BatchNorm/batchnorm")
133 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_3b_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000134
135 << ConvolutionLayer(3U, 3U, 192U,
136 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_weights.npy"),
137 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100138 .set_name("Conv2d_4a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000139 << BatchNormalizationLayer(get_weights_accessor(data_path,
140 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_mean.npy"),
141 get_weights_accessor(data_path,
142 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_variance.npy"),
143 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
144 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000145 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100146 .set_name("Conv2d_4a_3x3/BatchNorm/batchnorm")
147 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_4a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000148
Georgios Pinitas130986a2018-05-14 19:25:37 +0100149 << 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 +0000150
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100151 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 +0100152 32U)
153 .set_name("Mixed_5b/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100154 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 +0100155 64U, true)
156 .set_name("Mixed_5c/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100157 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 +0100158 64U)
159 .set_name("Mixed_5d/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000160
Georgios Pinitas130986a2018-05-14 19:25:37 +0100161 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 +0000162
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100163 graph << get_inception_node_C(data_path, "Mixed_6b", 192U, std::make_tuple(128U, 128U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100164 std::make_tuple(128U, 128U, 128U, 128U, 192U), 192U)
165 .set_name("Mixed_6b/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100166 graph << get_inception_node_C(data_path, "Mixed_6c", 192U, std::make_tuple(160U, 160U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100167 std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
168 .set_name("Mixed_6c/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100169 graph << get_inception_node_C(data_path, "Mixed_6d", 192U, std::make_tuple(160U, 160U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100170 std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
171 .set_name("Mixed_6d/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100172 graph << get_inception_node_C(data_path, "Mixed_6e", 192U, std::make_tuple(192U, 192U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100173 std::make_tuple(192U, 192U, 192U, 192U, 192U), 192U)
174 .set_name("Mixed_6e/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000175
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100176 graph << get_inception_node_D(data_path, "Mixed_7a", std::make_tuple(192U, 320U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100177 std::make_tuple(192U, 192U, 192U, 192U))
178 .set_name("Mixed_7a/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000179
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100180 graph << get_inception_node_E(data_path, "Mixed_7b", 320U, std::make_tuple(384U, 384U, 384U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100181 std::make_tuple(448U, 384U, 384U, 384U), 192U)
182 .set_name("Mixed_7b/concat");
Georgios Pinitas41c482d2018-04-17 13:23:26 +0100183 graph << get_inception_node_E(data_path, "Mixed_7c", 320U, std::make_tuple(384U, 384U, 384U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100184 std::make_tuple(448U, 384U, 384U, 384U), 192U, true)
185 .set_name("Mixed_7c/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000186
Georgios Pinitas130986a2018-05-14 19:25:37 +0100187 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 +0000188 << ConvolutionLayer(1U, 1U, 1001U, get_weights_accessor(data_path,
189 "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_weights.npy"),
190 get_weights_accessor(data_path,
191 "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_biases.npy"),
192 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100193 .set_name("Logits/Conv2d_1c_1x1/convolution")
194 << ReshapeLayer(TensorShape(1001U)).set_name("Predictions/Reshape")
195 << SoftmaxLayer().set_name("Predictions/Softmax")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100196 << OutputLayer(get_output_accessor(common_params, 5));
Gian Marcoc1b6e372018-02-21 18:03:26 +0000197
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000198 // Finalize graph
Georgios Pinitas9a8c6722018-03-21 17:52:35 +0000199 GraphConfig config;
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100200 config.num_threads = common_params.threads;
201 config.use_tuner = common_params.enable_tuner;
Anthony Barbier7b607dc2018-07-13 15:55:24 +0100202 config.tuner_file = common_params.tuner_file;
203
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100204 graph.finalize(common_params.target, config);
205
206 return true;
Georgios Pinitas652bde52018-01-10 15:33:28 +0000207 }
208
209 void do_run() override
210 {
211 graph.run();
212 }
213
214private:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100215 CommandLineParser cmd_parser;
216 CommonGraphOptions common_opts;
217 CommonGraphParams common_params;
218 Stream graph;
Georgios Pinitas652bde52018-01-10 15:33:28 +0000219
220private:
221 BranchLayer get_inception_node_A(const std::string &data_path, std::string &&param_path,
222 unsigned int a_filt,
223 std::tuple<unsigned int, unsigned int> b_filters,
224 std::tuple<unsigned int, unsigned int, unsigned int> c_filters,
225 unsigned int d_filt,
226 bool is_name_different = false)
227 {
228 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitas652bde52018-01-10 15:33:28 +0000229
230 // This is due to a naming issue in the tf model
231 std::string conv_id0 = "_0a_";
232 std::string conv_id1 = "2d_0b_";
233 if(is_name_different)
234 {
235 conv_id0 = "_0b_";
236 conv_id1 = "_1_0c_";
237 }
238
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000239 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000240 i_a << ConvolutionLayer(
241 1U, 1U, a_filt,
242 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
243 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
244 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100245 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000246 << BatchNormalizationLayer(
247 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
248 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
249 get_random_accessor(1.f, 1.f),
250 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000251 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100252 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
253 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000254
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000255 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000256 i_b << ConvolutionLayer(
257 1U, 1U, std::get<0>(b_filters),
258 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_weights.npy"),
259 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
260 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100261 .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000262 << BatchNormalizationLayer(
263 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_mean.npy"),
264 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_variance.npy"),
265 get_random_accessor(1.f, 1.f),
266 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000267 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100268 .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/BatchNorm/batchnorm")
269 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000270 << ConvolutionLayer(
271 5U, 5U, std::get<1>(b_filters),
272 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_weights.npy"),
273 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
274 PadStrideInfo(1, 1, 2, 2))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100275 .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000276 << BatchNormalizationLayer(
277 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_mean.npy"),
278 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_variance.npy"),
279 get_random_accessor(1.f, 1.f),
280 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000281 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100282 .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/BatchNorm/batchnorm")
283 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000284
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000285 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000286 i_c << ConvolutionLayer(
287 1U, 1U, std::get<0>(c_filters),
288 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"),
289 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
290 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100291 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000292 << BatchNormalizationLayer(
293 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
294 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
295 get_random_accessor(1.f, 1.f),
296 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000297 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100298 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
299 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000300 << ConvolutionLayer(
301 3U, 3U, std::get<1>(c_filters),
302 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy"),
303 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
304 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100305 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000306 << BatchNormalizationLayer(
307 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
308 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
309 get_random_accessor(1.f, 1.f),
310 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000311 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100312 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
313 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000314 << ConvolutionLayer(
315 3U, 3U, std::get<2>(c_filters),
316 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy"),
317 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
318 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100319 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000320 << BatchNormalizationLayer(
321 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
322 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
323 get_random_accessor(1.f, 1.f),
324 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000325 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100326 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm/batcnorm")
327 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000328
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000329 SubStream i_d(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100330 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 +0000331 << ConvolutionLayer(
332 1U, 1U, d_filt,
333 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"),
334 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
335 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100336 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000337 << BatchNormalizationLayer(
338 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
339 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
340 get_random_accessor(1.f, 1.f),
341 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000342 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100343 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
344 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000345
346 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
347 }
348
349 BranchLayer get_inception_node_B(const std::string &data_path, std::string &&param_path,
350 unsigned int a_filt,
351 std::tuple<unsigned int, unsigned int, unsigned int> b_filters)
352 {
353 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000354 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000355 i_a << ConvolutionLayer(
356 3U, 3U, a_filt,
357 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_weights.npy"),
358 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
359 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100360 .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000361 << BatchNormalizationLayer(
362 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
363 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
364 get_random_accessor(1.f, 1.f),
365 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000366 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100367 .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/BatchNorm/batchnorm")
368 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000369
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000370 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000371 i_b << ConvolutionLayer(
372 1U, 1U, std::get<0>(b_filters),
373 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
374 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
375 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100376 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000377 << BatchNormalizationLayer(
378 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
379 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
380 get_random_accessor(1.f, 1.f),
381 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000382 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100383 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
384 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000385 << ConvolutionLayer(
386 3U, 3U, std::get<1>(b_filters),
387 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy"),
388 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
389 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100390 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000391 << BatchNormalizationLayer(
392 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
393 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
394 get_random_accessor(1.f, 1.f),
395 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000396 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100397 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm/batchnorm")
398 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000399 << ConvolutionLayer(
400 3U, 3U, std::get<2>(b_filters),
401 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_weights.npy"),
402 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
403 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100404 .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000405 << BatchNormalizationLayer(
406 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
407 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
408 get_random_accessor(1.f, 1.f),
409 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000410 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100411 .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/BatchNorm/batchnorm")
412 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000413
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000414 SubStream i_c(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100415 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 +0000416
417 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c));
418 }
419
420 BranchLayer get_inception_node_C(const std::string &data_path, std::string &&param_path,
421 unsigned int a_filt,
422 std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
423 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
424 unsigned int d_filt)
425 {
426 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000427 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000428 i_a << ConvolutionLayer(
429 1U, 1U, a_filt,
430 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
431 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
432 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100433 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000434 << BatchNormalizationLayer(
435 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
436 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
437 get_random_accessor(1.f, 1.f),
438 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000439 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100440 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
441 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000442
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000443 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000444 i_b << ConvolutionLayer(
445 1U, 1U, std::get<0>(b_filters),
446 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
447 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
448 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100449 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000450 << BatchNormalizationLayer(
451 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
452 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
453 get_random_accessor(1.f, 1.f),
454 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000455 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100456 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
457 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000458 << ConvolutionLayer(
459 7U, 1U, std::get<1>(b_filters),
460 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy"),
461 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
462 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100463 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000464 << BatchNormalizationLayer(
465 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
466 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
467 get_random_accessor(1.f, 1.f),
468 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000469 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100470 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
471 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000472 << ConvolutionLayer(
473 1U, 7U, std::get<2>(b_filters),
474 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy"),
475 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
476 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100477 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000478 << BatchNormalizationLayer(
479 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
480 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
481 get_random_accessor(1.f, 1.f),
482 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000483 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100484 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
485 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0c_7x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000486
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000487 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000488 i_c << ConvolutionLayer(
489 1U, 1U, std::get<0>(c_filters),
490 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"),
491 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
492 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100493 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000494 << BatchNormalizationLayer(
495 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
496 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
497 get_random_accessor(1.f, 1.f),
498 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000499 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100500 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
501 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000502 << ConvolutionLayer(
503 1U, 7U, std::get<1>(c_filters),
504 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy"),
505 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
506 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100507 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000508 << BatchNormalizationLayer(
509 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
510 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
511 get_random_accessor(1.f, 1.f),
512 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000513 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100514 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm/batchnorm")
515 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000516 << ConvolutionLayer(
517 7U, 1U, std::get<2>(c_filters),
518 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy"),
519 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
520 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100521 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000522 << BatchNormalizationLayer(
523 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
524 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
525 get_random_accessor(1.f, 1.f),
526 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000527 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100528 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm/batchnorm")
529 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000530 << ConvolutionLayer(
531 1U, 7U, std::get<3>(c_filters),
532 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy"),
533 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
534 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100535 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000536 << BatchNormalizationLayer(
537 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
538 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
539 get_random_accessor(1.f, 1.f),
540 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000541 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100542 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm/batchnorm")
543 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000544 << ConvolutionLayer(
545 7U, 1U, std::get<4>(c_filters),
546 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy"),
547 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
548 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100549 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000550 << BatchNormalizationLayer(
551 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
552 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
553 get_random_accessor(1.f, 1.f),
554 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000555 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100556 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm/batchnorm")
557 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000558
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000559 SubStream i_d(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100560 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 +0000561 << ConvolutionLayer(
562 1U, 1U, d_filt,
563 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"),
564 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
565 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100566 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000567 << BatchNormalizationLayer(
568 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
569 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
570 get_random_accessor(1.f, 1.f),
571 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000572 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100573 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
574 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000575
576 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
577 }
578
579 BranchLayer get_inception_node_D(const std::string &data_path, std::string &&param_path,
580 std::tuple<unsigned int, unsigned int> a_filters,
581 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> b_filters)
582 {
583 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000584 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000585 i_a << ConvolutionLayer(
586 1U, 1U, std::get<0>(a_filters),
587 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
588 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
589 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100590 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000591 << BatchNormalizationLayer(
592 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
593 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
594 get_random_accessor(1.f, 1.f),
595 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000596 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100597 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
598 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000599 << ConvolutionLayer(
600 3U, 3U, std::get<1>(a_filters),
601 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy"),
602 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
603 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100604 .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000605 << BatchNormalizationLayer(
606 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
607 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
608 get_random_accessor(1.f, 1.f),
609 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000610 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100611 .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/BatchNorm/batchnorm")
612 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000613
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000614 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000615 i_b << ConvolutionLayer(
616 1U, 1U, std::get<0>(b_filters),
617 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
618 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
619 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100620 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000621 << BatchNormalizationLayer(
622 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
623 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
624 get_random_accessor(1.f, 1.f),
625 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000626 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100627 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
628 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000629 << ConvolutionLayer(
630 7U, 1U, std::get<1>(b_filters),
631 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy"),
632 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
633 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100634 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000635 << BatchNormalizationLayer(
636 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
637 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
638 get_random_accessor(1.f, 1.f),
639 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000640 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100641 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
642 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000643 << ConvolutionLayer(
644 1U, 7U, std::get<2>(b_filters),
645 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy"),
646 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
647 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100648 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000649 << BatchNormalizationLayer(
650 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
651 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
652 get_random_accessor(1.f, 1.f),
653 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000654 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100655 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
656 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000657 << ConvolutionLayer(
658 3U, 3U, std::get<3>(b_filters),
659 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy"),
660 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
661 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100662 .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000663 << BatchNormalizationLayer(
664 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
665 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
666 get_random_accessor(1.f, 1.f),
667 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000668 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100669 .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/BatchNorm/batchnorm")
670 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000671
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000672 SubStream i_c(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100673 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 +0000674
675 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c));
676 }
677
678 BranchLayer get_inception_node_E(const std::string &data_path, std::string &&param_path,
679 unsigned int a_filt,
680 std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
681 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
682 unsigned int d_filt,
683 bool is_name_different = false)
684 {
685 // This is due to a naming issue in the tf model
686 std::string conv_id = "_0b_";
687 if(is_name_different)
688 {
689 conv_id = "_0c_";
690 }
691
692 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000693 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000694 i_a << ConvolutionLayer(
695 1U, 1U, a_filt,
696 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"),
697 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
698 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100699 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000700 << BatchNormalizationLayer(
701 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
702 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
703 get_random_accessor(1.f, 1.f),
704 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000705 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100706 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
707 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000708
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000709 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000710 i_b << ConvolutionLayer(
711 1U, 1U, std::get<0>(b_filters),
712 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"),
713 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
714 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100715 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000716 << BatchNormalizationLayer(
717 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
718 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
719 get_random_accessor(1.f, 1.f),
720 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000721 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100722 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
723 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000724
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100725 SubStream i_b1(i_b);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000726 i_b1 << ConvolutionLayer(
727 3U, 1U, std::get<1>(b_filters),
728 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000729 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
730 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100731 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000732 << BatchNormalizationLayer(
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000733 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
734 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000735 get_random_accessor(1.f, 1.f),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000736 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
737 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100738 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm/batchnorm")
739 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000740
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100741 SubStream i_b2(i_b);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000742 i_b2 << ConvolutionLayer(
743 1U, 3U, std::get<2>(b_filters),
744 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_weights.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000745 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
746 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100747 .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000748 << BatchNormalizationLayer(
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000749 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_mean.npy"),
750 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_variance.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000751 get_random_accessor(1.f, 1.f),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000752 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_beta.npy"),
753 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100754 .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/BatchNorm/batchnorm")
755 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000756
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000757 // Merge b1 and b2
Georgios Pinitas130986a2018-05-14 19:25:37 +0100758 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 +0000759
760 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000761 i_c << ConvolutionLayer(
762 1U, 1U, std::get<0>(c_filters),
763 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"),
764 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
765 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100766 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000767 << BatchNormalizationLayer(
768 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
769 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
770 get_random_accessor(1.f, 1.f),
771 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000772 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100773 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
774 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000775 << ConvolutionLayer(
776 3U, 3U, std::get<1>(c_filters),
777 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy"),
778 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
779 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100780 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000781 << BatchNormalizationLayer(
782 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
783 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
784 get_random_accessor(1.f, 1.f),
785 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000786 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100787 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
788 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000789
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100790 SubStream i_c1(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000791 i_c1 << ConvolutionLayer(
792 3U, 1U, std::get<2>(c_filters),
793 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy"),
794 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
795 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100796 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/convolution")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000797 << BatchNormalizationLayer(
798 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
799 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
800 get_random_accessor(1.f, 1.f),
801 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
802 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100803 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm/batchnorm")
804 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000805
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100806 SubStream i_c2(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000807 i_c2 << ConvolutionLayer(
808 1U, 3U, std::get<3>(c_filters),
809 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_weights.npy"),
810 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
811 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100812 .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/convolution")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000813 << BatchNormalizationLayer(
814 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_mean.npy"),
815 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_variance.npy"),
816 get_random_accessor(1.f, 1.f),
817 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_beta.npy"),
818 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100819 .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/BatchNorm/batchnorm")
820 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_3x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000821
822 // Merge i_c1 and i_c2
Georgios Pinitas130986a2018-05-14 19:25:37 +0100823 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 +0000824
825 SubStream i_d(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100826 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 +0000827 << ConvolutionLayer(
828 1U, 1U, d_filt,
829 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"),
830 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
831 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100832 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000833 << BatchNormalizationLayer(
834 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
835 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
836 get_random_accessor(1.f, 1.f),
837 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000838 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100839 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
840 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000841
842 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
843 }
844};
845
846/** Main program for Inception V3
847 *
Georgios Pinitas9f28b392018-07-18 20:01:53 +0100848 * @note To list all the possible arguments execute the binary appended with the --help option
849 *
Georgios Pinitas652bde52018-01-10 15:33:28 +0000850 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100851 * @param[in] argv Arguments
Georgios Pinitas652bde52018-01-10 15:33:28 +0000852 */
853int main(int argc, char **argv)
854{
855 return arm_compute::utils::run_example<InceptionV3Example>(argc, argv);
856}