| 21 | #include "tensorflow/lite/toco/toco_convert.h" |
| 22 | |
| 23 | int main(int argc, char** argv) { |
| 24 | toco::string msg; |
| 25 | toco::ParsedTocoFlags parsed_toco_flags; |
| 26 | toco::ParsedModelFlags parsed_model_flags; |
| 27 | |
| 28 | // If no args were specified, give a help string to be helpful. |
| 29 | int* effective_argc = &argc; |
| 30 | char** effective_argv = argv; |
| 31 | if (argc == 1) { |
| 32 | // No arguments, so manufacture help argv. |
| 33 | static int dummy_argc = 2; |
| 34 | static char* dummy_argv[] = {argv[0], const_cast<char*>("--help")}; |
| 35 | effective_argc = &dummy_argc; |
| 36 | effective_argv = dummy_argv; |
| 37 | } |
| 38 | |
| 39 | // Parse toco flags and command flags in sequence, each one strips off args, |
| 40 | // giving InitGoogle a chance to handle all remaining arguments. |
| 41 | bool toco_success = toco::ParseTocoFlagsFromCommandLineFlags( |
| 42 | effective_argc, effective_argv, &msg, &parsed_toco_flags); |
| 43 | bool model_success = toco::ParseModelFlagsFromCommandLineFlags( |
| 44 | effective_argc, effective_argv, &msg, &parsed_model_flags); |
| 45 | if (!toco_success || !model_success || !msg.empty()) { |
| 46 | fprintf(stderr, "%s", msg.c_str()); |
| 47 | fflush(stderr); |
| 48 | return 1; |
| 49 | } |
| 50 | toco::port::InitGoogle(argv[0], effective_argc, &effective_argv, true); |
| 51 | auto status = toco::Convert(parsed_toco_flags, parsed_model_flags); |
| 52 | if (!status.ok()) { |
| 53 | fprintf(stderr, "%s\n", status.error_message().c_str()); |
| 54 | fflush(stderr); |
| 55 | return 1; |
| 56 | } |
| 57 | return 0; |
| 58 | } |
nothing calls this directly
no test coverage detected