41 class GraphGooglenetExample :
public Example 44 void do_setup(
int argc,
char **argv)
override 46 std::string data_path;
51 const std::array<float, 3> mean_rgb{ { 122.68f, 116.67f, 104.01f } };
52 std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<CaffePreproccessor>(mean_rgb);
55 const int target = argc > 1 ? std::strtol(argv[1],
nullptr, 10) : 0;
63 std::cout <<
"Usage: " << argv[0] <<
" [target] [path_to_data] [image] [labels] [fast_math_hint]\n\n";
64 std::cout <<
"No data folder provided: using random values\n\n";
68 std::cout <<
"Usage: " << argv[0] <<
" " << argv[1] <<
" [path_to_data] [image] [labels] [fast_math_hint]\n\n";
69 std::cout <<
"No data folder provided: using random values\n\n";
74 std::cout <<
"Usage: " << argv[0] <<
" " << argv[1] <<
" " << argv[2] <<
" [image] [labels] [fast_math_hint]\n\n";
75 std::cout <<
"No image provided: using random values\n\n";
81 std::cout <<
"Usage: " << argv[0] <<
" " << argv[1] <<
" " << argv[2] <<
" " << argv[3] <<
" [labels] [fast_math_hint]\n\n";
82 std::cout <<
"No text file with labels provided: skipping output accessor\n\n";
89 std::cout <<
"Usage: " << argv[0] <<
" " << argv[1] <<
" " << argv[2] <<
" " << argv[3] <<
" " << argv[4] <<
" [fast_math_hint]\n\n";
90 std::cout <<
"No fast math info provided: disabling fast math\n\n";
97 fast_math_hint = (std::strtol(argv[5],
nullptr, 1) == 0) ? FastMathHint::DISABLED : FastMathHint::ENABLED;
108 PadStrideInfo(2, 2, 3, 3))
116 PadStrideInfo(1, 1, 0, 0))
122 PadStrideInfo(1, 1, 1, 1))
126 graph << get_inception_node(data_path,
"inception_3a", 64, std::make_tuple(96U, 128U), std::make_tuple(16U, 32U), 32U);
127 graph << get_inception_node(data_path,
"inception_3b", 128, std::make_tuple(128U, 192U), std::make_tuple(32U, 96U), 64U);
129 graph << get_inception_node(data_path,
"inception_4a", 192, std::make_tuple(96U, 208U), std::make_tuple(16U, 48U), 64U);
130 graph << get_inception_node(data_path,
"inception_4b", 160, std::make_tuple(112U, 224U), std::make_tuple(24U, 64U), 64U);
131 graph << get_inception_node(data_path,
"inception_4c", 128, std::make_tuple(128U, 256U), std::make_tuple(24U, 64U), 64U);
132 graph << get_inception_node(data_path,
"inception_4d", 112, std::make_tuple(144U, 288U), std::make_tuple(32U, 64U), 64U);
133 graph << get_inception_node(data_path,
"inception_4e", 256, std::make_tuple(160U, 320U), std::make_tuple(32U, 128U), 128U);
135 graph << get_inception_node(data_path,
"inception_5a", 256, std::make_tuple(160U, 320U), std::make_tuple(32U, 128U), 128U);
136 graph << get_inception_node(data_path,
"inception_5b", 384, std::make_tuple(192U, 384U), std::make_tuple(48U, 128U), 128U);
147 config.use_tuner = (target == 2);
148 graph.finalize(target_hint, config);
150 void do_run()
override 157 Stream graph{ 0,
"GoogleNet" };
159 BranchLayer get_inception_node(
const std::string &data_path, std::string &¶m_path,
161 std::tuple<unsigned int, unsigned int> b_filters,
162 std::tuple<unsigned int, unsigned int> c_filters,
165 std::string total_path =
"/cnn_data/googlenet_model/" + param_path +
"/" + param_path +
"_";
171 PadStrideInfo(1, 1, 0, 0))
176 1U, 1U, std::get<0>(b_filters),
179 PadStrideInfo(1, 1, 0, 0))
182 3U, 3U, std::get<1>(b_filters),
185 PadStrideInfo(1, 1, 1, 1))
190 1U, 1U, std::get<0>(c_filters),
193 PadStrideInfo(1, 1, 0, 0))
196 5U, 5U, std::get<1>(c_filters),
199 PadStrideInfo(1, 1, 2, 2))
208 PadStrideInfo(1, 1, 0, 0))
211 return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d));
220 int main(
int argc,
char **argv)
222 return arm_compute::utils::run_example<GraphGooglenetExample>(argc, argv);
graph::Target set_target_hint(int target)
Utility function to return the TargetHint.
std::unique_ptr< graph::ITensorAccessor > get_output_accessor(const std::string &labels_path, size_t top_n=5, std::ostream &output_stream=std::cout)
Generates appropriate output accessor according to the specified labels_path.
int main(int argc, char **argv)
Main program for Googlenet.
1 channel, 1 F32 per channel
std::unique_ptr< graph::ITensorAccessor > get_input_accessor(const std::string &ppm_path, std::unique_ptr< IPreprocessor > preprocessor=nullptr, bool bgr=true)
Generates appropriate input accessor according to the specified ppm_path.
FastMathHint
Enable or disable fast math for Convolution layer.
std::unique_ptr< graph::ITensorAccessor > get_weights_accessor(const std::string &path, const std::string &data_file, DataLayout file_layout=DataLayout::NCHW)
Generates appropriate weights accessor according to the specified path.
Stream frontend class to construct simple graphs in a stream fashion.
Normalization applied cross maps.