blob: c41b0a808e70465d81d94c865bdb0f4c03be8ec8 [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!");
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010063
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 Pinitase2220552018-07-20 13:23:44 +010073 // Create input descriptor
74 const TensorShape tensor_shape = permute_shape(TensorShape(299U, 299U, 3U, 1U), DataLayout::NCHW, common_params.data_layout);
75 TensorDescriptor input_descriptor = TensorDescriptor(tensor_shape, common_params.data_type).set_layout(common_params.data_layout);
76
77 // Set weights trained layout
78 const DataLayout weights_layout = DataLayout::NCHW;
79
Georgios Pinitas12be7ab2018-07-03 12:06:23 +010080 graph << common_params.target
81 << common_params.fast_math_hint
Georgios Pinitase2220552018-07-20 13:23:44 +010082 << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false))
Georgios Pinitas652bde52018-01-10 15:33:28 +000083 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010084 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +000085 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +010086 .set_name("Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +000087 << BatchNormalizationLayer(get_weights_accessor(data_path,
88 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
89 get_weights_accessor(data_path,
90 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
91 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
92 "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +000093 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +010094 .set_name("Conv2d_1a_3x3/BatchNorm/batchnorm")
95 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +000096 << ConvolutionLayer(3U, 3U, 32U,
Georgios Pinitase2220552018-07-20 13:23:44 +010097 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +000098 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +010099 .set_name("Conv2d_2a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000100 << BatchNormalizationLayer(get_weights_accessor(data_path,
101 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"),
102 get_weights_accessor(data_path,
103 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"),
104 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
105 "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000106 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100107 .set_name("Conv2d_2a_3x3/BatchNorm/batchnorm")
108 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000109
110 << ConvolutionLayer(3U, 3U, 64U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100111 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000112 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100113 .set_name("Conv2d_2b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000114 << BatchNormalizationLayer(get_weights_accessor(data_path,
115 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"),
116 get_weights_accessor(data_path,
117 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"),
118 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
119 "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000120 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100121 .set_name("Conv2d_2b_3x3/BatchNorm/batchnorm")
122 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000123
Georgios Pinitas130986a2018-05-14 19:25:37 +0100124 << 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 +0000125
126 << ConvolutionLayer(1U, 1U, 80U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100127 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000128 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100129 .set_name("Conv2d_3b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000130 << BatchNormalizationLayer(get_weights_accessor(data_path,
131 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_mean.npy"),
132 get_weights_accessor(data_path,
133 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_variance.npy"),
134 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
135 "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000136 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100137 .set_name("Conv2d_3b_1x1/BatchNorm/batchnorm")
138 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_3b_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000139
140 << ConvolutionLayer(3U, 3U, 192U,
Georgios Pinitase2220552018-07-20 13:23:44 +0100141 get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000142 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100143 .set_name("Conv2d_4a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000144 << BatchNormalizationLayer(get_weights_accessor(data_path,
145 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_mean.npy"),
146 get_weights_accessor(data_path,
147 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_variance.npy"),
148 get_random_accessor(1.f, 1.f), get_weights_accessor(data_path,
149 "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000150 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100151 .set_name("Conv2d_4a_3x3/BatchNorm/batchnorm")
152 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_4a_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000153
Georgios Pinitas130986a2018-05-14 19:25:37 +0100154 << 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 +0000155
Georgios Pinitase2220552018-07-20 13:23:44 +0100156 graph << get_inception_node_A(data_path, "Mixed_5b", weights_layout, 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100157 32U)
158 .set_name("Mixed_5b/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100159 graph << get_inception_node_A(data_path, "Mixed_5c", weights_layout, 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100160 64U, true)
161 .set_name("Mixed_5c/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100162 graph << get_inception_node_A(data_path, "Mixed_5d", weights_layout, 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100163 64U)
164 .set_name("Mixed_5d/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000165
Georgios Pinitase2220552018-07-20 13:23:44 +0100166 graph << get_inception_node_B(data_path, "Mixed_6a", weights_layout, 384U, std::make_tuple(64U, 96U, 96U)).set_name("Mixed_6a/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000167
Georgios Pinitase2220552018-07-20 13:23:44 +0100168 graph << get_inception_node_C(data_path, "Mixed_6b", weights_layout, 192U, std::make_tuple(128U, 128U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100169 std::make_tuple(128U, 128U, 128U, 128U, 192U), 192U)
170 .set_name("Mixed_6b/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100171 graph << get_inception_node_C(data_path, "Mixed_6c", weights_layout, 192U, std::make_tuple(160U, 160U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100172 std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
173 .set_name("Mixed_6c/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100174 graph << get_inception_node_C(data_path, "Mixed_6d", weights_layout, 192U, std::make_tuple(160U, 160U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100175 std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U)
176 .set_name("Mixed_6d/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100177 graph << get_inception_node_C(data_path, "Mixed_6e", weights_layout, 192U, std::make_tuple(192U, 192U, 192U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100178 std::make_tuple(192U, 192U, 192U, 192U, 192U), 192U)
179 .set_name("Mixed_6e/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000180
Georgios Pinitase2220552018-07-20 13:23:44 +0100181 graph << get_inception_node_D(data_path, "Mixed_7a", weights_layout, std::make_tuple(192U, 320U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100182 std::make_tuple(192U, 192U, 192U, 192U))
183 .set_name("Mixed_7a/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000184
Georgios Pinitase2220552018-07-20 13:23:44 +0100185 graph << get_inception_node_E(data_path, "Mixed_7b", weights_layout, 320U, std::make_tuple(384U, 384U, 384U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100186 std::make_tuple(448U, 384U, 384U, 384U), 192U)
187 .set_name("Mixed_7b/concat");
Georgios Pinitase2220552018-07-20 13:23:44 +0100188 graph << get_inception_node_E(data_path, "Mixed_7c", weights_layout, 320U, std::make_tuple(384U, 384U, 384U),
Georgios Pinitas130986a2018-05-14 19:25:37 +0100189 std::make_tuple(448U, 384U, 384U, 384U), 192U, true)
190 .set_name("Mixed_7c/concat");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000191
Georgios Pinitas130986a2018-05-14 19:25:37 +0100192 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 +0000193 << ConvolutionLayer(1U, 1U, 1001U, get_weights_accessor(data_path,
Georgios Pinitase2220552018-07-20 13:23:44 +0100194 "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000195 get_weights_accessor(data_path,
196 "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_biases.npy"),
197 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100198 .set_name("Logits/Conv2d_1c_1x1/convolution")
199 << ReshapeLayer(TensorShape(1001U)).set_name("Predictions/Reshape")
200 << SoftmaxLayer().set_name("Predictions/Softmax")
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100201 << OutputLayer(get_output_accessor(common_params, 5));
Gian Marcoc1b6e372018-02-21 18:03:26 +0000202
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000203 // Finalize graph
Georgios Pinitas9a8c6722018-03-21 17:52:35 +0000204 GraphConfig config;
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100205 config.num_threads = common_params.threads;
206 config.use_tuner = common_params.enable_tuner;
Anthony Barbier7b607dc2018-07-13 15:55:24 +0100207 config.tuner_file = common_params.tuner_file;
208
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100209 graph.finalize(common_params.target, config);
210
211 return true;
Georgios Pinitas652bde52018-01-10 15:33:28 +0000212 }
213
214 void do_run() override
215 {
216 graph.run();
217 }
218
219private:
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100220 CommandLineParser cmd_parser;
221 CommonGraphOptions common_opts;
222 CommonGraphParams common_params;
223 Stream graph;
Georgios Pinitas652bde52018-01-10 15:33:28 +0000224
225private:
Georgios Pinitase2220552018-07-20 13:23:44 +0100226 BranchLayer get_inception_node_A(const std::string &data_path, std::string &&param_path, DataLayout weights_layout,
Georgios Pinitas652bde52018-01-10 15:33:28 +0000227 unsigned int a_filt,
228 std::tuple<unsigned int, unsigned int> b_filters,
229 std::tuple<unsigned int, unsigned int, unsigned int> c_filters,
230 unsigned int d_filt,
231 bool is_name_different = false)
232 {
233 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitas652bde52018-01-10 15:33:28 +0000234
235 // This is due to a naming issue in the tf model
236 std::string conv_id0 = "_0a_";
237 std::string conv_id1 = "2d_0b_";
238 if(is_name_different)
239 {
240 conv_id0 = "_0b_";
241 conv_id1 = "_1_0c_";
242 }
243
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000244 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000245 i_a << ConvolutionLayer(
246 1U, 1U, a_filt,
Georgios Pinitase2220552018-07-20 13:23:44 +0100247 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000248 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
249 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100250 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000251 << BatchNormalizationLayer(
252 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
253 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
254 get_random_accessor(1.f, 1.f),
255 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000256 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100257 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
258 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000259
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000260 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000261 i_b << ConvolutionLayer(
262 1U, 1U, std::get<0>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100263 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000264 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
265 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100266 .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000267 << BatchNormalizationLayer(
268 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_mean.npy"),
269 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_variance.npy"),
270 get_random_accessor(1.f, 1.f),
271 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000272 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100273 .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/BatchNorm/batchnorm")
274 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000275 << ConvolutionLayer(
276 5U, 5U, std::get<1>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100277 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000278 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
279 PadStrideInfo(1, 1, 2, 2))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100280 .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000281 << BatchNormalizationLayer(
282 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_mean.npy"),
283 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_variance.npy"),
284 get_random_accessor(1.f, 1.f),
285 get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000286 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100287 .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/BatchNorm/batchnorm")
288 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000289
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000290 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000291 i_c << ConvolutionLayer(
292 1U, 1U, std::get<0>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100293 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000294 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
295 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100296 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000297 << BatchNormalizationLayer(
298 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
299 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
300 get_random_accessor(1.f, 1.f),
301 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000302 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100303 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
304 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000305 << ConvolutionLayer(
306 3U, 3U, std::get<1>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100307 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000308 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
309 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100310 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000311 << BatchNormalizationLayer(
312 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
313 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
314 get_random_accessor(1.f, 1.f),
315 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000316 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100317 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
318 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000319 << ConvolutionLayer(
320 3U, 3U, std::get<2>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100321 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000322 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
323 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100324 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000325 << BatchNormalizationLayer(
326 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"),
327 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"),
328 get_random_accessor(1.f, 1.f),
329 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000330 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100331 .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm/batcnorm")
332 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000333
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000334 SubStream i_d(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100335 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 +0000336 << ConvolutionLayer(
337 1U, 1U, d_filt,
Georgios Pinitase2220552018-07-20 13:23:44 +0100338 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000339 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
340 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100341 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000342 << BatchNormalizationLayer(
343 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
344 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
345 get_random_accessor(1.f, 1.f),
346 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000347 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100348 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
349 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000350
351 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
352 }
353
Georgios Pinitase2220552018-07-20 13:23:44 +0100354 BranchLayer get_inception_node_B(const std::string &data_path, std::string &&param_path, DataLayout weights_layout,
Georgios Pinitas652bde52018-01-10 15:33:28 +0000355 unsigned int a_filt,
356 std::tuple<unsigned int, unsigned int, unsigned int> b_filters)
357 {
358 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000359 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000360 i_a << ConvolutionLayer(
361 3U, 3U, a_filt,
Georgios Pinitase2220552018-07-20 13:23:44 +0100362 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000363 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
364 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100365 .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000366 << BatchNormalizationLayer(
367 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
368 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
369 get_random_accessor(1.f, 1.f),
370 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000371 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100372 .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/BatchNorm/batchnorm")
373 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000374
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000375 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000376 i_b << ConvolutionLayer(
377 1U, 1U, std::get<0>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100378 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000379 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
380 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100381 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000382 << BatchNormalizationLayer(
383 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
384 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
385 get_random_accessor(1.f, 1.f),
386 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000387 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100388 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
389 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000390 << ConvolutionLayer(
391 3U, 3U, std::get<1>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100392 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000393 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
394 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100395 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000396 << BatchNormalizationLayer(
397 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
398 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
399 get_random_accessor(1.f, 1.f),
400 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000401 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100402 .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm/batchnorm")
403 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000404 << ConvolutionLayer(
405 3U, 3U, std::get<2>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100406 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000407 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
408 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100409 .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000410 << BatchNormalizationLayer(
411 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"),
412 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"),
413 get_random_accessor(1.f, 1.f),
414 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000415 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100416 .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/BatchNorm/batchnorm")
417 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000418
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000419 SubStream i_c(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100420 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 +0000421
422 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c));
423 }
424
Georgios Pinitase2220552018-07-20 13:23:44 +0100425 BranchLayer get_inception_node_C(const std::string &data_path, std::string &&param_path, DataLayout weights_layout,
Georgios Pinitas652bde52018-01-10 15:33:28 +0000426 unsigned int a_filt,
427 std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
428 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
429 unsigned int d_filt)
430 {
431 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000432 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000433 i_a << ConvolutionLayer(
434 1U, 1U, a_filt,
Georgios Pinitase2220552018-07-20 13:23:44 +0100435 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000436 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
437 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100438 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000439 << BatchNormalizationLayer(
440 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
441 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
442 get_random_accessor(1.f, 1.f),
443 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000444 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100445 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
446 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000447
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000448 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000449 i_b << ConvolutionLayer(
450 1U, 1U, std::get<0>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100451 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000452 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
453 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100454 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000455 << BatchNormalizationLayer(
456 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
457 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
458 get_random_accessor(1.f, 1.f),
459 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000460 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100461 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
462 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000463 << ConvolutionLayer(
464 7U, 1U, std::get<1>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100465 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000466 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
467 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100468 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000469 << BatchNormalizationLayer(
470 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
471 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
472 get_random_accessor(1.f, 1.f),
473 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000474 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100475 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
476 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000477 << ConvolutionLayer(
478 1U, 7U, std::get<2>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100479 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000480 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
481 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100482 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000483 << BatchNormalizationLayer(
484 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
485 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
486 get_random_accessor(1.f, 1.f),
487 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000488 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100489 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
490 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0c_7x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000491
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000492 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000493 i_c << ConvolutionLayer(
494 1U, 1U, std::get<0>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100495 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000496 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
497 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100498 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000499 << BatchNormalizationLayer(
500 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
501 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
502 get_random_accessor(1.f, 1.f),
503 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000504 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100505 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
506 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000507 << ConvolutionLayer(
508 1U, 7U, std::get<1>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100509 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000510 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
511 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100512 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000513 << BatchNormalizationLayer(
514 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"),
515 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"),
516 get_random_accessor(1.f, 1.f),
517 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000518 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100519 .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm/batchnorm")
520 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000521 << ConvolutionLayer(
522 7U, 1U, std::get<2>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100523 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000524 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
525 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100526 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000527 << BatchNormalizationLayer(
528 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"),
529 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"),
530 get_random_accessor(1.f, 1.f),
531 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000532 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100533 .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm/batchnorm")
534 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000535 << ConvolutionLayer(
536 1U, 7U, std::get<3>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100537 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000538 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
539 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100540 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000541 << BatchNormalizationLayer(
542 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"),
543 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"),
544 get_random_accessor(1.f, 1.f),
545 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000546 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100547 .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm/batchnorm")
548 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000549 << ConvolutionLayer(
550 7U, 1U, std::get<4>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100551 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000552 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
553 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100554 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000555 << BatchNormalizationLayer(
556 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"),
557 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"),
558 get_random_accessor(1.f, 1.f),
559 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000560 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100561 .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm/batchnorm")
562 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000563
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000564 SubStream i_d(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100565 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 +0000566 << ConvolutionLayer(
567 1U, 1U, d_filt,
Georgios Pinitase2220552018-07-20 13:23:44 +0100568 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000569 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
570 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100571 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000572 << BatchNormalizationLayer(
573 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
574 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
575 get_random_accessor(1.f, 1.f),
576 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000577 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100578 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
579 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000580
581 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
582 }
583
Georgios Pinitase2220552018-07-20 13:23:44 +0100584 BranchLayer get_inception_node_D(const std::string &data_path, std::string &&param_path, DataLayout weights_layout,
585 std::tuple<unsigned int, unsigned int> a_filters,
Georgios Pinitas652bde52018-01-10 15:33:28 +0000586 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> b_filters)
587 {
588 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000589 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000590 i_a << ConvolutionLayer(
591 1U, 1U, std::get<0>(a_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100592 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000593 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
594 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100595 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000596 << BatchNormalizationLayer(
597 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
598 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
599 get_random_accessor(1.f, 1.f),
600 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000601 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100602 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
603 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000604 << ConvolutionLayer(
605 3U, 3U, std::get<1>(a_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100606 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000607 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
608 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100609 .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000610 << BatchNormalizationLayer(
611 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
612 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
613 get_random_accessor(1.f, 1.f),
614 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000615 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100616 .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/BatchNorm/batchnorm")
617 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000618
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000619 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000620 i_b << ConvolutionLayer(
621 1U, 1U, std::get<0>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100622 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000623 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
624 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100625 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000626 << BatchNormalizationLayer(
627 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
628 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
629 get_random_accessor(1.f, 1.f),
630 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000631 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100632 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
633 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000634 << ConvolutionLayer(
635 7U, 1U, std::get<1>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100636 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000637 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
638 PadStrideInfo(1, 1, 3, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100639 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000640 << BatchNormalizationLayer(
641 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"),
642 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"),
643 get_random_accessor(1.f, 1.f),
644 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000645 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100646 .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm")
647 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000648 << ConvolutionLayer(
649 1U, 7U, std::get<2>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100650 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000651 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
652 PadStrideInfo(1, 1, 0, 3))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100653 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000654 << BatchNormalizationLayer(
655 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"),
656 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"),
657 get_random_accessor(1.f, 1.f),
658 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000659 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100660 .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm")
661 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000662 << ConvolutionLayer(
663 3U, 3U, std::get<3>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100664 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000665 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
666 PadStrideInfo(2, 2, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100667 .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000668 << BatchNormalizationLayer(
669 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"),
670 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"),
671 get_random_accessor(1.f, 1.f),
672 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000673 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100674 .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/BatchNorm/batchnorm")
675 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000676
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000677 SubStream i_c(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100678 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 +0000679
680 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c));
681 }
682
Georgios Pinitase2220552018-07-20 13:23:44 +0100683 BranchLayer get_inception_node_E(const std::string &data_path, std::string &&param_path, DataLayout weights_layout,
Georgios Pinitas652bde52018-01-10 15:33:28 +0000684 unsigned int a_filt,
685 std::tuple<unsigned int, unsigned int, unsigned int> b_filters,
686 std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> c_filters,
687 unsigned int d_filt,
688 bool is_name_different = false)
689 {
690 // This is due to a naming issue in the tf model
691 std::string conv_id = "_0b_";
692 if(is_name_different)
693 {
694 conv_id = "_0c_";
695 }
696
697 std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_";
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000698 SubStream i_a(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000699 i_a << ConvolutionLayer(
700 1U, 1U, a_filt,
Georgios Pinitase2220552018-07-20 13:23:44 +0100701 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000702 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
703 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100704 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000705 << BatchNormalizationLayer(
706 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
707 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
708 get_random_accessor(1.f, 1.f),
709 get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000710 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100711 .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm")
712 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000713
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000714 SubStream i_b(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000715 i_b << ConvolutionLayer(
716 1U, 1U, std::get<0>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100717 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000718 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
719 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100720 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000721 << BatchNormalizationLayer(
722 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
723 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
724 get_random_accessor(1.f, 1.f),
725 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000726 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100727 .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm")
728 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000729
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100730 SubStream i_b1(i_b);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000731 i_b1 << ConvolutionLayer(
732 3U, 1U, std::get<1>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100733 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000734 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
735 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100736 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000737 << BatchNormalizationLayer(
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000738 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"),
739 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000740 get_random_accessor(1.f, 1.f),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000741 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"),
742 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100743 .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm/batchnorm")
744 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000745
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100746 SubStream i_b2(i_b);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000747 i_b2 << ConvolutionLayer(
748 1U, 3U, std::get<2>(b_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100749 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000750 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
751 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100752 .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000753 << BatchNormalizationLayer(
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000754 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_mean.npy"),
755 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_variance.npy"),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000756 get_random_accessor(1.f, 1.f),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000757 get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_beta.npy"),
758 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100759 .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/BatchNorm/batchnorm")
760 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000761
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000762 // Merge b1 and b2
Georgios Pinitas130986a2018-05-14 19:25:37 +0100763 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 +0000764
765 SubStream i_c(graph);
Georgios Pinitas652bde52018-01-10 15:33:28 +0000766 i_c << ConvolutionLayer(
767 1U, 1U, std::get<0>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100768 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000769 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
770 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100771 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000772 << BatchNormalizationLayer(
773 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"),
774 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"),
775 get_random_accessor(1.f, 1.f),
776 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000777 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100778 .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm")
779 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000780 << ConvolutionLayer(
781 3U, 3U, std::get<1>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100782 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000783 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
784 PadStrideInfo(1, 1, 1, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100785 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000786 << BatchNormalizationLayer(
787 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"),
788 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"),
789 get_random_accessor(1.f, 1.f),
790 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000791 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100792 .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm")
793 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000794
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100795 SubStream i_c1(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000796 i_c1 << ConvolutionLayer(
797 3U, 1U, std::get<2>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100798 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000799 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
800 PadStrideInfo(1, 1, 1, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100801 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/convolution")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000802 << BatchNormalizationLayer(
803 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"),
804 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"),
805 get_random_accessor(1.f, 1.f),
806 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"),
807 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100808 .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm/batchnorm")
809 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000810
Georgios Pinitas772e17f2018-07-13 12:25:33 +0100811 SubStream i_c2(i_c);
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000812 i_c2 << ConvolutionLayer(
813 1U, 3U, std::get<3>(c_filters),
Georgios Pinitase2220552018-07-20 13:23:44 +0100814 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_weights.npy", weights_layout),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000815 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
816 PadStrideInfo(1, 1, 0, 1))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100817 .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/convolution")
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000818 << BatchNormalizationLayer(
819 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_mean.npy"),
820 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_variance.npy"),
821 get_random_accessor(1.f, 1.f),
822 get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_beta.npy"),
823 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100824 .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/BatchNorm/batchnorm")
825 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_3x1/Relu");
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000826
827 // Merge i_c1 and i_c2
Georgios Pinitas130986a2018-05-14 19:25:37 +0100828 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 +0000829
830 SubStream i_d(graph);
Georgios Pinitas130986a2018-05-14 19:25:37 +0100831 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 +0000832 << ConvolutionLayer(
833 1U, 1U, d_filt,
Georgios Pinitase2220552018-07-20 13:23:44 +0100834 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout),
Georgios Pinitas652bde52018-01-10 15:33:28 +0000835 std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr),
836 PadStrideInfo(1, 1, 0, 0))
Georgios Pinitas130986a2018-05-14 19:25:37 +0100837 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution")
Georgios Pinitas652bde52018-01-10 15:33:28 +0000838 << BatchNormalizationLayer(
839 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"),
840 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"),
841 get_random_accessor(1.f, 1.f),
842 get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"),
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000843 0.001f)
Georgios Pinitas130986a2018-05-14 19:25:37 +0100844 .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm")
845 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu");
Georgios Pinitas652bde52018-01-10 15:33:28 +0000846
847 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
848 }
849};
850
851/** Main program for Inception V3
852 *
Georgios Pinitas9f28b392018-07-18 20:01:53 +0100853 * @note To list all the possible arguments execute the binary appended with the --help option
854 *
Georgios Pinitas652bde52018-01-10 15:33:28 +0000855 * @param[in] argc Number of arguments
Georgios Pinitas12be7ab2018-07-03 12:06:23 +0100856 * @param[in] argv Arguments
Georgios Pinitas652bde52018-01-10 15:33:28 +0000857 */
858int main(int argc, char **argv)
859{
860 return arm_compute::utils::run_example<InceptionV3Example>(argc, argv);
861}