35 class ShuffleNetExample :
public Example 39 : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0,
"ShuffleNet")
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 if(!common_opts.data_layout->is_set())
68 std::cout << common_params << std::endl;
69 std::cout <<
"Model: Shufflenet_1_g4" << std::endl;
72 std::string model_path =
"/cnn_data/shufflenet_model/";
75 std::string data_path = common_params.data_path;
78 if(!data_path.empty())
80 data_path += model_path;
84 const auto operation_layout = common_params.data_layout;
92 std::unique_ptr<IPreprocessor> preprocessor = std::make_unique<TFPreproccessor>(0);
94 graph << common_params.target
95 << common_params.fast_math_hint
101 PadStrideInfo(2, 2, 1, 1))
148 config.
use_tuner = common_params.enable_tuner;
151 config.
mlgo_file = common_params.mlgo_file;
153 graph.finalize(common_params.target, config);
158 void do_run()
override 170 void add_residual_block(
const std::string &data_path,
DataLayout weights_layout,
171 unsigned int unit,
unsigned int depth,
unsigned int stride)
173 PadStrideInfo dwc_info = PadStrideInfo(1, 1, 1, 1);
174 const unsigned int gconv_id = unit * 2;
179 const std::string unit_name =
"unit" + unit_id_name;
187 dwc_info = PadStrideInfo(2, 2, 1, 1);
193 std::unique_ptr<arm_compute::graph::ITensorAccessor>(
nullptr),
194 PadStrideInfo(1, 1, 0, 0), num_groups)
195 .
set_name(unit_name +
"/gconv1_" + gconv_id_name +
"/convolution")
202 .
set_name(unit_name +
"/gconv1_" + gconv_id_name +
"/BatchNorm")
208 std::unique_ptr<arm_compute::graph::ITensorAccessor>(
nullptr),
210 .
set_name(unit_name +
"/gconv3_" + unit_id_name +
"/depthwise")
217 .
set_name(unit_name +
"/gconv3_" + unit_id_name +
"/BatchNorm")
221 std::unique_ptr<arm_compute::graph::ITensorAccessor>(
nullptr),
222 PadStrideInfo(1, 1, 0, 0), num_groups)
223 .
set_name(unit_name +
"/gconv1_" + gconv_id_1_name +
"/convolution")
230 .
set_name(unit_name +
"/gconv1_" + gconv_id_1_name +
"/BatchNorm");
234 graph <<
ConcatLayer(std::move(left_ss), std::move(right_ss)).
set_name(unit_name +
"/Concat");
238 graph <<
EltwiseLayer(std::move(left_ss), std::move(right_ss), EltwiseOperation::Add).
set_name(unit_name +
"/Add");
258 int main(
int argc,
char **argv)
260 return arm_compute::utils::run_example<ShuffleNetExample>(argc, argv);
Graph configuration structure Device target types.
CLTunerMode tuner_mode
Tuner mode to be used by the CL tuner.
std::unique_ptr< graph::ITensorAccessor > get_input_accessor(const arm_compute::utils::CommonGraphParams &graph_parameters, std::unique_ptr< IPreprocessor > preprocessor=nullptr, bool bgr=true)
Generates appropriate input accessor according to the specified graph parameters. ...
Depthwise Convolution Layer.
std::string to_string(T &&value)
Convert integer and float values to string.
void consume_common_graph_parameters(CommonGraphValidateOptions &options, CommonParams &common_params)
Consumes the consume_common_graph_parameters graph options and creates a structure containing any inf...
Includes all the Graph headers at once.
Common command line options used to configure the graph examples.
Class to parse command line arguments.
arm_compute::DataLayout data_layout
std::string mlgo_file
Filename to load MLGO heuristics from.
std::string tuner_file
File to load/store tuning values from.
#define ARM_COMPUTE_EXIT_ON_MSG(cond, msg)
If the condition is true, the given message is printed and program exits.
int main(int argc, char **argv)
Main program for ShuffleNet.
const unsigned int num_groups
Num samples, channels, height, width.
TensorShape permute_shape(TensorShape tensor_shape, DataLayout in_data_layout, DataLayout out_data_layout)
Permutes a given tensor shape given the input and output data layout.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
TensorDescriptor & set_layout(DataLayout data_layout)
Sets tensor descriptor data layout.
Structure holding all the common graph parameters.
Num samples, height, width, channels.
std::unique_ptr< graph::ITensorAccessor > get_output_accessor(const arm_compute::utils::CommonGraphParams &graph_parameters, size_t top_n=5, bool is_validation=false, std::ostream &output_stream=std::cout)
Generates appropriate output accessor according to the specified graph parameters.
bool use_tuner
Use a tuner in tunable backends.
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.
int num_threads
Number of threads to use (thread capable backends), if 0 the backend will auto-initialize, if -1 the backend will stay as it is.
Stream frontend class to construct simple graphs in a stream fashion.
Batchnormalization Layer.
DataLayout
[DataLayout enum definition]
ILayer & set_name(std::string name)
Sets the name of the layer.