MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / main

Function main

tensorflow/core/summary/loader.cc:48–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48int main(int argc, char* argv[]) {
49 string path;
50 string events;
51 string experiment_name;
52 string run_name;
53 string user_name;
54 std::vector<Flag> flag_list = {
55 Flag("db", &path, "Path of SQLite DB file"),
56 Flag("events", &events, "TensorFlow record proto event log file"),
57 Flag("experiment_name", &experiment_name, "The DB experiment_name value"),
58 Flag("run_name", &run_name, "The DB run_name value"),
59 Flag("user_name", &user_name, "The DB user_name value"),
60 };
61 string usage = Flags::Usage(argv[0], flag_list);
62 bool parse_result = Flags::Parse(&argc, argv, flag_list);
63 if (!parse_result || path.empty()) {
64 std::cerr << "The loader tool imports tf.Event record files, created by\n"
65 << "SummaryFileWriter, into the sorts of SQLite database files\n"
66 << "created by SummaryDbWriter.\n\n"
67 << "In addition to the flags below, the environment variables\n"
68 << "defined by core/lib/db/sqlite.cc can also be set.\n\n"
69 << usage;
70 return -1;
71 }
72 port::InitMain(argv[0], &argc, &argv);
73 Env* env = Env::Default();
74
75 LOG(INFO) << "Opening SQLite file: " << path;
76 Sqlite* db;
77 TF_CHECK_OK(Sqlite::Open(
78 path, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX,
79 &db));
80 core::ScopedUnref unref_db(db);
81
82 LOG(INFO) << "Initializing TensorBoard schema";
83 TF_CHECK_OK(SetupTensorboardSqliteDb(db));
84
85 LOG(INFO) << "Creating SummaryDbWriter";
86 SummaryWriterInterface* db_writer;
87 TF_CHECK_OK(CreateSummaryDbWriter(db, experiment_name, run_name, user_name,
88 env, &db_writer));
89 core::ScopedUnref unref(db_writer);
90
91 LOG(INFO) << "Loading TF event log: " << events;
92 std::unique_ptr<RandomAccessFile> file;
93 TF_CHECK_OK(env->NewRandomAccessFile(events, &file));
94 io::RecordReader reader(file.get());
95
96 uint64 start = env->NowMicros();
97 uint64 records = 0;
98 uint64 offset = 0;
99 string record;
100 while (true) {
101 std::unique_ptr<Event> event = std::unique_ptr<Event>(new Event);
102 Status s = reader.ReadRecord(&offset, &record);
103 if (s.code() == error::OUT_OF_RANGE) break;
104 TF_CHECK_OK(s);
105 if (!ParseProtoUnlimited(event.get(), record)) {

Callers

nothing calls this directly

Calls 15

UsageFunction · 0.85
ParseFunction · 0.85
DefaultFunction · 0.85
SetupTensorboardSqliteDbFunction · 0.85
CreateSummaryDbWriterFunction · 0.85
ParseProtoUnlimitedFunction · 0.85
AddCommasFunction · 0.85
FlagClass · 0.50
InitMainFunction · 0.50
emptyMethod · 0.45
NewRandomAccessFileMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected