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