Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 1 | /* |
SiCong Li | 4841c97 | 2021-02-03 12:17:35 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2021 Arm Limited. |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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 | |
Georgios Pinitas | 108ab0b | 2018-09-14 18:35:11 +0100 | [diff] [blame] | 34 | /** Example demonstrating how to implement InceptionV3's network using the Compute Library's graph API */ |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 35 | class InceptionV3Example : public Example |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 36 | { |
| 37 | public: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 38 | InceptionV3Example() |
| 39 | : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "InceptionV3") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 40 | { |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 41 | } |
| 42 | bool do_setup(int argc, char **argv) override |
| 43 | { |
| 44 | // Parse arguments |
| 45 | cmd_parser.parse(argc, argv); |
Georgios Pinitas | cd60a5f | 2019-08-21 17:06:54 +0100 | [diff] [blame] | 46 | cmd_parser.validate(); |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 47 | |
| 48 | // Consume common parameters |
| 49 | common_params = consume_common_graph_parameters(common_opts); |
| 50 | |
| 51 | // Return when help menu is requested |
| 52 | if(common_params.help) |
| 53 | { |
| 54 | cmd_parser.print_help(argv[0]); |
| 55 | return false; |
| 56 | } |
| 57 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 58 | // Print parameter values |
| 59 | std::cout << common_params << std::endl; |
| 60 | |
| 61 | // Get trainable parameters data path |
| 62 | std::string data_path = common_params.data_path; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 63 | |
Georgios Pinitas | 140fdc7 | 2018-02-16 11:42:38 +0000 | [diff] [blame] | 64 | // Create a preprocessor object |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 65 | std::unique_ptr<IPreprocessor> preprocessor = std::make_unique<TFPreproccessor>(); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 66 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 67 | // Create input descriptor |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 68 | const auto operation_layout = common_params.data_layout; |
| 69 | const TensorShape tensor_shape = permute_shape(TensorShape(299U, 299U, 3U, 1U), DataLayout::NCHW, operation_layout); |
| 70 | TensorDescriptor input_descriptor = TensorDescriptor(tensor_shape, common_params.data_type).set_layout(operation_layout); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 71 | |
| 72 | // Set weights trained layout |
| 73 | const DataLayout weights_layout = DataLayout::NCHW; |
| 74 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 75 | graph << common_params.target |
| 76 | << common_params.fast_math_hint |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 77 | << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false)) |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 78 | << ConvolutionLayer(3U, 3U, 32U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 79 | 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] | 80 | 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] | 81 | .set_name("Conv2d_1a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 82 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 83 | "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 84 | get_weights_accessor(data_path, |
| 85 | "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 86 | nullptr, get_weights_accessor(data_path, |
| 87 | "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 88 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 89 | .set_name("Conv2d_1a_3x3/BatchNorm/batchnorm") |
| 90 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 91 | << ConvolutionLayer(3U, 3U, 32U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 92 | 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] | 93 | 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] | 94 | .set_name("Conv2d_2a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 95 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 96 | "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"), |
| 97 | get_weights_accessor(data_path, |
| 98 | "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 99 | nullptr, get_weights_accessor(data_path, |
| 100 | "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 101 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 102 | .set_name("Conv2d_2a_3x3/BatchNorm/batchnorm") |
| 103 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 104 | |
| 105 | << ConvolutionLayer(3U, 3U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 106 | 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] | 107 | 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] | 108 | .set_name("Conv2d_2b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 109 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 110 | "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"), |
| 111 | get_weights_accessor(data_path, |
| 112 | "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 113 | nullptr, get_weights_accessor(data_path, |
| 114 | "/cnn_data/inceptionv3_model/Conv2d_2b_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 115 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 116 | .set_name("Conv2d_2b_3x3/BatchNorm/batchnorm") |
| 117 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 118 | |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 119 | << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, operation_layout, 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] | 120 | |
| 121 | << ConvolutionLayer(1U, 1U, 80U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 122 | 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] | 123 | 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] | 124 | .set_name("Conv2d_3b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 125 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 126 | "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_mean.npy"), |
| 127 | get_weights_accessor(data_path, |
| 128 | "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 129 | nullptr, get_weights_accessor(data_path, |
| 130 | "/cnn_data/inceptionv3_model/Conv2d_3b_1x1_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 131 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 132 | .set_name("Conv2d_3b_1x1/BatchNorm/batchnorm") |
| 133 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_3b_1x1/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 134 | |
| 135 | << ConvolutionLayer(3U, 3U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 136 | 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] | 137 | 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] | 138 | .set_name("Conv2d_4a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 139 | << BatchNormalizationLayer(get_weights_accessor(data_path, |
| 140 | "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_mean.npy"), |
| 141 | get_weights_accessor(data_path, |
| 142 | "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 143 | nullptr, get_weights_accessor(data_path, |
| 144 | "/cnn_data/inceptionv3_model/Conv2d_4a_3x3_BatchNorm_beta.npy"), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 145 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 146 | .set_name("Conv2d_4a_3x3/BatchNorm/batchnorm") |
| 147 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_4a_3x3/Relu") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 148 | |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 149 | << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, operation_layout, 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] | 150 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 151 | 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] | 152 | 32U) |
| 153 | .set_name("Mixed_5b/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 154 | 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] | 155 | 64U, true) |
| 156 | .set_name("Mixed_5c/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 157 | 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] | 158 | 64U) |
| 159 | .set_name("Mixed_5d/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 160 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 161 | 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] | 162 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 163 | 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] | 164 | std::make_tuple(128U, 128U, 128U, 128U, 192U), 192U) |
| 165 | .set_name("Mixed_6b/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 166 | 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] | 167 | std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U) |
| 168 | .set_name("Mixed_6c/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 169 | 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] | 170 | std::make_tuple(160U, 160U, 160U, 160U, 192U), 192U) |
| 171 | .set_name("Mixed_6d/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 172 | 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] | 173 | std::make_tuple(192U, 192U, 192U, 192U, 192U), 192U) |
| 174 | .set_name("Mixed_6e/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 175 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 176 | 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] | 177 | std::make_tuple(192U, 192U, 192U, 192U)) |
| 178 | .set_name("Mixed_7a/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 179 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 180 | 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] | 181 | std::make_tuple(448U, 384U, 384U, 384U), 192U) |
| 182 | .set_name("Mixed_7b/concat"); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 183 | 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] | 184 | std::make_tuple(448U, 384U, 384U, 384U), 192U, true) |
| 185 | .set_name("Mixed_7c/concat"); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 186 | |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 187 | graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 8, operation_layout, 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] | 188 | << ConvolutionLayer(1U, 1U, 1001U, get_weights_accessor(data_path, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 189 | "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 190 | get_weights_accessor(data_path, |
| 191 | "/cnn_data/inceptionv3_model/Logits_Conv2d_1c_1x1_biases.npy"), |
| 192 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 193 | .set_name("Logits/Conv2d_1c_1x1/convolution") |
| 194 | << ReshapeLayer(TensorShape(1001U)).set_name("Predictions/Reshape") |
| 195 | << SoftmaxLayer().set_name("Predictions/Softmax") |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 196 | << OutputLayer(get_output_accessor(common_params, 5)); |
Gian Marco | c1b6e37 | 2018-02-21 18:03:26 +0000 | [diff] [blame] | 197 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 198 | // Finalize graph |
Georgios Pinitas | 9a8c672 | 2018-03-21 17:52:35 +0000 | [diff] [blame] | 199 | GraphConfig config; |
Georgios Pinitas | f4261ad | 2019-12-02 11:58:19 +0000 | [diff] [blame] | 200 | config.num_threads = common_params.threads; |
| 201 | config.use_tuner = common_params.enable_tuner; |
| 202 | config.tuner_mode = common_params.tuner_mode; |
| 203 | config.tuner_file = common_params.tuner_file; |
SiCong Li | 4841c97 | 2021-02-03 12:17:35 +0000 | [diff] [blame] | 204 | config.mlgo_file = common_params.mlgo_file; |
Georgios Pinitas | f4261ad | 2019-12-02 11:58:19 +0000 | [diff] [blame] | 205 | config.convert_to_uint8 = (common_params.data_type == DataType::QASYMM8); |
Anthony Barbier | 7b607dc | 2018-07-13 15:55:24 +0100 | [diff] [blame] | 206 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 207 | graph.finalize(common_params.target, config); |
| 208 | |
| 209 | return true; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | void do_run() override |
| 213 | { |
| 214 | graph.run(); |
| 215 | } |
| 216 | |
| 217 | private: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 218 | CommandLineParser cmd_parser; |
| 219 | CommonGraphOptions common_opts; |
| 220 | CommonGraphParams common_params; |
| 221 | Stream graph; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 222 | |
| 223 | private: |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 224 | 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] | 225 | unsigned int a_filt, |
| 226 | std::tuple<unsigned int, unsigned int> b_filters, |
| 227 | std::tuple<unsigned int, unsigned int, unsigned int> c_filters, |
| 228 | unsigned int d_filt, |
| 229 | bool is_name_different = false) |
| 230 | { |
| 231 | std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_"; |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 232 | |
| 233 | // This is due to a naming issue in the tf model |
| 234 | std::string conv_id0 = "_0a_"; |
| 235 | std::string conv_id1 = "2d_0b_"; |
| 236 | if(is_name_different) |
| 237 | { |
| 238 | conv_id0 = "_0b_"; |
| 239 | conv_id1 = "_1_0c_"; |
| 240 | } |
| 241 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 242 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 243 | i_a << ConvolutionLayer( |
| 244 | 1U, 1U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 245 | 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] | 246 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 247 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 248 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 249 | << BatchNormalizationLayer( |
| 250 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 251 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 252 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 253 | 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] | 254 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 255 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 256 | << 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] | 257 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 258 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 259 | i_b << ConvolutionLayer( |
| 260 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 261 | 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] | 262 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 263 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 264 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 265 | << BatchNormalizationLayer( |
| 266 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_mean.npy"), |
| 267 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id0 + "1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 268 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 269 | 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] | 270 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 271 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id0 + "1x1/BatchNorm/batchnorm") |
| 272 | << 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] | 273 | << ConvolutionLayer( |
| 274 | 5U, 5U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 275 | 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] | 276 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 277 | PadStrideInfo(1, 1, 2, 2)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 278 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 279 | << BatchNormalizationLayer( |
| 280 | get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_mean.npy"), |
| 281 | get_weights_accessor(data_path, total_path + "Branch_1_Conv" + conv_id1 + "5x5_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 282 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 283 | 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] | 284 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 285 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id1 + "5x5/BatchNorm/batchnorm") |
| 286 | << 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] | 287 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 288 | SubStream i_c(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 289 | i_c << ConvolutionLayer( |
| 290 | 1U, 1U, std::get<0>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 291 | 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] | 292 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 293 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 294 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 295 | << BatchNormalizationLayer( |
| 296 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 297 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 298 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 299 | 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] | 300 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 301 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 302 | << 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] | 303 | << ConvolutionLayer( |
| 304 | 3U, 3U, std::get<1>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 305 | 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] | 306 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 307 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 308 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 309 | << BatchNormalizationLayer( |
| 310 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 311 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 312 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 313 | 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] | 314 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 315 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm") |
| 316 | << 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] | 317 | << ConvolutionLayer( |
| 318 | 3U, 3U, std::get<2>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 319 | 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] | 320 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 321 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 322 | .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 323 | << BatchNormalizationLayer( |
| 324 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"), |
| 325 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 326 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 327 | 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] | 328 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 329 | .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm/batcnorm") |
| 330 | << 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] | 331 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 332 | SubStream i_d(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 333 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), |
| 334 | true)) |
| 335 | .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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 345 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 351 | 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] | 352 | } |
| 353 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 354 | 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] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 369 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 385 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 399 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 413 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 420 | i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, 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 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 422 | 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] | 423 | } |
| 424 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 425 | 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] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 442 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 458 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 472 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 486 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 502 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 516 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 530 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 544 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 558 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 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); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 565 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), |
| 566 | true)) |
| 567 | .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 568 | << ConvolutionLayer( |
| 569 | 1U, 1U, d_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 570 | 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] | 571 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 572 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 573 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 574 | << BatchNormalizationLayer( |
| 575 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 576 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 577 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 578 | 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] | 579 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 580 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm") |
| 581 | << 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] | 582 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 583 | 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] | 584 | } |
| 585 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 586 | 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] | 587 | std::tuple<unsigned int, unsigned int> a_filters, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 588 | std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> b_filters) |
| 589 | { |
| 590 | std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_"; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 591 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 592 | i_a << ConvolutionLayer( |
| 593 | 1U, 1U, std::get<0>(a_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 594 | 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] | 595 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 596 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 597 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 598 | << BatchNormalizationLayer( |
| 599 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 600 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 601 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 602 | 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] | 603 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 604 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 605 | << 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] | 606 | << ConvolutionLayer( |
| 607 | 3U, 3U, std::get<1>(a_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 608 | 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] | 609 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 610 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 611 | .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 612 | << BatchNormalizationLayer( |
| 613 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 614 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 615 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 616 | 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] | 617 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 618 | .set_name(param_path + "/Branch_0/Conv2d_1a_3x3/BatchNorm/batchnorm") |
| 619 | << 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] | 620 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 621 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 622 | i_b << ConvolutionLayer( |
| 623 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 624 | 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] | 625 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 626 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 627 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 628 | << BatchNormalizationLayer( |
| 629 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 630 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 631 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 632 | 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] | 633 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 634 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 635 | << 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] | 636 | << ConvolutionLayer( |
| 637 | 7U, 1U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 638 | 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] | 639 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 640 | PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 641 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 642 | << BatchNormalizationLayer( |
| 643 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 644 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 645 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 646 | 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] | 647 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 648 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm/batchnorm") |
| 649 | << 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] | 650 | << ConvolutionLayer( |
| 651 | 1U, 7U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 652 | 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] | 653 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 654 | PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 655 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 656 | << BatchNormalizationLayer( |
| 657 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 658 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 659 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 660 | 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] | 661 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 662 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm/batchnorm") |
| 663 | << 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] | 664 | << ConvolutionLayer( |
| 665 | 3U, 3U, std::get<3>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 666 | 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] | 667 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 668 | PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 669 | .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 670 | << BatchNormalizationLayer( |
| 671 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 672 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 673 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 674 | 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] | 675 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 676 | .set_name(param_path + "/Branch_1/Conv2d_1a_3x3/BatchNorm/batchnorm") |
| 677 | << 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] | 678 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 679 | SubStream i_c(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 680 | i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, 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] | 681 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 682 | 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] | 683 | } |
| 684 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 685 | 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] | 686 | unsigned int a_filt, |
| 687 | std::tuple<unsigned int, unsigned int, unsigned int> b_filters, |
| 688 | std::tuple<unsigned int, unsigned int, unsigned int, unsigned int> c_filters, |
| 689 | unsigned int d_filt, |
| 690 | bool is_name_different = false) |
| 691 | { |
| 692 | // This is due to a naming issue in the tf model |
| 693 | std::string conv_id = "_0b_"; |
| 694 | if(is_name_different) |
| 695 | { |
| 696 | conv_id = "_0c_"; |
| 697 | } |
| 698 | |
| 699 | std::string total_path = "/cnn_data/inceptionv3_model/" + param_path + "_"; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 700 | SubStream i_a(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 701 | i_a << ConvolutionLayer( |
| 702 | 1U, 1U, a_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 703 | 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] | 704 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 705 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 706 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 707 | << BatchNormalizationLayer( |
| 708 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 709 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 710 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 711 | 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] | 712 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 713 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 714 | << 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] | 715 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 716 | SubStream i_b(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 717 | i_b << ConvolutionLayer( |
| 718 | 1U, 1U, std::get<0>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 719 | 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] | 720 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 721 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 722 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 723 | << BatchNormalizationLayer( |
| 724 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 725 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 726 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 727 | 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] | 728 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 729 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 730 | << 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] | 731 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 732 | SubStream i_b1(i_b); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 733 | i_b1 << ConvolutionLayer( |
| 734 | 3U, 1U, std::get<1>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 735 | 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] | 736 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 737 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 738 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 739 | << BatchNormalizationLayer( |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 740 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"), |
| 741 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 742 | nullptr, |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 743 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"), |
| 744 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 745 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm/batchnorm") |
| 746 | << 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] | 747 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 748 | SubStream i_b2(i_b); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 749 | i_b2 << ConvolutionLayer( |
| 750 | 1U, 3U, std::get<2>(b_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 751 | 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] | 752 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 753 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 754 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 755 | << BatchNormalizationLayer( |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 756 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_mean.npy"), |
| 757 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 758 | nullptr, |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 759 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d" + conv_id + "3x1_BatchNorm_beta.npy"), |
| 760 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 761 | .set_name(param_path + "/Branch_1/Conv2d" + conv_id + "3x1/BatchNorm/batchnorm") |
| 762 | << 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] | 763 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 764 | // Merge b1 and b2 |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 765 | 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] | 766 | |
| 767 | SubStream i_c(graph); |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 768 | i_c << ConvolutionLayer( |
| 769 | 1U, 1U, std::get<0>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 770 | 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] | 771 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 772 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 773 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 774 | << BatchNormalizationLayer( |
| 775 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 776 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 777 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 778 | 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] | 779 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 780 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm/batchnorm") |
| 781 | << 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] | 782 | << ConvolutionLayer( |
| 783 | 3U, 3U, std::get<1>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 784 | 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] | 785 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 786 | PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 787 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 788 | << BatchNormalizationLayer( |
| 789 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 790 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 791 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 792 | 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] | 793 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 794 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm/batchnorm") |
| 795 | << 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] | 796 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 797 | SubStream i_c1(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 798 | i_c1 << ConvolutionLayer( |
| 799 | 3U, 1U, std::get<2>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 800 | 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] | 801 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 802 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 803 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/convolution") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 804 | << BatchNormalizationLayer( |
| 805 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"), |
| 806 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 807 | nullptr, |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 808 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"), |
| 809 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 810 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm/batchnorm") |
| 811 | << 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] | 812 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 813 | SubStream i_c2(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 814 | i_c2 << ConvolutionLayer( |
| 815 | 1U, 3U, std::get<3>(c_filters), |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 816 | 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] | 817 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 818 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 819 | .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/convolution") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 820 | << BatchNormalizationLayer( |
| 821 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_mean.npy"), |
| 822 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 823 | nullptr, |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 824 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_3x1_BatchNorm_beta.npy"), |
| 825 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 826 | .set_name(param_path + "/Branch_2/Conv2d_0d_3x1/BatchNorm/batchnorm") |
| 827 | << 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] | 828 | |
| 829 | // Merge i_c1 and i_c2 |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 830 | 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] | 831 | |
| 832 | SubStream i_d(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 833 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), |
| 834 | true)) |
| 835 | .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 836 | << ConvolutionLayer( |
| 837 | 1U, 1U, d_filt, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 838 | 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] | 839 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 840 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 841 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/convolution") |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 842 | << BatchNormalizationLayer( |
| 843 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 844 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
giuros01 | 351bd13 | 2019-08-23 14:27:30 +0100 | [diff] [blame] | 845 | nullptr, |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 846 | 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] | 847 | 0.001f) |
Georgios Pinitas | 130986a | 2018-05-14 19:25:37 +0100 | [diff] [blame] | 848 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm/batchnorm") |
| 849 | << 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] | 850 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 851 | 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] | 852 | } |
| 853 | }; |
| 854 | |
| 855 | /** Main program for Inception V3 |
| 856 | * |
Georgios Pinitas | bdbbbe8 | 2018-11-07 16:06:47 +0000 | [diff] [blame] | 857 | * Model is based on: |
| 858 | * https://arxiv.org/abs/1512.00567 |
| 859 | * "Rethinking the Inception Architecture for Computer Vision" |
| 860 | * Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, Zbigniew Wojna |
| 861 | * |
Georgios Pinitas | 588ebc5 | 2018-12-21 13:39:07 +0000 | [diff] [blame] | 862 | * Provenance: download.tensorflow.org/models/inception_v3_2016_08_28.tar.gz |
| 863 | * |
Georgios Pinitas | 9f28b39 | 2018-07-18 20:01:53 +0100 | [diff] [blame] | 864 | * @note To list all the possible arguments execute the binary appended with the --help option |
| 865 | * |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 866 | * @param[in] argc Number of arguments |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 867 | * @param[in] argv Arguments |
Georgios Pinitas | 652bde5 | 2018-01-10 15:33:28 +0000 | [diff] [blame] | 868 | */ |
| 869 | int main(int argc, char **argv) |
| 870 | { |
| 871 | return arm_compute::utils::run_example<InceptionV3Example>(argc, argv); |
| 872 | } |