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 | |
| 61 | // Checks |
Georgios Pinitas | 6ed43b5 | 2018-07-12 17:34:22 +0100 | [diff] [blame] | 62 | ARM_COMPUTE_EXIT_ON_MSG(arm_compute::is_data_type_quantized_asymmetric(common_params.data_type), "Unsupported data type!"); |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 63 | |
| 64 | // Print parameter values |
| 65 | std::cout << common_params << std::endl; |
| 66 | |
| 67 | // Get trainable parameters data path |
| 68 | std::string data_path = common_params.data_path; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 69 | |
Georgios Pinitas | 140fdc7 | 2018-02-16 11:42:38 +0000 | [diff] [blame] | 70 | // Create a preprocessor object |
| 71 | std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>(); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 72 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 73 | // 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 Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 80 | graph << common_params.target |
| 81 | << common_params.fast_math_hint |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 82 | << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false)) |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 83 | << ConvolutionLayer(3U, 3U, 32U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 84 | 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] | 85 | 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] | 86 | .set_name("Conv2d_1a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 87 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 93 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 94 | .set_name("Conv2d_1a_3x3/BatchNorm/batchnorm") |
| 95 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 96 | << ConvolutionLayer(3U, 3U, 32U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 97 | 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] | 98 | 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] | 99 | .set_name("Conv2d_2a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 100 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 106 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 107 | .set_name("Conv2d_2a_3x3/BatchNorm/batchnorm") |
| 108 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 109 | |
| 110 | << ConvolutionLayer(3U, 3U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 111 | 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] | 112 | 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] | 113 | .set_name("Conv2d_2b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 114 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 120 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 121 | .set_name("Conv2d_2b_3x3/BatchNorm/batchnorm") |
| 122 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 123 | |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 124 | << 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] | 125 | |
| 126 | << ConvolutionLayer(1U, 1U, 80U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 127 | 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] | 128 | 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] | 129 | .set_name("Conv2d_3b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 130 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 136 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 137 | .set_name("Conv2d_3b_1x1/BatchNorm/batchnorm") |
| 138 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_3b_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 139 | |
| 140 | << ConvolutionLayer(3U, 3U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 141 | 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] | 142 | 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] | 143 | .set_name("Conv2d_4a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 144 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 150 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 151 | .set_name("Conv2d_4a_3x3/BatchNorm/batchnorm") |
| 152 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_4a_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 153 | |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 154 | << 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] | 155 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 156 | 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] | 157 | 32U) |
| 158 | .set_name("Mixed_5b/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 159 | 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] | 160 | 64U, true) |
| 161 | .set_name("Mixed_5c/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 162 | 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] | 163 | 64U) |
| 164 | .set_name("Mixed_5d/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 165 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 166 | 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] | 167 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 168 | 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] | 169 | std::make_tuple(128U, 128U, 128U, 128U, 192U), 192U) |
| 170 | .set_name("Mixed_6b/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 171 | 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] | 172 | std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U) |
| 173 | .set_name("Mixed_6c/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 174 | 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] | 175 | std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U) |
| 176 | .set_name("Mixed_6d/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 177 | 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] | 178 | std::make_tuple(192U, 192U, 192U, 192U, 192U), 192U) |
| 179 | .set_name("Mixed_6e/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 180 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 181 | 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] | 182 | std::make_tuple(192U, 192U, 192U, 192U)) |
| 183 | .set_name("Mixed_7a/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 184 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 185 | 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] | 186 | std::make_tuple(448U, 384U, 384U, 384U), 192U) |
| 187 | .set_name("Mixed_7b/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 188 | 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] | 189 | std::make_tuple(448U, 384U, 384U, 384U), 192U, true) |
| 190 | .set_name("Mixed_7c/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 191 | |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 192 | 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] | 193 | << ConvolutionLayer(1U, 1U, 1001U, get_weights_accessor(data_path, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 194 | "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 195 | get_weights_accessor(data_path, |
| 196 | "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_biases.npy"), |
| 197 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 198 | .set_name("Logits/Conv2d_1c_1x1/convolution") |
| 199 | << ReshapeLayer(TensorShape(1001U)).set_name("Predictions/Reshape") |
| 200 | << SoftmaxLayer().set_name("Predictions/Softmax") |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 201 | << OutputLayer(get_output_accessor(common_params, 5)); |
Gian Marco | c1b6e37 | 2018-02-21 18:03:26 +0000 | [diff] [blame] | 202 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 203 | // Finalize graph |
Georgios Pinitas | 9a8c672 | 2018-03-21 17:52:35 +0000 | [diff] [blame] | 204 | GraphConfig config; |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 205 | config.num_threads = common_params.threads; |
| 206 | config.use_tuner = common_params.enable_tuner; |
Anthony Barbier | 7b607dc | 2018-07-13 15:55:24 +0100 | [diff] [blame] | 207 | config.tuner_file = common_params.tuner_file; |
| 208 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 209 | graph.finalize(common_params.target, config); |
| 210 | |
| 211 | return true; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | void do_run() override |
| 215 | { |
| 216 | graph.run(); |
| 217 | } |
| 218 | |
| 219 | private: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 220 | CommandLineParser cmd_parser; |
| 221 | CommonGraphOptions common_opts; |
| 222 | CommonGraphParams common_params; |
| 223 | Stream graph; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 224 | |
| 225 | private: |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 226 | BranchLayer 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] | 227 | 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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 234 | |
| 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 244 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 245 | i_a << ConvolutionLayer( |
| 246 | 1U, 1U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 247 | 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] | 248 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 249 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 250 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 251 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 256 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 257 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 259 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 260 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 261 | i_b << ConvolutionLayer( |
| 262 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 263 | 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] | 264 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 265 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 266 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 267 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 272 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 273 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 275 | << ConvolutionLayer( |
| 276 | 5U, 5U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 277 | 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] | 278 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 279 | PadStrideInfo(1, 1, 2, 2)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 280 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 281 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 286 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 287 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 289 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 290 | SubStream i_c(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 291 | i_c << ConvolutionLayer( |
| 292 | 1U, 1U, std::get<0>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 293 | 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] | 294 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 295 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 296 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 297 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 302 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 303 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 305 | << ConvolutionLayer( |
| 306 | 3U, 3U, std::get<1>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 307 | 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] | 308 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 309 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 310 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 311 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 316 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 317 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 319 | << ConvolutionLayer( |
| 320 | 3U, 3U, std::get<2>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 321 | 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] | 322 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 323 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 324 | .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 325 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 330 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 331 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 333 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 334 | SubStream i_d(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 335 | 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] | 336 | << ConvolutionLayer( |
| 337 | 1U, 1U, d_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 338 | 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] | 339 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 340 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 341 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 342 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 347 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 348 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 350 | |
| 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 Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 354 | BranchLayer 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] | 355 | 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 359 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 360 | i_a << ConvolutionLayer( |
| 361 | 3U, 3U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 362 | 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] | 363 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 364 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 365 | .set_name(param_path + "/Branch_0/Conv2d_1a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 366 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 371 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 372 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 374 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 375 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 376 | i_b << ConvolutionLayer( |
| 377 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 378 | 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] | 379 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 380 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 381 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 382 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 387 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 388 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 390 | << ConvolutionLayer( |
| 391 | 3U, 3U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 392 | 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] | 393 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 394 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 395 | .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 396 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 401 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 402 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 404 | << ConvolutionLayer( |
| 405 | 3U, 3U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 406 | 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] | 407 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 408 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 409 | .set_name(param_path + "/Branch_1/Conv2d_1a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 410 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 415 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 416 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 418 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 419 | SubStream i_c(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 420 | 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] | 421 | |
| 422 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c)); |
| 423 | } |
| 424 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 425 | BranchLayer 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] | 426 | 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 432 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 433 | i_a << ConvolutionLayer( |
| 434 | 1U, 1U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 435 | 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] | 436 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 437 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 438 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 439 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 444 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 445 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 447 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 448 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 449 | i_b << ConvolutionLayer( |
| 450 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 451 | 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] | 452 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 453 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 454 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 455 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 460 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 461 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 463 | << ConvolutionLayer( |
| 464 | 7U, 1U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 465 | 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] | 466 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 467 | PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 468 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 469 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 474 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 475 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 477 | << ConvolutionLayer( |
| 478 | 1U, 7U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 479 | 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] | 480 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 481 | PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 482 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 483 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 488 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 489 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 491 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 492 | SubStream i_c(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 493 | i_c << ConvolutionLayer( |
| 494 | 1U, 1U, std::get<0>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 495 | 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] | 496 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 497 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 498 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 499 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 504 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 505 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 507 | << ConvolutionLayer( |
| 508 | 1U, 7U, std::get<1>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 509 | 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] | 510 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 511 | PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 512 | .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 513 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 518 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 519 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 521 | << ConvolutionLayer( |
| 522 | 7U, 1U, std::get<2>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 523 | 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] | 524 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 525 | PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 526 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 527 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 532 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 533 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 535 | << ConvolutionLayer( |
| 536 | 1U, 7U, std::get<3>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 537 | 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] | 538 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 539 | PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 540 | .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 541 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 546 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 547 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 549 | << ConvolutionLayer( |
| 550 | 7U, 1U, std::get<4>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 551 | 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] | 552 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 553 | PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 554 | .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 555 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 560 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 561 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 563 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 564 | SubStream i_d(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 565 | 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] | 566 | << ConvolutionLayer( |
| 567 | 1U, 1U, d_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 568 | 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] | 569 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 570 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 571 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 572 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 577 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 578 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 580 | |
| 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 Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 584 | BranchLayer get_inception_node_D(const std::string &data_path, std::string &¶m_path, DataLayout weights_layout, |
| 585 | std::tuple<unsigned int, unsigned int> a_filters, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 586 | 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 589 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 590 | i_a << ConvolutionLayer( |
| 591 | 1U, 1U, std::get<0>(a_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 592 | 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] | 593 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 594 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 595 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 596 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 601 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 602 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 604 | << ConvolutionLayer( |
| 605 | 3U, 3U, std::get<1>(a_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 606 | 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] | 607 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 608 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 609 | .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 610 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 615 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 616 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 618 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 619 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 620 | i_b << ConvolutionLayer( |
| 621 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 622 | 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] | 623 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 624 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 625 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 626 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 631 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 632 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 634 | << ConvolutionLayer( |
| 635 | 7U, 1U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 636 | 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] | 637 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 638 | PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 639 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 640 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 645 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 646 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 648 | << ConvolutionLayer( |
| 649 | 1U, 7U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 650 | 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] | 651 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 652 | PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 653 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 654 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 659 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 660 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 662 | << ConvolutionLayer( |
| 663 | 3U, 3U, std::get<3>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 664 | 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] | 665 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 666 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 667 | .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 668 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 673 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 674 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 676 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 677 | SubStream i_c(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 678 | 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] | 679 | |
| 680 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c)); |
| 681 | } |
| 682 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 683 | BranchLayer 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] | 684 | 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 698 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 699 | i_a << ConvolutionLayer( |
| 700 | 1U, 1U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 701 | 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] | 702 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 703 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 704 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 705 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 710 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 711 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 713 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 714 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 715 | i_b << ConvolutionLayer( |
| 716 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 717 | 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] | 718 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 719 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 720 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 721 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 726 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 727 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 729 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 730 | SubStream i_b1(i_b); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 731 | i_b1 << ConvolutionLayer( |
| 732 | 3U, 1U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 733 | 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] | 734 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 735 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 736 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 737 | << BatchNormalizationLayer( |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 738 | 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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 740 | get_random_accessor(1.f, 1.f), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 741 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"), |
| 742 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 743 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 745 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 746 | SubStream i_b2(i_b); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 747 | i_b2 << ConvolutionLayer( |
| 748 | 1U, 3U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 749 | 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] | 750 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 751 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 752 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 753 | << BatchNormalizationLayer( |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 754 | 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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 756 | get_random_accessor(1.f, 1.f), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 757 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_beta.npy"), |
| 758 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 759 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 761 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 762 | // Merge b1 and b2 |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 763 | i_b << BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, 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] | 764 | |
| 765 | SubStream i_c(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 766 | i_c << ConvolutionLayer( |
| 767 | 1U, 1U, std::get<0>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 768 | 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] | 769 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 770 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 771 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 772 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 777 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 778 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 780 | << ConvolutionLayer( |
| 781 | 3U, 3U, std::get<1>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 782 | 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] | 783 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 784 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 785 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 786 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 791 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 792 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 794 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 795 | SubStream i_c1(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 796 | i_c1 << ConvolutionLayer( |
| 797 | 3U, 1U, std::get<2>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 798 | 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] | 799 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 800 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 801 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/convolution") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 802 | << 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 Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 808 | .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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 810 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 811 | SubStream i_c2(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 812 | i_c2 << ConvolutionLayer( |
| 813 | 1U, 3U, std::get<3>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 814 | 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] | 815 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 816 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 817 | .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/convolution") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 818 | << 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 Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 824 | .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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 826 | |
| 827 | // Merge i_c1 and i_c2 |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 828 | i_c << BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, 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] | 829 | |
| 830 | SubStream i_d(graph); |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 831 | 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] | 832 | << ConvolutionLayer( |
| 833 | 1U, 1U, d_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 834 | 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] | 835 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 836 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 837 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 838 | << 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 Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 843 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 844 | .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 Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 846 | |
| 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 Pinitas | 9f28b39 | 2018-07-18 20:01:53 +0100 | [diff] [blame] | 853 | * @note To list all the possible arguments execute the binary appended with the --help option |
| 854 | * |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 855 | * @param[in] argc Number of arguments |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 856 | * @param[in] argv Arguments |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 857 | */ |
| 858 | int main(int argc, char **argv) |
| 859 | { |
| 860 | return arm_compute::utils::run_example<InceptionV3Example>(argc, argv); |
| 861 | } |