| 40 | { |
| 41 | } |
| 42 | bool do_setup(int argc, char **argv) override |
| 43 | { |
| 44 | // Parse arguments |
| 45 | cmd_parser.parse(argc, argv); |
| 46 | cmd_parser.validate(); |
| 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 | |
| 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; |
| 63 | |
| 64 | // Create a preprocessor object |
| 65 | const std::array<float, 3> mean_rgb{{122.68f, 116.67f, 104.01f}}; |
| 66 | std::unique_ptr<IPreprocessor> preprocessor = |
| 67 | std::make_unique<CaffePreproccessor>(mean_rgb, false /* Do not convert to BGR */); |
| 68 | |
| 69 | // Create input descriptor |
| 70 | const auto operation_layout = common_params.data_layout; |
| 71 | const TensorShape tensor_shape = |
| 72 | permute_shape(TensorShape(224U, 224U, 3U, common_params.batches), DataLayout::NCHW, operation_layout); |
| 73 | TensorDescriptor input_descriptor = |
| 74 | TensorDescriptor(tensor_shape, common_params.data_type).set_layout(operation_layout); |
| 75 | |
| 76 | // Set weights trained layout |
| 77 | const DataLayout weights_layout = DataLayout::NCHW; |
| 78 | |
| 79 | graph << common_params.target << common_params.fast_math_hint |
| 80 | << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), |
| 81 | false /* Do not convert to BGR */)) |
| 82 | << ConvolutionLayer( |
| 83 | 7U, 7U, 64U, |
| 84 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_weights.npy", weights_layout), |
| 85 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 3, 3)) |
| 86 | .set_name("conv1/convolution") |
| 87 | << BatchNormalizationLayer( |
| 88 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_BatchNorm_moving_mean.npy"), |
| 89 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_BatchNorm_moving_variance.npy"), |
| 90 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_BatchNorm_gamma.npy"), |
| 91 | get_weights_accessor(data_path, "/cnn_data/resnet50_model/conv1_BatchNorm_beta.npy"), |
| 92 | 0.0000100099996416f) |
| 93 | .set_name("conv1/BatchNorm") |
| 94 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 95 | .set_name("conv1/Relu") |
| 96 | << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, operation_layout, |
| 97 | PadStrideInfo(2, 2, 0, 1, 0, 1, DimensionRoundingType::FLOOR))) |
| 98 | .set_name("pool1/MaxPool"); |
| 99 |
nothing calls this directly
no test coverage detected