29 #include "utils/Utils.h"
36 class GraphSqueezenet_v1_1Example :
public Example
39 GraphSqueezenet_v1_1Example() : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0,
"SqueezeNetV1.1")
42 bool do_setup(
int argc,
char **argv)
override
45 cmd_parser.parse(argc, argv);
46 cmd_parser.validate();
52 if (common_params.help)
54 cmd_parser.print_help(argv[0]);
59 std::cout << common_params << std::endl;
62 std::string data_path = common_params.data_path;
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);
69 const auto operation_layout = common_params.data_layout;
70 const TensorShape tensor_shape =
78 graph << common_params.target << common_params.fast_math_hint
84 PadStrideInfo(2, 2, 0, 0))
86 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
96 PadStrideInfo(1, 1, 0, 0))
98 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
100 graph << get_expand_fire_node(data_path,
"fire2", weights_layout, 64U, 64U).
set_name(
"fire2/concat");
106 PadStrideInfo(1, 1, 0, 0))
108 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
110 graph << get_expand_fire_node(data_path,
"fire3", weights_layout, 64U, 64U).
set_name(
"fire3/concat");
119 PadStrideInfo(1, 1, 0, 0))
121 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
123 graph << get_expand_fire_node(data_path,
"fire4", weights_layout, 128U, 128U).
set_name(
"fire4/concat");
129 PadStrideInfo(1, 1, 0, 0))
131 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
133 graph << get_expand_fire_node(data_path,
"fire5", weights_layout, 128U, 128U).
set_name(
"fire5/concat");
142 PadStrideInfo(1, 1, 0, 0))
144 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
146 graph << get_expand_fire_node(data_path,
"fire6", weights_layout, 192U, 192U).
set_name(
"fire6/concat");
152 PadStrideInfo(1, 1, 0, 0))
154 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
156 graph << get_expand_fire_node(data_path,
"fire7", weights_layout, 192U, 192U).
set_name(
"fire7/concat");
162 PadStrideInfo(1, 1, 0, 0))
164 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
166 graph << get_expand_fire_node(data_path,
"fire8", weights_layout, 256U, 256U).
set_name(
"fire8/concat");
172 PadStrideInfo(1, 1, 0, 0))
174 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
176 graph << get_expand_fire_node(data_path,
"fire9", weights_layout, 256U, 256U).
set_name(
"fire9/concat");
179 get_weights_accessor(data_path,
"/cnn_data/squeezenet_v1_1_model/conv10_w.npy", weights_layout),
181 PadStrideInfo(1, 1, 0, 0))
183 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
192 config.
use_tuner = common_params.enable_tuner;
195 config.
mlgo_file = common_params.mlgo_file;
199 graph.finalize(common_params.target, config);
203 void do_run()
override
215 ConcatLayer get_expand_fire_node(
const std::string &data_path,
216 std::string &¶m_path,
218 unsigned int expand1_filt,
219 unsigned int expand3_filt)
221 std::string total_path =
"/cnn_data/squeezenet_v1_1_model/" + param_path +
"_";
226 PadStrideInfo(1, 1, 0, 0))
227 .
set_name(param_path +
"/expand1x1")
228 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
229 .
set_name(param_path +
"/relu_expand1x1");
235 PadStrideInfo(1, 1, 1, 1))
236 .
set_name(param_path +
"/expand3x3")
237 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
238 .
set_name(param_path +
"/relu_expand3x3");
240 return ConcatLayer(std::move(i_a), std::move(i_b));
258 int main(
int argc,
char **argv)
260 return arm_compute::utils::run_example<GraphSqueezenet_v1_1Example>(argc, argv);