35 class GraphResNeXt50Example :
public Example 38 GraphResNeXt50Example()
39 : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0,
"ResNeXt50")
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]);
62 std::cout << common_params << std::endl;
65 std::string data_path = common_params.data_path;
68 const auto operation_layout = common_params.data_layout;
75 graph << common_params.target
76 << common_params.fast_math_hint
90 add_residual_block(data_path, weights_layout, 256, 1, 3, 1);
91 add_residual_block(data_path, weights_layout, 512, 2, 4, 2);
92 add_residual_block(data_path, weights_layout, 1024, 3, 6, 2);
93 add_residual_block(data_path, weights_layout, 2048, 4, 3, 2);
102 config.
use_tuner = common_params.enable_tuner;
105 config.
mlgo_file = common_params.mlgo_file;
107 graph.finalize(common_params.target, config);
112 void do_run()
override 124 void add_residual_block(
const std::string &data_path,
DataLayout weights_layout,
125 unsigned int base_depth,
unsigned int stage,
unsigned int num_units,
unsigned int stride_conv_unit1)
127 for(
unsigned int i = 0; i < num_units; ++i)
129 std::stringstream unit_path_ss;
130 unit_path_ss <<
"/cnn_data/resnext50_model/stage" << stage <<
"_unit" << (i + 1) <<
"_";
131 std::string unit_path = unit_path_ss.str();
133 std::stringstream unit_name_ss;
134 unit_name_ss <<
"stage" << stage <<
"/unit" << (i + 1) <<
"/";
135 std::string unit_name = unit_name_ss.str();
137 PadStrideInfo pad_grouped_conv(1, 1, 1, 1);
140 pad_grouped_conv = (stage == 1) ? PadStrideInfo(stride_conv_unit1, stride_conv_unit1, 1, 1) : PadStrideInfo(stride_conv_unit1, stride_conv_unit1, 0, 1, 0, 1,
DimensionRoundingType::FLOOR);
145 1U, 1U, base_depth / 2,
148 PadStrideInfo(1, 1, 0, 0))
149 .
set_name(unit_name +
"conv1/convolution")
153 3U, 3U, base_depth / 2,
155 std::unique_ptr<arm_compute::graph::ITensorAccessor>(
nullptr),
156 pad_grouped_conv, 32)
157 .
set_name(unit_name +
"conv2/convolution")
160 .
set_name(unit_name +
"conv1/Scale")
167 PadStrideInfo(1, 1, 0, 0))
168 .
set_name(unit_name +
"conv3/convolution");
176 std::unique_ptr<arm_compute::graph::ITensorAccessor>(
nullptr),
177 PadStrideInfo(stride_conv_unit1, stride_conv_unit1, 0, 0))
178 .
set_name(unit_name +
"sc/convolution")
184 graph <<
EltwiseLayer(std::move(left), std::move(right), EltwiseOperation::Add).
set_name(unit_name +
"add");
202 int main(
int argc,
char **argv)
204 return arm_compute::utils::run_example<GraphResNeXt50Example>(argc, argv);
int main(int argc, char **argv)
Main program for ResNeXt50.
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. ...
1 channel, 1 F32 per channel
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.
std::unique_ptr< graph::ITensorAccessor > get_npy_output_accessor(const std::string &npy_path, TensorShape shape, DataType data_type, DataLayout data_layout=DataLayout::NCHW, std::ostream &output_stream=std::cout)
Generates appropriate npy output accessor according to the specified npy_path.
Class to parse command line arguments.
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.
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.
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.
DataLayout
[DataLayout enum definition]
ILayer & set_name(std::string name)
Sets the name of the layer.