Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 713045709
  • Loading branch information
lingvo-bot authored and copybara-github committed Jan 7, 2025
1 parent 9ce3ef0 commit 41306a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions lingvo/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ lingvo_cc_binary(
srcs = ["generate_proto_def.cc"],
deps = [
# Implicit proto dependency.
# Implicit absl.container.flat_hash_set dependency.
# Implicit tensorflow C++ proto dependency.
],
)
Expand Down
8 changes: 4 additions & 4 deletions lingvo/tools/generate_proto_def.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ limitations under the License.
#include <fstream>
#include <iostream>
#include <string>
#include <unordered_set>

#include "google/protobuf/descriptor.h"
#include "absl/container/flat_hash_set.h"
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/core/protobuf/meta_graph.pb.h"
Expand All @@ -39,19 +39,19 @@ void WriteDotProto(const google::protobuf::FileDescriptor* dot_proto,

void GenerateProtoDef(const google::protobuf::FileDescriptor* dot_proto,
const char* output_dirpath,
std::unordered_set<std::string>* printed_files) {
absl::flat_hash_set<std::string>* printed_files) {
if (printed_files->find(dot_proto->name()) != printed_files->end()) {
return;
}
printed_files->insert(dot_proto->name());
printed_files->emplace(dot_proto->name());
WriteDotProto(dot_proto, output_dirpath);
for (int k = 0; k < dot_proto->dependency_count(); ++k)
GenerateProtoDef(dot_proto->dependency(k), output_dirpath, printed_files);
}

// Regurgitate the text definitions from binary.
void GenerateProtoDefs(const char* output_dirpath) {
std::unordered_set<std::string> printed_files;
absl::flat_hash_set<std::string> printed_files;
GenerateProtoDef(tensorflow::GraphDef::descriptor()->file(), output_dirpath,
&printed_files);
GenerateProtoDef(tensorflow::DataType_descriptor()->file(), output_dirpath,
Expand Down

0 comments on commit 41306a0

Please sign in to comment.