MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / do_setup

Method do_setup

examples/graph_srcnn955.cpp:57–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55 GraphSRCNN955Example &operator=(const GraphSRCNN955Example &) = delete;
56 ~GraphSRCNN955Example() override = default;
57 bool do_setup(int argc, char **argv) override
58 {
59 // Parse arguments
60 cmd_parser.parse(argc, argv);
61 cmd_parser.validate();
62
63 // Consume common parameters
64 common_params = consume_common_graph_parameters(common_opts);
65
66 // Return when help menu is requested
67 if (common_params.help)
68 {
69 cmd_parser.print_help(argv[0]);
70 return false;
71 }
72
73 // Get input image width and height
74 const unsigned int image_width = model_input_width->value();
75 const unsigned int image_height = model_input_height->value();
76
77 // Print parameter values
78 std::cout << common_params << std::endl;
79 std::cout << "Image width: " << image_width << std::endl;
80 std::cout << "Image height: " << image_height << std::endl;
81
82 // Get trainable parameters data path
83 const std::string data_path = common_params.data_path;
84 const std::string model_path = "/cnn_data/srcnn955_model/";
85
86 // Create a preprocessor object
87 std::unique_ptr<IPreprocessor> preprocessor = std::make_unique<TFPreproccessor>();
88
89 // Create input descriptor
90 const TensorShape tensor_shape =
91 permute_shape(TensorShape(image_width, image_height, 3U, common_params.batches), DataLayout::NCHW,
92 common_params.data_layout);
93 TensorDescriptor input_descriptor =
94 TensorDescriptor(tensor_shape, common_params.data_type).set_layout(common_params.data_layout);
95
96 // Set weights trained layout
97 const DataLayout weights_layout = DataLayout::NCHW;
98
99 graph << common_params.target << common_params.fast_math_hint
100 << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor),
101 false /* Do not convert to BGR */))
102 << ConvolutionLayer(9U, 9U, 64U, get_weights_accessor(data_path, "conv1_weights.npy", weights_layout),
103 get_weights_accessor(data_path, "conv1_biases.npy"), PadStrideInfo(1, 1, 4, 4))
104 .set_name("conv1/convolution")
105 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
106 .set_name("conv1/Relu")
107 << ConvolutionLayer(5U, 5U, 32U, get_weights_accessor(data_path, "conv2_weights.npy", weights_layout),
108 get_weights_accessor(data_path, "conv2_biases.npy"), PadStrideInfo(1, 1, 2, 2))
109 .set_name("conv2/convolution")
110 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
111 .set_name("conv2/Relu")
112 << ConvolutionLayer(5U, 5U, 3U, get_weights_accessor(data_path, "conv3_weights.npy", weights_layout),
113 get_weights_accessor(data_path, "conv3_biases.npy"), PadStrideInfo(1, 1, 2, 2))
114 .set_name("conv3/convolution")

Callers

nothing calls this directly

Calls 15

permute_shapeFunction · 0.85
InputLayerClass · 0.85
get_input_accessorFunction · 0.85
ConvolutionLayerClass · 0.85
get_weights_accessorFunction · 0.85
PadStrideInfoClass · 0.85
ActivationLayerClass · 0.85
OutputLayerClass · 0.85
is_data_type_quantizedFunction · 0.85
print_helpMethod · 0.80
set_nameMethod · 0.80

Tested by

no test coverage detected