| 36 | TFStats* tf_stat = nullptr; |
| 37 | |
| 38 | string RunProfile(const string& command, const string& options, |
| 39 | TFStats* tf_stats) { |
| 40 | if (command == kCmds[4]) { |
| 41 | AdvisorOptionsProto option_pb; |
| 42 | if (!option_pb.ParseFromString(options)) { |
| 43 | fprintf(stderr, "Cannot parse AdvisorOptionsProto\n"); |
| 44 | return ""; |
| 45 | } |
| 46 | tf_stats->BuildAllViews(); |
| 47 | return Advisor(tf_stats).Advise(option_pb).SerializeAsString(); |
| 48 | } else { |
| 49 | tf_stats->BuildView(command); |
| 50 | } |
| 51 | |
| 52 | Options opts; |
| 53 | tensorflow::Status s = Options::FromProtoStr(options, &opts); |
| 54 | if (!s.ok()) { |
| 55 | fprintf(stderr, "%s\n", s.ToString().c_str()); |
| 56 | return ""; |
| 57 | } |
| 58 | |
| 59 | if (opts.output_type == kOutput[1]) { |
| 60 | printf("\n=========================Options=============================\n"); |
| 61 | printf("%s", opts.ToString().c_str()); |
| 62 | printf("\n==================Model Analysis Report======================\n"); |
| 63 | string ret = ""; |
| 64 | if (command == kCmds[2] || command == kCmds[3]) { |
| 65 | ret = tf_stats->ShowMultiGraphNode(command, opts).SerializeAsString(); |
| 66 | } else if (command == kCmds[0] || command == kCmds[1]) { |
| 67 | ret = tf_stats->ShowGraphNode(command, opts).SerializeAsString(); |
| 68 | } else { |
| 69 | fprintf(stderr, "Unknown command: %s\n", command.c_str()); |
| 70 | } |
| 71 | printf("\n======================End of Report==========================\n"); |
| 72 | fflush(stdout); |
| 73 | return ret; |
| 74 | } |
| 75 | if (command == kCmds[2] || command == kCmds[3]) { |
| 76 | return tf_stats->ShowMultiGraphNode(command, opts).SerializeAsString(); |
| 77 | } else if (command == kCmds[0] || command == kCmds[1]) { |
| 78 | return tf_stats->ShowGraphNode(command, opts).SerializeAsString(); |
| 79 | } else { |
| 80 | fprintf(stderr, "Unknown command: %s\n", command.c_str()); |
| 81 | return ""; |
| 82 | } |
| 83 | } |
| 84 | } // namespace |
| 85 | |
| 86 | bool NewProfiler(const string* graph, const string* op_log) { |
no test coverage detected