Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 1 | /* |
| 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 Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 24 | #include "arm_compute/graph.h" |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 25 | #include "support/ToolchainSupport.h" |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 26 | #include "utils/CommonGraphOptions.h" |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 27 | #include "utils/GraphUtils.h" |
| 28 | #include "utils/Utils.h" |
| 29 | |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 30 | using namespace arm_compute::utils; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 31 | using namespace arm_compute::graph::frontend; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 32 | using 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 Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 37 | * @param[in] argv Arguments |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 38 | */ |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 39 | class InceptionV3Example : public Example |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 40 | { |
| 41 | public: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 42 | InceptionV3Example() |
| 43 | : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "InceptionV3") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 44 | { |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 45 | } |
| 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 | |
Georgios Pinitas | 415a2bf | 2018-07-30 12:05:25 +0100 | [diff] [blame] | 61 | // Set default layout if needed |
| 62 | if(!common_opts.data_layout->is_set() && common_params.target == Target::NEON) |
| 63 | { |
| 64 | common_params.data_layout = DataLayout::NCHW; |
| 65 | } |
| 66 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 67 | // Checks |
Anthony Barbier | cdd68c0 | 2018-08-23 15:03:41 +0100 | [diff] [blame] | 68 | ARM_COMPUTE_EXIT_ON_MSG(arm_compute::is_data_type_quantized_asymmetric(common_params.data_type), "QASYMM8 not supported for this graph"); |
| 69 | ARM_COMPUTE_EXIT_ON_MSG(common_params.data_type == DataType::F16 && common_params.target == Target::NEON, "F16 NEON not supported for this graph"); |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 70 | |
| 71 | // Print parameter values |
| 72 | std::cout << common_params << std::endl; |
| 73 | |
| 74 | // Get trainable parameters data path |
| 75 | std::string data_path = common_params.data_path; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 76 | |
Georgios Pinitas | 140fdc7 | 2018-02-16 11:42:38 +0000 | [diff] [blame] | 77 | // Create a preprocessor object |
| 78 | std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>(); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 79 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 80 | // Create input descriptor |
| 81 | const TensorShape tensor_shape = permute_shape(TensorShape(299U, 299U, 3U, 1U), DataLayout::NCHW, common_params.data_layout); |
| 82 | TensorDescriptor input_descriptor = TensorDescriptor(tensor_shape, common_params.data_type).set_layout(common_params.data_layout); |
| 83 | |
| 84 | // Set weights trained layout |
| 85 | const DataLayout weights_layout = DataLayout::NCHW; |
| 86 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 87 | graph << common_params.target |
| 88 | << common_params.fast_math_hint |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 89 | << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false)) |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 90 | << ConvolutionLayer(3U, 3U, 32U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 91 | get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 92 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 93 | .set_name("Conv2d_1a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 94 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 95 | "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 96 | get_weights_accessor(data_path, |
| 97 | "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 98 | get_random_accessor(1.f, 1.f), get_weights_accessor(data_path, |
| 99 | "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 100 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 101 | .set_name("Conv2d_1a_3x3/BatchNorm/batchnorm") |
| 102 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 103 | << ConvolutionLayer(3U, 3U, 32U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 104 | get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 105 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 106 | .set_name("Conv2d_2a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 107 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 108 | "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"), |
| 109 | get_weights_accessor(data_path, |
| 110 | "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"), |
| 111 | get_random_accessor(1.f, 1.f), get_weights_accessor(data_path, |
| 112 | "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 113 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 114 | .set_name("Conv2d_2a_3x3/BatchNorm/batchnorm") |
| 115 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 116 | |
| 117 | << ConvolutionLayer(3U, 3U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 118 | get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 119 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 120 | .set_name("Conv2d_2b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 121 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 122 | "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"), |
| 123 | get_weights_accessor(data_path, |
| 124 | "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"), |
| 125 | get_random_accessor(1.f, 1.f), get_weights_accessor(data_path, |
| 126 | "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 127 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 128 | .set_name("Conv2d_2b_3x3/BatchNorm/batchnorm") |
| 129 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 130 | |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 131 | << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name("MaxPool_3a_3x3/MaxPool") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 132 | |
| 133 | << ConvolutionLayer(1U, 1U, 80U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 134 | get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 135 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 136 | .set_name("Conv2d_3b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 137 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 138 | "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_mean.npy"), |
| 139 | get_weights_accessor(data_path, |
| 140 | "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_variance.npy"), |
| 141 | get_random_accessor(1.f, 1.f), get_weights_accessor(data_path, |
| 142 | "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 143 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 144 | .set_name("Conv2d_3b_1x1/BatchNorm/batchnorm") |
| 145 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_3b_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 146 | |
| 147 | << ConvolutionLayer(3U, 3U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 148 | get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 149 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 150 | .set_name("Conv2d_4a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 151 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 152 | "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_mean.npy"), |
| 153 | get_weights_accessor(data_path, |
| 154 | "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_variance.npy"), |
| 155 | get_random_accessor(1.f, 1.f), get_weights_accessor(data_path, |
| 156 | "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 157 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 158 | .set_name("Conv2d_4a_3x3/BatchNorm/batchnorm") |
| 159 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_4a_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 160 | |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 161 | << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))).set_name("MaxPool_5a_3x3/MaxPool"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 162 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 163 | graph << get_inception_node_A(data_path, "Mixed_5b", weights_layout, 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 164 | 32U) |
| 165 | .set_name("Mixed_5b/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 166 | graph << get_inception_node_A(data_path, "Mixed_5c", weights_layout, 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 167 | 64U, true) |
| 168 | .set_name("Mixed_5c/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 169 | graph << get_inception_node_A(data_path, "Mixed_5d", weights_layout, 64U, std::make_tuple(48U, 64U), std::make_tuple(64U, 96U, 96U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 170 | 64U) |
| 171 | .set_name("Mixed_5d/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 172 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 173 | graph << get_inception_node_B(data_path, "Mixed_6a", weights_layout, 384U, std::make_tuple(64U, 96U, 96U)).set_name("Mixed_6a/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 174 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 175 | graph << get_inception_node_C(data_path, "Mixed_6b", weights_layout, 192U, std::make_tuple(128U, 128U, 192U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 176 | std::make_tuple(128U, 128U, 128U, 128U, 192U), 192U) |
| 177 | .set_name("Mixed_6b/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 178 | graph << get_inception_node_C(data_path, "Mixed_6c", weights_layout, 192U, std::make_tuple(160U, 160U, 192U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 179 | std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U) |
| 180 | .set_name("Mixed_6c/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 181 | graph << get_inception_node_C(data_path, "Mixed_6d", weights_layout, 192U, std::make_tuple(160U, 160U, 192U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 182 | std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U) |
| 183 | .set_name("Mixed_6d/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 184 | graph << get_inception_node_C(data_path, "Mixed_6e", weights_layout, 192U, std::make_tuple(192U, 192U, 192U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 185 | std::make_tuple(192U, 192U, 192U, 192U, 192U), 192U) |
| 186 | .set_name("Mixed_6e/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 187 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 188 | graph << get_inception_node_D(data_path, "Mixed_7a", weights_layout, std::make_tuple(192U, 320U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 189 | std::make_tuple(192U, 192U, 192U, 192U)) |
| 190 | .set_name("Mixed_7a/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 191 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 192 | graph << get_inception_node_E(data_path, "Mixed_7b", weights_layout, 320U, std::make_tuple(384U, 384U, 384U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 193 | std::make_tuple(448U, 384U, 384U, 384U), 192U) |
| 194 | .set_name("Mixed_7b/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 195 | graph << get_inception_node_E(data_path, "Mixed_7c", weights_layout, 320U, std::make_tuple(384U, 384U, 384U), |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 196 | std::make_tuple(448U, 384U, 384U, 384U), 192U, true) |
| 197 | .set_name("Mixed_7c/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 198 | |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 199 | graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 8, PadStrideInfo(1, 1, 0, 0, DimensionRoundingType::CEIL))).set_name("Logits/AvgPool_1a_8x8/AvgPool") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 200 | << ConvolutionLayer(1U, 1U, 1001U, get_weights_accessor(data_path, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 201 | "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 202 | get_weights_accessor(data_path, |
| 203 | "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_biases.npy"), |
| 204 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 205 | .set_name("Logits/Conv2d_1c_1x1/convolution") |
| 206 | << ReshapeLayer(TensorShape(1001U)).set_name("Predictions/Reshape") |
| 207 | << SoftmaxLayer().set_name("Predictions/Softmax") |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 208 | << OutputLayer(get_output_accessor(common_params, 5)); |
Gian Marco | c1b6e37 | 2018-02-21 18:03:26 +0000 | [diff] [blame] | 209 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 210 | // Finalize graph |
Georgios Pinitas | 9a8c672 | 2018-03-21 17:52:35 +0000 | [diff] [blame] | 211 | GraphConfig config; |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 212 | config.num_threads = common_params.threads; |
| 213 | config.use_tuner = common_params.enable_tuner; |
Anthony Barbier | 7b607dc | 2018-07-13 15:55:24 +0100 | [diff] [blame] | 214 | config.tuner_file = common_params.tuner_file; |
| 215 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 216 | graph.finalize(common_params.target, config); |
| 217 | |
| 218 | return true; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | void do_run() override |
| 222 | { |
| 223 | graph.run(); |
| 224 | } |
| 225 | |
| 226 | private: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 227 | CommandLineParser cmd_parser; |
| 228 | CommonGraphOptions common_opts; |
| 229 | CommonGraphParams common_params; |
| 230 | Stream graph; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 231 | |
| 232 | private: |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 233 | ConcatLayer get_inception_node_A(const std::string &data_path, std::string &¶m_path, DataLayout weights_layout, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 234 | unsigned int a_filt, |
| 235 | std::tuple<unsigned int, unsigned int> b_filters, |
| 236 | std::tuple<unsigned int, unsigned int, unsigned int> c_filters, |
| 237 | unsigned int d_filt, |
| 238 | bool is_name_different = false) |
| 239 | { |
| 240 | std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_"; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 241 | |
| 242 | // This is due to a naming issue in the tf model |
| 243 | std::string conv_id0 = "_0a_"; |
| 244 | std::string conv_id1 = "2d_0b_"; |
| 245 | if(is_name_different) |
| 246 | { |
| 247 | conv_id0 = "_0b_"; |
| 248 | conv_id1 = "_1_0c_"; |
| 249 | } |
| 250 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 251 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 252 | i_a << ConvolutionLayer( |
| 253 | 1U, 1U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 254 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 255 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 256 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 257 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 258 | << BatchNormalizationLayer( |
| 259 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 260 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 261 | get_random_accessor(1.f, 1.f), |
| 262 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 263 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 264 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 265 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 266 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 267 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 268 | i_b << ConvolutionLayer( |
| 269 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 270 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 271 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 272 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 273 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 274 | << BatchNormalizationLayer( |
| 275 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_mean.npy"), |
| 276 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_variance.npy"), |
| 277 | get_random_accessor(1.f, 1.f), |
| 278 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 279 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 280 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/BatchNorm/batchnorm") |
| 281 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 282 | << ConvolutionLayer( |
| 283 | 5U, 5U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 284 | get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 285 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 286 | PadStrideInfo(1, 1, 2, 2)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 287 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 288 | << BatchNormalizationLayer( |
| 289 | get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_mean.npy"), |
| 290 | get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_variance.npy"), |
| 291 | get_random_accessor(1.f, 1.f), |
| 292 | get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 293 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 294 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/BatchNorm/batchnorm") |
| 295 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 296 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 297 | SubStream i_c(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 298 | i_c << ConvolutionLayer( |
| 299 | 1U, 1U, std::get<0>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 300 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 301 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 302 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 303 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 304 | << BatchNormalizationLayer( |
| 305 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 306 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 307 | get_random_accessor(1.f, 1.f), |
| 308 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 309 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 310 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 311 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 312 | << ConvolutionLayer( |
| 313 | 3U, 3U, std::get<1>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 314 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 315 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 316 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 317 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 318 | << BatchNormalizationLayer( |
| 319 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 320 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 321 | get_random_accessor(1.f, 1.f), |
| 322 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 323 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 324 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm") |
| 325 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 326 | << ConvolutionLayer( |
| 327 | 3U, 3U, std::get<2>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 328 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 329 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 330 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 331 | .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 332 | << BatchNormalizationLayer( |
| 333 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"), |
| 334 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"), |
| 335 | get_random_accessor(1.f, 1.f), |
| 336 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 337 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 338 | .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm/batcnorm") |
| 339 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 340 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 341 | SubStream i_d(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 342 | 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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 343 | << ConvolutionLayer( |
| 344 | 1U, 1U, d_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 345 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 346 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 347 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 348 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 349 | << BatchNormalizationLayer( |
| 350 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 351 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 352 | get_random_accessor(1.f, 1.f), |
| 353 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 354 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 355 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm") |
| 356 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 357 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 358 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 359 | } |
| 360 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 361 | ConcatLayer get_inception_node_B(const std::string &data_path, std::string &¶m_path, DataLayout weights_layout, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 362 | unsigned int a_filt, |
| 363 | std::tuple<unsigned int, unsigned int, unsigned int> b_filters) |
| 364 | { |
| 365 | std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_"; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 366 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 367 | i_a << ConvolutionLayer( |
| 368 | 3U, 3U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 369 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 370 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 371 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 372 | .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 373 | << BatchNormalizationLayer( |
| 374 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"), |
| 375 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"), |
| 376 | get_random_accessor(1.f, 1.f), |
| 377 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 378 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 379 | .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/BatchNorm/batchnorm") |
| 380 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_1x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 381 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 382 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 383 | i_b << ConvolutionLayer( |
| 384 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 385 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 386 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 387 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 388 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 389 | << BatchNormalizationLayer( |
| 390 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 391 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 392 | get_random_accessor(1.f, 1.f), |
| 393 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 394 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 395 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 396 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 397 | << ConvolutionLayer( |
| 398 | 3U, 3U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 399 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 400 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 401 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 402 | .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 403 | << BatchNormalizationLayer( |
| 404 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 405 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 406 | get_random_accessor(1.f, 1.f), |
| 407 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 408 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 409 | .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm/batchnorm") |
| 410 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 411 | << ConvolutionLayer( |
| 412 | 3U, 3U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 413 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 414 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 415 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 416 | .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 417 | << BatchNormalizationLayer( |
| 418 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_mean.npy"), |
| 419 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_moving_variance.npy"), |
| 420 | get_random_accessor(1.f, 1.f), |
| 421 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 422 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 423 | .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/BatchNorm/batchnorm") |
| 424 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_1x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 425 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 426 | SubStream i_c(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 427 | 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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 428 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 429 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c)); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 430 | } |
| 431 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 432 | ConcatLayer get_inception_node_C(const std::string &data_path, std::string &¶m_path, DataLayout weights_layout, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 433 | unsigned int a_filt, |
| 434 | std::tuple<unsigned int, unsigned int, unsigned int> b_filters, |
| 435 | std::tuple<unsigned int, unsigned int, unsigned int, unsigned int, unsigned int> c_filters, |
| 436 | unsigned int d_filt) |
| 437 | { |
| 438 | std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_"; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 439 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 440 | i_a << ConvolutionLayer( |
| 441 | 1U, 1U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 442 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 443 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 444 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 445 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 446 | << BatchNormalizationLayer( |
| 447 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 448 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 449 | get_random_accessor(1.f, 1.f), |
| 450 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 451 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 452 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 453 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 454 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 455 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 456 | i_b << ConvolutionLayer( |
| 457 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 458 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 459 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 460 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 461 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 462 | << BatchNormalizationLayer( |
| 463 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 464 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 465 | get_random_accessor(1.f, 1.f), |
| 466 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 467 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 468 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 469 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 470 | << ConvolutionLayer( |
| 471 | 7U, 1U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 472 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 473 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 474 | PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 475 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 476 | << BatchNormalizationLayer( |
| 477 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 478 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 479 | get_random_accessor(1.f, 1.f), |
| 480 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 481 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 482 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm") |
| 483 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 484 | << ConvolutionLayer( |
| 485 | 1U, 7U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 486 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 487 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 488 | PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 489 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 490 | << BatchNormalizationLayer( |
| 491 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 492 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 493 | get_random_accessor(1.f, 1.f), |
| 494 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 495 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 496 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm") |
| 497 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0c_7x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 498 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 499 | SubStream i_c(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 500 | i_c << ConvolutionLayer( |
| 501 | 1U, 1U, std::get<0>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 502 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 503 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 504 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 505 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 506 | << BatchNormalizationLayer( |
| 507 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 508 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 509 | get_random_accessor(1.f, 1.f), |
| 510 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 511 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 512 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 513 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 514 | << ConvolutionLayer( |
| 515 | 1U, 7U, std::get<1>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 516 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 517 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 518 | PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 519 | .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 520 | << BatchNormalizationLayer( |
| 521 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"), |
| 522 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"), |
| 523 | get_random_accessor(1.f, 1.f), |
| 524 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 525 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 526 | .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm/batchnorm") |
| 527 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 528 | << ConvolutionLayer( |
| 529 | 7U, 1U, std::get<2>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 530 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 531 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 532 | PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 533 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 534 | << BatchNormalizationLayer( |
| 535 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"), |
| 536 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"), |
| 537 | get_random_accessor(1.f, 1.f), |
| 538 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 539 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 540 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm/batchnorm") |
| 541 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 542 | << ConvolutionLayer( |
| 543 | 1U, 7U, std::get<3>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 544 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 545 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 546 | PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 547 | .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 548 | << BatchNormalizationLayer( |
| 549 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"), |
| 550 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"), |
| 551 | get_random_accessor(1.f, 1.f), |
| 552 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 553 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 554 | .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm/batchnorm") |
| 555 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 556 | << ConvolutionLayer( |
| 557 | 7U, 1U, std::get<4>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 558 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 559 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 560 | PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 561 | .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 562 | << BatchNormalizationLayer( |
| 563 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"), |
| 564 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"), |
| 565 | get_random_accessor(1.f, 1.f), |
| 566 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 567 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 568 | .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm/batchnorm") |
| 569 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 570 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 571 | SubStream i_d(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 572 | 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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 573 | << ConvolutionLayer( |
| 574 | 1U, 1U, d_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 575 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 576 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 577 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 578 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 579 | << BatchNormalizationLayer( |
| 580 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 581 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 582 | get_random_accessor(1.f, 1.f), |
| 583 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 584 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 585 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm") |
| 586 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 587 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 588 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 591 | ConcatLayer get_inception_node_D(const std::string &data_path, std::string &¶m_path, DataLayout weights_layout, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 592 | std::tuple<unsigned int, unsigned int> a_filters, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 593 | std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> b_filters) |
| 594 | { |
| 595 | std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_"; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 596 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 597 | i_a << ConvolutionLayer( |
| 598 | 1U, 1U, std::get<0>(a_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 599 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 600 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 601 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 602 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 603 | << BatchNormalizationLayer( |
| 604 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 605 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 606 | get_random_accessor(1.f, 1.f), |
| 607 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 608 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 609 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 610 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 611 | << ConvolutionLayer( |
| 612 | 3U, 3U, std::get<1>(a_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 613 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 614 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 615 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 616 | .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 617 | << BatchNormalizationLayer( |
| 618 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 619 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 620 | get_random_accessor(1.f, 1.f), |
| 621 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 622 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 623 | .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/BatchNorm/batchnorm") |
| 624 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 625 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 626 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 627 | i_b << ConvolutionLayer( |
| 628 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 629 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 630 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 631 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 632 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 633 | << BatchNormalizationLayer( |
| 634 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 635 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 636 | get_random_accessor(1.f, 1.f), |
| 637 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 638 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 639 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 640 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 641 | << ConvolutionLayer( |
| 642 | 7U, 1U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 643 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 644 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 645 | PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 646 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 647 | << BatchNormalizationLayer( |
| 648 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 649 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 650 | get_random_accessor(1.f, 1.f), |
| 651 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 652 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 653 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm") |
| 654 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 655 | << ConvolutionLayer( |
| 656 | 1U, 7U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 657 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 658 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 659 | PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 660 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 661 | << BatchNormalizationLayer( |
| 662 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 663 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 664 | get_random_accessor(1.f, 1.f), |
| 665 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 666 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 667 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm") |
| 668 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 669 | << ConvolutionLayer( |
| 670 | 3U, 3U, std::get<3>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 671 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 672 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 673 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 674 | .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 675 | << BatchNormalizationLayer( |
| 676 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 677 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 678 | get_random_accessor(1.f, 1.f), |
| 679 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 680 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 681 | .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/BatchNorm/batchnorm") |
| 682 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 683 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 684 | SubStream i_c(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 685 | 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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 686 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 687 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c)); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 688 | } |
| 689 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 690 | ConcatLayer get_inception_node_E(const std::string &data_path, std::string &¶m_path, DataLayout weights_layout, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 691 | unsigned int a_filt, |
| 692 | std::tuple<unsigned int, unsigned int, unsigned int> b_filters, |
| 693 | std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> c_filters, |
| 694 | unsigned int d_filt, |
| 695 | bool is_name_different = false) |
| 696 | { |
| 697 | // This is due to a naming issue in the tf model |
| 698 | std::string conv_id = "_0b_"; |
| 699 | if(is_name_different) |
| 700 | { |
| 701 | conv_id = "_0c_"; |
| 702 | } |
| 703 | |
| 704 | std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_"; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 705 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 706 | i_a << ConvolutionLayer( |
| 707 | 1U, 1U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 708 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 709 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 710 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 711 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 712 | << BatchNormalizationLayer( |
| 713 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 714 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 715 | get_random_accessor(1.f, 1.f), |
| 716 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 717 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 718 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 719 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 720 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 721 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 722 | i_b << ConvolutionLayer( |
| 723 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 724 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 725 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 726 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 727 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 728 | << BatchNormalizationLayer( |
| 729 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 730 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 731 | get_random_accessor(1.f, 1.f), |
| 732 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 733 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 734 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 735 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 736 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 737 | SubStream i_b1(i_b); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 738 | i_b1 << ConvolutionLayer( |
| 739 | 3U, 1U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 740 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 741 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 742 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 743 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 744 | << BatchNormalizationLayer( |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 745 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"), |
| 746 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 747 | get_random_accessor(1.f, 1.f), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 748 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"), |
| 749 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 750 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm/batchnorm") |
| 751 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 752 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 753 | SubStream i_b2(i_b); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 754 | i_b2 << ConvolutionLayer( |
| 755 | 1U, 3U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 756 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 757 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 758 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 759 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 760 | << BatchNormalizationLayer( |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 761 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_mean.npy"), |
| 762 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_variance.npy"), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 763 | get_random_accessor(1.f, 1.f), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 764 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_beta.npy"), |
| 765 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 766 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/BatchNorm/batchnorm") |
| 767 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 768 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 769 | // Merge b1 and b2 |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 770 | i_b << ConcatLayer(std::move(i_b1), std::move(i_b2)).set_name(param_path + "/Branch_1/concat"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 771 | |
| 772 | SubStream i_c(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 773 | i_c << ConvolutionLayer( |
| 774 | 1U, 1U, std::get<0>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 775 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 776 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 777 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 778 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 779 | << BatchNormalizationLayer( |
| 780 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 781 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 782 | get_random_accessor(1.f, 1.f), |
| 783 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 784 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 785 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 786 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 787 | << ConvolutionLayer( |
| 788 | 3U, 3U, std::get<1>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 789 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 790 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 791 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 792 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 793 | << BatchNormalizationLayer( |
| 794 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 795 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 796 | get_random_accessor(1.f, 1.f), |
| 797 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 798 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 799 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm") |
| 800 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 801 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 802 | SubStream i_c1(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 803 | i_c1 << ConvolutionLayer( |
| 804 | 3U, 1U, std::get<2>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 805 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 806 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 807 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 808 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/convolution") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 809 | << BatchNormalizationLayer( |
| 810 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"), |
| 811 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"), |
| 812 | get_random_accessor(1.f, 1.f), |
| 813 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"), |
| 814 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 815 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm/batchnorm") |
| 816 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 817 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 818 | SubStream i_c2(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 819 | i_c2 << ConvolutionLayer( |
| 820 | 1U, 3U, std::get<3>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 821 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_weights.npy", weights_layout), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 822 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 823 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 824 | .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/convolution") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 825 | << BatchNormalizationLayer( |
| 826 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_mean.npy"), |
| 827 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_variance.npy"), |
| 828 | get_random_accessor(1.f, 1.f), |
| 829 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_beta.npy"), |
| 830 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 831 | .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/BatchNorm/batchnorm") |
| 832 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_3x1/Relu"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 833 | |
| 834 | // Merge i_c1 and i_c2 |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 835 | i_c << ConcatLayer(std::move(i_c1), std::move(i_c2)).set_name(param_path + "/Branch_2/concat"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 836 | |
| 837 | SubStream i_d(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 838 | 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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 839 | << ConvolutionLayer( |
| 840 | 1U, 1U, d_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 841 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 842 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 843 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 844 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 845 | << BatchNormalizationLayer( |
| 846 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 847 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 848 | get_random_accessor(1.f, 1.f), |
| 849 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 850 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 851 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm") |
| 852 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 853 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 854 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 855 | } |
| 856 | }; |
| 857 | |
| 858 | /** Main program for Inception V3 |
| 859 | * |
Georgios Pinitas | 9f28b39 | 2018-07-18 20:01:53 +0100 | [diff] [blame] | 860 | * @note To list all the possible arguments execute the binary appended with the --help option |
| 861 | * |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 862 | * @param[in] argc Number of arguments |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 863 | * @param[in] argv Arguments |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 864 | */ |
| 865 | int main(int argc, char **argv) |
| 866 | { |
| 867 | return arm_compute::utils::run_example<InceptionV3Example>(argc, argv); |
| 868 | } |