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

Function ReadProtoFile

tensorflow/core/profiler/internal/tfprof_utils.h:45–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44template <typename T>
45Status ReadProtoFile(Env* env, const string& fname, T* proto,
46 bool binary_first) {
47 string out;
48 Status s = ReadFileToString(env, fname, &out);
49 if (!s.ok()) return s;
50
51 if (binary_first) {
52 if (ReadBinaryProto(tensorflow::Env::Default(), fname, proto).ok()) {
53 return Status();
54 } else if (protobuf::TextFormat::ParseFromString(out, proto)) {
55 return Status();
56 }
57 } else {
58 if (protobuf::TextFormat::ParseFromString(out, proto)) {
59 return Status();
60 } else if (ReadBinaryProto(tensorflow::Env::Default(), fname, proto).ok()) {
61 return Status();
62 }
63 }
64 return errors::InvalidArgument("Cannot parse proto file.");
65}
66
67void PrintHelp();
68

Callers 5

TFProfShowTestMethod · 0.70
TFProfTimelineTestMethod · 0.70
TFProfTensorTestMethod · 0.70
TFProfStatsTestMethod · 0.70
RunFunction · 0.50

Calls 6

ReadFileToStringFunction · 0.85
ReadBinaryProtoFunction · 0.85
DefaultFunction · 0.85
InvalidArgumentFunction · 0.85
StatusClass · 0.50
okMethod · 0.45

Tested by 4

TFProfShowTestMethod · 0.56
TFProfTimelineTestMethod · 0.56
TFProfTensorTestMethod · 0.56
TFProfStatsTestMethod · 0.56