37 arser::Arser arser{
"tflite2circle is a Tensorflow lite to circle model converter"};
42 arser.add_argument(
"tflite").help(
"Source tflite file path to convert");
43 arser.add_argument(
"circle").help(
"Target circle file path");
47 arser.parse(argc, argv);
49 catch (
const std::runtime_error &err)
51 std::cerr << err.what() << std::endl;
56 std::string tfl_path =
arser.get<std::string>(
"tflite");
57 std::string circle_path =
arser.get<std::string>(
"circle");
60 if (not tfl_model.verify_data())
62 std::cerr <<
"ERROR: Failed to verify tflite '" << tfl_path <<
"'" << std::endl;
67 auto flatbuffer_builder = std::make_unique<flatbuffers::FlatBufferBuilder>(1024);
70 const std::vector<char> &raw_data = tfl_model.raw_data();
73 circle_model.load_offsets(tfl_model.get_model());
74 circle_model.model_build();
75 circle_model.finalize();
77 std::ofstream outfile{circle_path, std::ios::binary};
79 outfile.write(circle_model.base(), circle_model.size());
84 std::cerr <<
"ERROR: Failed to write circle '" << circle_path <<
"'" << std::endl;