Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 1 | /* |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 ARM Limited. |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +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 | 240cfa6 | 2018-02-26 19:58:04 +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 | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 27 | #include "utils/GraphUtils.h" |
| 28 | #include "utils/Utils.h" |
| 29 | |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +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 | 240cfa6 | 2018-02-26 19:58:04 +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 InceptionV4's network using the Compute Library's graph API */ |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 35 | class InceptionV4Example final : public Example |
| 36 | { |
| 37 | public: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 38 | InceptionV4Example() |
| 39 | : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "InceptionV4") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +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 | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 63 | |
| 64 | // Create a preprocessor object |
| 65 | std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>(); |
| 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 | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 78 | // Conv2d_1a_3x3 |
| 79 | << ConvolutionLayer(3U, 3U, 32U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 80 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 81 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 82 | .set_name("Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 83 | << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 84 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 85 | get_random_accessor(1.f, 1.f), |
| 86 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 87 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 88 | .set_name("Conv2d_1a_3x3/BatchNorm") |
| 89 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 90 | // Conv2d_2a_3x3 |
| 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/inceptionv4_model/Conv2d_2a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 93 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 94 | .set_name("Conv2d_2a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 95 | << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"), |
| 96 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"), |
| 97 | get_random_accessor(1.f, 1.f), |
| 98 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_beta.npy"), |
| 99 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 100 | .set_name("Conv2d_2a_3x3/BatchNorm") |
| 101 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 102 | // Conv2d_2b_3x3 |
| 103 | << ConvolutionLayer(3U, 3U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 104 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 105 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 106 | .set_name("Conv2d_2b_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 107 | << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"), |
| 108 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"), |
| 109 | get_random_accessor(1.f, 1.f), |
| 110 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_beta.npy"), |
| 111 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 112 | .set_name("Conv2d_2b_3x3/BatchNorm") |
| 113 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 114 | |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 115 | graph << get_mixed_3a(data_path, weights_layout).set_name("Mixed_3a/concat"); |
| 116 | graph << get_mixed_4a(data_path, weights_layout).set_name("Mixed_4a/concat"); |
| 117 | graph << get_mixed_5a(data_path, weights_layout).set_name("Mixed_5a/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 118 | // 4 inception A blocks |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 119 | graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5b").set_name("Mixed_5b/concat"); |
| 120 | graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5c").set_name("Mixed_5c/concat"); |
| 121 | graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5d").set_name("Mixed_5d/concat"); |
| 122 | graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5e").set_name("Mixed_5e/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 123 | // reduction A block |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 124 | graph << get_reductionA_block(data_path, weights_layout).set_name("Mixed_6a/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 125 | // 7 inception B blocks |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 126 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6b").set_name("Mixed_6b/concat"); |
| 127 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6c").set_name("Mixed_6c/concat"); |
| 128 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6d").set_name("Mixed_6d/concat"); |
| 129 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6e").set_name("Mixed_6e/concat"); |
| 130 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6f").set_name("Mixed_6f/concat"); |
| 131 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6g").set_name("Mixed_6g/concat"); |
| 132 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6h").set_name("Mixed_6h/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 133 | // reduction B block |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 134 | graph << get_reductionB_block(data_path, weights_layout).set_name("Mixed_7a/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 135 | // 3 inception C blocks |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 136 | graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7b").set_name("Mixed_7b/concat"); |
| 137 | graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7c").set_name("Mixed_7c/concat"); |
| 138 | graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7d").set_name("Mixed_7d/concat"); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 139 | graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, operation_layout)).set_name("Logits/AvgPool_1a/AvgPool") |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 140 | << FlattenLayer().set_name("Logits/Flatten") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 141 | << FullyConnectedLayer( |
| 142 | 1001U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 143 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 144 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_biases.npy")) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 145 | .set_name("Logits/MatMul") |
| 146 | << SoftmaxLayer().set_name("Logits/Predictions") |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 147 | << OutputLayer(get_output_accessor(common_params, 5)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 148 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 149 | // Finalize graph |
Georgios Pinitas | 9a8c672 | 2018-03-21 17:52:35 +0000 | [diff] [blame] | 150 | GraphConfig config; |
Georgios Pinitas | f4261ad | 2019-12-02 11:58:19 +0000 | [diff] [blame] | 151 | config.num_threads = common_params.threads; |
| 152 | config.use_tuner = common_params.enable_tuner; |
| 153 | config.tuner_mode = common_params.tuner_mode; |
| 154 | config.tuner_file = common_params.tuner_file; |
| 155 | config.convert_to_uint8 = (common_params.data_type == DataType::QASYMM8); |
Anthony Barbier | 7b607dc | 2018-07-13 15:55:24 +0100 | [diff] [blame] | 156 | |
Pablo Tello | db9116f | 2019-07-11 16:50:37 +0100 | [diff] [blame] | 157 | // Load the precompiled kernels from a file into the kernel library, in this way the next time they are needed |
| 158 | // compilation won't be required. |
| 159 | if(common_params.enable_cl_cache) |
| 160 | { |
| 161 | restore_program_cache_from_file(); |
| 162 | } |
| 163 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 164 | graph.finalize(common_params.target, config); |
| 165 | |
Pablo Tello | db9116f | 2019-07-11 16:50:37 +0100 | [diff] [blame] | 166 | // Save the opencl kernels to a file |
| 167 | if(common_opts.enable_cl_cache) |
| 168 | { |
| 169 | save_program_cache_to_file(); |
| 170 | } |
| 171 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 172 | return true; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | void do_run() override |
| 176 | { |
| 177 | graph.run(); |
| 178 | } |
| 179 | |
| 180 | private: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 181 | CommandLineParser cmd_parser; |
| 182 | CommonGraphOptions common_opts; |
| 183 | CommonGraphParams common_params; |
| 184 | Stream graph; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 185 | |
| 186 | private: |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 187 | ConcatLayer get_mixed_3a(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 188 | { |
| 189 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_3a_"; |
| 190 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 191 | SubStream i_a(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 192 | i_a << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), |
| 193 | true)) |
| 194 | .set_name("Mixed_3a/Branch_0/MaxPool_0a_3x3/MaxPool"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 195 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 196 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 197 | i_b << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 198 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 199 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 200 | .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 201 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_mean.npy"), |
| 202 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_variance.npy"), |
| 203 | get_random_accessor(1.f, 1.f), |
| 204 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_beta.npy"), |
| 205 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 206 | .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/BatchNorm") |
| 207 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 208 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 209 | return ConcatLayer(std::move(i_a), std::move(i_b)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 210 | } |
| 211 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 212 | ConcatLayer get_mixed_4a(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 213 | { |
| 214 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_4a_"; |
| 215 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 216 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 217 | i_a << ConvolutionLayer(1U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 218 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 219 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 220 | .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 221 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 222 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 223 | get_random_accessor(1.f, 1.f), |
| 224 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 225 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 226 | .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/BatchNorm") |
| 227 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 228 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 229 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 230 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 231 | .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 232 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 233 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 234 | get_random_accessor(1.f, 1.f), |
| 235 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 236 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 237 | .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/BatchNorm") |
| 238 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 239 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 240 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 241 | i_b << ConvolutionLayer(1U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 242 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 243 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 244 | .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 245 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 246 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 247 | get_random_accessor(1.f, 1.f), |
| 248 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 249 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 250 | .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 251 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 252 | << ConvolutionLayer(7U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 253 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 254 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 255 | .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 256 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 257 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 258 | get_random_accessor(1.f, 1.f), |
| 259 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
| 260 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 261 | .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/BatchNorm") |
| 262 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 263 | << ConvolutionLayer(1U, 7U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 264 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 265 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 266 | .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 267 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 268 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 269 | get_random_accessor(1.f, 1.f), |
| 270 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
| 271 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 272 | .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/BatchNorm") |
| 273 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 274 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 275 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 276 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 277 | .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 278 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 279 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 280 | get_random_accessor(1.f, 1.f), |
| 281 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 282 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 283 | .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/BatchNorm") |
| 284 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 285 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 286 | return ConcatLayer(std::move(i_a), std::move(i_b)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 287 | } |
| 288 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 289 | ConcatLayer get_mixed_5a(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 290 | { |
| 291 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_5a_"; |
| 292 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 293 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 294 | i_a << ConvolutionLayer(3U, 3U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 295 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 296 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 297 | .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 298 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 299 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 300 | get_random_accessor(1.f, 1.f), |
| 301 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 302 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 303 | .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/BatchNorm") |
| 304 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 305 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 306 | SubStream i_b(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 307 | i_b << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), |
| 308 | true)) |
| 309 | .set_name("Mixed_5a/Branch_1/MaxPool_1a_3x3/MaxPool"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 310 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 311 | return ConcatLayer(std::move(i_a), std::move(i_b)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 312 | } |
| 313 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 314 | ConcatLayer get_inceptionA_block(const std::string &data_path, DataLayout weights_layout, std::string &¶m_path) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 315 | { |
| 316 | std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_"; |
| 317 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 318 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 319 | i_a << ConvolutionLayer(1U, 1U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 320 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 321 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 322 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 323 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 324 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 325 | get_random_accessor(1.f, 1.f), |
| 326 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 327 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 328 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm") |
| 329 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 330 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 331 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 332 | i_b << ConvolutionLayer(1U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 333 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 334 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 335 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 336 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 337 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 338 | get_random_accessor(1.f, 1.f), |
| 339 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 340 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 341 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 342 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 343 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 344 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 345 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 346 | .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 347 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 348 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 349 | get_random_accessor(1.f, 1.f), |
| 350 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
| 351 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 352 | .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm") |
| 353 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 354 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 355 | SubStream i_c(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 356 | i_c << ConvolutionLayer(1U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 357 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 358 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 359 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 360 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 361 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 362 | get_random_accessor(1.f, 1.f), |
| 363 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 364 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 365 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm") |
| 366 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 367 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 368 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 369 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 370 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 371 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 372 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 373 | get_random_accessor(1.f, 1.f), |
| 374 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
| 375 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 376 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm") |
| 377 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 378 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 379 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 380 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 381 | .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 382 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"), |
| 383 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"), |
| 384 | get_random_accessor(1.f, 1.f), |
| 385 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"), |
| 386 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 387 | .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm") |
| 388 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 389 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 390 | SubStream i_d(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 391 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), |
| 392 | true)) |
| 393 | .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 394 | << ConvolutionLayer(1U, 1U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 395 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 396 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 397 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 398 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 399 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 400 | get_random_accessor(1.f, 1.f), |
| 401 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
| 402 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 403 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm") |
| 404 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 405 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 406 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 409 | ConcatLayer get_reductionA_block(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 410 | { |
| 411 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_6a_"; |
| 412 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 413 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 414 | i_a << ConvolutionLayer(3U, 3U, 384U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 415 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 416 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 417 | .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 418 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 419 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 420 | get_random_accessor(1.f, 1.f), |
| 421 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 422 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 423 | .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/BatchNorm") |
| 424 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 425 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 426 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 427 | i_b << ConvolutionLayer(1U, 1U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 428 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 429 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 430 | .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 431 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 432 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 433 | get_random_accessor(1.f, 1.f), |
| 434 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 435 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 436 | .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 437 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 438 | << ConvolutionLayer(3U, 3U, 224U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 439 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 440 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 441 | .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 442 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 443 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 444 | get_random_accessor(1.f, 1.f), |
| 445 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
| 446 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 447 | .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/BatchNorm") |
| 448 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 449 | << ConvolutionLayer(3U, 3U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 450 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 451 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 452 | .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 453 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 454 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 455 | get_random_accessor(1.f, 1.f), |
| 456 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 457 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 458 | .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/BatchNorm") |
| 459 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 460 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 461 | SubStream i_c(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 462 | i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), |
| 463 | true)) |
| 464 | .set_name("Mixed_6a/Branch_2/MaxPool_1a_3x3/MaxPool"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 465 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 466 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 467 | } |
| 468 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 469 | ConcatLayer get_inceptionB_block(const std::string &data_path, DataLayout weights_layout, std::string &¶m_path) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 470 | { |
| 471 | std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_"; |
| 472 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 473 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 474 | i_a << ConvolutionLayer(1U, 1U, 384U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 475 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 476 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 477 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 478 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 479 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 480 | get_random_accessor(1.f, 1.f), |
| 481 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 482 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 483 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm") |
| 484 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 485 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 486 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 487 | i_b << ConvolutionLayer(1U, 1U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 488 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 489 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 490 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 491 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 492 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 493 | get_random_accessor(1.f, 1.f), |
| 494 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 495 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 496 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 497 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 498 | << ConvolutionLayer(7U, 1U, 224U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 499 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 500 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 501 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 502 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 503 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 504 | get_random_accessor(1.f, 1.f), |
| 505 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
| 506 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 507 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm") |
| 508 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 509 | << ConvolutionLayer(1U, 7U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 510 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 511 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 512 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 513 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 514 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 515 | get_random_accessor(1.f, 1.f), |
| 516 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
| 517 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 518 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm") |
| 519 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 520 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 521 | SubStream i_c(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 522 | i_c << ConvolutionLayer(1U, 1U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 523 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 524 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 525 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 526 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 527 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 528 | get_random_accessor(1.f, 1.f), |
| 529 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 530 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 531 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm") |
| 532 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 533 | << ConvolutionLayer(1U, 7U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 534 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 535 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 536 | .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 537 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"), |
| 538 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"), |
| 539 | get_random_accessor(1.f, 1.f), |
| 540 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"), |
| 541 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 542 | .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm") |
| 543 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 544 | << ConvolutionLayer(7U, 1U, 224U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 545 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 546 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 547 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 548 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"), |
| 549 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"), |
| 550 | get_random_accessor(1.f, 1.f), |
| 551 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"), |
| 552 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 553 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm") |
| 554 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 555 | << ConvolutionLayer(1U, 7U, 224U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 556 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 557 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 558 | .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 559 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"), |
| 560 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"), |
| 561 | get_random_accessor(1.f, 1.f), |
| 562 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"), |
| 563 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 564 | .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm") |
| 565 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 566 | << ConvolutionLayer(7U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 567 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 568 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 569 | .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 570 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"), |
| 571 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"), |
| 572 | get_random_accessor(1.f, 1.f), |
| 573 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"), |
| 574 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 575 | .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm") |
| 576 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 577 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 578 | SubStream i_d(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 579 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), |
| 580 | true)) |
| 581 | .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 582 | << ConvolutionLayer(1U, 1U, 128U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 583 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 584 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 585 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 586 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 587 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 588 | get_random_accessor(1.f, 1.f), |
| 589 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
| 590 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 591 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm") |
| 592 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 593 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 594 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 595 | } |
| 596 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 597 | ConcatLayer get_reductionB_block(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 598 | { |
| 599 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_7a_"; |
| 600 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 601 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 602 | i_a << ConvolutionLayer(1U, 1U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 603 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 604 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 605 | .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 606 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 607 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 608 | get_random_accessor(1.f, 1.f), |
| 609 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 610 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 611 | .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 612 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 613 | << ConvolutionLayer(3U, 3U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 614 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 615 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 616 | .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 617 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 618 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 619 | get_random_accessor(1.f, 1.f), |
| 620 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 621 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 622 | .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/BatchNorm") |
| 623 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 624 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 625 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 626 | i_b << ConvolutionLayer(1U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 627 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 628 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 629 | .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 630 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 631 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 632 | get_random_accessor(1.f, 1.f), |
| 633 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 634 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 635 | .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 636 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 637 | << ConvolutionLayer(7U, 1U, 256U, |
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 | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 639 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 640 | .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 641 | << BatchNormalizationLayer(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"), |
| 645 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 646 | .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/BatchNorm") |
| 647 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 648 | << ConvolutionLayer(1U, 7U, 320U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 649 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 650 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 651 | .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 652 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 653 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 654 | get_random_accessor(1.f, 1.f), |
| 655 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
| 656 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 657 | .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/BatchNorm") |
| 658 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 659 | << ConvolutionLayer(3U, 3U, 320U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 660 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 661 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 662 | .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 663 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 664 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 665 | get_random_accessor(1.f, 1.f), |
| 666 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 667 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 668 | .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/BatchNorm") |
| 669 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 670 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 671 | SubStream i_c(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 672 | i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, common_params.data_layout, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), |
| 673 | true)) |
| 674 | .set_name("Mixed_7a/Branch_2/MaxPool_1a_3x3/MaxPool"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 675 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 676 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 677 | } |
| 678 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 679 | ConcatLayer get_inceptionC_block(const std::string &data_path, DataLayout weights_layout, std::string &¶m_path) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 680 | { |
| 681 | std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_"; |
| 682 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 683 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 684 | i_a << ConvolutionLayer(1U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 685 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 686 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 687 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 688 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 689 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 690 | get_random_accessor(1.f, 1.f), |
| 691 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 692 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 693 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm") |
| 694 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 695 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 696 | SubStream i_b(graph); |
| 697 | i_b << ConvolutionLayer( |
| 698 | 1U, 1U, 384U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 699 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 700 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 701 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 702 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 703 | << BatchNormalizationLayer( |
| 704 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 705 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 706 | get_random_accessor(1.f, 1.f), |
| 707 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 708 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 709 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 710 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 711 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 712 | SubStream i_b1(i_b); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 713 | i_b1 << ConvolutionLayer( |
| 714 | 3U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 715 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 716 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 717 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 718 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 719 | << BatchNormalizationLayer( |
| 720 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"), |
| 721 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"), |
| 722 | get_random_accessor(1.f, 1.f), |
| 723 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"), |
| 724 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 725 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm") |
| 726 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 727 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 728 | SubStream i_b2(i_b); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 729 | i_b2 << ConvolutionLayer( |
| 730 | 1U, 3U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 731 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 732 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 733 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 734 | .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 735 | << BatchNormalizationLayer( |
| 736 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_mean.npy"), |
| 737 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_variance.npy"), |
| 738 | get_random_accessor(1.f, 1.f), |
| 739 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_beta.npy"), |
| 740 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 741 | .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/BatchNorm") |
| 742 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 743 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 744 | // Merge b1 and b2 |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 745 | i_b << ConcatLayer(std::move(i_b1), std::move(i_b2)).set_name(param_path + "/Branch_1/concat"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 746 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 747 | SubStream i_c(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 748 | i_c << ConvolutionLayer( |
| 749 | 1U, 1U, 384U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 750 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 751 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 752 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 753 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 754 | << BatchNormalizationLayer( |
| 755 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 756 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 757 | get_random_accessor(1.f, 1.f), |
| 758 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 759 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 760 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm") |
| 761 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 762 | << ConvolutionLayer( |
| 763 | 1U, 3U, 448U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 764 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 765 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 766 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 767 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 768 | << BatchNormalizationLayer( |
| 769 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_mean.npy"), |
| 770 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_variance.npy"), |
| 771 | get_random_accessor(1.f, 1.f), |
| 772 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_beta.npy"), |
| 773 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 774 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/BatchNorm") |
| 775 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 776 | << ConvolutionLayer( |
| 777 | 3U, 1U, 512U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 778 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 779 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 780 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 781 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 782 | << BatchNormalizationLayer( |
| 783 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"), |
| 784 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"), |
| 785 | get_random_accessor(1.f, 1.f), |
| 786 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"), |
| 787 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 788 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm") |
| 789 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 790 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 791 | SubStream i_c1(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 792 | i_c1 << ConvolutionLayer( |
| 793 | 3U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 794 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_weights.npy", weights_layout), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 795 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 796 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 797 | .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Conv2D") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 798 | << BatchNormalizationLayer( |
| 799 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_mean.npy"), |
| 800 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_variance.npy"), |
| 801 | get_random_accessor(1.f, 1.f), |
| 802 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_beta.npy"), |
| 803 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 804 | .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/BatchNorm") |
| 805 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Relu"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 806 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 807 | SubStream i_c2(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 808 | i_c2 << ConvolutionLayer( |
| 809 | 1U, 3U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 810 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_weights.npy", weights_layout), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 811 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 812 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 813 | .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Conv2D") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 814 | << BatchNormalizationLayer( |
| 815 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_mean.npy"), |
| 816 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_variance.npy"), |
| 817 | get_random_accessor(1.f, 1.f), |
| 818 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_beta.npy"), |
| 819 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 820 | .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/BatchNorm") |
| 821 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Relu"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 822 | |
| 823 | // Merge i_c1 and i_c2 |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 824 | 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] | 825 | |
| 826 | SubStream i_d(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 827 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, common_params.data_layout, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), |
| 828 | true)) |
| 829 | .set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 830 | << ConvolutionLayer(1U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 831 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 832 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 833 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 834 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 835 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 836 | get_random_accessor(1.f, 1.f), |
| 837 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
| 838 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 839 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm") |
| 840 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 841 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 842 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 843 | } |
| 844 | }; |
| 845 | |
| 846 | /** Main program for Inception V4 |
| 847 | * |
Georgios Pinitas | bdbbbe8 | 2018-11-07 16:06:47 +0000 | [diff] [blame] | 848 | * Model is based on: |
| 849 | * https://arxiv.org/abs/1602.07261 |
| 850 | * "Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning" |
| 851 | * Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi |
| 852 | * |
Georgios Pinitas | 588ebc5 | 2018-12-21 13:39:07 +0000 | [diff] [blame] | 853 | * Provenance: download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz |
| 854 | * |
Georgios Pinitas | 9f28b39 | 2018-07-18 20:01:53 +0100 | [diff] [blame] | 855 | * @note To list all the possible arguments execute the binary appended with the --help option |
| 856 | * |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 857 | * @param[in] argc Number of arguments |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 858 | * @param[in] argv Arguments |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 859 | */ |
| 860 | int main(int argc, char **argv) |
| 861 | { |
| 862 | return arm_compute::utils::run_example<InceptionV4Example>(argc, argv); |
| 863 | } |