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