32 "circle-inspect allows users to retrieve various information from a Circle model file"};
33 arser.add_argument(
"--operators").nargs(0).help(
"Dump operators in circle file");
34 arser.add_argument(
"--conv2d_weight")
36 .help(
"Dump Conv2D series weight operators in circle file");
37 arser.add_argument(
"--constants").nargs(0).help(
"Dump constant tensors name");
38 arser.add_argument(
"--op_version").nargs(0).help(
"Dump versions of the operators in circle file");
39 arser.add_argument(
"--tensor_dtype").nargs(0).help(
"Dump dtype of tensors");
40 arser.add_argument(
"--tensor_shape").nargs(0).help(
"Dump shape of tensors");
41 arser.add_argument(
"circle").help(
"Circle file to inspect");
45 arser.parse(argc, argv);
47 catch (
const std::runtime_error &err)
49 std::cout << err.what() << std::endl;
54 if (!
arser[
"--operators"] && !
arser[
"--conv2d_weight"] && !
arser[
"--op_version"] &&
55 !
arser[
"--tensor_dtype"] && !
arser[
"--constants"] && !
arser[
"--tensor_shape"])
57 std::cout <<
"At least one option must be specified" << std::endl;
62 std::vector<std::unique_ptr<circleinspect::DumpInterface>> dumps;
64 if (
arser[
"--operators"])
65 dumps.push_back(std::make_unique<circleinspect::DumpOperators>());
66 if (
arser[
"--conv2d_weight"])
67 dumps.push_back(std::make_unique<circleinspect::DumpConv2DWeight>());
68 if (
arser[
"--op_version"])
69 dumps.push_back(std::make_unique<circleinspect::DumpOperatorVersion>());
70 if (
arser[
"--tensor_dtype"])
71 dumps.push_back(std::make_unique<circleinspect::DumpTensorDType>());
72 if (
arser[
"--constants"])
73 dumps.push_back(std::make_unique<circleinspect::DumpConstants>());
74 if (
arser[
"--tensor_shape"])
75 dumps.push_back(std::make_unique<circleinspect::DumpTensorShape>());
77 std::string model_file =
arser.get<std::string>(
"circle");
81 std::vector<char> modelData = fileLoader.
load();
82 const circle::Model *circleModel = circle::GetModel(modelData.data());
83 if (circleModel ==
nullptr)
85 std::cerr <<
"ERROR: Failed to load circle '" << model_file <<
"'" << std::endl;
89 for (
auto &
dump : dumps)
91 dump->run(std::cout, circleModel, &modelData);