29 #include "utils/Utils.h"
36 class GraphVGG16Example :
public Example
39 GraphVGG16Example() : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0,
"VGG16")
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{{123.68f, 116.779f, 103.939f}};
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 =
80 << common_params.target << common_params.fast_math_hint
84 3U, 3U, 64U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv1_1_w.npy", weights_layout),
85 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv1_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
87 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
91 3U, 3U, 64U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv1_2_w.npy", weights_layout),
92 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv1_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
94 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
100 3U, 3U, 128U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv2_1_w.npy", weights_layout),
101 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv2_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
103 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
107 3U, 3U, 128U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv2_2_w.npy", weights_layout),
108 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv2_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
110 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
116 3U, 3U, 256U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv3_1_w.npy", weights_layout),
117 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv3_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
119 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
123 3U, 3U, 256U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv3_2_w.npy", weights_layout),
124 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv3_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
126 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
130 3U, 3U, 256U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv3_3_w.npy", weights_layout),
131 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv3_3_b.npy"), PadStrideInfo(1, 1, 1, 1))
133 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
139 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv4_1_w.npy", weights_layout),
140 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv4_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
142 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
146 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv4_2_w.npy", weights_layout),
147 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv4_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
149 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
153 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv4_3_w.npy", weights_layout),
154 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv4_3_b.npy"), PadStrideInfo(1, 1, 1, 1))
156 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
162 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv5_1_w.npy", weights_layout),
163 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv5_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
165 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
169 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv5_2_w.npy", weights_layout),
170 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv5_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
172 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
176 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv5_3_w.npy", weights_layout),
177 get_weights_accessor(data_path,
"/cnn_data/vgg16_model/conv5_3_b.npy"), PadStrideInfo(1, 1, 1, 1))
179 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
206 config.
use_tuner = common_params.enable_tuner;
209 config.
mlgo_file = common_params.mlgo_file;
213 graph.finalize(common_params.target, config);
217 void do_run()
override
244 int main(
int argc,
char **argv)
246 return arm_compute::utils::run_example<GraphVGG16Example>(argc, argv);