100{
101 tensorflow::GraphDef graph_def;
102
103
104
105
106
107
108 assert(argc >= 4);
109 assert(std::string(argv[0]) == "--input-format");
110 const std::string input_format{
argv[1]};
111 assert(std::string(argv[2]) == "--output-format");
112 const std::string output_format{
argv[3]};
113
114 std::map<std::string, std::unique_ptr<Importer>> importers;
115
116 importers["pb"] = std::make_unique<ImporterImpl<DataFormat::PBBIN>>();
117 importers["pbtxt"] = std::make_unique<ImporterImpl<DataFormat::PBTXT>>();
118
119 std::map<std::string, std::unique_ptr<Exporter>> exporters;
120
121 exporters["json"] = std::make_unique<ExporterImpl<DataFormat::JSON>>();
122
123 auto importer = importers.at(input_format).get();
124 auto exporter = exporters.at(output_format).get();
125
126 CmdArguments cmdargs(argc - 4, argv + 4);
127
129
130 if (!importer->run(ioconfig->in(), graph_def))
131 {
132 std::cerr << "ERROR: Failed to import" << std::endl;
133 return 255;
134 }
135
136 if (!exporter->run(graph_def, ioconfig->out()))
137 {
138 std::cerr << "ERROR: Failed to export" << std::endl;
139 return 255;
140 }
141
142 return 0;
143}
std::unique_ptr< IOConfiguration > make_ioconfig(const CmdArguments &cmdargs)