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

Method do_setup

examples/graph_squeezenet.cpp:42–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 = std::make_unique<CaffePreproccessor>(mean_rgb);
67
68 // Create input descriptor
69 const auto operation_layout = common_params.data_layout;
70 const TensorShape tensor_shape =
71 permute_shape(TensorShape(224U, 224U, 3U, common_params.batches), DataLayout::NCHW, operation_layout);
72 TensorDescriptor input_descriptor =
73 TensorDescriptor(tensor_shape, common_params.data_type).set_layout(operation_layout);
74
75 // Set weights trained layout
76 const DataLayout weights_layout = DataLayout::NCHW;
77
78 graph << common_params.target << common_params.fast_math_hint
79 << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor)))
80 << ConvolutionLayer(
81 7U, 7U, 96U,
82 get_weights_accessor(data_path, "/cnn_data/squeezenet_v1.0_model/conv1_w.npy", weights_layout),
83 get_weights_accessor(data_path, "/cnn_data/squeezenet_v1.0_model/conv1_b.npy"),
84 PadStrideInfo(2, 2, 0, 0))
85 .set_name("conv1")
86 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
87 .set_name("relu_conv1")
88 << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, operation_layout,
89 PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)))
90 .set_name("pool1")
91 << ConvolutionLayer(
92 1U, 1U, 16U,
93 get_weights_accessor(data_path, "/cnn_data/squeezenet_v1.0_model/fire2_squeeze1x1_w.npy",
94 weights_layout),
95 get_weights_accessor(data_path, "/cnn_data/squeezenet_v1.0_model/fire2_squeeze1x1_b.npy"),
96 PadStrideInfo(1, 1, 0, 0))
97 .set_name("fire2/squeeze1x1")
98 << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
99 .set_name("fire2/relu_squeeze1x1");

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
PoolingLayerClass · 0.85
FlattenLayerClass · 0.85
SoftmaxLayerClass · 0.85
OutputLayerClass · 0.85
get_output_accessorFunction · 0.85

Tested by

no test coverage detected