Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 688763667
  • Loading branch information
Google AI Edge authored and copybara-github committed Oct 23, 2024
1 parent 5c0ffe2 commit 05e6223
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/builtin-adapter/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ cc_binary(
":models_to_json_lib",
":visualize_config",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@org_tensorflow//tensorflow/compiler/mlir:init_mlir",
"@org_tensorflow//tensorflow/compiler/mlir/lite/tools:command_line_flags",
Expand Down
10 changes: 8 additions & 2 deletions src/builtin-adapter/models_to_json_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <vector>

#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "tensorflow/compiler/mlir/init_mlir.h"
#include "models_to_json_lib.h"
Expand Down Expand Up @@ -47,9 +48,9 @@ int main(int argc, char* argv[]) {
std::vector<mlir::Flag> flag_list = {
mlir::Flag::CreateFlag(kInputFileFlag, &input_file,
"Input filename or directory",
mlir::Flag::kRequired),
mlir::Flag::kOptional),
mlir::Flag::CreateFlag(kOutputFileFlag, &output_file, "Output filename",
mlir::Flag::kRequired),
mlir::Flag::kOptional),
mlir::Flag::CreateFlag(
kConstElementCountLimitFlag, &const_element_count_limit,
"The maximum number of constant elements. If the number exceeds this "
Expand All @@ -69,6 +70,11 @@ int main(int argc, char* argv[]) {
return 1;
}

if (output_file.empty()) {
LOG(ERROR) << "Output filename cannot be empty.";
return 1;
}

if (output_file.substr(output_file.size() - 4, 4) != "json") {
LOG(WARNING) << "Please specify output format to be JSON.";
}
Expand Down

0 comments on commit 05e6223

Please sign in to comment.