Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 1 | /* |
SiCong Li | 4841c97 | 2021-02-03 12:17:35 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2021 Arm Limited. |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +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" |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +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" |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 27 | #include "utils/GraphUtils.h" |
| 28 | #include "utils/Utils.h" |
| 29 | |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +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; |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +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 ResNetV1_50 network using the Compute Library's graph API */ |
Georgios Pinitas | 7b2f026 | 2018-08-14 16:40:18 +0100 | [diff] [blame] | 35 | class GraphResNetV1_50Example : public Example |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 36 | { |
| 37 | public: |
Georgios Pinitas | 7b2f026 | 2018-08-14 16:40:18 +0100 | [diff] [blame] | 38 | GraphResNetV1_50Example() |
| 39 | : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "ResNetV1_50") |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 40 | { |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 41 | } |
| 42 | bool do_setup(int argc, char **argv) override |
| 43 | { |
| 44 | // Parse arguments |
| 45 | cmd_parser.parse(argc, argv); |
Georgios Pinitas | cd60a5f | 2019-08-21 17:06:54 +0100 | [diff] [blame] | 46 | cmd_parser.validate(); |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 47 | |
| 48 | // Consume common parameters |
| 49 | common_params = consume_common_graph_parameters(common_opts); |
| 50 | |
| 51 | // Return when help menu is requested |
| 52 | if(common_params.help) |
| 53 | { |
| 54 | cmd_parser.print_help(argv[0]); |
| 55 | return false; |
| 56 | } |
| 57 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 58 | // Print parameter values |
| 59 | std::cout << common_params << std::endl; |
| 60 | |
| 61 | // Get trainable parameters data path |
| 62 | std::string data_path = common_params.data_path; |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 63 | |
| 64 | // Create a preprocessor object |
| 65 | const std::array<float, 3> mean_rgb{ { 122.68f, 116.67f, 104.01f } }; |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 66 | std::unique_ptr<IPreprocessor> preprocessor = std::make_unique<CaffePreproccessor>(mean_rgb, |
| 67 | false /* Do not convert to BGR */); |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 68 | |
| 69 | // Create input descriptor |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 70 | const auto operation_layout = common_params.data_layout; |
| 71 | const TensorShape tensor_shape = permute_shape(TensorShape(224U, 224U, 3U, 1U), DataLayout::NCHW, operation_layout); |
| 72 | 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] | 73 | |
| 74 | // Set weights trained layout |
| 75 | const DataLayout weights_layout = DataLayout::NCHW; |
| 76 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 77 | graph << common_params.target |
| 78 | << common_params.fast_math_hint |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 79 | << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false /* Do not convert to BGR */)) |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 80 | << ConvolutionLayer( |
| 81 | 7U, 7U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 82 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_weights.npy", weights_layout), |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 83 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 84 | PadStrideInfo(2, 2, 3, 3)) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 85 | .set_name("conv1/convolution") |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 86 | << BatchNormalizationLayer( |
| 87 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_BatchNorm_moving_mean.npy"), |
| 88 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_BatchNorm_moving_variance.npy"), |
| 89 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_BatchNorm_gamma.npy"), |
| 90 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_BatchNorm_beta.npy"), |
| 91 | 0.0000100099996416f) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 92 | .set_name("conv1/BatchNorm") |
| 93 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("conv1/Relu") |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 94 | << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, operation_layout, PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR))).set_name("pool1/MaxPool"); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 95 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 96 | add_residual_block(data_path, "block1", weights_layout, 64, 3, 2); |
| 97 | add_residual_block(data_path, "block2", weights_layout, 128, 4, 2); |
| 98 | add_residual_block(data_path, "block3", weights_layout, 256, 6, 2); |
| 99 | add_residual_block(data_path, "block4", weights_layout, 512, 3, 1); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 100 | |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 101 | graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, operation_layout)).set_name("pool5") |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 102 | << ConvolutionLayer( |
| 103 | 1U, 1U, 1000U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 104 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/logits_weights.npy", weights_layout), |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 105 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/logits_biases.npy"), |
| 106 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 107 | .set_name("logits/convolution") |
| 108 | << FlattenLayer().set_name("predictions/Reshape") |
| 109 | << SoftmaxLayer().set_name("predictions/Softmax") |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 110 | << OutputLayer(get_output_accessor(common_params, 5)); |
Gian Marco | c1b6e37 | 2018-02-21 18:03:26 +0000 | [diff] [blame] | 111 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 112 | // Finalize graph |
Georgios Pinitas | 9a8c672 | 2018-03-21 17:52:35 +0000 | [diff] [blame] | 113 | GraphConfig config; |
Georgios Pinitas | f4261ad | 2019-12-02 11:58:19 +0000 | [diff] [blame] | 114 | config.num_threads = common_params.threads; |
| 115 | config.use_tuner = common_params.enable_tuner; |
| 116 | config.tuner_mode = common_params.tuner_mode; |
| 117 | config.tuner_file = common_params.tuner_file; |
SiCong Li | 4841c97 | 2021-02-03 12:17:35 +0000 | [diff] [blame] | 118 | config.mlgo_file = common_params.mlgo_file; |
Georgios Pinitas | f4261ad | 2019-12-02 11:58:19 +0000 | [diff] [blame] | 119 | config.convert_to_uint8 = (common_params.data_type == DataType::QASYMM8); |
Michele Di Giorgio | 1df9cca | 2019-01-17 13:20:32 +0000 | [diff] [blame] | 120 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 121 | graph.finalize(common_params.target, config); |
| 122 | |
| 123 | return true; |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 124 | } |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 125 | |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 126 | void do_run() override |
| 127 | { |
| 128 | // Run graph |
| 129 | graph.run(); |
| 130 | } |
| 131 | |
| 132 | private: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 133 | CommandLineParser cmd_parser; |
| 134 | CommonGraphOptions common_opts; |
| 135 | CommonGraphParams common_params; |
| 136 | Stream graph; |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 137 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 138 | void add_residual_block(const std::string &data_path, const std::string &name, DataLayout weights_layout, |
| 139 | unsigned int base_depth, unsigned int num_units, unsigned int stride) |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 140 | { |
| 141 | for(unsigned int i = 0; i < num_units; ++i) |
| 142 | { |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 143 | std::stringstream unit_path_ss; |
| 144 | unit_path_ss << "/cnn_data/resnet50_model/" << name << "_unit_" << (i + 1) << "_bottleneck_v1_"; |
| 145 | std::stringstream unit_name_ss; |
| 146 | unit_name_ss << name << "/unit" << (i + 1) << "/bottleneck_v1/"; |
| 147 | |
| 148 | std::string unit_path = unit_path_ss.str(); |
| 149 | std::string unit_name = unit_name_ss.str(); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 150 | |
| 151 | unsigned int middle_stride = 1; |
| 152 | |
| 153 | if(i == (num_units - 1)) |
| 154 | { |
| 155 | middle_stride = stride; |
| 156 | } |
| 157 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 158 | SubStream right(graph); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 159 | right << ConvolutionLayer( |
| 160 | 1U, 1U, base_depth, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 161 | get_weights_accessor(data_path, unit_path + "conv1_weights.npy", weights_layout), |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 162 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 163 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 164 | .set_name(unit_name + "conv1/convolution") |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 165 | << BatchNormalizationLayer( |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 166 | get_weights_accessor(data_path, unit_path + "conv1_BatchNorm_moving_mean.npy"), |
| 167 | get_weights_accessor(data_path, unit_path + "conv1_BatchNorm_moving_variance.npy"), |
| 168 | get_weights_accessor(data_path, unit_path + "conv1_BatchNorm_gamma.npy"), |
| 169 | get_weights_accessor(data_path, unit_path + "conv1_BatchNorm_beta.npy"), |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 170 | 0.0000100099996416f) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 171 | .set_name(unit_name + "conv1/BatchNorm") |
| 172 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(unit_name + "conv1/Relu") |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 173 | |
| 174 | << ConvolutionLayer( |
| 175 | 3U, 3U, base_depth, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 176 | get_weights_accessor(data_path, unit_path + "conv2_weights.npy", weights_layout), |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 177 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 178 | PadStrideInfo(middle_stride, middle_stride, 1, 1)) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 179 | .set_name(unit_name + "conv2/convolution") |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 180 | << BatchNormalizationLayer( |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 181 | get_weights_accessor(data_path, unit_path + "conv2_BatchNorm_moving_mean.npy"), |
| 182 | get_weights_accessor(data_path, unit_path + "conv2_BatchNorm_moving_variance.npy"), |
| 183 | get_weights_accessor(data_path, unit_path + "conv2_BatchNorm_gamma.npy"), |
| 184 | get_weights_accessor(data_path, unit_path + "conv2_BatchNorm_beta.npy"), |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 185 | 0.0000100099996416f) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 186 | .set_name(unit_name + "conv2/BatchNorm") |
| 187 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(unit_name + "conv1/Relu") |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 188 | |
| 189 | << ConvolutionLayer( |
| 190 | 1U, 1U, base_depth * 4, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 191 | get_weights_accessor(data_path, unit_path + "conv3_weights.npy", weights_layout), |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 192 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 193 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 194 | .set_name(unit_name + "conv3/convolution") |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 195 | << BatchNormalizationLayer( |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 196 | get_weights_accessor(data_path, unit_path + "conv3_BatchNorm_moving_mean.npy"), |
| 197 | get_weights_accessor(data_path, unit_path + "conv3_BatchNorm_moving_variance.npy"), |
| 198 | get_weights_accessor(data_path, unit_path + "conv3_BatchNorm_gamma.npy"), |
| 199 | get_weights_accessor(data_path, unit_path + "conv3_BatchNorm_beta.npy"), |
| 200 | 0.0000100099996416f) |
| 201 | .set_name(unit_name + "conv2/BatchNorm"); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 202 | |
| 203 | if(i == 0) |
| 204 | { |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 205 | SubStream left(graph); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 206 | left << ConvolutionLayer( |
| 207 | 1U, 1U, base_depth * 4, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 208 | get_weights_accessor(data_path, unit_path + "shortcut_weights.npy", weights_layout), |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 209 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 210 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 211 | .set_name(unit_name + "shortcut/convolution") |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 212 | << BatchNormalizationLayer( |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 213 | get_weights_accessor(data_path, unit_path + "shortcut_BatchNorm_moving_mean.npy"), |
| 214 | get_weights_accessor(data_path, unit_path + "shortcut_BatchNorm_moving_variance.npy"), |
| 215 | get_weights_accessor(data_path, unit_path + "shortcut_BatchNorm_gamma.npy"), |
| 216 | get_weights_accessor(data_path, unit_path + "shortcut_BatchNorm_beta.npy"), |
| 217 | 0.0000100099996416f) |
| 218 | .set_name(unit_name + "shortcut/BatchNorm"); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 219 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 220 | graph << EltwiseLayer(std::move(left), std::move(right), EltwiseOperation::Add).set_name(unit_name + "add"); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 221 | } |
| 222 | else if(middle_stride > 1) |
| 223 | { |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 224 | SubStream left(graph); |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 225 | left << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 1, common_params.data_layout, PadStrideInfo(middle_stride, middle_stride, 0, 0), true)).set_name(unit_name + "shortcut/MaxPool"); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 226 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 227 | graph << EltwiseLayer(std::move(left), std::move(right), EltwiseOperation::Add).set_name(unit_name + "add"); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 228 | } |
| 229 | else |
| 230 | { |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 231 | SubStream left(graph); |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 232 | graph << EltwiseLayer(std::move(left), std::move(right), EltwiseOperation::Add).set_name(unit_name + "add"); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 233 | } |
| 234 | |
Georgios Pinitas | 5c2fb3f | 2018-05-01 15:26:20 +0100 | [diff] [blame] | 235 | graph << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(unit_name + "Relu"); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 236 | } |
| 237 | } |
| 238 | }; |
| 239 | |
Georgios Pinitas | 7b2f026 | 2018-08-14 16:40:18 +0100 | [diff] [blame] | 240 | /** Main program for ResNetV1_50 |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 241 | * |
Georgios Pinitas | bdbbbe8 | 2018-11-07 16:06:47 +0000 | [diff] [blame] | 242 | * Model is based on: |
| 243 | * https://arxiv.org/abs/1512.03385 |
| 244 | * "Deep Residual Learning for Image Recognition" |
| 245 | * Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun |
| 246 | * |
Georgios Pinitas | 588ebc5 | 2018-12-21 13:39:07 +0000 | [diff] [blame] | 247 | * Provenance: download.tensorflow.org/models/resnet_v1_50_2016_08_28.tar.gz |
| 248 | * |
Georgios Pinitas | 9f28b39 | 2018-07-18 20:01:53 +0100 | [diff] [blame] | 249 | * @note To list all the possible arguments execute the binary appended with the --help option |
| 250 | * |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 251 | * @param[in] argc Number of arguments |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 252 | * @param[in] argv Arguments |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 253 | */ |
| 254 | int main(int argc, char **argv) |
| 255 | { |
Georgios Pinitas | 7b2f026 | 2018-08-14 16:40:18 +0100 | [diff] [blame] | 256 | return arm_compute::utils::run_example<GraphResNetV1_50Example>(argc, argv); |
Alex Gilday | 8913d8d | 2018-02-15 11:07:18 +0000 | [diff] [blame] | 257 | } |