29 #include "utils/Utils.h"
35 class GraphVGG19Example :
public Example
38 GraphVGG19Example() : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0,
"VGG19")
41 bool do_setup(
int argc,
char **argv)
override
44 cmd_parser.parse(argc, argv);
45 cmd_parser.validate();
51 if (common_params.help)
53 cmd_parser.print_help(argv[0]);
58 std::cout << common_params << std::endl;
61 std::string data_path = common_params.data_path;
64 const std::array<float, 3> mean_rgb{{123.68f, 116.779f, 103.939f}};
65 std::unique_ptr<IPreprocessor> preprocessor = std::make_unique<CaffePreproccessor>(mean_rgb);
68 const auto operation_layout = common_params.data_layout;
69 const TensorShape tensor_shape =
78 << common_params.target << common_params.fast_math_hint
82 3U, 3U, 64U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv1_1_w.npy", weights_layout),
83 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv1_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
85 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
88 3U, 3U, 64U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv1_2_w.npy", weights_layout),
89 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv1_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
91 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
97 3U, 3U, 128U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv2_1_w.npy", weights_layout),
98 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv2_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
100 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
103 3U, 3U, 128U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv2_2_w.npy", weights_layout),
104 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv2_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
106 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
112 3U, 3U, 256U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv3_1_w.npy", weights_layout),
113 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv3_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
115 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
118 3U, 3U, 256U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv3_2_w.npy", weights_layout),
119 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv3_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
121 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
124 3U, 3U, 256U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv3_3_w.npy", weights_layout),
125 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv3_3_b.npy"), PadStrideInfo(1, 1, 1, 1))
127 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
130 3U, 3U, 256U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv3_4_w.npy", weights_layout),
131 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv3_4_b.npy"), PadStrideInfo(1, 1, 1, 1))
133 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
139 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv4_1_w.npy", weights_layout),
140 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv4_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
142 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
145 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv4_2_w.npy", weights_layout),
146 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv4_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
148 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
151 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv4_3_w.npy", weights_layout),
152 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv4_3_b.npy"), PadStrideInfo(1, 1, 1, 1))
154 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
157 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv4_4_w.npy", weights_layout),
158 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv4_4_b.npy"), PadStrideInfo(1, 1, 1, 1))
160 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
166 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv5_1_w.npy", weights_layout),
167 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv5_1_b.npy"), PadStrideInfo(1, 1, 1, 1))
169 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
172 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv5_2_w.npy", weights_layout),
173 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv5_2_b.npy"), PadStrideInfo(1, 1, 1, 1))
175 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
178 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv5_3_w.npy", weights_layout),
179 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv5_3_b.npy"), PadStrideInfo(1, 1, 1, 1))
181 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
184 3U, 3U, 512U,
get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv5_4_w.npy", weights_layout),
185 get_weights_accessor(data_path,
"/cnn_data/vgg19_model/conv5_4_b.npy"), PadStrideInfo(1, 1, 1, 1))
187 <<
ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU))
214 config.
use_tuner = common_params.enable_tuner;
217 config.
mlgo_file = common_params.mlgo_file;
221 graph.finalize(common_params.target, config);
225 void do_run()
override
252 int main(
int argc,
char **argv)
254 return arm_compute::utils::run_example<GraphVGG19Example>(argc, argv);